espressif / esp-dl

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

Problem with template function nn::mul2d (AIV-480) #84

Closed michalber closed 2 years ago

michalber commented 2 years ago

When using Mul2D layer there is compile error in running nn:mul2d function. I am using C++17, with ESP32. Problem is occuring either when creating layer with inplace option or without. Tried to comment if constexpr statement but it didn't help.

no matching function for call to 'mul2d<true>(dl::Tensor<short int>&, dl::Tensor<short int>&, dl::Tensor<short int>&, const dl::Activation<short int>*&, const std::vector<int>&)'

I will edit this issue if I found cause of this bug.

EDIT: Solution: I compared Mul2D to Add2D layer and found solution. There is wrong use of nn::mul2d<true>(*this->output, input0, input1, this->activation, assign_core);

Instead you should write nn::mul2d(*this->output, input0, input1, this->activation, assign_core, this->output_exponent); or nn::mul2d<true>(this->output_exponent, input0, input1, this->activation, assign_core);

but the second approach seems to be slower

TiramisuJ commented 2 years ago
  1. Thank you for your feedback, we will fix the bugs soon.
  2. nn::mul2d<true>(this->output_exponent, input0, input1, this->activation, assign_core); this function will malloc the output tensor, and return it. so this approach is slower
TiramisuJ commented 2 years ago

The bugs have been fixed