You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found a bug happening when translating a Resize op that uses a 'sizes' argument.
The required input arguments 'rois' and 'scales' are being dropped, since they are None, but they are "required empty" by onnxruntime.
The strange thing is that the translation when running 'from function' is OK, but exporting the model misses the inputs.
Here is the minimal working example:
importnumpyasnpimportonnximportonnxruntimeasortfromonnxscriptimportFLOATfromonnxscriptimportopset20asopfromonnxscriptimportscript@script()defresize(X: FLOAT[800, 600]) ->FLOAT[512, 512]:
returnop.Resize(X, sizes=[512, 512])
# checker is OKonnx.checker.check_model(resize.to_model_proto())
# This works - skipped arguments `roi` and `scales` get correctly translated to "empty tensors"print("From function - OK")
X=np.eye(800, 600, dtype=np.float32)
Y=resize(X)
# This doesn't - the `roi` and `scales` get omitted, which makes `sizes` a second argument, while it needs to be fourth.try:
print("\n\n\nBug - not OK \n==================")
session=ort.InferenceSession(resize.to_model_proto().SerializeToString())
Y=session.run(None, {"X": X})
exceptExceptionase:
print(e)
print("==================")
# workaround - add two empty arguments for `roi` and `scales`args=resize.function_ir.stmts[-1].argsresize.function_ir.stmts[-1].args= (args[0], "", "", args[1])
# Now it's OKprint("\nWith workaround - OK")
session=ort.InferenceSession(resize.to_model_proto().SerializeToString())
Y=session.run(None, {"X": X})
And the output of it:
From function - OK
Bug - not OK
==================
[ONNXRuntimeError] : 10 : INVALID_GRAPH : This is an invalid model. Type Error: Type 'tensor(int64)' of input parameter (const) of operator (Resize) in node (n1) is invalid.
==================
With workaround - OK
I'm using onnxscript=0.1.0.dev20250108
And lastly - THANKS - onnxscript is such a great idea for writing pre/post-processing functions!
The text was updated successfully, but these errors were encountered:
Hi,
I found a bug happening when translating a Resize op that uses a 'sizes' argument.
The required input arguments 'rois' and 'scales' are being dropped, since they are None, but they are "required empty" by onnxruntime.
The strange thing is that the translation when running 'from function' is OK, but exporting the model misses the inputs.
Here is the minimal working example:
And the output of it:
I'm using onnxscript=0.1.0.dev20250108
And lastly - THANKS - onnxscript is such a great idea for writing pre/post-processing functions!
The text was updated successfully, but these errors were encountered: