Skip to content

Draft: onnx import export unit tests for every operator

!! Still in initial steps

Context

Import from ONNX and export to ONNX was not being tested. This merge request has the objective of adding unit test for every operator where their attributes, dimensions and parameters are compared. If the unit tests are correctly, it would guarrantee that the imported and exported models are equal.

For each operator there will be a test function for every existing ONNX opset. Even if there are no differences between opsets a function will be made for every opset.

Organisational improvements should also be considered.

Modified files

One unit test file is added for every operator. These files are located in aidge_onnx/unit_tests and have the following naming convention: test_node_operator.

Although it should be considered the creation of a dedicated folder for these unit tests as to not drown the other tests.

TODO

As said above this merge request is in its initial steps. Most operators are partially/almost done but they need some verifications.

General

  • Check attribute "consumed_inputs" precense in operators, and if present send an error
  • Custom way of adding inputs and initializers is needed
  • Test all opsets
  • Look at special cases, ex: "Constant" not having export to ONNX, Identity, Dropout
  • Adapt comments to operators

Operator progress:

An operator being checked does not mean that it is finalised, at this point it just means that the basic tests were created; some polishing and corrections are still needed.

  • add
  • averagepool
  • batchnorm (missing parameters and some attributes tests)
  • concat
  • conv
  • div
  • erf
  • gather (issue: attributes and parameters in inputs)
  • gemm (rework needed)
  • globalaveragepooling
  • leakyrelu (verifications needed)
  • lstm
  • matmul
  • maxpool
  • mul
  • pow
  • reducemean (issue: attributes and parameters in inputs, opset 18 missing)
  • relu
  • reshape (issue: attributes and parameters in inputs)
  • shape (verifications needed)
  • sigmoid (verifications needed)
  • slice (issue: attributes and parameters in inputs)
  • softmax (verifications needed)
  • split (issue: attributes and parameters in inputs)
  • sqrt (verifications needed)
  • sub (verifications needed)
  • tanh (verifications needed)
  • transpose (verifications needed)

Merge request reports