Skip to content
Snippets Groups Projects

Add missing operators for basic onnx model exporting

Merged Gallas Gaye requested to merge gallasko/aidge_export_cpp:new_operator into dev

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 both Conv2D and PaddedConv2
  • 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)
Edited by Gallas Gaye

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Christophe Guillon
  • Christophe Guillon
  • Christophe Guillon
  • Christophe Guillon
  • Christophe Guillon
  • 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?

  • Christophe Guillon changed the description

    changed the description

  • Olivier BICHLER
  • Gallas Gaye added 2 commits

    added 2 commits

    • 8dd89f61 - fix: _setup_pooling not used correctly
    • 7ddf2ee5 - feat: Reshape is a noop if the inputs and ouputs points to the same buffer

    Compare with previous version

  • Gallas Gaye changed the description

    changed the description

  • Christophe Guillon resolved all threads

    resolved all threads

  • Olivier BICHLER resolved all threads

    resolved all threads

  • @gallasko please squash the 2 commits _setup*, and the 2 commits related to reshape implementation`. Also fix the author which must be you Eclipse account email.

  • Gallas Gaye 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

    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

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading