justinchuby / torch-onnx

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

aten::add fails for u8 #38

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 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.add', overload='Tensor')>. Failure message: All overloads did not match the node `%add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%arg0_1, %arg1_1), kwargs = {})`.
- Failed to match overload `OnnxFunction(<function aten_add at 0x146ae2160>)`: Parameter type not compatible with argument: param=`Parameter(name='self', type_constraint=TypeConstraintParam(name='TReal', allowed_types={Tensor(FLOAT16), Tensor(INT32), Tensor(FLOAT), Tensor(INT16), Tensor(DOUBLE), Tensor(INT8), Tensor(BFLOAT16), Tensor(INT64)}, description=''), required=True, variadic=False, default=_EMPTY_DEFAULT)`, assigned_types=`{}`, arg=`UINT8`
- Failed to match overload `OnnxFunction(<function aten_logical_or at 0x1470fc5e0>)`: Parameter type not compatible with argument: param=`Parameter(name='self', type_constraint=TypeConstraintParam(name='T_self', allowed_types={Tensor(BOOL)}, description=''), required=True, variadic=False, default=_EMPTY_DEFAULT)`, assigned_types=`{}`, arg=`UINT8`

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 222, 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 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 %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%arg0_1, %arg1_1), kwargs = {}). See the stack trace for more information.

Exported program:

ExportedProgram:
    class GraphModule(torch.nn.Module):
        def forward(self, arg0_1: "u8[3]", arg1_1: "u8[3]"):
            # File: /Users/justinc/Documents/GitHub/torch-onnx/tests/torch_tests/torch_onnx_test.py:3112 in forward, code: return x + y
            add: "u8[3]" = torch.ops.aten.add.Tensor(arg0_1, arg1_1);  arg0_1 = arg1_1 = None
            return (add,)

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='add'), 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 4 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: