Skip to content

[onnx] Nodes without biases cause the creation of input Producer nodes

I'm attempting to perform inferences using a MobileNetv2 from the ONNX zoo.

https://github.com/onnx/models/blob/main/validated/vision/classification/mobilenet/model/mobilenetv2-7.onnx

But, when calling scheduler.forward(True, [input_tensor]), I get the following error:

RuntimeError: Provided 1 inputs to the scheduler, but graph has 7 inputs (required inputs in order: )

After invesigation, I understand that the problem is caused by the handling of bias-less Convolution nodes : the loaded model contains Producer nodes connected to the bias slots of the convolution nodes that are out of the graphView.

nobias

Here is a code snippet that can reproduce the error :

import random
import numpy as np

import aidge_core
import aidge_onnx
import aidge_backend_cpu

MODEL_NAME   = 'mobilenetv2-7'

# --------------------------------------------------------------
# CREATE THE DUMMY SAMPLE
# --------------------------------------------------------------

tensor = aidge_core.Tensor([1, 3, 224, 224])
tensor.set_backend("cpu")
tensor.set_datatype(aidge_core.dtype.float32)

# --------------------------------------------------------------
# SETUP THE MODEL
# --------------------------------------------------------------

aidge_model = aidge_onnx.load_onnx(MODEL_NAME + ".onnx", verbose=False)

aidge_core.remove_flatten(aidge_model)
aidge_core.fuse_batchnorm(aidge_model)

aidge_model.compile("cpu", aidge_core.dtype.float32, dims=[[1, 3, 224, 224]])

# --------------------------------------------------------------
# RUN THE INFERENCE
# --------------------------------------------------------------

scheduler = aidge_core.SequentialScheduler(aidge_model)
scheduler.forward(True, [tensor])    

I'm not sure how I'm supposed to deal with this issue, not either if it is caused by aidge_core or aidge_onnx.

Edited by Maxence Naud