Skip to content

[onnx] Unable to export a simple Sequential model

Descritpion

I'm trying to setup a simple script that tests the ONNX export function, but I'm facing an error.

Here is the script :

import aidge_core
import aidge_onnx

# setup the model 
model = aidge_core.sequential(
            [aidge_core.FC(name="FC0", in_channels=784, out_channels=100),
             aidge_core.ReLU(name="ReLU0"),
             aidge_core.FC(name="FC1", in_channels=100, out_channels=100),
             aidge_core.ReLU(name="ReLU1"),
             aidge_core.FC(name="FC2", in_channels=100, out_channels=10)])

# export the model
aidge_onnx.export_onnx(
    model, 
    'model.onnx', 
    inputs_dims=[[1, 784]],
    outputs_dims=[[1, 10]],
    opset = 18
    )

And here is the log :

Traceback (most recent call last):
  File "/data1/is156025/bh277217/workspace/dev_operator/test-export.py", line 43, in <module>
    aidge_onnx.export_onnx(
  File "/data1/is156025/bh277217/miniconda3/envs/main/lib/python3.10/site-packages/aidge_onnx/onnx_export.py", line 273, in export_onnx
    new_nodes = AIDGE_NODE_CONVERTER_[aidge_node.type()](
  File "/data1/is156025/bh277217/miniconda3/envs/main/lib/python3.10/site-packages/aidge_onnx/node_export/aidge_converters/producer.py", line 32, in export_producer
    raise ValueError("Initializer operator has not been catched when creating Initializers.")

It appears that the error is caused by the export_producer function that catches Producers with attributes constant set to False.

On the other hand, if I force the constant attribute values (op.attr.constant = True), the export ends up in a segfault.