Open justinchuby opened 3 weeks ago
✅ Obtain model graph with `torch.export.export`
✅ Translate the graph into ONNX
✅ Run `onnx.checker` on the ONNX model
✅ Execute the model with ONNX Runtime
✅ Validate model output accuracy
_ ._ __/__ _ _ _ _ _/_ Recorded: 10:17:49 Samples: 949
/_//_/// /_\ / //_// / //_'/ // Duration: 2.263 CPU time: 0.864
/ _/ v4.6.2
Program: -c
2.262 _torch_onnx_export_adapter_with_error_report torch_onnx/_patch.py:210
└─ 2.262 _torch_onnx_export_adaptor torch_onnx/_patch.py:139
├─ 1.637 export torch/export/__init__.py:73
│ [126 frames hidden] torch, contextlib, importlib, jinja2,...
└─ 0.625 exported_program_to_ir torch_onnx/_core.py:574
├─ 0.527 OnnxRegistry.from_torchlib torch_onnx/_registration.py:114
│ ├─ 0.325 TracedOnnxFunction.function_ir ../onnxscript/onnxscript/values.py:587
│ │ ├─ 0.242 get_src_and_ast ../onnxscript/onnxscript/_internal/ast_utils.py:16
│ │ │ ├─ 0.200 getsource inspect.py:1256
│ │ │ │ [6 frames hidden] inspect, tokenize, <built-in>
│ │ │ └─ 0.039 parse ast.py:33
│ │ │ [2 frames hidden] ast, <built-in>
│ │ └─ 0.067 Converter.translate_function_signature ../onnxscript/onnxscript/converter.py:1463
│ │ └─ 0.067 Converter._translate_function_signature_common ../onnxscript/onnxscript/converter.py:1378
│ │ └─ 0.029 is_valid_type ../onnxscript/onnxscript/type_annotation.py:172
│ │ └─ 0.029 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ ├─ 0.128 OpSignature.from_function torch_onnx/_schemas.py:398
│ │ ├─ 0.066 get_type_hints typing.py:2300
│ │ │ [6 frames hidden] typing, <built-in>
│ │ └─ 0.035 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ └─ 0.025 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ └─ 0.051 _get_overload torch_onnx/_registration.py:57
│ └─ 0.041 _OpNamespace.__getattr__ torch/_ops.py:905
├─ 0.037 create_onnx_friendly_decomposition_table torch_onnx/_decomp.py:39
│ └─ 0.027 _get_registered_ops torch_onnx/_decomp.py:12
└─ 0.035 wrapper torch/export/exported_program.py:80
[6 frames hidden] torch
✅ Obtain model graph with `torch.export.export`
❌ Translate the graph into ONNX
⚪ Run `onnx.checker` on the ONNX model
⚪ Execute the model with ONNX Runtime
⚪ Validate model output accuracy
Error message:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 490, in _add_nodes
_handle_call_function_node_with_lowering(
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 372, in _handle_call_function_node_with_lowering
raise RuntimeError(
RuntimeError: No ONNX function found for <OpOverload(op='aten.index_put', overload='default')>. Failure message: All overloads did not match the node `%index_put : [num_users=1] = call_function[target=torch.ops.aten.index_put.default](args = (%arg0_1, [%arg1_1], %lift_fresh_copy), kwargs = {})`.
- Failed to match overload `OnnxFunction(<function aten_index_put at 0x1784c82c0>)`: Parameter type not compatible with argument: param=`Parameter(name='self', type_constraint=TypeConstraintParam(name='TReal', allowed_types={Tensor(INT32), Tensor(FLOAT), Tensor(INT16), Tensor(FLOAT16), Tensor(BFLOAT16), Tensor(INT8), Tensor(DOUBLE), Tensor(INT64)}, description=''), required=True, variadic=False, default=_EMPTY_DEFAULT)`, assigned_types=`{}`, arg=`BOOL`
- Failed to match overload `OnnxFunction(<function aten_index_put_bool at 0x1784c8360>)`: Parameter type not compatible with argument: param=`Parameter(name='self', type_constraint=TypeConstraintParam(name='TReal', allowed_types={Tensor(INT32), Tensor(FLOAT), Tensor(INT16), Tensor(FLOAT16), Tensor(BFLOAT16), Tensor(INT8), Tensor(DOUBLE), Tensor(INT64)}, description=''), required=True, variadic=False, default=_EMPTY_DEFAULT)`, assigned_types=`{}`, arg=`BOOL`
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 174, in _torch_onnx_export_adaptor
ir_model = torch_onnx.exported_program_to_ir(program)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 626, in exported_program_to_ir
values = _add_nodes(exported_program, model, lower=lower, registry=registry)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 501, in _add_nodes
raise RuntimeError(
RuntimeError: Error when translating node %index_put : [num_users=1] = call_function[target=torch.ops.aten.index_put.default](args = (%arg0_1, [%arg1_1], %lift_fresh_copy), kwargs = {}). See the stack trace for more information.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 230, in _torch_onnx_export_adapter_with_error_report
ir_model, program = _torch_onnx_export_adaptor(*args, **kwargs, check=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 197, in _torch_onnx_export_adaptor
raise OnnxConversionError(
torch_onnx._patch.OnnxConversionError: Failed to convert the exported program to an ONNX model. [96mThis is step 2/2[0m of exporting the model to ONNX. Please create an issue in the PyTorch GitHub repository against the [96m*onnx*[0m component and attach the full error stack as well as reproduction scripts. You can run `torch_onnx.analyze()` to produce an error report after obtaining an ExportedProgram with `torch.export.export()`.
Exported program:
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, _lifted_tensor_constant0: "b8[]", arg0_1: "b8[100]", arg1_1: "i64[25]"):
# File: /Users/justinc/Documents/GitHub/torch-onnx/tests/pytorch_test.py:2361 in forward, code: mask[indices] = True
lift_fresh_copy: "b8[]" = torch.ops.aten.lift_fresh_copy.default(_lifted_tensor_constant0); _lifted_tensor_constant0 = None
index_put: "b8[100]" = torch.ops.aten.index_put.default(arg0_1, [arg1_1], lift_fresh_copy); arg0_1 = arg1_1 = lift_fresh_copy = None
return (index_put, index_put)
Graph signature: ExportGraphSignature(input_specs=[InputSpec(kind=<InputKind.CONSTANT_TENSOR: 4>, arg=TensorArgument(name='_lifted_tensor_constant0'), target='_lifted_tensor_constant0', persistent=None), InputSpec(kind=<InputKind.USER_INPUT: 1>, arg=TensorArgument(name='arg0_1'), target=None, persistent=None), InputSpec(kind=<InputKind.USER_INPUT: 1>, arg=TensorArgument(name='arg1_1'), target=None, persistent=None)], output_specs=[OutputSpec(kind=<OutputKind.USER_INPUT_MUTATION: 6>, arg=TensorArgument(name='index_put'), target='arg0_1'), OutputSpec(kind=<OutputKind.USER_OUTPUT: 1>, arg=TensorArgument(name='index_put'), target=None)])
Range constraints: {}
PyTorch ONNX Conversion Analysis
The model has 0 parameters and 0 buffers (non-trainable parameters). Number of parameters per dtype: defaultdict(<class 'int'>, {}) Number of buffers per dtype: defaultdict(<class 'int'>, {})
Inputs:
arg0_1
: TensorMetadata(shape=torch.Size([100]), dtype=torch.bool, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={})
arg1_1
: TensorMetadata(shape=torch.Size([25]), dtype=torch.int64, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={})
Outputs:
index_put
: TensorMetadata(shape=torch.Size([100]), dtype=torch.bool, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={})
The FX graph has 6 nodes in total. Number of FX nodes per op:
placeholder
: 3call_function
: 2output
: 1Of the call_function nodes, the counts of operators used are:
aten.lift_fresh_copy.default
: 1aten.index_put.default
: 1The model contains operators the dispatcher could not find registered ONNX decompositions for. This may be due to missing implementations, decompositions not registered correctly, or a bug in the dispatcher.
Errors grouped by operator:
aten.index_put.default
: All overloads did not match the node %index_put : [num_users=1] = call_function[target=torch.ops.aten.index_put.default](args = (%arg0_1, [%arg1_1], %lift_fresh_copy), kwargs = {})
.
OnnxFunction(<function aten_index_put at 0x1784c82c0>)
: Parameter type not compatible with argument: param=Parameter(name='self', type_constraint=TypeConstraintParam(name='TReal', allowed_types={Tensor(INT32), Tensor(FLOAT), Tensor(INT16), Tensor(FLOAT16), Tensor(BFLOAT16), Tensor(INT8), Tensor(DOUBLE), Tensor(INT64)}, description=''), required=True, variadic=False, default=_EMPTY_DEFAULT)
, assigned_types={}
, arg=BOOL
OnnxFunction(<function aten_index_put_bool at 0x1784c8360>)
: Parameter type not compatible with argument: param=Parameter(name='self', type_constraint=TypeConstraintParam(name='TReal', allowed_types={Tensor(INT32), Tensor(FLOAT), Tensor(INT16), Tensor(FLOAT16), Tensor(BFLOAT16), Tensor(INT8), Tensor(DOUBLE), Tensor(INT64)}, description=''), required=True, variadic=False, default=_EMPTY_DEFAULT)
, assigned_types={}
, arg=BOOL
. Example node: %index_put : [num_users=1] = call_function[target=torch.ops.aten.index_put.default](args = (%arg0_1, [%arg1_1], %lift_fresh_copy), kwargs = {})
. All nodes: [index_put]
_ ._ __/__ _ _ _ _ _/_ Recorded: 10:26:29 Samples: 319
/_//_/// /_\ / //_// / //_'/ // Duration: 0.587 CPU time: 0.261
/ _/ v4.6.2
Program: -c
0.587 _torch_onnx_export_adapter_with_error_report torch_onnx/_patch.py:210
└─ 0.587 _torch_onnx_export_adaptor torch_onnx/_patch.py:139
├─ 0.510 exported_program_to_ir torch_onnx/_core.py:574
│ ├─ 0.421 OnnxRegistry.from_torchlib torch_onnx/_registration.py:114
│ │ ├─ 0.228 TracedOnnxFunction.function_ir ../onnxscript/onnxscript/values.py:587
│ │ │ ├─ 0.175 get_src_and_ast ../onnxscript/onnxscript/_internal/ast_utils.py:16
│ │ │ │ ├─ 0.146 getsource inspect.py:1256
│ │ │ │ │ [14 frames hidden] inspect, tokenize, <built-in>, <string>
│ │ │ │ └─ 0.029 parse ast.py:33
│ │ │ │ [2 frames hidden] ast, <built-in>
│ │ │ └─ 0.050 Converter.translate_function_signature ../onnxscript/onnxscript/converter.py:1463
│ │ │ └─ 0.050 Converter._translate_function_signature_common ../onnxscript/onnxscript/converter.py:1378
│ │ │ ├─ 0.025 is_valid_type ../onnxscript/onnxscript/type_annotation.py:172
│ │ │ │ └─ 0.025 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ │ ├─ 0.015 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ │ │ └─ 0.007 <listcomp> ../onnxscript/onnxscript/type_annotation.py:150
│ │ │ │ │ └─ 0.007 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ │ │ └─ 0.007 _is_tensor_type ../onnxscript/onnxscript/type_annotation.py:123
│ │ │ │ └─ 0.006 <listcomp> ../onnxscript/onnxscript/type_annotation.py:150
│ │ │ │ └─ 0.006 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ ├─ 0.011 is_attr_type ../onnxscript/onnxscript/type_annotation.py:168
│ │ │ │ └─ 0.011 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ └─ 0.007 pytype_to_attrtype ../onnxscript/onnxscript/type_annotation.py:83
│ │ │ └─ 0.007 _remove_annotation ../onnxscript/onnxscript/type_annotation.py:70
│ │ │ └─ 0.007 get_origin typing.py:2424
│ │ └─ 0.181 OpSignature.from_function torch_onnx/_schemas.py:398
│ │ ├─ 0.071 get_type_hints typing.py:2300
│ │ │ [8 frames hidden] typing, <built-in>
│ │ ├─ 0.067 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ └─ 0.060 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ ├─ 0.037 _is_optional torch_onnx/_schemas.py:185
│ │ │ │ └─ 0.037 get_args typing.py:2454
│ │ │ │ [2 frames hidden] typing
│ │ │ └─ 0.018 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ └─ 0.012 [self] torch_onnx/_schemas.py
│ │ ├─ 0.028 [self] torch_onnx/_schemas.py
│ │ └─ 0.010 signature inspect.py:3278
│ │ [4 frames hidden] inspect
│ ├─ 0.049 create_onnx_friendly_decomposition_table torch_onnx/_decomp.py:39
│ │ ├─ 0.037 core_aten_decompositions torch/_decomp/__init__.py:253
│ │ │ [5 frames hidden] torch
│ │ └─ 0.008 OpOverload.__hash__ torch/_ops.py:596
│ └─ 0.036 wrapper torch/export/exported_program.py:80
│ [22 frames hidden] torch
└─ 0.076 export torch/export/__init__.py:73
[56 frames hidden] torch, contextlib, traceback
✅ Obtain model graph with `torch.export.export`
✅ Translate the graph into ONNX
❌ Run `onnx.checker` on the ONNX model
⚪ Execute the model with ONNX Runtime
⚪ Validate model output accuracy
Error message:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 292, in _torch_onnx_export_adapter_with_error_report
onnx.checker.check_model(proto, full_check=True)
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/onnx/checker.py", line 179, in check_model
C.check_model(
onnx.onnx_cpp2py_export.shape_inference.InferenceError: [ShapeInferenceError] Inference error(s): (op_type:Cast, node name: node_Cast_0): [ShapeInferenceError] Inferred shape and existing shape differ in rank: (2) vs (0)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 296, in _torch_onnx_export_adapter_with_error_report
raise OnnxCheckerError(
torch_onnx._patch.OnnxCheckerError: Conversion successful but the ONNX model fails ONNX checker. Please create an issue in the PyTorch GitHub repository against the [96m*onnx*[0m component and attach the full error stack as well as reproduction scripts.
Exported program:
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, arg0_1: "b8[2, 2]"):
# File: /Users/justinc/Documents/GitHub/torch-onnx/tests/pytorch_test.py:9451 in forward, code: return x.all()
all_1: "b8[]" = torch.ops.aten.all.default(arg0_1); arg0_1 = None
return (all_1,)
Graph signature: ExportGraphSignature(input_specs=[InputSpec(kind=<InputKind.USER_INPUT: 1>, arg=TensorArgument(name='arg0_1'), target=None, persistent=None)], output_specs=[OutputSpec(kind=<OutputKind.USER_OUTPUT: 1>, arg=TensorArgument(name='all_1'), target=None)])
Range constraints: {}
PyTorch ONNX Conversion Analysis
The model has 0 parameters and 0 buffers (non-trainable parameters). Number of parameters per dtype: defaultdict(<class 'int'>, {}) Number of buffers per dtype: defaultdict(<class 'int'>, {})
Inputs:
arg0_1
: TensorMetadata(shape=torch.Size([2, 2]), dtype=torch.bool, requires_grad=False, stride=(2, 1), memory_format=torch.contiguous_format, is_quantized=False, qparams={})
Outputs:
all_1
: TensorMetadata(shape=torch.Size([]), dtype=torch.bool, requires_grad=False, stride=(), memory_format=torch.contiguous_format, is_quantized=False, qparams={})
The FX graph has 3 nodes in total. Number of FX nodes per op:
placeholder
: 1call_function
: 1output
: 1Of the call_function nodes, the counts of operators used are:
aten.all.default
: 1All operators in the model have registered ONNX decompositions.
_ ._ __/__ _ _ _ _ _/_ Recorded: 10:30:52 Samples: 1171
/_//_/// /_\ / //_// / //_'/ // Duration: 2.612 CPU time: 1.174
/ _/ v4.6.2
Program: -c
2.611 _torch_onnx_export_adapter_with_error_report torch_onnx/_patch.py:210
└─ 2.611 _torch_onnx_export_adaptor torch_onnx/_patch.py:139
├─ 1.940 export torch/export/__init__.py:73
│ [92 frames hidden] torch, contextlib, tokenize, <string>...
└─ 0.670 exported_program_to_ir torch_onnx/_core.py:574
├─ 0.577 OnnxRegistry.from_torchlib torch_onnx/_registration.py:114
│ ├─ 0.269 OpSignature.from_function torch_onnx/_schemas.py:398
│ │ ├─ 0.120 get_type_hints typing.py:2300
│ │ │ [4 frames hidden] typing, <built-in>
│ │ ├─ 0.089 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ └─ 0.077 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ └─ 0.068 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ └─ 0.064 TensorType.__hash__ ../onnxscript/onnxscript/ir/_core.py:1291
│ │ │ └─ 0.064 TensorType.__repr__ ../onnxscript/onnxscript/ir/_core.py:1299
│ │ │ └─ 0.062 DataType.__repr__ ../onnxscript/onnxscript/ir/_enums.py:94
│ │ │ └─ 0.050 [self] ../onnxscript/onnxscript/ir/_enums.py
│ │ └─ 0.039 _get_attr_type torch_onnx/_schemas.py:204
│ └─ 0.267 TracedOnnxFunction.function_ir ../onnxscript/onnxscript/values.py:587
│ ├─ 0.214 get_src_and_ast ../onnxscript/onnxscript/_internal/ast_utils.py:16
│ │ ├─ 0.168 getsource inspect.py:1256
│ │ │ [5 frames hidden] inspect, tokenize
│ │ └─ 0.043 parse ast.py:33
│ │ [2 frames hidden] ast, <built-in>
│ └─ 0.044 Converter.translate_function_signature ../onnxscript/onnxscript/converter.py:1463
│ └─ 0.044 Converter._translate_function_signature_common ../onnxscript/onnxscript/converter.py:1378
├─ 0.039 wrapper torch/export/exported_program.py:80
│ [2 frames hidden] torch
└─ 0.036 create_onnx_friendly_decomposition_table torch_onnx/_decomp.py:39
└─ 0.033 _get_registered_ops torch_onnx/_decomp.py:12
✅ Obtain model graph with `torch.export.export`
✅ Translate the graph into ONNX
✅ Run `onnx.checker` on the ONNX model
✅ Execute the model with ONNX Runtime
✅ Validate model output accuracy
Exported program:
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, arg0_1: "f32[10, 10, 10]", arg1_1: "f32[10, 10, 10]", arg2_1: "f32[20, 5, 10, 10, 10]"):
# File: /Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/external_utils.py:36 in inner, code: return fn(*args, **kwargs)
native_layer_norm = torch.ops.aten.native_layer_norm.default(arg2_1, [10, 10, 10], arg0_1, arg1_1, 1e-05); arg2_1 = arg0_1 = arg1_1 = None
getitem: "f32[20, 5, 10, 10, 10]" = native_layer_norm[0]; native_layer_norm = None
return (getitem,)
Graph signature: ExportGraphSignature(input_specs=[InputSpec(kind=<InputKind.PARAMETER: 2>, arg=TensorArgument(name='arg0_1'), target='weight', persistent=None), InputSpec(kind=<InputKind.PARAMETER: 2>, arg=TensorArgument(name='arg1_1'), target='bias', persistent=None), InputSpec(kind=<InputKind.USER_INPUT: 1>, arg=TensorArgument(name='arg2_1'), target=None, persistent=None)], output_specs=[OutputSpec(kind=<OutputKind.USER_OUTPUT: 1>, arg=TensorArgument(name='getitem'), target=None)])
Range constraints: {}
_ ._ __/__ _ _ _ _ _/_ Recorded: 10:31:18 Samples: 285
/_//_/// /_\ / //_// / //_'/ // Duration: 0.682 CPU time: 0.310
/ _/ v4.6.2
Program: -c
0.681 _torch_onnx_export_adapter_with_error_report torch_onnx/_patch.py:210
└─ 0.681 _torch_onnx_export_adaptor torch_onnx/_patch.py:139
├─ 0.496 exported_program_to_ir torch_onnx/_core.py:574
│ ├─ 0.403 OnnxRegistry.from_torchlib torch_onnx/_registration.py:114
│ │ ├─ 0.257 TracedOnnxFunction.function_ir ../onnxscript/onnxscript/values.py:587
│ │ │ ├─ 0.188 get_src_and_ast ../onnxscript/onnxscript/_internal/ast_utils.py:16
│ │ │ │ ├─ 0.174 getsource inspect.py:1256
│ │ │ │ │ [8 frames hidden] inspect, tokenize, <built-in>, <string>
│ │ │ │ └─ 0.009 parse ast.py:33
│ │ │ │ [2 frames hidden] ast, <built-in>
│ │ │ └─ 0.068 Converter.translate_function_signature ../onnxscript/onnxscript/converter.py:1463
│ │ │ └─ 0.068 Converter._translate_function_signature_common ../onnxscript/onnxscript/converter.py:1378
│ │ │ └─ 0.057 is_valid_type ../onnxscript/onnxscript/type_annotation.py:172
│ │ │ └─ 0.057 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ └─ 0.054 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ └─ 0.051 <listcomp> ../onnxscript/onnxscript/type_annotation.py:150
│ │ │ └─ 0.051 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ └─ 0.049 _is_tensor_type ../onnxscript/onnxscript/type_annotation.py:123
│ │ │ └─ 0.048 [self] ../onnxscript/onnxscript/type_annotation.py
│ │ └─ 0.137 OpSignature.from_function torch_onnx/_schemas.py:398
│ │ ├─ 0.088 get_type_hints typing.py:2300
│ │ │ [11 frames hidden] typing, <built-in>
│ │ ├─ 0.033 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ └─ 0.030 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ └─ 0.027 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ ├─ 0.013 TensorType.__hash__ ../onnxscript/onnxscript/ir/_core.py:1291
│ │ │ │ └─ 0.010 TensorType.__repr__ ../onnxscript/onnxscript/ir/_core.py:1299
│ │ │ │ └─ 0.008 [self] ../onnxscript/onnxscript/ir/_core.py
│ │ │ └─ 0.009 [self] torch_onnx/_schemas.py
│ │ └─ 0.009 signature inspect.py:3278
│ │ [4 frames hidden] inspect
│ ├─ 0.073 wrapper torch/export/exported_program.py:80
│ │ [62 frames hidden] torch, <built-in>
│ └─ 0.018 create_onnx_friendly_decomposition_table torch_onnx/_decomp.py:39
│ └─ 0.007 core_aten_decompositions torch/_decomp/__init__.py:253
│ [2 frames hidden] torch
└─ 0.185 export torch/export/__init__.py:73
[69 frames hidden] torch, contextlib, traceback, <built-in>
✅ Obtain model graph with `torch.export.export`
✅ Translate the graph into ONNX
❌ Run `onnx.checker` on the ONNX model
⚪ Execute the model with ONNX Runtime
⚪ Validate model output accuracy
Error message:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 292, in _torch_onnx_export_adapter_with_error_report
onnx.checker.check_model(proto, full_check=True)
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/onnx/checker.py", line 179, in check_model
C.check_model(
onnx.onnx_cpp2py_export.shape_inference.InferenceError: [ShapeInferenceError] Inference error(s): (op_type:Cast, node name: node_Cast_0): [ShapeInferenceError] Inferred shape and existing shape differ in rank: (2) vs (0)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 296, in _torch_onnx_export_adapter_with_error_report
raise OnnxCheckerError(
torch_onnx._patch.OnnxCheckerError: Conversion successful but the ONNX model fails ONNX checker. Please create an issue in the PyTorch GitHub repository against the [96m*onnx*[0m component and attach the full error stack as well as reproduction scripts.
Exported program:
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, arg0_1: "b8[2, 2]"):
# File: /Users/justinc/Documents/GitHub/torch-onnx/tests/pytorch_test.py:9451 in forward, code: return x.all()
all_1: "b8[]" = torch.ops.aten.all.default(arg0_1); arg0_1 = None
return (all_1,)
Graph signature: ExportGraphSignature(input_specs=[InputSpec(kind=<InputKind.USER_INPUT: 1>, arg=TensorArgument(name='arg0_1'), target=None, persistent=None)], output_specs=[OutputSpec(kind=<OutputKind.USER_OUTPUT: 1>, arg=TensorArgument(name='all_1'), target=None)])
Range constraints: {}
ONNX model:
<
ir_version=9,
opset_imports={'': 18},
producer_name='torch',
producer_version='2.3.1',
domain=None,
model_version=None,
>
graph(
name=main_graph,
inputs=(
%"arg0_1"<BOOL,[2,2]>
),
outputs=(
%"val_all_1"<BOOL,[]>
),
) {
0 | # node_Cast_0
%"val_all_1"<BOOL,[]> ⬅️ ::Cast(%"arg0_1") {to=9}
return %"val_all_1"<BOOL,[]>
}
PyTorch ONNX Conversion Analysis
The model has 0 parameters and 0 buffers (non-trainable parameters). Number of parameters per dtype: defaultdict(<class 'int'>, {}) Number of buffers per dtype: defaultdict(<class 'int'>, {})
Inputs:
arg0_1
: TensorMetadata(shape=torch.Size([2, 2]), dtype=torch.bool, requires_grad=False, stride=(2, 1), memory_format=torch.contiguous_format, is_quantized=False, qparams={})
Outputs:
all_1
: TensorMetadata(shape=torch.Size([]), dtype=torch.bool, requires_grad=False, stride=(), memory_format=torch.contiguous_format, is_quantized=False, qparams={})
The FX graph has 3 nodes in total. Number of FX nodes per op:
placeholder
: 1call_function
: 1output
: 1Of the call_function nodes, the counts of operators used are:
aten.all.default
: 1All operators in the model have registered ONNX decompositions.
_ ._ __/__ _ _ _ _ _/_ Recorded: 10:34:51 Samples: 1165
/_//_/// /_\ / //_// / //_'/ // Duration: 3.177 CPU time: 1.208
/ _/ v4.6.2
Program: -c
3.176 _torch_onnx_export_adapter_with_error_report torch_onnx/_patch.py:210
└─ 3.176 _torch_onnx_export_adaptor torch_onnx/_patch.py:139
├─ 2.397 export torch/export/__init__.py:73
│ [97 frames hidden] torch, contextlib, importlib, functoo...
└─ 0.779 exported_program_to_ir torch_onnx/_core.py:574
├─ 0.650 OnnxRegistry.from_torchlib torch_onnx/_registration.py:114
│ ├─ 0.305 TracedOnnxFunction.function_ir ../onnxscript/onnxscript/values.py:587
│ │ ├─ 0.218 get_src_and_ast ../onnxscript/onnxscript/_internal/ast_utils.py:16
│ │ │ ├─ 0.186 getsource inspect.py:1256
│ │ │ │ [7 frames hidden] inspect, tokenize
│ │ │ └─ 0.032 parse ast.py:33
│ │ │ [2 frames hidden] ast, <built-in>
│ │ └─ 0.074 Converter.translate_function_signature ../onnxscript/onnxscript/converter.py:1463
│ │ └─ 0.074 Converter._translate_function_signature_common ../onnxscript/onnxscript/converter.py:1378
│ │ └─ 0.048 is_valid_type ../onnxscript/onnxscript/type_annotation.py:172
│ │ └─ 0.047 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ └─ 0.035 get_origin typing.py:2424
│ ├─ 0.298 OpSignature.from_function torch_onnx/_schemas.py:398
│ │ ├─ 0.115 _get_attr_type torch_onnx/_schemas.py:204
│ │ │ └─ 0.115 get_origin typing.py:2424
│ │ │ [2 frames hidden] typing, <built-in>
│ │ ├─ 0.091 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ ├─ 0.044 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ │ └─ 0.038 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ └─ 0.036 isinstance <built-in>
│ │ └─ 0.054 get_type_hints typing.py:2300
│ └─ 0.041 _get_overload torch_onnx/_registration.py:57
│ └─ 0.037 OpOverloadPacket.__getattr__ torch/_ops.py:800
├─ 0.058 create_onnx_friendly_decomposition_table torch_onnx/_decomp.py:39
│ └─ 0.056 _get_registered_ops torch_onnx/_decomp.py:12
│ └─ 0.047 OpOverloadPacket.__getattr__ torch/_ops.py:800
└─ 0.049 wrapper torch/export/exported_program.py:80
[9 frames hidden] torch
✅ Obtain model graph with `torch.export.export`
❌ Translate the graph into ONNX
⚪ Run `onnx.checker` on the ONNX model
⚪ Execute the model with ONNX Runtime
⚪ Validate model output accuracy
Error message:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 490, in _add_nodes
_handle_call_function_node_with_lowering(
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 372, in _handle_call_function_node_with_lowering
raise RuntimeError(
RuntimeError: No ONNX function found for <OpOverload(op='aten.grid_sampler_3d', overload='default')>. Failure message: No decompositions registered for the real-valued input
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 174, in _torch_onnx_export_adaptor
ir_model = torch_onnx.exported_program_to_ir(program)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 626, in exported_program_to_ir
values = _add_nodes(exported_program, model, lower=lower, registry=registry)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 501, in _add_nodes
raise RuntimeError(
RuntimeError: Error when translating node %grid_sampler_3d : [num_users=1] = call_function[target=torch.ops.aten.grid_sampler_3d.default](args = (%arg0_1, %arg1_1, 0, 0, True), kwargs = {}). See the stack trace for more information.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 230, in _torch_onnx_export_adapter_with_error_report
ir_model, program = _torch_onnx_export_adaptor(*args, **kwargs, check=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 197, in _torch_onnx_export_adaptor
raise OnnxConversionError(
torch_onnx._patch.OnnxConversionError: Failed to convert the exported program to an ONNX model. [96mThis is step 2/2[0m of exporting the model to ONNX. Please create an issue in the PyTorch GitHub repository against the [96m*onnx*[0m component and attach the full error stack as well as reproduction scripts. You can run `torch_onnx.analyze()` to produce an error report after obtaining an ExportedProgram with `torch.export.export()`.
Exported program:
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, arg0_1: "f32[1, 1, 2, 3, 2]", arg1_1: "f32[1, 3, 2, 4, 3]"):
# File: /Users/justinc/Documents/GitHub/torch-onnx/tests/pytorch_test.py:13040 in forward, code: return torch.nn.functional.grid_sample(
grid_sampler_3d: "f32[1, 1, 3, 2, 4]" = torch.ops.aten.grid_sampler_3d.default(arg0_1, arg1_1, 0, 0, True); arg0_1 = arg1_1 = None
return (grid_sampler_3d,)
Graph signature: ExportGraphSignature(input_specs=[InputSpec(kind=<InputKind.USER_INPUT: 1>, arg=TensorArgument(name='arg0_1'), target=None, persistent=None), InputSpec(kind=<InputKind.USER_INPUT: 1>, arg=TensorArgument(name='arg1_1'), target=None, persistent=None)], output_specs=[OutputSpec(kind=<OutputKind.USER_OUTPUT: 1>, arg=TensorArgument(name='grid_sampler_3d'), target=None)])
Range constraints: {}
PyTorch ONNX Conversion Analysis
The model has 0 parameters and 0 buffers (non-trainable parameters). Number of parameters per dtype: defaultdict(<class 'int'>, {}) Number of buffers per dtype: defaultdict(<class 'int'>, {})
Inputs:
arg0_1
: TensorMetadata(shape=torch.Size([1, 1, 2, 3, 2]), dtype=torch.float32, requires_grad=False, stride=(12, 12, 6, 2, 1), memory_format=torch.channels_last_3d, is_quantized=False, qparams={})
arg1_1
: TensorMetadata(shape=torch.Size([1, 3, 2, 4, 3]), dtype=torch.float32, requires_grad=False, stride=(72, 24, 12, 3, 1), memory_format=torch.contiguous_format, is_quantized=False, qparams={})
Outputs:
grid_sampler_3d
: TensorMetadata(shape=torch.Size([1, 1, 3, 2, 4]), dtype=torch.float32, requires_grad=False, stride=(24, 24, 8, 4, 1), memory_format=torch.channels_last_3d, is_quantized=False, qparams={})
The FX graph has 4 nodes in total. Number of FX nodes per op:
placeholder
: 2call_function
: 1output
: 1Of the call_function nodes, the counts of operators used are:
aten.grid_sampler_3d.default
: 1The model contains operators the dispatcher could not find registered ONNX decompositions for. This may be due to missing implementations, decompositions not registered correctly, or a bug in the dispatcher.
Errors grouped by operator:
aten.grid_sampler_3d.default
: No decompositions registered for the real-valued input. Example node: %grid_sampler_3d : [num_users=1] = call_function[target=torch.ops.aten.grid_sampler_3d.default](args = (%arg0_1, %arg1_1, 0, 0, True), kwargs = {})
. All nodes: [grid_sampler_3d]
_ ._ __/__ _ _ _ _ _/_ Recorded: 10:35:03 Samples: 303
/_//_/// /_\ / //_// / //_'/ // Duration: 0.652 CPU time: 0.256
/ _/ v4.6.2
Program: -c
0.652 _torch_onnx_export_adapter_with_error_report torch_onnx/_patch.py:210
└─ 0.652 _torch_onnx_export_adaptor torch_onnx/_patch.py:139
├─ 0.459 exported_program_to_ir torch_onnx/_core.py:574
│ ├─ 0.440 OnnxRegistry.from_torchlib torch_onnx/_registration.py:114
│ │ ├─ 0.277 TracedOnnxFunction.function_ir ../onnxscript/onnxscript/values.py:587
│ │ │ ├─ 0.164 get_src_and_ast ../onnxscript/onnxscript/_internal/ast_utils.py:16
│ │ │ │ ├─ 0.115 getsource inspect.py:1256
│ │ │ │ │ [11 frames hidden] inspect, tokenize, <built-in>, linecache
│ │ │ │ └─ 0.045 parse ast.py:33
│ │ │ │ [2 frames hidden] ast, <built-in>
│ │ │ └─ 0.108 Converter.translate_function_signature ../onnxscript/onnxscript/converter.py:1463
│ │ │ ├─ 0.096 Converter._translate_function_signature_common ../onnxscript/onnxscript/converter.py:1378
│ │ │ │ ├─ 0.026 is_attr_type ../onnxscript/onnxscript/type_annotation.py:168
│ │ │ │ │ └─ 0.026 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ │ │ ├─ 0.014 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ │ │ └─ 0.010 _is_primitive_attr_type ../onnxscript/onnxscript/type_annotation.py:79
│ │ │ │ │ └─ 0.010 _GenericAlias.__hash__ typing.py:1378
│ │ │ │ ├─ 0.021 Converter._bind ../onnxscript/onnxscript/converter.py:278
│ │ │ │ │ └─ 0.019 [self] ../onnxscript/onnxscript/converter.py
│ │ │ │ ├─ 0.018 is_valid_type ../onnxscript/onnxscript/type_annotation.py:172
│ │ │ │ │ └─ 0.018 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ │ │ └─ 0.013 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ │ │ └─ 0.012 <listcomp> ../onnxscript/onnxscript/type_annotation.py:150
│ │ │ │ │ └─ 0.012 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ │ │ └─ 0.009 _is_tensor_type ../onnxscript/onnxscript/type_annotation.py:123
│ │ │ │ │ └─ 0.007 [self] ../onnxscript/onnxscript/type_annotation.py
│ │ │ │ ├─ 0.010 Converter._source_of ../onnxscript/onnxscript/converter.py:238
│ │ │ │ │ └─ 0.009 [self] ../onnxscript/onnxscript/converter.py
│ │ │ │ ├─ 0.010 Converter._eval_constant_expr ../onnxscript/onnxscript/converter.py:451
│ │ │ │ └─ 0.010 [self] ../onnxscript/onnxscript/converter.py
│ │ │ └─ 0.011 [self] ../onnxscript/onnxscript/converter.py
│ │ └─ 0.154 OpSignature.from_function torch_onnx/_schemas.py:398
│ │ ├─ 0.067 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ └─ 0.056 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ └─ 0.053 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ ├─ 0.034 TensorType.__hash__ ../onnxscript/onnxscript/ir/_core.py:1291
│ │ │ │ └─ 0.025 TensorType.__repr__ ../onnxscript/onnxscript/ir/_core.py:1299
│ │ │ │ ├─ 0.016 [self] ../onnxscript/onnxscript/ir/_core.py
│ │ │ │ └─ 0.009 DataType.__repr__ ../onnxscript/onnxscript/ir/_enums.py:94
│ │ │ └─ 0.017 [self] torch_onnx/_schemas.py
│ │ ├─ 0.062 get_type_hints typing.py:2300
│ │ │ [10 frames hidden] typing, <built-in>
│ │ └─ 0.012 signature inspect.py:3278
│ │ [4 frames hidden] inspect
│ ├─ 0.010 wrapper torch/export/exported_program.py:80
│ │ [6 frames hidden] torch
│ └─ 0.007 create_onnx_friendly_decomposition_table torch_onnx/_decomp.py:39
└─ 0.193 export torch/export/__init__.py:73
[78 frames hidden] torch, contextlib, ast, <built-in>, <...
✅ Obtain model graph with `torch.export.export`
❌ Translate the graph into ONNX
⚪ Run `onnx.checker` on the ONNX model
⚪ Execute the model with ONNX Runtime
⚪ Validate model output accuracy
Error message:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 490, in _add_nodes
_handle_call_function_node_with_lowering(
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 372, in _handle_call_function_node_with_lowering
raise RuntimeError(
RuntimeError: No ONNX function found for <OpOverload(op='aten.index_put', overload='default')>. Failure message: All overloads did not match the node `%index_put : [num_users=1] = call_function[target=torch.ops.aten.index_put.default](args = (%arg0_1, [%arg1_1], %lift_fresh_copy), kwargs = {})`.
- Failed to match overload `OnnxFunction(<function aten_index_put at 0x1436c82c0>)`: Parameter type not compatible with argument: param=`Parameter(name='self', type_constraint=TypeConstraintParam(name='TReal', allowed_types={Tensor(BFLOAT16), Tensor(INT8), Tensor(INT32), Tensor(INT64), Tensor(FLOAT), Tensor(DOUBLE), Tensor(FLOAT16), Tensor(INT16)}, description=''), required=True, variadic=False, default=_EMPTY_DEFAULT)`, assigned_types=`{}`, arg=`BOOL`
- Failed to match overload `OnnxFunction(<function aten_index_put_bool at 0x1436c8360>)`: Parameter type not compatible with argument: param=`Parameter(name='self', type_constraint=TypeConstraintParam(name='TReal', allowed_types={Tensor(BFLOAT16), Tensor(INT8), Tensor(INT32), Tensor(INT64), Tensor(FLOAT), Tensor(DOUBLE), Tensor(FLOAT16), Tensor(INT16)}, description=''), required=True, variadic=False, default=_EMPTY_DEFAULT)`, assigned_types=`{}`, arg=`BOOL`
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 174, in _torch_onnx_export_adaptor
ir_model = torch_onnx.exported_program_to_ir(program)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 626, in exported_program_to_ir
values = _add_nodes(exported_program, model, lower=lower, registry=registry)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 501, in _add_nodes
raise RuntimeError(
RuntimeError: Error when translating node %index_put : [num_users=1] = call_function[target=torch.ops.aten.index_put.default](args = (%arg0_1, [%arg1_1], %lift_fresh_copy), kwargs = {}). See the stack trace for more information.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 230, in _torch_onnx_export_adapter_with_error_report
ir_model, program = _torch_onnx_export_adaptor(*args, **kwargs, check=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 197, in _torch_onnx_export_adaptor
raise OnnxConversionError(
torch_onnx._patch.OnnxConversionError: Failed to convert the exported program to an ONNX model. [96mThis is step 2/2[0m of exporting the model to ONNX. Please create an issue in the PyTorch GitHub repository against the [96m*onnx*[0m component and attach the full error stack as well as reproduction scripts. You can run `torch_onnx.analyze()` to produce an error report after obtaining an ExportedProgram with `torch.export.export()`.
Exported program:
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, _lifted_tensor_constant0: "b8[]", arg0_1: "b8[100]", arg1_1: "i64[25]"):
# File: /Users/justinc/Documents/GitHub/torch-onnx/tests/pytorch_test.py:2361 in forward, code: mask[indices] = True
lift_fresh_copy: "b8[]" = torch.ops.aten.lift_fresh_copy.default(_lifted_tensor_constant0); _lifted_tensor_constant0 = None
index_put: "b8[100]" = torch.ops.aten.index_put.default(arg0_1, [arg1_1], lift_fresh_copy); arg0_1 = arg1_1 = lift_fresh_copy = None
return (index_put, index_put)
Graph signature: ExportGraphSignature(input_specs=[InputSpec(kind=<InputKind.CONSTANT_TENSOR: 4>, arg=TensorArgument(name='_lifted_tensor_constant0'), target='_lifted_tensor_constant0', persistent=None), InputSpec(kind=<InputKind.USER_INPUT: 1>, arg=TensorArgument(name='arg0_1'), target=None, persistent=None), InputSpec(kind=<InputKind.USER_INPUT: 1>, arg=TensorArgument(name='arg1_1'), target=None, persistent=None)], output_specs=[OutputSpec(kind=<OutputKind.USER_INPUT_MUTATION: 6>, arg=TensorArgument(name='index_put'), target='arg0_1'), OutputSpec(kind=<OutputKind.USER_OUTPUT: 1>, arg=TensorArgument(name='index_put'), target=None)])
Range constraints: {}
PyTorch ONNX Conversion Analysis
The model has 0 parameters and 0 buffers (non-trainable parameters). Number of parameters per dtype: defaultdict(<class 'int'>, {}) Number of buffers per dtype: defaultdict(<class 'int'>, {})
Inputs:
arg0_1
: TensorMetadata(shape=torch.Size([100]), dtype=torch.bool, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={})
arg1_1
: TensorMetadata(shape=torch.Size([25]), dtype=torch.int64, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={})
Outputs:
index_put
: TensorMetadata(shape=torch.Size([100]), dtype=torch.bool, requires_grad=False, stride=(1,), memory_format=torch.contiguous_format, is_quantized=False, qparams={})
The FX graph has 6 nodes in total. Number of FX nodes per op:
placeholder
: 3call_function
: 2output
: 1Of the call_function nodes, the counts of operators used are:
aten.lift_fresh_copy.default
: 1aten.index_put.default
: 1The model contains operators the dispatcher could not find registered ONNX decompositions for. This may be due to missing implementations, decompositions not registered correctly, or a bug in the dispatcher.
Errors grouped by operator:
aten.index_put.default
: All overloads did not match the node %index_put : [num_users=1] = call_function[target=torch.ops.aten.index_put.default](args = (%arg0_1, [%arg1_1], %lift_fresh_copy), kwargs = {})
.
OnnxFunction(<function aten_index_put at 0x1436c82c0>)
: Parameter type not compatible with argument: param=Parameter(name='self', type_constraint=TypeConstraintParam(name='TReal', allowed_types={Tensor(BFLOAT16), Tensor(INT8), Tensor(INT32), Tensor(INT64), Tensor(FLOAT), Tensor(DOUBLE), Tensor(FLOAT16), Tensor(INT16)}, description=''), required=True, variadic=False, default=_EMPTY_DEFAULT)
, assigned_types={}
, arg=BOOL
OnnxFunction(<function aten_index_put_bool at 0x1436c8360>)
: Parameter type not compatible with argument: param=Parameter(name='self', type_constraint=TypeConstraintParam(name='TReal', allowed_types={Tensor(BFLOAT16), Tensor(INT8), Tensor(INT32), Tensor(INT64), Tensor(FLOAT), Tensor(DOUBLE), Tensor(FLOAT16), Tensor(INT16)}, description=''), required=True, variadic=False, default=_EMPTY_DEFAULT)
, assigned_types={}
, arg=BOOL
. Example node: %index_put : [num_users=1] = call_function[target=torch.ops.aten.index_put.default](args = (%arg0_1, [%arg1_1], %lift_fresh_copy), kwargs = {})
. All nodes: [index_put]
_ ._ __/__ _ _ _ _ _/_ Recorded: 10:35:13 Samples: 305
/_//_/// /_\ / //_// / //_'/ // Duration: 0.678 CPU time: 0.241
/ _/ v4.6.2
Program: -c
0.678 _torch_onnx_export_adapter_with_error_report torch_onnx/_patch.py:210
└─ 0.678 _torch_onnx_export_adaptor torch_onnx/_patch.py:139
├─ 0.548 exported_program_to_ir torch_onnx/_core.py:574
│ ├─ 0.480 OnnxRegistry.from_torchlib torch_onnx/_registration.py:114
│ │ ├─ 0.268 TracedOnnxFunction.function_ir ../onnxscript/onnxscript/values.py:587
│ │ │ ├─ 0.171 get_src_and_ast ../onnxscript/onnxscript/_internal/ast_utils.py:16
│ │ │ │ ├─ 0.144 getsource inspect.py:1256
│ │ │ │ │ [10 frames hidden] inspect, tokenize, <built-in>, <string>
│ │ │ │ └─ 0.027 parse ast.py:33
│ │ │ │ [2 frames hidden] ast, <built-in>
│ │ │ └─ 0.086 Converter.translate_function_signature ../onnxscript/onnxscript/converter.py:1463
│ │ │ └─ 0.085 Converter._translate_function_signature_common ../onnxscript/onnxscript/converter.py:1378
│ │ │ ├─ 0.059 is_valid_type ../onnxscript/onnxscript/type_annotation.py:172
│ │ │ │ └─ 0.059 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ │ └─ 0.056 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ │ └─ 0.054 <listcomp> ../onnxscript/onnxscript/type_annotation.py:150
│ │ │ │ └─ 0.054 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ │ └─ 0.049 _is_tensor_type ../onnxscript/onnxscript/type_annotation.py:123
│ │ │ │ ├─ 0.041 TensorType.__subclasscheck__ <frozen abc>:121
│ │ │ │ │ [2 frames hidden] <frozen abc>
│ │ │ │ └─ 0.008 [self] ../onnxscript/onnxscript/type_annotation.py
│ │ │ └─ 0.018 is_attr_type ../onnxscript/onnxscript/type_annotation.py:168
│ │ │ └─ 0.018 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ └─ 0.010 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ └─ 0.009 <listcomp> ../onnxscript/onnxscript/type_annotation.py:150
│ │ │ └─ 0.007 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ ├─ 0.196 OpSignature.from_function torch_onnx/_schemas.py:398
│ │ │ ├─ 0.118 get_type_hints typing.py:2300
│ │ │ │ [13 frames hidden] typing, <built-in>
│ │ │ ├─ 0.049 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ │ └─ 0.044 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ │ ├─ 0.026 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ │ │ ├─ 0.014 [self] torch_onnx/_schemas.py
│ │ │ │ │ └─ 0.008 DataType.__call__ enum.py:686
│ │ │ │ └─ 0.007 [self] torch_onnx/_schemas.py
│ │ │ └─ 0.020 signature inspect.py:3278
│ │ │ [4 frames hidden] inspect
│ │ └─ 0.009 [self] torch_onnx/_registration.py
│ └─ 0.060 wrapper torch/export/exported_program.py:80
│ [32 frames hidden] torch
└─ 0.130 export torch/export/__init__.py:73
[55 frames hidden] torch, contextlib, <built-in>
✅ Obtain model graph with `torch.export.export`
❌ Translate the graph into ONNX
⚪ Run `onnx.checker` on the ONNX model
⚪ Execute the model with ONNX Runtime
⚪ Validate model output accuracy
Error message:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 490, in _add_nodes
_handle_call_function_node_with_lowering(
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 372, in _handle_call_function_node_with_lowering
raise RuntimeError(
RuntimeError: No ONNX function found for <OpOverload(op='aten.grid_sampler_3d', overload='default')>. Failure message: No decompositions registered for the real-valued input
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 174, in _torch_onnx_export_adaptor
ir_model = torch_onnx.exported_program_to_ir(program)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 626, in exported_program_to_ir
values = _add_nodes(exported_program, model, lower=lower, registry=registry)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 501, in _add_nodes
raise RuntimeError(
RuntimeError: Error when translating node %grid_sampler_3d : [num_users=1] = call_function[target=torch.ops.aten.grid_sampler_3d.default](args = (%arg0_1, %arg1_1, 0, 0, True), kwargs = {}). See the stack trace for more information.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 230, in _torch_onnx_export_adapter_with_error_report
ir_model, program = _torch_onnx_export_adaptor(*args, **kwargs, check=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_patch.py", line 197, in _torch_onnx_export_adaptor
raise OnnxConversionError(
torch_onnx._patch.OnnxConversionError: Failed to convert the exported program to an ONNX model. [96mThis is step 2/2[0m of exporting the model to ONNX. Please create an issue in the PyTorch GitHub repository against the [96m*onnx*[0m component and attach the full error stack as well as reproduction scripts. You can run `torch_onnx.analyze()` to produce an error report after obtaining an ExportedProgram with `torch.export.export()`.
Exported program:
ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, arg0_1: "f32[1, 1, 2, 3, 2]", arg1_1: "f32[1, 3, 2, 4, 3]"):
# File: /Users/justinc/Documents/GitHub/torch-onnx/tests/pytorch_test.py:13040 in forward, code: return torch.nn.functional.grid_sample(
grid_sampler_3d: "f32[1, 1, 3, 2, 4]" = torch.ops.aten.grid_sampler_3d.default(arg0_1, arg1_1, 0, 0, True); arg0_1 = arg1_1 = None
return (grid_sampler_3d,)
Graph signature: ExportGraphSignature(input_specs=[InputSpec(kind=<InputKind.USER_INPUT: 1>, arg=TensorArgument(name='arg0_1'), target=None, persistent=None), InputSpec(kind=<InputKind.USER_INPUT: 1>, arg=TensorArgument(name='arg1_1'), target=None, persistent=None)], output_specs=[OutputSpec(kind=<OutputKind.USER_OUTPUT: 1>, arg=TensorArgument(name='grid_sampler_3d'), target=None)])
Range constraints: {}
PyTorch ONNX Conversion Analysis
The model has 0 parameters and 0 buffers (non-trainable parameters). Number of parameters per dtype: defaultdict(<class 'int'>, {}) Number of buffers per dtype: defaultdict(<class 'int'>, {})
Inputs:
arg0_1
: TensorMetadata(shape=torch.Size([1, 1, 2, 3, 2]), dtype=torch.float32, requires_grad=False, stride=(12, 12, 6, 2, 1), memory_format=torch.contiguous_format, is_quantized=False, qparams={})
arg1_1
: TensorMetadata(shape=torch.Size([1, 3, 2, 4, 3]), dtype=torch.float32, requires_grad=False, stride=(72, 24, 12, 3, 1), memory_format=torch.contiguous_format, is_quantized=False, qparams={})
Outputs:
grid_sampler_3d
: TensorMetadata(shape=torch.Size([1, 1, 3, 2, 4]), dtype=torch.float32, requires_grad=False, stride=(24, 24, 8, 4, 1), memory_format=torch.contiguous_format, is_quantized=False, qparams={})
The FX graph has 4 nodes in total. Number of FX nodes per op:
placeholder
: 2call_function
: 1output
: 1Of the call_function nodes, the counts of operators used are:
aten.grid_sampler_3d.default
: 1The model contains operators the dispatcher could not find registered ONNX decompositions for. This may be due to missing implementations, decompositions not registered correctly, or a bug in the dispatcher.
Errors grouped by operator:
aten.grid_sampler_3d.default
: No decompositions registered for the real-valued input. Example node: %grid_sampler_3d : [num_users=1] = call_function[target=torch.ops.aten.grid_sampler_3d.default](args = (%arg0_1, %arg1_1, 0, 0, True), kwargs = {})
. All nodes: [grid_sampler_3d]
_ ._ __/__ _ _ _ _ _/_ Recorded: 10:35:23 Samples: 286
/_//_/// /_\ / //_// / //_'/ // Duration: 0.600 CPU time: 0.245
/ _/ v4.6.2
Program: -c
0.600 _torch_onnx_export_adapter_with_error_report torch_onnx/_patch.py:210
└─ 0.600 _torch_onnx_export_adaptor torch_onnx/_patch.py:139
├─ 0.512 exported_program_to_ir torch_onnx/_core.py:574
│ ├─ 0.436 OnnxRegistry.from_torchlib torch_onnx/_registration.py:114
│ │ ├─ 0.283 TracedOnnxFunction.function_ir ../onnxscript/onnxscript/values.py:587
│ │ │ ├─ 0.193 get_src_and_ast ../onnxscript/onnxscript/_internal/ast_utils.py:16
│ │ │ │ ├─ 0.167 getsource inspect.py:1256
│ │ │ │ │ [13 frames hidden] inspect, tokenize, <string>, <built-in>
│ │ │ │ └─ 0.024 parse ast.py:33
│ │ │ │ [2 frames hidden] ast, <built-in>
│ │ │ └─ 0.088 Converter.translate_function_signature ../onnxscript/onnxscript/converter.py:1463
│ │ │ └─ 0.087 Converter._translate_function_signature_common ../onnxscript/onnxscript/converter.py:1378
│ │ │ ├─ 0.075 is_valid_type ../onnxscript/onnxscript/type_annotation.py:172
│ │ │ │ └─ 0.075 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ │ ├─ 0.061 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ │ │ └─ 0.060 <listcomp> ../onnxscript/onnxscript/type_annotation.py:150
│ │ │ │ │ └─ 0.060 is_value_type ../onnxscript/onnxscript/type_annotation.py:131
│ │ │ │ │ └─ 0.060 _is_tensor_type ../onnxscript/onnxscript/type_annotation.py:123
│ │ │ │ │ └─ 0.059 TensorType.__instancecheck__ <frozen abc>:117
│ │ │ │ │ [3 frames hidden] <frozen abc>, <built-in>
│ │ │ │ └─ 0.010 _remove_annotation ../onnxscript/onnxscript/type_annotation.py:70
│ │ │ │ └─ 0.006 get_origin typing.py:2424
│ │ │ └─ 0.006 Converter._eval_constant_expr ../onnxscript/onnxscript/converter.py:451
│ │ └─ 0.145 OpSignature.from_function torch_onnx/_schemas.py:398
│ │ ├─ 0.053 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ ├─ 0.037 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ │ ├─ 0.018 _get_allowed_types_from_type_annotation torch_onnx/_schemas.py:255
│ │ │ │ │ └─ 0.006 [self] torch_onnx/_schemas.py
│ │ │ │ └─ 0.014 _is_optional torch_onnx/_schemas.py:185
│ │ │ │ └─ 0.011 [self] torch_onnx/_schemas.py
│ │ │ └─ 0.015 DataType.__call__ enum.py:686
│ │ │ [2 frames hidden] enum
│ │ ├─ 0.042 signature inspect.py:3278
│ │ │ [5 frames hidden] inspect
│ │ └─ 0.039 get_type_hints typing.py:2300
│ │ [9 frames hidden] typing, <built-in>
│ ├─ 0.040 wrapper torch/export/exported_program.py:80
│ │ [20 frames hidden] torch
│ └─ 0.033 create_onnx_friendly_decomposition_table torch_onnx/_decomp.py:39
│ └─ 0.028 _get_registered_ops torch_onnx/_decomp.py:12
│ └─ 0.025 OnnxRegistry.is_registered torch_onnx/_registration.py:232
│ └─ 0.025 OnnxRegistry.get_decomps torch_onnx/_registration.py:209
│ └─ 0.024 [self] torch_onnx/_registration.py
└─ 0.088 export torch/export/__init__.py:73
[76 frames hidden] torch, contextlib, ast, traceback
Include step status