Add missing operators for basic onnx model exporting
Context
While trying to export a hugging face onnx model to cpp, some operators were missing So in this merge request, I add a reshape operator as well as adding back the matmul operator (that was previously removed because of old api use) to the export_cpp module, to be able to correctly export a basic MLP onnx model to cpp. The onnx model can be found at: https://huggingface.co/EclipseAidge/mobilenet_v1
Modified files
- Added
reshape.h
,reshape.cpp
and matching jinja kernel to add Operator reshape to export -
operator.py
, to add reshape and matmul operator as well as refactor some duplicate code -
matmul.cpp
,,matmul.h
, to adapt the operator to the new api interface
Detailed major modifications
Created a reshape operator for the export (Basic memcopy of the input buffer to the output buffer)
Adapted the matmul kernel and jinja for the new operator interface (inputs_dims
-> in_dims
for exemple)
Then added back this matmul operator in the export
In operator.py refactor all the shared code for all the composed operator:
-
setupConv2D
for bothConv2D
andPaddedConv2
-
setupElemWiseOp
for all the elemwise operators (Add, Sub, Mul, ...) -
setupPooling
for all the pooling operators (Max, Avg, PaddedMax, ...)
TODO
-
(ref discussion !31 (comment 3330814)) Refactor the reshape operator as a non op for the c++ side (as the reshape doesn't affect the buffer, only the forward dims of the buffer and those are already calculated with the scheduler in python)
Merge request reports
Activity
requested review from @cguillon
added 8 commits
-
c8993e14...f3a546b9 - 4 commits from branch
eclipse/aidge:dev
- 58a14b6a - feat: Add reshape export op
- a703cd5d - fix: Add Matmul export operator back
- fae220eb - chore: Refactor duplicate code in operators
- 3eeb8d95 - fix: conv2D export failure when no biases given
Toggle commit list-
c8993e14...f3a546b9 - 4 commits from branch
- Resolved by Olivier BICHLER
- Resolved by Christophe Guillon
- Resolved by Christophe Guillon
- Resolved by Christophe Guillon
- Resolved by Christophe Guillon
- Resolved by Christophe Guillon
- Resolved by Christophe Guillon
@gallasko Please reference the actual huggingface network you used in the description.
requested review from @pineapple
- Resolved by Christophe Guillon
@pineapple we took the route for the reshape operator to make a plain copy, do you have objections? Here are the rationales:
- while from the dataflow graph operations point of view, it would be legitimate to just return the input pointer, the memory layouter actually allocates the output hence, without further wok there is an inconsistency.
- reshape in itself could be removed from the graph as it is the case for flatten, though we prefer to have an implementation of the operator such that the forward, export and al. work without graph optimization.
For the first point, do you known if there is already in aidge core some way to specify that the output of an operation may overlap (or here fully overlap) with some input. Such that we can describe this and it is managed by the memory scheduler, and it would be legitimate for the export to simply make a pointer copy?
- Resolved by Christophe Guillon
@gallasko please squash the 2 commits
_setup*
, and the 2 commits related toreshape
implementation`. Also fix the author which must be you Eclipse account email.marked the checklist item (ref discussion !31 (comment 3330814)) Refactor the reshape operator as a non op for the c++ side (as the reshape doesn't affect the buffer, only the forward dims of the buffer and those are already calculated with the scheduler in python) as completed