Closed PureHing closed 3 years ago
Hi @PureHing
In your code, it actually calls this void mul2d(Tensor
Recommend Option-1: If you just only have this operation(won't mix with other padding-required operations, such as Conv2D)
#include <stdint.h>
#include "dl_variable.hpp"
#include "dl_constant.hpp"
#include "dl_nn_mul2d.hpp"
using namespace dl;
using namespace nn;
extern "C" void app_main(void)
{
int16_t element1[] = {5, 6, 7, 8};
int16_t element2[] = {1, 2, 3, 4};
Tensor<int16_t> input1;
input1.set_element((int16_t *)element1).set_exponent(0).set_shape({2, 2, 1}).set_auto_free(false);
Tensor<int16_t> input2;
input2.set_element((int16_t *)element2).set_exponent(0).set_shape({2, 2, 1}).set_auto_free(false);
Tensor<int16_t> output = dl::nn::mul2d(0, input1, input2, (Activation<int16_t> *)NULL);
output.print(0, 2, 0, 2, 0, 1, "output", 2);
}
you'll get:
output[0:2, 0:2, 0:1] | shape = (0 + 2 + 0, 0 + 2 + 0, 1(1))
c = 0
0 1
0 5 12
1 21 32
Recommend Option-2: If this operation is mixed with other padding-required operations, I recommend you dl::layer::Mul2D.
@yehangyang
Thanks.
BTW, How to achieve the same function as numpy.dot
@PureHing It's not implemented yet. We planed to support it later.
@yehangyang Hi,How to use mul2d to multiply two matrices(AxB)?
Is this reasonable?