Open softwarePupil opened 2 years ago
Hi @softwarePupil, Did you still see (?, ?, ?, ?) after using onnx.shape_inference? Could you please share this model for me to repro if possible? Thanks.
I have a similar issue with ReflectionPad2d
I trained a CycleGAN, and after the Pad
node, every shape is unknown.
Initially, I had an error msg of Resource import for /Users/youjin/Downloads/latest_net_G (1).onnx failed: The ONNX network's output '625' dimensions should be non-negative.
To trace back, I used
onnx.save(onnx.shape_inference.infer_shapes(onnx.load(save_path)), save_path)
to see the shapes
and found that after the first initial pad
node, all following shapes are unknown.
This is the link of the onnx file just in case you want to see
Thanks for providing the model -- I can repro this issue. Pad cannot infer a concrete shape inference, because it needs to know the exact value of second input "pads" (it only knows its shape instead): https://github.com/onnx/onnx/blob/f0d824c0ead2825f7c24790c05f985ad1fb909f2/onnx/defs/tensor/old.cc#L2325 Therefore it can only perform rank inference. Basic ONNX shape inference can only propagate "shape" and here such a pads value comes from "ConstantOfShape" through a few operators. Although ONNX does have data propagation to handle this kind of situation, currently Transpose does not have data propagation support.
Hello @jcwchen ,
Thanks for the reply.
I wonder if the answer implies that I cannot use my model due to having transpose
and pad
?
Or should I be able to use it even if onnx cannot infer shapes?
Sorry for such a noob question. I am confused if a normal onnx model should show all shapes, at least shapes of input and output, or if a model is still normal without shape inference.
No worries. I am happy to resolve your confusion. Please note that ONNX shape inference is not guaranteed to be complete. See limitation here. Therefore, it's possible to see some nodes cannot get the inferred shapes from ONNX shape inference and they are still valid ONNX models.
Ask a Question
Question
I have made a very simple network with only pad and relu operation.After generating the onnx model and visualizing him, the tensor size after pad becomes (????).
Did I make a mistake somewhere?