espressif / esp-dl

Espressif deep-learning library for AIoT applications
MIT License
516 stars 115 forks source link

How to multiply 1D tensor with 1D constant tensor (AIV-478) #82

Closed michalber closed 2 years ago

michalber commented 2 years ago

Hi everyone!

I want you to ask how to do multiplication od 1D tensora in ESP-DL. I found only 2D version in repository. Also I came across idea to create two tensors with shape N x 1 and use nn::mul_2d, but how to do multiplication with constant tensor? Should I use Constant class to assign values that I will use and later create Tensor with its values to do multiplication? Or there is another solutions?

Thanks for all replies!

TiramisuJ commented 2 years ago

Hi michalber

  1. The current multiplication only supports the multiplication of two tensors with shape H x W x C. So you can create two tensors with shape N, then use Tensor's member function expand_dims () to set the shape from N to 1 x 1 x N, after the multiplication, you can use the Tensor's member function squeeze() to remove extra dimensions.
  2. We will provide general addition, subtraction and multiplication operators in the future.