Skip to content

Add proper unit tests

Description

Add unit tests to aidge_nir. The full list of NIR nodes is given at https://neuroir.org/docs/api_nir.html#module-nir.ir.

Status

  • Conv1d
  • Conv2d
  • Flatten
  • Leaky
  • AvgPool2d
  • Linear

Proposal

Since aidge_nir is very similar to aidge_onnx, the tests should be similar too.

aidge_onnx has different types of unit tests :

  • Converter contract: check that import/export registries have the expected operator keys, test dynamic registration (addition or removal of an operator), and check the signature of converters.
  • Import Coverage: per-node and full model imports. (Note: The full model could use SnnTorch for comparison, but as of writing these lines, snntorch and nir interop is broken, requiring downgrading the nir package and installing snntorch from sources.)

Unit Tests for node import

Each NIR node type should have its own node import test (starting with lif, flatten and affine). The tests follow the same pattern :

  • Create an NIR node.
  • Define an implementation with NumPy for reference (ONNX has ONNX runtime, but NIR does not have any runtime).
  • Convert the NIR node to Aidge using NIR_NODE_CONVERTER
  • Compare the forward pass of Aidge and the reference implementation.
Edited by Jerome Hue