justinchuby / torch-onnx

Prototype of the next torch exporter
MIT License
1 stars 1 forks source link

'NoneType' object has no attribute 'meta' #50

Open justinchuby opened 2 weeks ago

justinchuby commented 2 weeks ago

PyTorch ONNX Conversion Error Report

✅ 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 480, in _add_nodes
    _handle_call_function_node_with_lowering(

  File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 348, in _handle_call_function_node_with_lowering
    onnx_function, message = _dispatching.dispatch(node, registry)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_dispatching.py", line 326, in dispatch
    overload, message = get_matching_overload(
                        ^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_dispatching.py", line 252, in get_matching_overload
    first_tensor = _get_first_tensor_in_node_list(arg)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_dispatching.py", line 180, in _get_first_tensor_in_node_list
    if "val" in node.meta and isinstance(node.meta["val"], torch.Tensor):
                ^^^^^^^^^

AttributeError: 'NoneType' object has no attribute 'meta'

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 196, in _torch_onnx_export
    ir_model = torch_onnx.exported_program_to_ir(program)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/_core.py", line 619, 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 491, in _add_nodes
    raise errors.OnnxConversionError(

torch_onnx.errors.OnnxConversionError: Error when translating node %index : [num_users=1] = call_function[target=torch.ops.aten.index.Tensor](args = (%slice_2, [None, %lift_fresh_copy, None, %lift_fresh_copy_1, %lift_fresh_copy_2]), kwargs = {}). See the stack trace for more information.

Exported program:

ExportedProgram:
    class GraphModule(torch.nn.Module):
        def forward(self, _lifted_tensor_constant0: "i64[2, 2]", _lifted_tensor_constant1: "i64[2]", _lifted_tensor_constant2: "i64[2]", arg0_1: "f32[3, 4, 5, 6, 7]"):
            # File: /Users/justinc/Documents/GitHub/torch-onnx/tests/torch_tests/torch_onnx_test.py:2226 in forward, code: torch.tensor([[0, 2], [1, 1]]),
            lift_fresh_copy: "i64[2, 2]" = torch.ops.aten.lift_fresh_copy.default(_lifted_tensor_constant0);  _lifted_tensor_constant0 = None

            # File: /Users/justinc/Documents/GitHub/torch-onnx/tests/torch_tests/torch_onnx_test.py:2228 in forward, code: torch.tensor([2, 1]),
            lift_fresh_copy_1: "i64[2]" = torch.ops.aten.lift_fresh_copy.default(_lifted_tensor_constant1);  _lifted_tensor_constant1 = None

            # File: /Users/justinc/Documents/GitHub/torch-onnx/tests/torch_tests/torch_onnx_test.py:2229 in forward, code: torch.tensor([0, 3]),
            lift_fresh_copy_2: "i64[2]" = torch.ops.aten.lift_fresh_copy.default(_lifted_tensor_constant2);  _lifted_tensor_constant2 = None

            # File: /Users/justinc/Documents/GitHub/torch-onnx/tests/torch_tests/torch_onnx_test.py:2224 in forward, code: return input[
            slice_1: "f32[3, 4, 5, 6, 7]" = torch.ops.aten.slice.Tensor(arg0_1, 0, 0, 9223372036854775807);  arg0_1 = None
            slice_2: "f32[3, 4, 5, 6, 7]" = torch.ops.aten.slice.Tensor(slice_1, 2, 0, 9223372036854775807);  slice_1 = None
            index: "f32[2, 2, 3, 5]" = torch.ops.aten.index.Tensor(slice_2, [None, lift_fresh_copy, None, lift_fresh_copy_1, lift_fresh_copy_2]);  slice_2 = lift_fresh_copy = lift_fresh_copy_1 = lift_fresh_copy_2 = None
            return (index,)

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.CONSTANT_TENSOR: 4>, arg=TensorArgument(name='_lifted_tensor_constant1'), target='_lifted_tensor_constant1', persistent=None), InputSpec(kind=<InputKind.CONSTANT_TENSOR: 4>, arg=TensorArgument(name='_lifted_tensor_constant2'), target='_lifted_tensor_constant2', persistent=None), 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='index'), target=None)])
Range constraints: {}

Analysis

PyTorch ONNX Conversion Analysis

Model Information

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:

Outputs:

The FX graph has 11 nodes in total. Number of FX nodes per op:

Of the call_function nodes, the counts of operators used are:

ONNX Conversion Information

The 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: