tomstewart89 / BasicLinearAlgebra

A library for using matrices and linear algebra on Arduino
MIT License
185 stars 38 forks source link

template instantiation depth exceeds maximum of 900 #76

Closed TIMESTICKING closed 3 months ago

TIMESTICKING commented 3 months ago

The error is

 required from here
.pio/libdeps/esp32_s3_8_8/BasicLinearAlgebra/ElementStorage.h:33:9: fatal error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum)
         FillRowMajor(++start_idx, tail...);
         ^~~~~~~~~~~~
compilation terminated.

I'm trying to use a 32x64 matrix like this:

BLA::Matrix<64, 32> mlp10weight = {
      0.05446106567978859,     0.04698100686073303,    0.10509192943572998,
      0.002267003059387207,    0.3
.................. }

according to the error, I added a flag to the compiler: -ftemplate-depth=2100, but the indexing process is taking forever, it's just stuck here. Could you please enlighten me on how to resolve this?

tomstewart89 commented 3 months ago

Hey @TIMESTICKING, sorry about the slow reply here. The problem is that for many arduinos I can't define a constructor that takes a std::initializer_list so I wrote an alternative using some template logic which doesn't scale so well to large matrices.

For now I'd suggest just defining your weights in a static array filling in the Matrix manually. In the future we can probably write something like numpy.asarray which would save you having to make a copy of your data.

Hope that helps!