Skip to content

[MatMul] Add implementation of MatMul export as MatMulCPP

Context

Add implementation of export for MAtMul in exportCPP.

Choice to provide a dedicated matmul.hpp kernel as mapping to FC does not really scale to 2-Dims and N-dims matmults,

  • supports scalar/1D inputs as MatMul::forwardDims does, see below
  • provision for activation as done in elemwise operators
  • new kernel matmul.hpp provided
  • as of now do not support >2D inputs/broadcasts, see below

Notes:

  • 2D+ support: This change does no include the support for >2D inputs. It would require managing multi broadcast which is also not supported for CPP export of elemwise operators. This support is delayed until a further change factorizing multi-broadcast on elemwise/matmul and after availability of a more comprehensive unit tests suite.
  • scalar support: added scalar support, i.e.: 2 @ 3 == 6, which is actually equivalent to [2] @ [3] == 6 (or with mul operator: 2 * 3 == 6) I added this support as in the aidge_core defined MatMul::forwardDims(), scalar @ scalar -> scalar is supported (forwards a scalar dim) Note, though that this is more general than np.matmul which does not support scalar inputs, don't know if it was expected. This seems reasonable to me, but for instance the backend_cpu does not support it.

Modified files

Add in operator export file operators.py the single class MatMulCPP, plus the templates/kernel files.

Detailed major modifications

No major modification. Feature added as Matmul is now supported in export CPP.

TODO

No TODO forecasted, as explained above I prefer to add the >2D inputs support at a later stage if you don't mind.

Edited by Christophe Guillon

Merge request reports

Loading