[frontend][onnx]fix pad constant value is none#12555
[frontend][onnx]fix pad constant value is none#12555chengven027 wants to merge 1 commit intoapache:mainfrom chengven027:pad.fix
Conversation
python/tvm/relay/frontend/onnx.py
Outdated
| def _impl_v11(cls, inputs, attr, params): | ||
| pads = inputs[1] | ||
| if len(inputs) == 3: | ||
| if len(inputs) == 3 and input[2] is not None: |
There was a problem hiding this comment.
Reading the docs https://github.com/onnx/onnx/blob/main/docs/Operators.md#Pad we should also be checking if input[2] is also an empty string or False.
Pythonically we can just do and input[2] (though I would add a comment since this handles multiple types)
leandron
left a comment
There was a problem hiding this comment.
Hi @chengven027-intellif, thanks for the PR. Any chance we can have a test case for this change?
|
Dose this PR need to be reviewed again? @AndrewZhaoLuo @leandron |
| verify_pad_v11(np.random.randn(2, 2).astype(np.float32), [0, 1, 0, 0], "constant", 0.0) | ||
| verify_pad_v11(np.random.randn(2, 3).astype(np.float32), [1, 0, 0, 1], "constant", 0.0) | ||
| verify_pad_v11(np.random.randn(3, 2).astype(np.float32), [0, 0, 1, 0], "constant", 5.0) | ||
| verify_pad_v11(np.random.randn(3, 2).astype(np.float32), [0, 0, 1, 0], "constant", False) |
There was a problem hiding this comment.
Is setting False here (as opposed to None) reproducing the same issue this patch is fixing?
There was a problem hiding this comment.
No, But I can't add a test case with None.
First, In the doc test_forward.py test_pad, The value is a default number 0.0,can't set None.
def verify_pad_v11(indata, pads, mode="constant", value=0.0)
Then, the input node constant_value is a TensorProto.FLOAT. not None too.
Can you give me some suggestions to add a test case with 'None'? Thanks very much.
Yeah I'll leave it to Leandron B) |
|
I am sorry, I really can't create an unit test with empty string of |
In verify_pad_v11 I can seem to make the following: However, my version of ONNXRT can't seem to accept the string type. What have you tried? |
|
@AndrewZhaoLuo Yes, I tried many times but I got the same error as yours. |
|
Can you share your model by any chance? Can you also run your model via ONNX-RT? |
|
|
Sorry, I'll take a look tomorrow. Edit: On Friday |
|
Hey, @AndrewZhaoLuo Have you seen this PR, and any update with me? thanks. |
|
Oops, I am so sorry, I have been very busy lately. I will try to get to this this weekend |
hi, cc @AndrewZhaoLuo

When I import my onnx model. I found my model get a error with pad. because the
padconstant value is none. shown as follow:It`s just a very little bug. So I fix it and no unnit test.