Dealing with multiple inputs for onnx export

My model takes multiple inputs (9 tensors), how do I pass it as one input in the following form:

torch.onnx.export(model,inputs,'model.onnx')

I’ve tried putting all the tensors in the list and passing it as input.
TypeError: forward() missing 8 required positional argument. What can be a work around for this ?

@ptrblck Could you please suggest some workaround ?

I’m not really experienced in ONNX, so that unfortunately I cannot really help.

However, could you just change the forward method of your model to take a list instead of 9 arguments?

My forward method takes 9 arguments only. But in this case, they (as per docs) assume that only one tensor is passed to model. But what about models which take multiple tensors as input ?

I have a similar problem but looks simpler taking only two arguments inputs.
For your case, from other forum, the solution is to wrap your input as tuple e.g. instead of

onnx.export(model, inputs, ...)

use this:

onnx.export(model, (inputs,), ...)
3 Likes