Exported ONNX with Dynamic Shapes

The following script shows the exported program for many short cases and various l-plot-export-with-dynamic-shape to retrieve an ONNX model equivalent to the original model.

<<<

import inspect
import textwrap
import pandas
from onnx_diagnostic.helpers import string_type
from onnx_diagnostic.helpers.onnx_helper import pretty_onnx
from onnx_diagnostic.torch_export_patches.eval import discover, run_exporter
from onnx_diagnostic.ext_test_case import unit_test_going

cases = discover()
print()
print(":ref:`Summary <ledx-summary-exported-program>`")
print()
sorted_cases = sorted(cases.items())
if unit_test_going():
    sorted_cases = sorted_cases[:3]
for name, cls_model in sorted_cases:
    print(f"* :ref:`{name} <ledx-model-case-export-{name}>`")
print()
print()

obs = []
for name, cls_model in sorted(cases.items()):
    print()
    print(f".. _ledx-model-case-export-{name}:")
    print()
    print(name)
    print("=" * len(name))
    print()
    print("forward")
    print("+++++++")
    print()
    print(".. code-block:: python")
    print()
    src = inspect.getsource(cls_model.forward)
    if src:
        print(textwrap.indent(textwrap.dedent(src), "    "))
    else:
        print("    # code is missing")
    print()
    print()
    for exporter in ("custom", "dynamo-ir"):
        expname = exporter.replace("export-", "")
        print()
        print(expname)
        print("+" * len(expname))
        print()
        res = run_exporter(exporter, cls_model, True, quiet=True)
        case_ref = f":ref:`{name} <ledx-model-case-export-{name}>`"
        expo = exporter.split("-", maxsplit=1)[-1]
        if "inputs" in res:
            print(f"* **inputs:** ``{string_type(res['inputs'], with_shape=True)}``")
        if "dynamic_shapes" in res:
            print(f"* **shapes:** ``{string_type(res['dynamic_shapes'])}``")
        print()
        print()
        if "onx" in res:
            print(".. code-block:: text")
            print()
            print(textwrap.indent(pretty_onnx(res["onx"]), "    "))
            print()
            print()
            if "error" not in res:
                obs.append(dict(case=case_ref, error="", exporter=expo))
        if "error" in res:
            print("**FAILED**")
            print()
            print(".. code-block:: text")
            print()
            err = str(res["error"])
            if err:
                print(textwrap.indent(err, "    "))
            else:
                print("    # no error found for the failure")
            print()
            print()
            obs.append(dict(case=case_ref, error="FAIL", exporter=expo))

print()
print(".. _ledx-summary-exported-program:")
print()
print("Summary")
print("+++++++")
print()
df = pandas.DataFrame(obs)
piv = df.pivot(index="case", columns="exporter", values="error")
print(piv.to_markdown(tablefmt="rst"))
print()

>>>

Summary

AtenAsStrided

forward

def forward(self, x):
    y = torch.as_strided(x, (2, 2, 8, 4), (128, 8, 16, 1))
    return y

custom

FAILED

The implementation is still incorrect, x='x', shape=('batch', 2, 8, 8), size=[2, 2, 8, 4], stride=[128, 8, 16, 1], storage_offset=None
--DEBUG--
[GraphBuilder-IMA] Message starts, there are 0 initializers, 0 nodes, 1 inputs, 1 outputs.
--CONSTRAINTS--
    batch = {'s77'}
    s77 = {'batch'}
--SHAPE--
_dynamic_examples=
dynamic_objects=
   batch = 'batch'
   s77 = 's77'
dynamic_objects_rev=
   'batch' = <class 'list'>
     tuple
       'batch'
       ERR**: <class 'torch.SymInt'>:'batch'
dynamic_dimensions_source={'batch': [{'axis': 0, 'input_name': 'x'}]}
dynamic_dimensions_source_flat=['x']
output_dynamic_dimensions_source_flat=None
dynamic_alias={'s77': 'batch'}
dynamic_shapes={'x': {0: Dim('batch', min=0)}}
_known_shapes={'x': ('batch', 2, 8, 8)}
_known_types={'x': 1}
_known_value_shape={}
_known_constants=[]
_known_ranks={}
--PARAMETERS--
_parameter_renaming=
--TORCH-USERS--
    as_strided -> {output}
    x -> {as_strided}
--TORCH-SHAPES--
    x: ('run_node', ('', ('val', torch.float32, torch.Size([s77, 2, 8, 8])))) --- 1:4:('batch', 2, 8, 8):
    as_strided: ('run_node', ('', ('val', torch.float32, torch.Size([2, 2, 8, 4])))) --- :::
--ONNX--
-- EXEPATH --
export-export_options=ExportOptions()
-- process.graph_module --
ExportedProgram:
    class GraphModule(torch.nn.Module):
        def forward(self, x: "f32[s77, 2, 8, 8]"):
             # File: ~/github/onnx-diagnostic/onnx_diagnostic/torch_export_patches/eval/model_cases.py:186 in forward, code: y = torch.as_strided(x, (2, 2, 8, 4), (128, 8, 16, 1))
            as_strided: "f32[2, 2, 8, 4]" = torch.ops.aten.as_strided.default(x, [2, 2, 8, 4], [128, 8, 16, 1]);  x = None
            return (as_strided,)
        
Graph signature: 
    # inputs
    x: USER_INPUT

    # outputs
    as_strided: USER_OUTPUT

Range constraints: {s77: VR[0, int_oo]}

-- process.graph_module.graph --
graph():
    %x : [num_users=1] = placeholder[target=x]
    %as_strided : [num_users=1] = call_function[target=torch.ops.aten.as_strided.default](args = (%x, [2, 2, 8, 4], [128, 8, 16, 1]), kwargs = {})
    return (as_strided,)
-- process.inputs_to_remove --
set()
-- process.progress --
node 1/3 target=aten.as_strided.default
-- 1 INPUTS
[GraphBuilder-IMA.make_tensor_input] x[1:batchx2x8x8]
-- 0 INITIALIZERS
-- 0 OUTPUTS
[GraphBuilder-IMA] Message completed, there are 0 initializers, 0 nodes, 1 inputs, 1 outputs.

dynamo-ir

  • inputs: #1[(T1s2x2x8x8,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 2, 8, 8]
init: name='val_0' type=int64 shape=(4,) -- array([2, 2, 8, 4])
init: name='val_1' type=int64 shape=(4,) -- array([128,   8,  16,   1])
init: name='neg_1' type=int64 shape=(1,) -- array([-1])
init: name='rank_tensor' type=int64 shape=(1,) -- array([4])
init: name='indices' type=int64 shape=() -- array([0])
init: name='rank_0' type=int64 shape=() -- array([4])
init: name='int64_1_cast' type=int64 shape=() -- array([1])
init: name='tmp_14' type=float32 shape=(1,) -- array([1.], dtype=float32)
Reshape(x, neg_1) -> self_flatten
SequenceEmpty() -> one_seq
Loop(rank_0, , one_seq, indices, body=G1) -> one_seq_16, indices_17
  CastLike(indices, indices_17) -> storage_offset_cast
  Add(indices_17, storage_offset_cast) -> indices_19
  Gather(self_flatten, indices_19) -> as_strided
output: name='as_strided' type=dtype('float32') shape=[2, 2, 8, 4]
----- subgraph ---- Loop - n6_2 - att.body=G1 -- level=1 -- i,cond_in,one_seq_1,indices_2 -> cond_out,one_seq_15,indices_13
input: name='i' type=dtype('int64') shape=None
input: name='cond_in' type=dtype('bool') shape=None
input: name='one_seq_1' type='NOTENSOR' shape=None
input: name='indices_2' type='NOTENSOR' shape=None
Equal(i, indices) -> cond
Sub(rank_0, i) -> tmp
Sub(tmp, int64_1_cast) -> j
Reshape(j, neg_1) -> j_tensor
Gather(val_0, j_tensor, axis=0) -> size_dim_j
Range(indices, size_dim_j, int64_1_cast) -> tmp_6
Slice(val_0, j_tensor, rank_tensor) -> size_after_j
  Expand(indices_2, size_after_j) -> indices_4
Gather(val_1, j_tensor, axis=0) -> stride_dim_j
  Mul(tmp_6, stride_dim_j) -> add_value
If(cond, then_branch=G2, else_branch=G3) -> shape_11
  Reshape(add_value, shape_11) -> add_value_12
    Add(indices_4, add_value_12) -> indices_13
SequenceInsert(one_seq_1, tmp_14) -> one_seq_15
Identity(cond_in) -> cond_out
output: name='cond_out' type=dtype('bool') shape=None
output: name='one_seq_15' type='NOTENSOR' shape=None
output: name='indices_13' type='NOTENSOR' shape=None
----- subgraph ---- If - n20 - att.then_branch=G2 -- level=2 --  -> shape
Identity(size_dim_j) -> shape
output: name='shape' type=dtype('int64') shape=[1]
----- subgraph ---- If - n20 - att.else_branch=G3 -- level=2 --  -> shape_10
Cast(size_dim_j, to=1) -> tmp_8
ConcatFromSequence(one_seq_1, axis=0) -> ones
  Concat(tmp_8, ones, axis=0) -> shape_9
    Cast(shape_9, to=7) -> shape_10
output: name='shape_10' type=dtype('int64') shape=None
----- subgraph ---- If - n20 - att.then_branch=G2 -- level=1 --  -> shape
Identity(size_dim_j) -> shape
output: name='shape' type=dtype('int64') shape=[1]
----- subgraph ---- If - n20 - att.else_branch=G3 -- level=1 --  -> shape_10
Cast(size_dim_j, to=1) -> tmp_8
ConcatFromSequence(one_seq_1, axis=0) -> ones
  Concat(tmp_8, ones, axis=0) -> shape_9
    Cast(shape_9, to=7) -> shape_10
output: name='shape_10' type=dtype('int64') shape=None

AtenInterpolate

forward

def forward(self, x):
    y = torch.nn.functional.interpolate(
        x,
        scale_factor=2.0,
        mode="bilinear",
        recompute_scale_factor=False,
    )
    return y

custom

  • inputs: #1[(T1s2x2x3x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 2, 3, 4]
init: name='init7_s2_6_8' type=int64 shape=(2,) -- array([6, 8])      -- _aten_upsample_output_size.rsize
Shape(x, end=2, start=0) -> x::Shape:2
  Concat(x::Shape:2, init7_s2_6_8, axis=0) -> _onx_concat_x::Shape:2
Resize(x, , , _onx_concat_x::Shape:2, coordinate_transformation_mode=b'pytorch_half_pixel', mode=b'linear', nearest_mode=b'floor') -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 2, 6, 8]

dynamo-ir

  • inputs: #1[(T1s2x2x3x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 2, 3, 4]
init: name='val_0' type=float32 shape=(4,) -- array([1., 1., 2., 2.], dtype=float32)
Resize(x, , val_0, keep_aspect_ratio_policy=b'stretch', antialias=0, extrapolation_value=0.00, exclude_outside=0, nearest_mode=b'floor', coordinate_transformation_mode=b'pytorch_half_pixel', cubic_coeff_a=-0.75, mode=b'linear') -> upsample_bilinear2d
output: name='upsample_bilinear2d' type=dtype('float32') shape=['batch', 2, 6, 8]

AtenNonZero

forward

def forward(self, x):
    y = torch.nonzero(x)
    return y

custom

  • inputs: #1[(T1s3x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 4]
NonZero(x) -> _onx_nonzero_x
  Transpose(_onx_nonzero_x, perm=[1,0]) -> output_0
output: name='output_0' type=dtype('int64') shape=['NEWDIM_nonzero', 2]

dynamo-ir

  • inputs: #1[(T1s3x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 4]
NonZero(x) -> val_0
  Transpose(val_0, perm=[1,0]) -> nonzero
output: name='nonzero' type=dtype('int64') shape=['u0', 2]

AtenNonZeroTuple

forward

def forward(self, x):
    y = torch.nonzero(x, as_tuple=True)
    return y[0], y[1]

custom

  • inputs: #1[(T1s3x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 4]
init: name='init7_s1_-1' type=int64 shape=(1,) -- array([-1])         -- Opset.make_node.1/Shape##Opset.make_node.1/Shape
NonZero(x) -> _onx_nonzero_x
  Split(_onx_nonzero_x, num_outputs=2) -> _onx_split_nonzero_x_0, _onx_split_nonzero_x_1
    Reshape(_onx_split_nonzero_x_0, init7_s1_-1) -> output_0
Reshape(_onx_split_nonzero_x_1, init7_s1_-1) -> output_1
output: name='output_0' type=dtype('int64') shape=['u0']
output: name='output_1' type=dtype('int64') shape=['u0']

dynamo-ir

  • inputs: #1[(T1s3x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 4]
init: name='unbind_axis' type=int64 shape=(1,) -- array([1])
NonZero(x) -> val_0
  Transpose(val_0, perm=[1,0]) -> nonzero
    Split(nonzero, axis=1, num_outputs=2) -> unbind_split_0, unbind_split_1
      Squeeze(unbind_split_0, unbind_axis) -> getitem
Squeeze(unbind_split_1, unbind_axis) -> getitem_1
output: name='getitem' type=dtype('int64') shape=['u0']
output: name='getitem_1' type=dtype('int64') shape=['u0']

AtenRollPos

forward

def forward(self, x):
    return torch.roll(x, 1, -1)

custom

  • inputs: #1[(T1s2x3x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 3, 4]
init: name='init7_s1_-1' type=int64 shape=(1,) -- array([-1])         -- Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s1_4' type=int64 shape=(1,) -- array([4])           -- Opset.make_node.1/Shape
init: name='init7_s1_0' type=int64 shape=(1,) -- array([0])           -- Opset.make_node.1/Shape
Slice(x, init7_s1_-1, init7_s1_4, init7_s1_-1) -> _onx_slice_x
Slice(x, init7_s1_0, init7_s1_-1, init7_s1_-1) -> _onx_slice_x2
  Concat(_onx_slice_x, _onx_slice_x2, axis=-1) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 3, 4]

dynamo-ir

  • inputs: #1[(T1s2x3x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 3, 4]
init: name='neg_1' type=int64 shape=(1,) -- array([-1])
init: name='shift_tensor' type=int64 shape=(1,) -- array([1])
init: name='slice_length_3' type=int64 shape=(1,) -- array([3])
init: name='tmp_4' type=int64 shape=(1,) -- array([0])
Size(x) -> tmp_5
  Reshape(tmp_5, neg_1) -> tmp_6
    Slice(x, slice_length_3, tmp_6, neg_1) -> prefix
Slice(x, tmp_4, slice_length_3, neg_1) -> suffix
  Concat(prefix, suffix, axis=-1) -> roll
output: name='roll' type=dtype('float32') shape=['batch', 3, 4]

AtenRollRelu

forward

def forward(self, x):
    return torch.relu(torch.roll(x, -1, -1))

custom

  • inputs: #1[(T1s2x3x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 3, 4]
init: name='init7_s1_1' type=int64 shape=(1,) -- array([1])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s1_4' type=int64 shape=(1,) -- array([4])           -- Opset.make_node.1/Shape
init: name='init7_s1_-1' type=int64 shape=(1,) -- array([-1])         -- Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s1_0' type=int64 shape=(1,) -- array([0])           -- Opset.make_node.1/Shape
Slice(x, init7_s1_1, init7_s1_4, init7_s1_-1) -> _onx_slice_x
Slice(x, init7_s1_0, init7_s1_1, init7_s1_-1) -> _onx_slice_x2
  Concat(_onx_slice_x, _onx_slice_x2, axis=-1) -> _onx_concat_slice_x
    Relu(_onx_concat_slice_x) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 3, 4]

dynamo-ir

  • inputs: #1[(T1s2x3x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 3, 4]
init: name='neg_1' type=int64 shape=(1,) -- array([-1])
init: name='slice_length_3' type=int64 shape=(1,) -- array([1])
init: name='tmp_4' type=int64 shape=(1,) -- array([0])
Size(x) -> tmp_5
  Reshape(tmp_5, neg_1) -> tmp_6
    Slice(x, slice_length_3, tmp_6, neg_1) -> prefix
Slice(x, tmp_4, slice_length_3, neg_1) -> suffix
  Concat(prefix, suffix, axis=-1) -> roll
    Relu(roll) -> relu
output: name='relu' type=dtype('float32') shape=['batch', 3, 4]

BuildInIsInstance

forward

def forward(self, x, lx: list | torch.Tensor):
    if isinstance(lx, list):
        t = lx[0] * lx[1].sum(axis=1, keepdim=True)
        return torch.sigmoid(self.linear(x)) - self.buff + t
    return torch.sigmoid(self.linear(x)) - self.buff + lx

custom

  • inputs: #2[(T1s4x3,#2[T1s4x1,T1s4x2]),(T1s8x3,#2[T1s8x1,T1s8x2])]

  • shapes: dict(x:{0:Dim(batch)},lx:#2[{0:Dim(batch)},{0:Dim(batch)}])

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 3]
input: name='lx_0' type=dtype('float32') shape=['batch', 1]
input: name='lx_1' type=dtype('float32') shape=['batch', 2]
init: name='b_buff' type=float32 shape=(1,) -- array([0.5], dtype=float32)-- DynamoInterpret.placeholder.0
init: name='init7_s1_1' type=int64 shape=(1,) -- array([1])           -- Opset.make_node.1/Shape
init: name='GemmTransposePattern--p_linear_weight::T10' type=float32 shape=(1, 3) -- array([ 0.118, -0.185, -0.567], dtype=float32)-- GraphBuilder.constant_folding.from/fold(init7_s2_1_-1,p_linear_weight::T10)##p_linear_weight::T10/GraphBuilder.constant_folding.from/fold(p_linear_weight)##p_linear_weight/DynamoInterpret.placeholder.1/P(linear.weight)##init7_s2_1_-1/TransposeEqualReshapePattern.apply.new_shape
init: name='linear.bias' type=float32 shape=(1,) -- array([0.157], dtype=float32)-- DynamoInterpret.placeholder.1/P(linear.bias)
Gemm(x, GemmTransposePattern--p_linear_weight::T10, linear.bias, transB=1) -> linear
  Sigmoid(linear) -> sigmoid
    Sub(sigmoid, b_buff) -> sub
ReduceSum(lx_1, init7_s1_1, keepdims=1) -> sum_1
  Mul(lx_0, sum_1) -> mul
    Add(sub, mul) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 1]

dynamo-ir

  • inputs: #2[(T1s4x3,#2[T1s4x1,T1s4x2]),(T1s8x3,#2[T1s8x1,T1s8x2])]

  • shapes: dict(x:{0:Dim(batch)},lx:#2[{0:Dim(batch)},{0:Dim(batch)}])

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 3]
input: name='lx_0' type=dtype('float32') shape=['batch', 1]
input: name='lx_1' type=dtype('float32') shape=['batch', 2]
init: name='linear.weight' type=float32 shape=(1, 3) -- array([-0.147, -0.469,  0.169], dtype=float32)
init: name='linear.bias' type=float32 shape=(1,) -- array([0.354], dtype=float32)
init: name='buff' type=float32 shape=(1,) -- array([0.5], dtype=float32)
init: name='val_6' type=int64 shape=(1,) -- array([1])
Gemm(x, linear.weight, linear.bias, beta=1.00, transB=1, alpha=1.00, transA=0) -> linear
  Sigmoid(linear) -> sigmoid
    Sub(sigmoid, buff) -> sub_4
ReduceSum(lx_1, val_6, noop_with_empty_axes=0, keepdims=1) -> sum_1
  Mul(lx_0, sum_1) -> mul_1
    Add(sub_4, mul_1) -> add_15
output: name='add_15' type=dtype('float32') shape=['batch', 1]

BuildInLen

forward

def forward(self, x, lx: list):
    t = lx[0] * lx[1].sum(axis=1, keepdim=True)
    if len(lx) > 2:
        t = t + lx[2].sum(axis=1, keepdim=True)
    return torch.sigmoid(self.linear(x)) - self.buff + t

custom

  • inputs: #2[(T1s4x3,#2[T1s4x1,T1s4x2]),(T1s8x3,#3[T1s8x1,T1s8x2,T1s8x3])]

  • shapes: dict(x:{0:Dim(batch)},lx:#2[{0:Dim(batch)},{0:Dim(batch)}])

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 3]
input: name='lx_0' type=dtype('float32') shape=['batch', 1]
input: name='lx_1' type=dtype('float32') shape=['batch', 2]
init: name='b_buff' type=float32 shape=(1,) -- array([0.5], dtype=float32)-- DynamoInterpret.placeholder.0
init: name='init7_s1_1' type=int64 shape=(1,) -- array([1])           -- Opset.make_node.1/Shape
init: name='GemmTransposePattern--p_linear_weight::T10' type=float32 shape=(1, 3) -- array([-0.37 , -0.295,  0.331], dtype=float32)-- GraphBuilder.constant_folding.from/fold(init7_s2_1_-1,p_linear_weight::T10)##p_linear_weight::T10/GraphBuilder.constant_folding.from/fold(p_linear_weight)##p_linear_weight/DynamoInterpret.placeholder.1/P(linear.weight)##init7_s2_1_-1/TransposeEqualReshapePattern.apply.new_shape
init: name='linear.bias' type=float32 shape=(1,) -- array([0.163], dtype=float32)-- DynamoInterpret.placeholder.1/P(linear.bias)
Gemm(x, GemmTransposePattern--p_linear_weight::T10, linear.bias, transB=1) -> linear
  Sigmoid(linear) -> sigmoid
    Sub(sigmoid, b_buff) -> sub
ReduceSum(lx_1, init7_s1_1, keepdims=1) -> sum_1
  Mul(lx_0, sum_1) -> mul
    Add(sub, mul) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 1]

FAILED

diff.1

dynamo-ir

  • inputs: #2[(T1s4x3,#2[T1s4x1,T1s4x2]),(T1s8x3,#3[T1s8x1,T1s8x2,T1s8x3])]

  • shapes: dict(x:{0:Dim(batch)},lx:#2[{0:Dim(batch)},{0:Dim(batch)}])

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 3]
input: name='lx_0' type=dtype('float32') shape=['batch', 1]
input: name='lx_1' type=dtype('float32') shape=['batch', 2]
init: name='linear.weight' type=float32 shape=(1, 3) -- array([-0.271,  0.043,  0.314], dtype=float32)
init: name='linear.bias' type=float32 shape=(1,) -- array([-0.032], dtype=float32)
init: name='buff' type=float32 shape=(1,) -- array([0.5], dtype=float32)
init: name='val_6' type=int64 shape=(1,) -- array([1])
Gemm(x, linear.weight, linear.bias, beta=1.00, transB=1, alpha=1.00, transA=0) -> linear
  Sigmoid(linear) -> sigmoid
    Sub(sigmoid, buff) -> sub_4
ReduceSum(lx_1, val_6, noop_with_empty_axes=0, keepdims=1) -> sum_1
  Mul(lx_0, sum_1) -> mul_1
    Add(sub_4, mul_1) -> add_15
output: name='add_15' type=dtype('float32') shape=['batch', 1]

FAILED

diff.1

ComplexPolar

forward

def forward(self, x, angle):
    return torch.polar(x, angle)

custom

  • inputs: #1[(T1s4x4,T1s4x4)]

  • shapes: dict(x:{0:Dim(batch)},angle:{0:Dim(batch)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 4]
input: name='angle' type=dtype('float32') shape=['batch', 4]
init: name='init14_s1_' type=complex64 shape=(1,) -- array([0.+1.j], dtype=complex64)-- Opset.make_node.1/Small
Cast(x, to=14) -> x::C14
Cos(angle) -> _onx_cos_angle
  Cast(_onx_cos_angle, to=14) -> _onx_cos_angle::C14
Sin(angle) -> _onx_sin_angle
  Cast(_onx_sin_angle, to=14) -> _onx_sin_angle::C14
    Mul(_onx_sin_angle::C14, init14_s1_) -> _onx_mul_sin_angle::C14
    Add(_onx_cos_angle::C14, _onx_mul_sin_angle::C14) -> _onx_add_cos_angle::C14
  Mul(x::C14, _onx_add_cos_angle::C14) -> output_0
output: name='output_0' type=dtype('complex64') shape=['batch', 4]

FAILED

[ONNXRuntimeError] : 10 : INVALID_GRAPH : This is an invalid model. Type Error: Type 'tensor(complex64)' of input parameter (_onx_sin_angle::C14) of operator (Mul) in node (polar5) is invalid.

dynamo-ir

  • inputs: #1[(T1s4x4,T1s4x4)]

  • shapes: dict(x:{0:Dim(batch)},angle:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 4]
input: name='angle' type=dtype('float32') shape=['batch', 4]
init: name='int64_m1_1d' type=int64 shape=(1,) -- array([-1])
Cos(angle) -> tmp
  Mul(x, tmp) -> tmp_0
    Unsqueeze(tmp_0, int64_m1_1d) -> real
Sin(angle) -> tmp_1
  Mul(x, tmp_1) -> tmp_2
    Unsqueeze(tmp_2, int64_m1_1d) -> imag
      Concat(real, imag, axis=-1) -> polar
output: name='polar' type=dtype('float32') shape=['batch', 4, 2]

FAILED

diff.0

ControlFlowCond

forward

def forward(self, x):
    def true_fn(x):
        return torch.sin(x)

    def false_fn(x):
        return torch.cos(x)

    return torch.cond(x.sum() > 0, true_fn, false_fn, [x])

custom

  • inputs: #1[(T1s5x3,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
opset: domain='local_functions' version=1
input: name='x' type=dtype('float32') shape=['batch', 3]
init: name='init1_s_' type=float32 shape=() -- array([0.], dtype=float32)-- shape_type_compute._cast_inputs.1(gt_Scalar)
ReduceSum(x, keepdims=0) -> sum_1
  Greater(sum_1, init1_s_) -> gt
    If(gt, else_branch=G1, then_branch=G2) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 3]
----- subgraph ---- If - cond - att.else_branch=G1 -- level=1 --  -> cond#0
Cos(x) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None
----- subgraph ---- If - cond - att.then_branch=G2 -- level=1 --  -> cond#0
Sin(x) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None

dynamo-ir

  • inputs: #1[(T1s5x3,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 3]
init: name='scalar_tensor_default' type=float32 shape=() -- array([0.], dtype=float32)
ReduceSum(x, noop_with_empty_axes=0, keepdims=0) -> sum_1
  Greater(sum_1, scalar_tensor_default) -> gt
    If(gt, then_branch=G1, else_branch=G2) -> getitem
output: name='getitem' type=dtype('float32') shape=['batch', 3]
----- subgraph ---- If - node_cond__0 - att.then_branch=G1 -- level=1 --  -> sin_true_graph_0
Sin(x) -> sin_true_graph_0
output: name='sin_true_graph_0' type=dtype('float32') shape=['batch', 3]
----- subgraph ---- If - node_cond__0 - att.else_branch=G2 -- level=1 --  -> cos_false_graph_0
Cos(x) -> cos_false_graph_0
output: name='cos_false_graph_0' type=dtype('float32') shape=['batch', 3]

ControlFlowCond2Inputs

forward

def forward(self, x, y):
    def true_fn(x, y):
        return torch.sin(x), torch.cos(x) + y

    def false_fn(x, y):
        return torch.cos(x), torch.sin(x) + y

    return torch.cond(x.sum() > 0, true_fn, false_fn, [x, y])

custom

  • inputs: #1[(T1s5x3,T1s5x3)]

  • shapes: dict(x:{0:Dim(batch)},y:{0:Dim(batch)})

opset: domain='' version=18
opset: domain='local_functions' version=1
input: name='x' type=dtype('float32') shape=['batch', 3]
input: name='y' type=dtype('float32') shape=['batch', 3]
init: name='init1_s_' type=float32 shape=() -- array([0.], dtype=float32)-- shape_type_compute._cast_inputs.1(gt_Scalar)
ReduceSum(x, keepdims=0) -> sum_1
  Greater(sum_1, init1_s_) -> gt
    If(gt, else_branch=G1, then_branch=G2) -> output_0, output_1
output: name='output_0' type=dtype('float32') shape=['batch', 3]
output: name='output_1' type=dtype('float32') shape=['batch', 3]
----- subgraph ---- If - cond - att.else_branch=G1 -- level=1 --  -> cond#0,cond#1
Cos(x) -> cond#0
Sin(x) -> sin2
Add(sin2, y) -> cond#1
output: name='cond#0' type='NOTENSOR' shape=None
output: name='cond#1' type='NOTENSOR' shape=None
----- subgraph ---- If - cond - att.then_branch=G2 -- level=1 --  -> cond#0,cond#1
Cos(x) -> cos2
Add(cos2, y) -> cond#1
Sin(x) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None
output: name='cond#1' type='NOTENSOR' shape=None

dynamo-ir

  • inputs: #1[(T1s5x3,T1s5x3)]

  • shapes: dict(x:{0:Dim(batch)},y:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 3]
input: name='y' type=dtype('float32') shape=['batch', 3]
init: name='scalar_tensor_default' type=float32 shape=() -- array([0.], dtype=float32)
ReduceSum(x, noop_with_empty_axes=0, keepdims=0) -> sum_1
  Greater(sum_1, scalar_tensor_default) -> gt
    If(gt, then_branch=G1, else_branch=G2) -> getitem, getitem_1
output: name='getitem' type=dtype('float32') shape=['batch', 3]
output: name='getitem_1' type=dtype('float32') shape=['batch', 3]
----- subgraph ---- If - node_cond__1 - att.then_branch=G1 -- level=1 --  -> sin_true_graph_0,add_12_true_graph_0
Cos(x) -> cos
Add(cos, y) -> add_12_true_graph_0
Sin(x) -> sin_true_graph_0
output: name='sin_true_graph_0' type=dtype('float32') shape=['batch', 3]
output: name='add_12_true_graph_0' type=dtype('float32') shape=['batch', 3]
----- subgraph ---- If - node_cond__1 - att.else_branch=G2 -- level=1 --  -> cos_false_graph_0,add_12_false_graph_0
Cos(x) -> cos_false_graph_0
Sin(x) -> sin_2
Add(sin_2, y) -> add_12_false_graph_0
output: name='cos_false_graph_0' type=dtype('float32') shape=['batch', 3]
output: name='add_12_false_graph_0' type=dtype('float32') shape=['batch', 3]

ControlFlowCond2Outputs

forward

def forward(self, x):
    def true_fn(x):
        return torch.sin(x), torch.cos(x)

    def false_fn(x):
        return torch.cos(x), torch.sin(x)

    return torch.cond(x.sum() > 0, true_fn, false_fn, [x])

custom

  • inputs: #1[(T1s5x3,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
opset: domain='local_functions' version=1
input: name='x' type=dtype('float32') shape=['batch', 3]
init: name='init1_s_' type=float32 shape=() -- array([0.], dtype=float32)-- shape_type_compute._cast_inputs.1(gt_Scalar)
ReduceSum(x, keepdims=0) -> sum_1
  Greater(sum_1, init1_s_) -> gt
    If(gt, else_branch=G1, then_branch=G2) -> output_0, output_1
output: name='output_0' type=dtype('float32') shape=['batch', 3]
output: name='output_1' type=dtype('float32') shape=['batch', 3]
----- subgraph ---- If - cond - att.else_branch=G1 -- level=1 --  -> cond#0,cond#1
Cos(x) -> cond#0
Sin(x) -> cond#1
output: name='cond#0' type='NOTENSOR' shape=None
output: name='cond#1' type='NOTENSOR' shape=None
----- subgraph ---- If - cond - att.then_branch=G2 -- level=1 --  -> cond#0,cond#1
Cos(x) -> cond#1
Sin(x) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None
output: name='cond#1' type='NOTENSOR' shape=None

dynamo-ir

  • inputs: #1[(T1s5x3,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 3]
init: name='scalar_tensor_default' type=float32 shape=() -- array([0.], dtype=float32)
ReduceSum(x, noop_with_empty_axes=0, keepdims=0) -> sum_1
  Greater(sum_1, scalar_tensor_default) -> gt
    If(gt, then_branch=G1, else_branch=G2) -> getitem, getitem_1
output: name='getitem' type=dtype('float32') shape=['batch', 3]
output: name='getitem_1' type=dtype('float32') shape=['batch', 3]
----- subgraph ---- If - node_cond__1 - att.then_branch=G1 -- level=1 --  -> sin_true_graph_0,cos_true_graph_0
Cos(x) -> cos_true_graph_0
Sin(x) -> sin_true_graph_0
output: name='sin_true_graph_0' type=dtype('float32') shape=['batch', 3]
output: name='cos_true_graph_0' type=dtype('float32') shape=['batch', 3]
----- subgraph ---- If - node_cond__1 - att.else_branch=G2 -- level=1 --  -> cos_false_graph_0,sin_false_graph_0
Cos(x) -> cos_false_graph_0
Sin(x) -> sin_false_graph_0
output: name='cos_false_graph_0' type=dtype('float32') shape=['batch', 3]
output: name='sin_false_graph_0' type=dtype('float32') shape=['batch', 3]

ControlFlowCondConstant

forward

def forward(self, x):
    def true_fn(x):
        return torch.sin(x) - torch.ones(x.shape, dtype=x.dtype)

    def false_fn(x):
        return torch.cos(x) + torch.ones((1, 1024), dtype=x.dtype)

    return torch.cond(x.sum() > 0, true_fn, false_fn, [x])

custom

  • inputs: #1[(T1s1024x1024,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
opset: domain='local_functions' version=1
input: name='x' type=dtype('float32') shape=['batch', 1024]
init: name='init1_s_' type=float32 shape=() -- array([0.], dtype=float32)-- shape_type_compute._cast_inputs.1(gt_Scalar)
ReduceSum(x, keepdims=0) -> sum_1
  Greater(sum_1, init1_s_) -> gt
    If(gt, else_branch=G1, then_branch=G2) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 1024]
----- subgraph ---- If - cond - att.else_branch=G1 -- level=1 --  -> cond#0
Constant(value=[1, 1024]) -> init7_s2_1_10242
  ConstantOfShape(init7_s2_1_10242, value=[1.0]) -> ones2
Cos(x) -> cos2
  Add(cos2, ones2) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None
----- subgraph ---- If - cond - att.then_branch=G2 -- level=1 --  -> cond#0
Constant(value=[1024]) -> init7_s1_10242
Shape(x, end=1, start=0) -> x::Shape:12
  Concat(x::Shape:12, init7_s1_10242, axis=0) -> _onx_concat_sym_size_int_1::UnSq02
    ConstantOfShape(_onx_concat_sym_size_int_1::UnSq02, value=[1.0]) -> ones32
Sin(x) -> sin2
  Sub(sin2, ones32) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None

dynamo-ir

  • inputs: #1[(T1s1024x1024,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 1024]
init: name='scalar_tensor_default' type=float32 shape=() -- array([0.], dtype=float32)
init: name='val_1' type=int64 shape=(1,) -- array([-1])
init: name='val_3' type=int64 shape=(1,) -- array([1024])
init: name='val_7' type=float32 shape=() -- array([1.], dtype=float32)
init: name='ones_2' type=float32 shape=(1, 1024)
ReduceSum(x, noop_with_empty_axes=0, keepdims=0) -> sum_1
  Greater(sum_1, scalar_tensor_default) -> gt
    If(gt, then_branch=G1, else_branch=G2) -> getitem
output: name='getitem' type=dtype('float32') shape=['batch', 1024]
----- subgraph ---- If - node_cond__0 - att.then_branch=G1 -- level=1 --  -> sub_3_true_graph_0
Shape(x, end=1, start=0) -> val_0_2
  Squeeze(val_0_2) -> sym_size_int_1
Reshape(sym_size_int_1, val_1, allowzero=0) -> val_2
Concat(val_2, val_3, axis=0) -> val_4
Expand(val_7, val_4) -> ones
Sin(x) -> sin
  Sub(sin, ones) -> sub_3_true_graph_0
output: name='sub_3_true_graph_0' type=dtype('float32') shape=['', 1024]
----- subgraph ---- If - node_cond__0 - att.else_branch=G2 -- level=1 --  -> add_6_false_graph_0
Cos(x) -> cos
Add(cos, ones_2) -> add_6_false_graph_0
output: name='add_6_false_graph_0' type=dtype('float32') shape=['batch', 1024]

ControlFlowCondIdentity_153832

forward

def forward(self, x, y):

    def branch_cond_then_1(x):
        x = torch.abs(x) + 1
        return x

    def branch_cond_else_1(x):
        return x  # fails but succeeds with x.clone()

    x = torch.cond(x.sum() > 0, branch_cond_then_1, branch_cond_else_1, [x])
    return x + y

custom

FAILED

Cond doesn't work unless it is captured completely with torch.compile. Scroll up to find out what causes the graph break.

from user code:
   File "~/vv/this312/lib/python3.12/site-packages/torch/_higher_order_ops/cond.py", line 187, in _cond_op_wrapper
    return cond_op(*args, **kwargs)

Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"

dynamo-ir

FAILED

Failed to export the model with torch.export. This is step 1/3 of exporting the model to ONNX. Next steps:
- Modify the model code for `torch.export.export` to succeed. Refer to https://pytorch.org/docs/stable/generated/exportdb/index.html for more information.
- Debug `torch.export.export` and summit a PR to PyTorch.
- Create an issue in the PyTorch GitHub repository against the *torch.export* component and attach the full error stack as well as reproduction scripts.

## Exception summary

<class 'torch._dynamo.exc.Unsupported'>: Encountered aliasing during higher order op tracing
  Explanation: Higher order ops do not support aliasing. Found in cond
  Hint: Replace `return input` with `return input.clone()` to avoid aliasing.
  Hint: Consider using the debug context to change user code to avoid aliasing.
  Hint: Please open an issue.

  Developer debug context: Input-to-output aliasing detected at nodes l_args_3_0_ and l_args_3_0_ in
     graph():
        %l_args_3_0_ : torch._subclasses.fake_tensor.FakeTensor [num_users=1] = placeholder[target=l_args_3_0_]
        return (l_args_3_0_,)

⬆️
<class 'torch._dynamo.exc.UncapturedHigherOrderOpError'>: Cond doesn't work unless it is captured completely with torch.compile. Scroll up to find out what causes the graph break.

from user code:
   File "~/vv/this312/lib/python3.12/site-packages/torch/_higher_order_ops/cond.py", line 187, in _cond_op_wrapper
    return cond_op(*args, **kwargs)

Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"


(Refer to the full stack trace above for more information.)

ControlFlowCondNestedModule

forward

def forward(self, x):
    def true_fn(x):
        return self.submodule(x)

    def false_fn(x):
        return x - self.weight

    y = torch.cond(x.sum() > 0, true_fn, false_fn, [x])
    return y

custom

  • inputs: #1[(T7s2,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
opset: domain='local_functions.0' version=1
opset: domain='local_functions' version=1
input: name='x' type=dtype('int64') shape=['batch']
init: name='init7_s_0' type=int64 shape=() -- array([0])              -- shape_type_compute._cast_inputs.1(gt_Scalar)
init: name='weight' type=float32 shape=(1,) -- array([42.], dtype=float32)-- DynamoInterpret.placeholder.1/P(weight)
init: name='submodule.weight' type=float32 shape=(1,) -- array([100.], dtype=float32)-- DynamoInterpret.placeholder.1/P(submodule.weight)
ReduceSum(x, keepdims=0) -> sum_1
  Greater(sum_1, init7_s_0) -> gt
    If(gt, else_branch=G1, then_branch=G2) -> output_0
output: name='output_0' type=dtype('float32') shape=['d_output_0_0']
----- subgraph ---- If - cond - att.else_branch=G1 -- level=1 --  -> cond#0
Cast(x, to=1) -> x::C12
Sub(x::C12, weight) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None
----- subgraph ---- If - cond - att.then_branch=G2 -- level=1 --  -> cond#0
Abs(x) -> abs_12
  ReduceSum(abs_12, keepdims=0) -> sum_122
Constant(value=100) -> init7_s_1002
  Greater(sum_122, init7_s_1002) -> gt22
    If(gt22, else_branch=G3, then_branch=G4) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None
----- subgraph ---- If - cond22 - att.else_branch=G3 -- level=2 --  -> cond#0
Cast(x, to=1) -> x::C132
Div(x::C132, submodule.weight) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None
----- subgraph ---- If - cond22 - att.then_branch=G4 -- level=2 --  -> cond#0
Cast(x, to=1) -> x::C142
Mul(x::C142, submodule.weight) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None
----- subgraph ---- If - cond22 - att.else_branch=G3 -- level=1 --  -> cond#0
Cast(x, to=1) -> x::C132
Div(x::C132, submodule.weight) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None
----- subgraph ---- If - cond22 - att.then_branch=G4 -- level=1 --  -> cond#0
Cast(x, to=1) -> x::C142
Mul(x::C142, submodule.weight) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None

dynamo-ir

  • inputs: #1[(T7s2,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('int64') shape=['batch']
init: name='weight' type=float32 shape=(1,) -- array([42.], dtype=float32)
init: name='submodule.weight' type=float32 shape=(1,) -- array([100.], dtype=float32)
init: name='val_0' type=int64 shape=() -- array([0])
init: name='val_0_2' type=int64 shape=() -- array([100])
ReduceSum(x, noop_with_empty_axes=0, keepdims=0) -> sum_1
  Greater(sum_1, val_0) -> gt
    If(gt, then_branch=G1, else_branch=G2) -> getitem
output: name='getitem' type=dtype('float32') shape=['batch']
----- subgraph ---- If - node_cond__0 - att.then_branch=G1 -- level=1 --  -> getitem_true_graph_0
Abs(x) -> abs_1
  ReduceSum(abs_1, noop_with_empty_axes=0, keepdims=0) -> sum_1_2
Greater(sum_1_2, val_0_2) -> gt_2
  If(gt_2, then_branch=G3, else_branch=G4) -> getitem_true_graph_0
output: name='getitem_true_graph_0' type='NOTENSOR' shape=None
----- subgraph ---- If - node_cond__0_2 - att.then_branch=G3 -- level=2 --  -> mul_1_true_graph_0__true_graph_0
Cast(x, to=1) -> convert_element_type_default
Mul(convert_element_type_default, submodule.weight) -> mul_1_true_graph_0__true_graph_0
output: name='mul_1_true_graph_0__true_graph_0' type=dtype('float32') shape=['batch']
----- subgraph ---- If - node_cond__0_2 - att.else_branch=G4 -- level=2 --  -> div_true_graph_0__false_graph_0
Cast(x, to=1) -> convert_element_type_default_2
Div(convert_element_type_default_2, submodule.weight) -> div_true_graph_0__false_graph_0
output: name='div_true_graph_0__false_graph_0' type=dtype('float32') shape=['batch']
----- subgraph ---- If - node_cond__0_2 - att.then_branch=G3 -- level=1 --  -> mul_1_true_graph_0__true_graph_0
Cast(x, to=1) -> convert_element_type_default
Mul(convert_element_type_default, submodule.weight) -> mul_1_true_graph_0__true_graph_0
output: name='mul_1_true_graph_0__true_graph_0' type=dtype('float32') shape=['batch']
----- subgraph ---- If - node_cond__0_2 - att.else_branch=G4 -- level=1 --  -> div_true_graph_0__false_graph_0
Cast(x, to=1) -> convert_element_type_default_2
Div(convert_element_type_default_2, submodule.weight) -> div_true_graph_0__false_graph_0
output: name='div_true_graph_0__false_graph_0' type=dtype('float32') shape=['batch']
----- subgraph ---- If - node_cond__0 - att.else_branch=G2 -- level=1 --  -> sub_1_false_graph_0
Cast(x, to=1) -> convert_element_type_default_3
Sub(convert_element_type_default_3, weight) -> sub_1_false_graph_0
output: name='sub_1_false_graph_0' type=dtype('float32') shape=['batch']

ControlFlowCondNonZero

forward

def forward(self, input_ids, image_features, vocab_size):
    def then_branch(input_ids, image_features, vocab_size):
        input_shape = input_ids.size()
        input_ids = input_ids.view(-1, input_shape[-1])

        condition = (input_ids < 0) & (input_ids > -int(1e9))
        positions = torch.nonzero(condition, as_tuple=True)
        input_ids = input_ids.clamp_min(0).clamp_max(vocab_size)
        return (input_ids, positions[0], positions[1])

    def else_branch(input_ids, image_features, vocab_size):
        r = torch.where(torch.zeros((1, 1), dtype=torch.bool))
        return (input_ids, r[0], r[1])

    a, b, c = torch.cond(
        image_features.numel() > 0,
        then_branch,
        else_branch,
        [input_ids, image_features, vocab_size],
    )
    return a, b, c

custom

FAILED

Expect operands to be a tuple of possibly nested dict/list/tuple that only consists of tensor leaves, but got [FakeTensor(..., size=(s72, 12), dtype=torch.int64), FakeTensor(..., size=(s28, s11)), 1025].

dynamo-ir

FAILED

Failed to export the model with torch.export. This is step 1/3 of exporting the model to ONNX. Next steps:
- Modify the model code for `torch.export.export` to succeed. Refer to https://pytorch.org/docs/stable/generated/exportdb/index.html for more information.
- Debug `torch.export.export` and summit a PR to PyTorch.
- Create an issue in the PyTorch GitHub repository against the *torch.export* component and attach the full error stack as well as reproduction scripts.

## Exception summary

<class 'RuntimeError'>: Expect operands to be a tuple of possibly nested dict/list/tuple that only consists of tensor leaves, but got [FakeTensor(..., size=(s72, 12), dtype=torch.int64), FakeTensor(..., size=(s28, s11)), 1025].

(Refer to the full stack trace above for more information.)

ControlFlowNestCond

forward

def forward(self, x):
    def true_fn2(x):
        def true_fn1(x):
            return torch.sin(x)

        def false_fn1(x):
            return torch.cos(x)

        return torch.cond(x.sum() < 0, true_fn1, false_fn1, [x])

    def false_fn2(x):
        return -x

    return torch.cond(x.sum() > 0, true_fn2, false_fn2, [x])

custom

  • inputs: #1[(T1s5x3,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
opset: domain='local_functions.0' version=1
opset: domain='local_functions' version=1
input: name='x' type=dtype('float32') shape=['batch', 3]
init: name='init1_s_' type=float32 shape=() -- array([0.], dtype=float32)-- shape_type_compute._cast_inputs.1(gt_Scalar)
ReduceSum(x, keepdims=0) -> sum_1
  Greater(sum_1, init1_s_) -> gt
    If(gt, else_branch=G1, then_branch=G2) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 3]
----- subgraph ---- If - cond - att.else_branch=G1 -- level=1 --  -> cond#0
Neg(x) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None
----- subgraph ---- If - cond - att.then_branch=G2 -- level=1 --  -> cond#0
Constant(value=0.0) -> init1_s_22
ReduceSum(x, keepdims=0) -> sum_122
  Less(sum_122, init1_s_22) -> lt2
    If(lt2, else_branch=G3, then_branch=G4) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None
----- subgraph ---- If - cond22 - att.else_branch=G3 -- level=2 --  -> cond#0
Cos(x) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None
----- subgraph ---- If - cond22 - att.then_branch=G4 -- level=2 --  -> cond#0
Sin(x) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None
----- subgraph ---- If - cond22 - att.else_branch=G3 -- level=1 --  -> cond#0
Cos(x) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None
----- subgraph ---- If - cond22 - att.then_branch=G4 -- level=1 --  -> cond#0
Sin(x) -> cond#0
output: name='cond#0' type='NOTENSOR' shape=None

dynamo-ir

  • inputs: #1[(T1s5x3,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 3]
init: name='scalar_tensor_default' type=float32 shape=() -- array([0.], dtype=float32)
ReduceSum(x, noop_with_empty_axes=0, keepdims=0) -> sum_1
  Greater(sum_1, scalar_tensor_default) -> gt
    If(gt, then_branch=G1, else_branch=G2) -> getitem
output: name='getitem' type=dtype('float32') shape=['batch', 3]
----- subgraph ---- If - node_cond__0 - att.then_branch=G1 -- level=1 --  -> getitem_true_graph_0
ReduceSum(x, noop_with_empty_axes=0, keepdims=0) -> sum_1_2
Less(sum_1_2, scalar_tensor_default) -> lt
  If(lt, then_branch=G3, else_branch=G4) -> getitem_true_graph_0
output: name='getitem_true_graph_0' type='NOTENSOR' shape=None
----- subgraph ---- If - node_cond__0_2 - att.then_branch=G3 -- level=2 --  -> sin_true_graph_0__true_graph_0
Sin(x) -> sin_true_graph_0__true_graph_0
output: name='sin_true_graph_0__true_graph_0' type=dtype('float32') shape=['batch', 3]
----- subgraph ---- If - node_cond__0_2 - att.else_branch=G4 -- level=2 --  -> cos_true_graph_0__false_graph_0
Cos(x) -> cos_true_graph_0__false_graph_0
output: name='cos_true_graph_0__false_graph_0' type=dtype('float32') shape=['batch', 3]
----- subgraph ---- If - node_cond__0_2 - att.then_branch=G3 -- level=1 --  -> sin_true_graph_0__true_graph_0
Sin(x) -> sin_true_graph_0__true_graph_0
output: name='sin_true_graph_0__true_graph_0' type=dtype('float32') shape=['batch', 3]
----- subgraph ---- If - node_cond__0_2 - att.else_branch=G4 -- level=1 --  -> cos_true_graph_0__false_graph_0
Cos(x) -> cos_true_graph_0__false_graph_0
output: name='cos_true_graph_0__false_graph_0' type=dtype('float32') shape=['batch', 3]
----- subgraph ---- If - node_cond__0 - att.else_branch=G2 -- level=1 --  -> neg_false_graph_0
Neg(x) -> neg_false_graph_0
output: name='neg_false_graph_0' type=dtype('float32') shape=['batch', 3]

ControlFlowScan

forward

def forward(self, x):
    init = torch.zeros_like(x[0])
    carry, out = torch.ops.higher_order.scan(
        ControlFlowScan.add, [init], [x], additional_inputs=[]
    )
    return carry

custom

  • inputs: #1[(T1s3x3,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
opset: domain='local_functions' version=1
input: name='x' type=dtype('float32') shape=['batch', 3]
init: name='init7_s1_3' type=int64 shape=(1,) -- array([3])           -- Opset.make_node.1/Shape
ConstantOfShape(init7_s1_3, value=[0.0]) -> zeros_like
  Scan(zeros_like, x, body=G1, num_scan_inputs=1, scan_input_directions=[0], scan_output_axes=[0], scan_output_directions=[0]) -> output_0, scan#1
output: name='output_0' type=dtype('float32') shape=[3]
----- subgraph ---- Scan - scan - att.body=G1 -- level=1 -- init_0_zeros_like,scan_0_x -> output_0,output_1
input: name='init_0_zeros_like' type='NOTENSOR' shape=None
input: name='scan_0_x' type='NOTENSOR' shape=None
Add(init_0_zeros_like, scan_0_x) -> output_0
  Identity(output_0) -> output_1
output: name='output_0' type='NOTENSOR' shape=None
output: name='output_1' type='NOTENSOR' shape=None

dynamo-ir

FAILED

Failed to decompose the FX graph for ONNX compatibility. This is step 2/3 of exporting the model to ONNX. Next steps:
- Create an issue in the PyTorch GitHub repository against the *torch.export* component and attach the full error stack as well as reproduction scripts.
- Create an error report with `torch.onnx.export(..., report=True)`, and save the ExportedProgram as a pt2 file. Create an issue in the PyTorch GitHub repository against the *onnx* component. Attach the error report and the pt2 model.

## Exception summary

<class 'RuntimeError'>: scan might be aliasing the input or the output!

While executing %scan : [num_users=2] = call_function[target=torch.ops.higher_order.scan](args = (%scan_combine_graph_0, [%zeros_like], [%x], ()), kwargs = {})
Original traceback:
File "~/github/onnx-diagnostic/onnx_diagnostic/torch_export_patches/eval/model_cases.py", line 387, in forward
    carry, out = torch.ops.higher_order.scan(
Use tlparse to see full graph. (https://github.com/pytorch/tlparse?tab=readme-ov-file#tlparse-parse-structured-pt2-logs)

(Refer to the full stack trace above for more information.)

ControlFlowScan2Carried

forward

def forward(self, x):
    init1 = torch.zeros_like(x[0])
    init2 = torch.ones_like(x[0])
    carry1, carry2, out1, out2 = torch.ops.higher_order.scan(
        ControlFlowScan2Carried.add,
        [init1, init2],
        [x, x * 2],
        # dim=0,  # 01/31/2025, not supported anymore
        additional_inputs=[],
    )
    return carry1, carry2, out1, out2

custom

  • inputs: #1[(T1s3x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
opset: domain='local_functions' version=1
input: name='x' type=dtype('float32') shape=['batch', 4]
init: name='init7_s1_4' type=int64 shape=(1,) -- array([4])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init1_s_::RSh1' type=float32 shape=(1,) -- array([2.], dtype=float32)-- GraphBuilder.constant_folding.from/fold(init1_s_,init7_s1_1)##init1_s_/shape_type_compute._cast_inputs.1(mul_Tensor)##init7_s1_1/Opset.make_node.1/Shape
ConstantOfShape(init7_s1_4, value=[1.0]) -> ones_like
ConstantOfShape(init7_s1_4, value=[0.0]) -> zeros_like
Mul(x, init1_s_::RSh1) -> _onx_mul_x
  Scan(zeros_like, ones_like, x, _onx_mul_x, body=G1, num_scan_inputs=2, scan_input_directions=[0,0], scan_output_axes=[0,0], scan_output_directions=[0,0]) -> output_0, output_1, output_2, output_3
output: name='output_0' type=dtype('float32') shape=[4]
output: name='output_1' type=dtype('float32') shape=[4]
output: name='output_2' type=dtype('float32') shape=['batch', 4]
output: name='output_3' type=dtype('float32') shape=['batch', 4]
----- subgraph ---- Scan - scan - att.body=G1 -- level=1 -- init_0_zeros_like,init_1_ones_like,scan_0_x,scan_1_mul -> output_0,output_1,output_2,output_3
input: name='init_0_zeros_like' type='NOTENSOR' shape=None
input: name='init_1_ones_like' type='NOTENSOR' shape=None
input: name='scan_0_x' type='NOTENSOR' shape=None
input: name='scan_1_mul' type='NOTENSOR' shape=None
Add(init_0_zeros_like, scan_0_x) -> output_0
  Identity(output_0) -> output_2
Mul(init_1_ones_like, scan_1_mul) -> output_1
  Identity(output_1) -> output_3
output: name='output_0' type='NOTENSOR' shape=None
output: name='output_1' type='NOTENSOR' shape=None
output: name='output_2' type='NOTENSOR' shape=None
output: name='output_3' type='NOTENSOR' shape=None

dynamo-ir

FAILED

Failed to decompose the FX graph for ONNX compatibility. This is step 2/3 of exporting the model to ONNX. Next steps:
- Create an issue in the PyTorch GitHub repository against the *torch.export* component and attach the full error stack as well as reproduction scripts.
- Create an error report with `torch.onnx.export(..., report=True)`, and save the ExportedProgram as a pt2 file. Create an issue in the PyTorch GitHub repository against the *onnx* component. Attach the error report and the pt2 model.

## Exception summary

<class 'RuntimeError'>: scan might be aliasing the input or the output!

While executing %scan : [num_users=4] = call_function[target=torch.ops.higher_order.scan](args = (%scan_combine_graph_0, [%zeros_like, %ones_like], [%x, %mul], ()), kwargs = {})
Original traceback:
File "~/github/onnx-diagnostic/onnx_diagnostic/torch_export_patches/eval/model_cases.py", line 406, in forward
    carry1, carry2, out1, out2 = torch.ops.higher_order.scan(
Use tlparse to see full graph. (https://github.com/pytorch/tlparse?tab=readme-ov-file#tlparse-parse-structured-pt2-logs)

(Refer to the full stack trace above for more information.)

ControlFlowScanCDist

forward

def forward(self, x):
    carry, out = torch.ops.higher_order.scan(
        ControlFlowScanCDist.dist,
        [x],
        [x],
        # dim=0,  # 01/31/2025, not supported anymore
        additional_inputs=[],
    )
    return out

custom

  • inputs: #1[(T1s3x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
opset: domain='local_functions' version=1
input: name='x' type=dtype('float32') shape=['batch', 4]
Scan(x, x, body=G1, num_scan_inputs=1, scan_input_directions=[0], scan_output_axes=[0], scan_output_directions=[0]) -> scan#0, output_0
output: name='output_0' type=dtype('float32') shape=['batch', 'batch']
----- subgraph ---- Scan - scan - att.body=G1 -- level=1 -- init_0_x,scan_0_x -> output_0,output_1
input: name='init_0_x' type='NOTENSOR' shape=None
input: name='scan_0_x' type='NOTENSOR' shape=None
Constant(value=[1]) -> init7_s1_12
Constant(value=[1, -1]) -> init7_s2_1_-12
  Reshape(scan_0_x, init7_s2_1_-12) -> reshape2
    Sub(init_0_x, reshape2) -> sub2
      Mul(sub2, sub2) -> mul2
  ReduceSum(mul2, init7_s1_12, keepdims=0) -> sum_12
Constant(value=0.5) -> init1_s_2
  Pow(sum_12, init1_s_2) -> output_1
Identity(init_0_x) -> output_0
output: name='output_0' type='NOTENSOR' shape=None
output: name='output_1' type='NOTENSOR' shape=None

dynamo-ir

  • inputs: #1[(T1s3x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 4]
init: name='val_1' type=int64 shape=(2,) -- array([ 1, -1])
init: name='val_5' type=int64 shape=(1,) -- array([1])
init: name='val_6' type=float32 shape=() -- array([0.5], dtype=float32)
Scan(x, x, body=G1, num_scan_inputs=1, scan_input_directions=[0], scan_output_directions=[0]) -> scan__0, getitem_1
output: name='getitem_1' type=dtype('float32') shape=['batch', 'batch']
----- subgraph ---- Scan - node_scan__1 - att.body=G1 -- level=1 -- x_scan_combine_graph_0__subgraph_in,x_scan_combine_graph_0__subgraph_in -> clone_scan_combine_graph_0,pow_1_scan_combine_graph_0
input: name='x_scan_combine_graph_0__subgraph_in' type=dtype('float32') shape=['s77', 4]
input: name='x_scan_combine_graph_0__subgraph_in' type=dtype('float32') shape=[4]
Identity(x_scan_combine_graph_0__subgraph_in) -> clone_scan_combine_graph_0
Reshape(x_scan_combine_graph_0__subgraph_in, val_1, allowzero=1) -> view
  Sub(x_scan_combine_graph_0__subgraph_in, view) -> sub_1
    Mul(sub_1, sub_1) -> mul_4
ReduceSum(mul_4, val_5, noop_with_empty_axes=0, keepdims=0) -> sum_1
Pow(sum_1, val_6) -> pow_1_scan_combine_graph_0
output: name='clone_scan_combine_graph_0' type=dtype('float32') shape=['s77', 4]
output: name='pow_1_scan_combine_graph_0' type=dtype('float32') shape=['s77']

FAILED

[ONNXRuntimeError] : 1 : FAIL : Error: Duplicate definition-site for (x_scan_combine_graph_0__subgraph_in).

ControlFlowScanCDist2

forward

def forward(self, x):
    z = torch.tensor([0], dtype=torch.float32)
    y = x.clone()
    out = torch.ops.higher_order.scan(
        ControlFlowScanCDist2.dist,
        [z],
        [x],
        # dim=0,  # 01/31/2025, not supported anymore
        additional_inputs=[y],
    )
    return out[1]

custom

  • inputs: #1[(T1s3x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
opset: domain='local_functions' version=1
input: name='x' type=dtype('float32') shape=['batch', 4]
init: name='c_lifted_tensor_0' type=float32 shape=(1,) -- array([0.], dtype=float32)-- DynamoInterpret.placeholder.0
Identity(x) -> hidden_input_scan_0_clone
Scan(c_lifted_tensor_0, x, body=G1, num_scan_inputs=1, scan_input_directions=[0], scan_output_axes=[0], scan_output_directions=[0]) -> scan#0, output_0
output: name='output_0' type=dtype('float32') shape=['batch', 'batch']
----- subgraph ---- Scan - scan - att.body=G1 -- level=1 -- init_0_detach_,scan_0_x -> output_0,output_1
input: name='init_0_detach_' type='NOTENSOR' shape=None
input: name='scan_0_x' type='NOTENSOR' shape=None
Constant(value=[1]) -> init7_s1_12
Constant(value=[1, -1]) -> init7_s2_1_-12
  Reshape(scan_0_x, init7_s2_1_-12) -> reshape2
Sub(hidden_input_scan_0_clone, reshape2) -> sub2
  Mul(sub2, sub2) -> mul2
  ReduceSum(mul2, init7_s1_12, keepdims=0) -> sum_12
    Sqrt(sum_12) -> output_1
Identity(init_0_detach_) -> output_0
output: name='output_0' type='NOTENSOR' shape=None
output: name='output_1' type='NOTENSOR' shape=None

dynamo-ir

  • inputs: #1[(T1s3x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 4]
init: name='clone' type=float32 shape=(1,) -- array([0.], dtype=float32)
init: name='val_1' type=int64 shape=(2,) -- array([ 1, -1])
init: name='val_5' type=int64 shape=(1,) -- array([1])
Scan(clone, x, body=G1, num_scan_inputs=1, scan_input_directions=[0], scan_output_directions=[0]) -> scan__0, getitem_1
output: name='getitem_1' type=dtype('float32') shape=['batch', 'batch']
----- subgraph ---- Scan - node_scan__1 - att.body=G1 -- level=1 -- clone_scan_combine_graph_0__subgraph_in,x_scan_combine_graph_0__subgraph_in -> clone_scan_combine_graph_0,sqrt_scan_combine_graph_0
input: name='clone_scan_combine_graph_0__subgraph_in' type=dtype('float32') shape=[1]
input: name='x_scan_combine_graph_0__subgraph_in' type=dtype('float32') shape=[4]
Identity(clone_scan_combine_graph_0__subgraph_in) -> clone_scan_combine_graph_0
Reshape(x_scan_combine_graph_0__subgraph_in, val_1, allowzero=1) -> view
Sub(x, view) -> sub_1
  Mul(sub_1, sub_1) -> mul_4
ReduceSum(mul_4, val_5, noop_with_empty_axes=0, keepdims=0) -> sum_1
  Sqrt(sum_1) -> sqrt_scan_combine_graph_0
output: name='clone_scan_combine_graph_0' type=dtype('float32') shape=[1]
output: name='sqrt_scan_combine_graph_0' type=dtype('float32') shape=['batch']

ControlFlowScanCDistXY

forward

def forward(self, x, y):
    carry, out = torch.ops.higher_order.scan(
        ControlFlowScanCDistXY.dist,
        [y],
        [x],
        # dim=0,  # 01/31/2025, not supported anymore
        additional_inputs=[],
    )
    return out

custom

  • inputs: #2[(T1s3x4,T1s5x4),(T1s13x14,T1s15x14)]

  • shapes: dict(x:{0:Dim(x_rows),1:Dim(dim)},y:{0:Dim(y_rows),1:Dim(dim)})

opset: domain='' version=18
opset: domain='local_functions' version=1
input: name='x' type=dtype('float32') shape=['x_rows', 'dim']
input: name='y' type=dtype('float32') shape=['y_rows', 'dim']
Scan(y, x, body=G1, num_scan_inputs=1, scan_input_directions=[0], scan_output_axes=[0], scan_output_directions=[0]) -> scan#0, output_0
output: name='output_0' type=dtype('float32') shape=['x_rows', 'y_rows']
----- subgraph ---- Scan - scan - att.body=G1 -- level=1 -- init_0_y,scan_0_x -> output_0,output_1
input: name='init_0_y' type='NOTENSOR' shape=None
input: name='scan_0_x' type='NOTENSOR' shape=None
Constant(value=[1]) -> init7_s1_12
Constant(value=[1, -1]) -> init7_s2_1_-12
  Reshape(scan_0_x, init7_s2_1_-12) -> reshape2
    Sub(init_0_y, reshape2) -> sub2
      Mul(sub2, sub2) -> mul2
  ReduceSum(mul2, init7_s1_12, keepdims=0) -> sum_12
    Sqrt(sum_12) -> output_1
Identity(init_0_y) -> output_0
output: name='output_0' type='NOTENSOR' shape=None
output: name='output_1' type='NOTENSOR' shape=None

dynamo-ir

  • inputs: #2[(T1s3x4,T1s5x4),(T1s13x14,T1s15x14)]

  • shapes: dict(x:{0:Dim(x_rows),1:Dim(dim)},y:{0:Dim(y_rows),1:Dim(dim)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['x_rows', 'dim']
input: name='y' type=dtype('float32') shape=['y_rows', 'dim']
init: name='val_3' type=int64 shape=(2,) -- array([ 1, -1])
init: name='val_7' type=int64 shape=(1,) -- array([1])
Scan(y, x, body=G1, num_scan_inputs=1, scan_input_directions=[0], scan_output_directions=[0]) -> scan__0, getitem_1
output: name='getitem_1' type=dtype('float32') shape=['x_rows', 'y_rows']
----- subgraph ---- Scan - node_scan__1 - att.body=G1 -- level=1 -- y_scan_combine_graph_0__subgraph_in,x_scan_combine_graph_0__subgraph_in -> clone_scan_combine_graph_0,sqrt_scan_combine_graph_0
input: name='y_scan_combine_graph_0__subgraph_in' type=dtype('float32') shape=['s17', 's27']
input: name='x_scan_combine_graph_0__subgraph_in' type=dtype('float32') shape=['s27']
Identity(y_scan_combine_graph_0__subgraph_in) -> clone_scan_combine_graph_0
Reshape(x_scan_combine_graph_0__subgraph_in, val_3, allowzero=1) -> view
  Sub(y_scan_combine_graph_0__subgraph_in, view) -> sub_4
    Mul(sub_4, sub_4) -> mul_7
ReduceSum(mul_7, val_7, noop_with_empty_axes=0, keepdims=0) -> sum_1
  Sqrt(sum_1) -> sqrt_scan_combine_graph_0
output: name='clone_scan_combine_graph_0' type=dtype('float32') shape=['s17', 's27']
output: name='sqrt_scan_combine_graph_0' type=dtype('float32') shape=['s17']

ControlFlowScanDecomposition_151564

forward

def forward(self, images, position):
    return self.select_when_exporting(self.dummy_loop, self.dummy_loop_with_scan)(
        images, position
    )

custom

  • inputs: #1[(T1s5x6,T7s5)]

  • shapes: dict(images:{0:DYNAMIC,1:DYNAMIC},position:{0:DYNAMIC})

opset: domain='' version=18
opset: domain='local_functions' version=1
input: name='images' type=dtype('float32') shape=['batch', 'channel']
input: name='position' type=dtype('int64') shape=['batch_1']
Scan(images, position, body=G1, num_scan_inputs=2, scan_input_directions=[0,0], scan_output_axes=[0], scan_output_directions=[0]) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 'channel']
----- subgraph ---- Scan - scan - att.body=G1 -- level=1 -- scan_0_images,scan_1_position -> output_0
input: name='scan_0_images' type='NOTENSOR' shape=None
input: name='scan_1_position' type='NOTENSOR' shape=None
Constant(value=[0]) -> init7_s1_02
  Unsqueeze(scan_1_position, init7_s1_02) -> item::UnSq03
  Slice(scan_0_images, init7_s1_02, item::UnSq03, init7_s1_02) -> slice_12
Shape(scan_0_images, end=1, start=0) -> padded_1::Shape:12
  ConstantOfShape(padded_1::Shape:12, value=[0.0]) -> zeros2
    Shape(zeros2) -> zeros::Shape:2
  Slice(zeros2, item::UnSq03, zeros::Shape:2, init7_s1_02) -> _onx_slice_zeros2
    Concat(slice_12, _onx_slice_zeros2, axis=0) -> output_0
output: name='output_0' type='NOTENSOR' shape=None

dynamo-ir

  • inputs: #1[(T1s5x6,T7s5)]

  • shapes: dict(images:{0:DYNAMIC,1:DYNAMIC},position:{0:DYNAMIC})

opset: domain='' version=20
input: name='images' type=dtype('float32') shape=['s34', 's90']
input: name='position' type=dtype('int64') shape=['s71']
init: name='val_1' type=int64 shape=(1,) -- array([-1])
init: name='val_6' type=float32 shape=() -- array([0.], dtype=float32)
init: name='val_9' type=int64 shape=() -- array([0])
init: name='val_11' type=int64 shape=() -- array([1])
init: name='val_14' type=int64 shape=(1,) -- array([0])
init: name='val_21' type=int64 shape=(1,) -- array([1])
Scan(images, position, body=G1, num_scan_inputs=2, scan_input_directions=[0,0], scan_output_directions=[0]) -> getitem
output: name='getitem' type=dtype('float32') shape=['s34', 's90']
----- subgraph ---- Scan - node_scan__0 - att.body=G1 -- level=1 -- images_scan_combine_graph_0__subgraph_in,position_scan_combine_graph_0__subgraph_in -> slice_scatter_scan_combine_graph_0
input: name='images_scan_combine_graph_0__subgraph_in' type=dtype('float32') shape=['s90']
input: name='position_scan_combine_graph_0__subgraph_in' type=dtype('int64') shape=None
Reshape(position_scan_combine_graph_0__subgraph_in, val_1, allowzero=0) -> val_8
Gather(val_8, val_9, axis=0) -> val_10
Reshape(val_10, val_1, allowzero=0) -> val_17
Slice(images_scan_combine_graph_0__subgraph_in, val_14, val_17, val_14, val_21) -> slice_1
Shape(images_scan_combine_graph_0__subgraph_in, end=1, start=0) -> val_0
  Squeeze(val_0) -> sym_size_int_4
Reshape(sym_size_int_4, val_1, allowzero=0) -> val_2
Expand(val_6, val_2) -> zeros
  Shape(zeros, start=0) -> val_33
Gather(val_33, val_9, axis=0) -> val_34
Range(val_9, val_34, val_11) -> val_35
Unsqueeze(val_10, val_14) -> val_37
Slice(val_35, val_14, val_37, val_14, val_21) -> val_39
Unsqueeze(val_39, val_1) -> val_40
  ScatterND(zeros, val_40, slice_1, reduction=b'none') -> slice_scatter_scan_combine_graph_0
output: name='slice_scatter_scan_combine_graph_0' type=dtype('float32') shape=['']

ControlFlowScanInplace_153705

forward

def forward(self, x, y):
    def loop_body_1(z, iv, x, y):
        z = z.clone()
        i = iv.item()
        z[i, :] = ((x[i, :] - y) ** 2).sum(dim=-1)
        return [z, iv]

    z = torch.empty((x.shape[0], y.shape[0]))
    r = torch.ops.higher_order.scan(
        loop_body_1, [z], [torch.arange(x.shape[0], dtype=torch.int64)], [x, y]
    )
    return r[0]

custom

FAILED

only integers, slices (`:`), ellipsis (`...`), None and long or byte Variables are valid indices (got SymInt)

dynamo-ir

FAILED

Failed to decompose the FX graph for ONNX compatibility. This is step 2/3 of exporting the model to ONNX. Next steps:
- Create an issue in the PyTorch GitHub repository against the *torch.export* component and attach the full error stack as well as reproduction scripts.
- Create an error report with `torch.onnx.export(..., report=True)`, and save the ExportedProgram as a pt2 file. Create an issue in the PyTorch GitHub repository against the *onnx* component. Attach the error report and the pt2 model.

## Exception summary

<class 'RuntimeError'>: scan might be aliasing the input or the output!

While executing %scan : [num_users=2] = call_function[target=torch.ops.higher_order.scan](args = (%scan_combine_graph_0, [%empty], [%arange], (%x, %y)), kwargs = {})
Original traceback:
File "~/github/onnx-diagnostic/onnx_diagnostic/torch_export_patches/eval/model_cases.py", line 518, in forward
    r = torch.ops.higher_order.scan(
Use tlparse to see full graph. (https://github.com/pytorch/tlparse?tab=readme-ov-file#tlparse-parse-structured-pt2-logs)

(Refer to the full stack trace above for more information.)

CreateFromShape

forward

def forward(self, x):
    y = torch.ones((x.shape[0], x.shape[1] + 1))
    return y

custom

  • inputs: #2[(T1s4x4,),(T1s5x5,)]

  • shapes: dict(x:{0:Dim(dx),1:Dim(dy)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['dx', 'dy']
init: name='init7_s_1' type=int64 shape=() -- array([1])              -- shape_type_compute._cast_inputs.1(add)
init: name='init7_s1_0' type=int64 shape=(1,) -- array([0])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape
Shape(x, end=1, start=0) -> x::Shape:1
Shape(x, end=2, start=1) -> x::Shape1:2
  Squeeze(x::Shape1:2) -> sym_size_int_3
    Add(sym_size_int_3, init7_s_1) -> _onx_add_sym_size_int_3
      Unsqueeze(_onx_add_sym_size_int_3, init7_s1_0) -> add::UnSq0
  Concat(x::Shape:1, add::UnSq0, axis=0) -> _onx_concat_sym_size_int_2::UnSq0
    ConstantOfShape(_onx_concat_sym_size_int_2::UnSq0, value=[1.0]) -> output_0
output: name='output_0' type=dtype('float32') shape=['dx', 'dy+1']

dynamo-ir

  • inputs: #2[(T1s4x4,),(T1s5x5,)]

  • shapes: dict(x:{0:Dim(dx),1:Dim(dy)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['dx', 'dy']
init: name='val_2' type=int64 shape=() -- array([1])
init: name='val_5' type=int64 shape=(1,) -- array([-1])
init: name='val_10' type=float32 shape=() -- array([1.], dtype=float32)
Shape(x, end=1, start=0) -> val_0
Shape(x, end=2, start=1) -> val_1
  Squeeze(val_1) -> sym_size_int_3
    Add(sym_size_int_3, val_2) -> add
      Reshape(add, val_5, allowzero=0) -> val_6
  Concat(val_0, val_6, axis=0) -> val_7
    Expand(val_10, val_7) -> ones
output: name='ones' type=dtype('float32') shape=['dx', 'dy + 1']

CreateFromShapeThroughFunction

forward

def forward(self, x):
    dy1 = CreateFromShapeThroughFunction.add_one(x.shape[1])
    y = torch.ones((x.shape[0], dy1))
    return y

custom

  • inputs: #2[(T1s4x4,),(T1s5x5,)]

  • shapes: dict(x:{0:Dim(dx),1:Dim(dy)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['dx', 'dy']
init: name='init7_s_1' type=int64 shape=() -- array([1])              -- shape_type_compute._cast_inputs.1(add)
init: name='init7_s1_0' type=int64 shape=(1,) -- array([0])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape
Shape(x, end=1, start=0) -> x::Shape:1
Shape(x, end=2, start=1) -> x::Shape1:2
  Squeeze(x::Shape1:2) -> sym_size_int_3
    Add(sym_size_int_3, init7_s_1) -> _onx_add_sym_size_int_3
      Unsqueeze(_onx_add_sym_size_int_3, init7_s1_0) -> add::UnSq0
  Concat(x::Shape:1, add::UnSq0, axis=0) -> _onx_concat_sym_size_int_2::UnSq0
    ConstantOfShape(_onx_concat_sym_size_int_2::UnSq0, value=[1.0]) -> output_0
output: name='output_0' type=dtype('float32') shape=['dx', 'dy+1']

dynamo-ir

  • inputs: #2[(T1s4x4,),(T1s5x5,)]

  • shapes: dict(x:{0:Dim(dx),1:Dim(dy)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['dx', 'dy']
init: name='val_2' type=int64 shape=() -- array([1])
init: name='val_5' type=int64 shape=(1,) -- array([-1])
init: name='val_10' type=float32 shape=() -- array([1.], dtype=float32)
Shape(x, end=1, start=0) -> val_0
Shape(x, end=2, start=1) -> val_1
  Squeeze(val_1) -> sym_size_int_3
    Add(sym_size_int_3, val_2) -> add
      Reshape(add, val_5, allowzero=0) -> val_6
  Concat(val_0, val_6, axis=0) -> val_7
    Expand(val_10, val_7) -> ones
output: name='ones' type=dtype('float32') shape=['dx', 'dy + 1']

CropLastDimensionWithTensorContent

forward

def forward(self, x, shape):
    return x[..., : shape[0]]

custom

FAILED

Could not extract specialized integer from data-dependent expression u0 (unhinted: u0).  (Size-like symbols: none)

Caused by: (_export/non_strict_utils.py:1066 in __torch_function__)
For more information, run with TORCH_LOGS="dynamic"
For extended logs when we create symbols, also add TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="u0"
If you suspect the guard was triggered from C++, add TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
For more debugging help, see https://docs.google.com/document/d/1HSuTTVvYH1pTew89Rtpeu84Ht3nQEFTYhAX3Ypa_xJs/edit?usp=sharing

For C++ stack trace, run with TORCHDYNAMO_EXTENDED_DEBUG_CPP=1

The following call raised this error:
  File "~/github/onnx-diagnostic/onnx_diagnostic/torch_export_patches/eval/model_cases.py", line 818, in forward
    return x[..., : shape[0]]


The error above occurred when calling torch.export.export. If you would like to view some more information about this error, and get a list of all other errors that may occur in your export call, you can replace your `export()` call with `draft_export()`.

dynamo-ir

  • inputs: #2[(T1s3x4x4,T7s1),(T1s6x4x4,T7s1)]

  • shapes: dict(x:{0:Dim(batch)},shape:{})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 4, 4]
input: name='shape' type=dtype('int64') shape=[1]
init: name='val_7' type=int64 shape=(1,) -- array([0])
init: name='val_10' type=int64 shape=(1,) -- array([2])
init: name='val_14' type=int64 shape=(1,) -- array([1])
Slice(x, val_7, val_10, val_10, val_14) -> slice_1
output: name='slice_1' type=dtype('float32') shape=['batch', 4, 2]

FAILED

diff.1

CropLastDimensionWithTensorShape

forward

def forward(self, x, y):
    return x[..., : y.shape[0]]

custom

  • inputs: #2[(T1s3x4x4,T1s2),(T1s6x4x4,T1s3)]

  • shapes: dict(x:{0:Dim(batch)},y:{0:Dim(crop)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 4, 4]
input: name='y' type=dtype('float32') shape=['crop']
init: name='init7_s1_0' type=int64 shape=(1,) -- array([0])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s1_2' type=int64 shape=(1,) -- array([2])           -- Opset.make_node.1/Shape
Shape(y, end=1, start=0) -> y::Shape:1
  Slice(x, init7_s1_0, y::Shape:1, init7_s1_2) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 4, 'crop']

dynamo-ir

  • inputs: #2[(T1s3x4x4,T1s2),(T1s6x4x4,T1s3)]

  • shapes: dict(x:{0:Dim(batch)},y:{0:Dim(crop)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 4, 4]
input: name='y' type=dtype('float32') shape=['crop']
init: name='val_1' type=int64 shape=(1,) -- array([0])
init: name='val_8' type=int64 shape=(1,) -- array([2])
init: name='val_9' type=int64 shape=(1,) -- array([1])
Shape(y, end=1, start=0) -> val_0
  Slice(x, val_1, val_0, val_8, val_9) -> slice_1
output: name='slice_1' type=dtype('float32') shape=['batch', 4, 'crop']

InplaceAdd

forward

def forward(self, x):
    x += self.bias
    return x

custom

  • inputs: #2[(T1s3x4,),(T1s5x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 4]
init: name='c_bias' type=float32 shape=(1, 4) -- array([1., 1., 1., 1.], dtype=float32)-- DynamoInterpret.placeholder.0
Add(x, c_bias) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 4]

dynamo-ir

  • inputs: #2[(T1s3x4,),(T1s5x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 4]
init: name='bias' type=float32 shape=(1, 4) -- array([1., 1., 1., 1.], dtype=float32)
Add(x, bias) -> add_3
output: name='add_3' type=dtype('float32') shape=['batch', 4]

InplaceAdd2

forward

def forward(self, x):
    x.add_(self.bias)
    return x

custom

  • inputs: #2[(T1s3x4,),(T1s5x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 4]
init: name='c_bias' type=float32 shape=(1, 4) -- array([1., 1., 1., 1.], dtype=float32)-- DynamoInterpret.placeholder.0
Add(x, c_bias) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 4]

dynamo-ir

  • inputs: #2[(T1s3x4,),(T1s5x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 4]
init: name='bias' type=float32 shape=(1, 4) -- array([1., 1., 1., 1.], dtype=float32)
Add(x, bias) -> add_3
output: name='add_3' type=dtype('float32') shape=['batch', 4]

InplaceAdd_Mul

forward

def forward(self, x):
    x.add_(self.bias)
    return x * 2

custom

  • inputs: #2[(T1s3x4,),(T1s5x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 4]
init: name='c_bias' type=float32 shape=(1, 4) -- array([1., 1., 1., 1.], dtype=float32)-- DynamoInterpret.placeholder.0
init: name='init1_s_::RSh1' type=float32 shape=(1,) -- array([2.], dtype=float32)-- GraphBuilder.constant_folding.from/fold(init1_s_,init7_s1_1)##init1_s_/shape_type_compute._cast_inputs.1(mul_Tensor)##init7_s1_1/Opset.make_node.1/Shape
Add(x, c_bias) -> add_
  Mul(add_, init1_s_::RSh1) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 4]

dynamo-ir

  • inputs: #2[(T1s3x4,),(T1s5x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 4]
init: name='bias' type=float32 shape=(1, 4) -- array([1., 1., 1., 1.], dtype=float32)
init: name='scalar_tensor_default' type=float32 shape=() -- array([2.], dtype=float32)
Add(x, bias) -> add_3
  Mul(add_3, scalar_tensor_default) -> mul_4
output: name='mul_4' type=dtype('float32') shape=['batch', 4]

InplaceCloneAdd

forward

def forward(self, x):
    x = x.clone()
    x.add_(self.bias)
    return x

custom

  • inputs: #2[(T1s3x4,),(T1s5x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 4]
init: name='c_bias' type=float32 shape=(1, 4) -- array([1., 1., 1., 1.], dtype=float32)-- DynamoInterpret.placeholder.0
Add(x, c_bias) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 4]

dynamo-ir

  • inputs: #2[(T1s3x4,),(T1s5x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 4]
init: name='bias' type=float32 shape=(1, 4) -- array([1., 1., 1., 1.], dtype=float32)
Add(x, bias) -> add_6
output: name='add_6' type=dtype('float32') shape=['batch', 4]

InplaceSetItemEllipsis_1

forward

def forward(self, index, update):
    copy = self.params.clone()
    copy[..., index] = update
    return copy

custom

FAILED

L['update'].size()[0] = 8192 is not equal to L['index'].size()[0] = 4

The error above occurred when calling torch.export.export. If you would like to view some more information about this error, and get a list of all other errors that may occur in your export call, you can replace your `export()` call with `draft_export()`.

dynamo-ir

FAILED

Failed to convert the exported program to an ONNX model. This is step 3/3 of exporting the model to ONNX. Next steps:
- If there is a missing ONNX function, implement it and register it to the registry.
- If there is an internal error during ONNX conversion, debug the error and summit a PR to PyTorch.
- Create an error report with `torch.onnx.export(..., report=True)`, and save the ExportedProgram as a pt2 file. Create an issue in the PyTorch GitHub repository against the *onnx* component. Attach the error report and the pt2 model.

## Exception summary

<class 'TypeError'>: int() argument must be a string, a bytes-like object or a real number, not 'SymbolicDim'
⬆️
<class 'torch.onnx._internal.exporter._errors.GraphConstructionError'>: Error processing Python constants for operator '::Expand'. named_inputs={'input': SymbolicTensor(name='anonymous:134972185979760', producer=anonymous_node:134972187114768, index=0), 'shape': (SymbolicDim(s5), SymbolicDim(s32))}, named_attrs={}, opset=, op_signature=''::Expand(input: T, shape: shape) -> (T) where T=UINT8 | UINT32 | BOOL | BFLOAT16 | COMPLEX64 | INT16 | FLOAT16 | FLOAT | UINT64 | STRING | INT64 | DOUBLE | INT8 | UINT16 | COMPLEX128 | INT32, shape=INT64.
⬆️
<class 'torch.onnx._internal.exporter._errors.GraphConstructionError'>: Error calling operator 'Expand' with args (SymbolicTensor(name='anonymous:134972185979760', producer=anonymous_node:134972187114768, index=0), (SymbolicDim(s5), SymbolicDim(s32))) and kwargs {}.
⬆️
<class 'torch.onnx._internal.exporter._errors.GraphConstructionError'>: Error when calling function 'TracedOnnxFunction(<function aten_index_put at 0x7ac1ab6c9ee0>)' with args '[SymbolicTensor(name='clone', type=Tensor(FLOAT), shape=Shape([1, 8192, 4]), producer='node_clone', index=0), [None, None, SymbolicTensor(name='index', type=Tensor(INT64), shape=Shape([SymbolicDim(s91)]))], SymbolicTensor(name='update', type=Tensor(FLOAT), shape=Shape([SymbolicDim(s5), SymbolicDim(s32)]))]' and kwargs '{}'
⬆️
<class 'torch.onnx._internal.exporter._errors.ConversionError'>: Error when translating node %index_put : [num_users=1] = call_function[target=torch.ops.aten.index_put.default](args = (%clone, [None, None, %index], %update), kwargs = {}). See the stack trace for more information.

(Refer to the full stack trace above for more information.)

InplaceSetItemEllipsis_2

forward

def forward(self, index, update):
    copy = self.params.clone()
    copy[..., index] = update
    return copy

custom

FAILED

L['update'].size()[0] = 8192 is not equal to L['index'].size()[0] = 4

The error above occurred when calling torch.export.export. If you would like to view some more information about this error, and get a list of all other errors that may occur in your export call, you can replace your `export()` call with `draft_export()`.

dynamo-ir

FAILED

Failed to convert the exported program to an ONNX model. This is step 3/3 of exporting the model to ONNX. Next steps:
- If there is a missing ONNX function, implement it and register it to the registry.
- If there is an internal error during ONNX conversion, debug the error and summit a PR to PyTorch.
- Create an error report with `torch.onnx.export(..., report=True)`, and save the ExportedProgram as a pt2 file. Create an issue in the PyTorch GitHub repository against the *onnx* component. Attach the error report and the pt2 model.

## Exception summary

<class 'TypeError'>: int() argument must be a string, a bytes-like object or a real number, not 'SymbolicDim'
⬆️
<class 'torch.onnx._internal.exporter._errors.GraphConstructionError'>: Error processing Python constants for operator '::Expand'. named_inputs={'input': SymbolicTensor(name='anonymous:134971766327568', producer=anonymous_node:134972208177968, index=0), 'shape': (SymbolicDim(s5), SymbolicDim(s32))}, named_attrs={}, opset=, op_signature=''::Expand(input: T, shape: shape) -> (T) where T=UINT8 | UINT32 | BOOL | BFLOAT16 | COMPLEX64 | INT16 | FLOAT16 | FLOAT | UINT64 | STRING | INT64 | DOUBLE | INT8 | UINT16 | COMPLEX128 | INT32, shape=INT64.
⬆️
<class 'torch.onnx._internal.exporter._errors.GraphConstructionError'>: Error calling operator 'Expand' with args (SymbolicTensor(name='anonymous:134971766327568', producer=anonymous_node:134972208177968, index=0), (SymbolicDim(s5), SymbolicDim(s32))) and kwargs {}.
⬆️
<class 'torch.onnx._internal.exporter._errors.GraphConstructionError'>: Error when calling function 'TracedOnnxFunction(<function aten_index_put at 0x7ac1ab6c9ee0>)' with args '[SymbolicTensor(name='clone', type=Tensor(FLOAT), shape=Shape([1, 8192, 6]), producer='node_clone', index=0), [None, None, SymbolicTensor(name='index', type=Tensor(INT64), shape=Shape([SymbolicDim(s91)]))], SymbolicTensor(name='update', type=Tensor(FLOAT), shape=Shape([SymbolicDim(s5), SymbolicDim(s32)]))]' and kwargs '{}'
⬆️
<class 'torch.onnx._internal.exporter._errors.ConversionError'>: Error when translating node %index_put : [num_users=1] = call_function[target=torch.ops.aten.index_put.default](args = (%clone, [None, None, %index], %update), kwargs = {}). See the stack trace for more information.

(Refer to the full stack trace above for more information.)

InplaceSetItemMask

forward

def forward(self, x):
    mask = x.to(bool)
    x[mask] = 2
    return x

custom

  • inputs: #2[(T1s2x3x3,),(T1s3x3x3,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 3, 3]
init: name='c_lifted_tensor_0' type=float32 shape=() -- array([2.], dtype=float32)-- DynamoInterpret.placeholder.0
Cast(x, to=9) -> to
  Where(to, c_lifted_tensor_0, x) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 3, 3]

dynamo-ir

  • inputs: #2[(T1s2x3x3,),(T1s3x3x3,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 3, 3]
init: name='clone' type=float32 shape=() -- array([2.], dtype=float32)
Cast(x, to=9) -> _to_copy
  Where(_to_copy, clone, x) -> index_put
output: name='index_put' type=dtype('float32') shape=['batch', 3, 3]

InplaceSetItemSquare

forward

def forward(self, x):
    x[:2, :3] = 1
    return x

custom

  • inputs: #2[(T1s5x5,),(T1s7x5,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 5]
init: name='init7_s1_0' type=int64 shape=(1,) -- array([0])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s1_2' type=int64 shape=(1,) -- array([2])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s1_1' type=int64 shape=(1,) -- array([1])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s2_-1_1' type=int64 shape=(2,) -- array([-1,  1])   -- Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s3_0_1_2::RSh-1x1' type=int64 shape=(3, 1) -- array([0, 1, 2])-- GraphBuilder.constant_folding.from/fold(init7_s2_-1_1,init7_s3_0_1_2)##init7_s3_0_1_2/Opset.make_node.1/Shape##init7_s2_-1_1/Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='fill::T10' type=float32 shape=(3, 2)                      -- GraphBuilder.constant_folding.from/fold(fill)##fill/
Shape(x) -> x::Shape:
  Gather(x::Shape:, init7_s1_0) -> _onx_gather_x::Shape:
    Range(init7_s1_0, _onx_gather_x::Shape:, init7_s1_1) -> _onx_range_init7_s1_0
      Slice(_onx_range_init7_s1_0, init7_s1_0, init7_s1_2, init7_s1_0, init7_s1_1) -> _onx_slice_range_init7_s1_0
        Reshape(_onx_slice_range_init7_s1_0, init7_s2_-1_1) -> _onx_slice_range_init7_s1_0::RSh-1x1
Slice(x, init7_s1_0, init7_s1_2, init7_s1_0) -> slice_3
  Transpose(slice_3, perm=[1,0]) -> slice_3::T10
    ScatterND(slice_3::T10, init7_s3_0_1_2::RSh-1x1, fill::T10) -> _onx_scatternd_slice_3::T10
      Transpose(_onx_scatternd_slice_3::T10, perm=[1,0]) -> slice_scatter
        ScatterND(x, _onx_slice_range_init7_s1_0::RSh-1x1, slice_scatter) -> output_0
          Identity(output_0) -> output_1
output: name='output_1' type=dtype('float32') shape=['batch', 5]

dynamo-ir

  • inputs: #2[(T1s5x5,),(T1s7x5,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 5]
init: name='val_26' type=int64 shape=(1,) -- array([0])
init: name='val_29' type=int64 shape=(1,) -- array([2])
init: name='val_33' type=int64 shape=(1,) -- array([1])
init: name='val_43' type=int64 shape=(3, 1) -- array([0, 1, 2])
init: name='val_44' type=float32 shape=(3, 2)
Slice(x, val_26, val_29, val_26, val_33) -> slice_3
  Transpose(slice_3, perm=[1,0]) -> val_45
    ScatterND(val_45, val_43, val_44, reduction=b'none') -> val_46
      Transpose(val_46, perm=[1,0]) -> slice_scatter_1
output: name='slice_scatter_1' type=dtype('float32') shape=[2, 5]

FAILED

diff.1

InplaceSetItemSquareAdd

forward

def forward(self, x):
    x[:2, :3] = 1
    return x + 2

custom

  • inputs: #2[(T1s5x5,),(T1s7x5,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 5]
init: name='init7_s1_0' type=int64 shape=(1,) -- array([0])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s1_2' type=int64 shape=(1,) -- array([2])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s1_1' type=int64 shape=(1,) -- array([1])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s2_-1_1' type=int64 shape=(2,) -- array([-1,  1])   -- Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s3_0_1_2::RSh-1x1' type=int64 shape=(3, 1) -- array([0, 1, 2])-- GraphBuilder.constant_folding.from/fold(init7_s2_-1_1,init7_s3_0_1_2)##init7_s3_0_1_2/Opset.make_node.1/Shape##init7_s2_-1_1/Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='fill::T10' type=float32 shape=(3, 2)                      -- GraphBuilder.constant_folding.from/fold(fill)##fill/
init: name='init1_s_::RSh1' type=float32 shape=(1,) -- array([2.], dtype=float32)-- GraphBuilder.constant_folding.from/fold(init1_s_,init7_s1_1)##init1_s_/shape_type_compute._cast_inputs.0##init7_s1_1/Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape
Shape(x) -> x::Shape:
  Gather(x::Shape:, init7_s1_0) -> _onx_gather_x::Shape:
    Range(init7_s1_0, _onx_gather_x::Shape:, init7_s1_1) -> _onx_range_init7_s1_0
      Slice(_onx_range_init7_s1_0, init7_s1_0, init7_s1_2, init7_s1_0, init7_s1_1) -> _onx_slice_range_init7_s1_0
        Reshape(_onx_slice_range_init7_s1_0, init7_s2_-1_1) -> _onx_slice_range_init7_s1_0::RSh-1x1
Slice(x, init7_s1_0, init7_s1_2, init7_s1_0) -> slice_3
  Transpose(slice_3, perm=[1,0]) -> slice_3::T10
    ScatterND(slice_3::T10, init7_s3_0_1_2::RSh-1x1, fill::T10) -> _onx_scatternd_slice_3::T10
      Transpose(_onx_scatternd_slice_3::T10, perm=[1,0]) -> slice_scatter
        ScatterND(x, _onx_slice_range_init7_s1_0::RSh-1x1, slice_scatter) -> output_0
          Add(output_0, init1_s_::RSh1) -> output_1
output: name='output_1' type=dtype('float32') shape=['batch', 5]

dynamo-ir

  • inputs: #2[(T1s5x5,),(T1s7x5,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 5]
init: name='val_26' type=int64 shape=(1,) -- array([0])
init: name='val_29' type=int64 shape=(1,) -- array([2])
init: name='val_33' type=int64 shape=(1,) -- array([1])
init: name='val_43' type=int64 shape=(3, 1) -- array([0, 1, 2])
init: name='val_44' type=float32 shape=(3, 2)
init: name='scalar_tensor_default' type=float32 shape=() -- array([2.], dtype=float32)
Slice(x, val_26, val_29, val_26, val_33) -> slice_3
  Transpose(slice_3, perm=[1,0]) -> val_45
    ScatterND(val_45, val_43, val_44, reduction=b'none') -> val_46
      Transpose(val_46, perm=[1,0]) -> slice_scatter
        Add(slice_scatter, scalar_tensor_default) -> add
output: name='add' type=dtype('float32') shape=[2, 5]

FAILED

diff.1

InplaceSetItemSquareAdd2

forward

def forward(self, x):
    x[:2, :3] = 1
    return x + 2, x + 3

custom

  • inputs: #2[(T1s5x5,),(T1s7x5,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 5]
init: name='init7_s1_0' type=int64 shape=(1,) -- array([0])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s1_2' type=int64 shape=(1,) -- array([2])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s1_1' type=int64 shape=(1,) -- array([1])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s2_-1_1' type=int64 shape=(2,) -- array([-1,  1])   -- Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s3_0_1_2::RSh-1x1' type=int64 shape=(3, 1) -- array([0, 1, 2])-- GraphBuilder.constant_folding.from/fold(init7_s2_-1_1,init7_s3_0_1_2)##init7_s3_0_1_2/Opset.make_node.1/Shape##init7_s2_-1_1/Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='fill::T10' type=float32 shape=(3, 2)                      -- GraphBuilder.constant_folding.from/fold(fill)##fill/
init: name='init1_s_::RSh1' type=float32 shape=(1,) -- array([2.], dtype=float32)-- GraphBuilder.constant_folding.from/fold(init1_s_,init7_s1_1)##init1_s_/shape_type_compute._cast_inputs.0##init7_s1_1/Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init1_s_2::RSh1' type=float32 shape=(1,) -- array([3.], dtype=float32)-- GraphBuilder.constant_folding.from/fold(init1_s_2,init7_s1_1)##init1_s_2/shape_type_compute._cast_inputs.0##init7_s1_1/Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape##Opset.make_node.1/Shape
Shape(x) -> x::Shape:
  Gather(x::Shape:, init7_s1_0) -> _onx_gather_x::Shape:
    Range(init7_s1_0, _onx_gather_x::Shape:, init7_s1_1) -> _onx_range_init7_s1_0
      Slice(_onx_range_init7_s1_0, init7_s1_0, init7_s1_2, init7_s1_0, init7_s1_1) -> _onx_slice_range_init7_s1_0
        Reshape(_onx_slice_range_init7_s1_0, init7_s2_-1_1) -> _onx_slice_range_init7_s1_0::RSh-1x1
Slice(x, init7_s1_0, init7_s1_2, init7_s1_0) -> slice_3
  Transpose(slice_3, perm=[1,0]) -> slice_3::T10
    ScatterND(slice_3::T10, init7_s3_0_1_2::RSh-1x1, fill::T10) -> _onx_scatternd_slice_3::T10
      Transpose(_onx_scatternd_slice_3::T10, perm=[1,0]) -> slice_scatter
        ScatterND(x, _onx_slice_range_init7_s1_0::RSh-1x1, slice_scatter) -> output_0
          Add(output_0, init1_s_::RSh1) -> output_1
Add(output_0, init1_s_2::RSh1) -> output_2
output: name='output_1' type=dtype('float32') shape=['batch', 5]
output: name='output_2' type=dtype('float32') shape=['batch', 5]

dynamo-ir

  • inputs: #2[(T1s5x5,),(T1s7x5,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 5]
init: name='val_26' type=int64 shape=(1,) -- array([0])
init: name='val_29' type=int64 shape=(1,) -- array([2])
init: name='val_33' type=int64 shape=(1,) -- array([1])
init: name='val_43' type=int64 shape=(3, 1) -- array([0, 1, 2])
init: name='val_44' type=float32 shape=(3, 2)
init: name='scalar_tensor_default' type=float32 shape=() -- array([2.], dtype=float32)
init: name='scalar_tensor_default_1' type=float32 shape=() -- array([3.], dtype=float32)
Slice(x, val_26, val_29, val_26, val_33) -> slice_3
  Transpose(slice_3, perm=[1,0]) -> val_45
    ScatterND(val_45, val_43, val_44, reduction=b'none') -> val_46
      Transpose(val_46, perm=[1,0]) -> slice_scatter
        Add(slice_scatter, scalar_tensor_default) -> add
Add(slice_scatter, scalar_tensor_default_1) -> add_4
output: name='add' type=dtype('float32') shape=[2, 5]
output: name='add_4' type=dtype('float32') shape=[2, 5]

FAILED

diff.1

SignatureFloat1

forward

def forward(self, x, alpha: float = 2.0):
    return torch.sigmoid(self.linear(x)) - self.buff * alpha

custom

  • inputs: #2[(T1s4x3,float),(T1s8x3,float)]

  • shapes: ({0:Dim(batch)},None)

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 3]
init: name='mul' type=float32 shape=(1,) -- array([0.75], dtype=float32)-- GraphBuilder.constant_folding.from/fold(_onx_mul_b_buff)##_onx_mul_b_buff/
init: name='GemmTransposePattern--p_linear_weight::T10' type=float32 shape=(1, 3) -- array([-0.572, -0.34 ,  0.314], dtype=float32)-- GraphBuilder.constant_folding.from/fold(init7_s2_1_-1,p_linear_weight::T10)##p_linear_weight::T10/GraphBuilder.constant_folding.from/fold(p_linear_weight)##p_linear_weight/DynamoInterpret.placeholder.1/P(linear.weight)##init7_s2_1_-1/TransposeEqualReshapePattern.apply.new_shape
init: name='linear.bias' type=float32 shape=(1,) -- array([-0.408], dtype=float32)-- DynamoInterpret.placeholder.1/P(linear.bias)
Gemm(x, GemmTransposePattern--p_linear_weight::T10, linear.bias, transB=1) -> linear
  Sigmoid(linear) -> sigmoid
    Sub(sigmoid, mul) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 1]

FAILED

Input mismatch, inputs[0]=(T1r2,float) but names=['x'], model=SignatureFloat1, export='custom'

dynamo-ir

  • inputs: #2[(T1s4x3,float),(T1s8x3,float)]

  • shapes: ({0:Dim(batch)},None)

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['s77', 3]
init: name='linear.weight' type=float32 shape=(1, 3) -- array([-0.416,  0.286,  0.075], dtype=float32)
init: name='linear.bias' type=float32 shape=(1,) -- array([0.381], dtype=float32)
init: name='mul_2' type=float32 shape=(1,) -- array([0.75], dtype=float32)
Gemm(x, linear.weight, linear.bias, beta=1.00, transB=1, alpha=1.00, transA=0) -> linear
  Sigmoid(linear) -> sigmoid
    Sub(sigmoid, mul_2) -> sub_2
output: name='sub_2' type=dtype('float32') shape=['s77', 1]

FAILED

Input mismatch, inputs[0]=(T1r2,float) but names=['x'], model=SignatureFloat1, export='dynamo-ir'

SignatureInt1

forward

def forward(self, x, i: int = 2):
    return torch.sigmoid(self.linear(x)) - self.buff + x[:, i : i + 1]

custom

  • inputs: #2[(T1s4x3,int),(T1s8x3,int)]

  • shapes: ({0:Dim(batch)},None)

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 3]
init: name='b_buff' type=float32 shape=(1,) -- array([0.5], dtype=float32)-- DynamoInterpret.placeholder.0
init: name='init7_s1_1' type=int64 shape=(1,) -- array([1])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s1_2' type=int64 shape=(1,) -- array([2])           -- Opset.make_node.1/Shape
init: name='GemmTransposePattern--p_linear_weight::T10' type=float32 shape=(1, 3) -- array([ 0.576,  0.177, -0.514], dtype=float32)-- GraphBuilder.constant_folding.from/fold(init7_s2_1_-1,p_linear_weight::T10)##p_linear_weight::T10/GraphBuilder.constant_folding.from/fold(p_linear_weight)##p_linear_weight/DynamoInterpret.placeholder.1/P(linear.weight)##init7_s2_1_-1/TransposeEqualReshapePattern.apply.new_shape
init: name='linear.bias' type=float32 shape=(1,) -- array([0.461], dtype=float32)-- DynamoInterpret.placeholder.1/P(linear.bias)
Gemm(x, GemmTransposePattern--p_linear_weight::T10, linear.bias, transB=1) -> linear
  Sigmoid(linear) -> sigmoid
    Sub(sigmoid, b_buff) -> sub
Slice(x, init7_s1_1, init7_s1_2, init7_s1_1) -> slice_1
  Add(sub, slice_1) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 1]

FAILED

Input mismatch, inputs[0]=(T1r2,int) but names=['x'], model=SignatureInt1, export='custom'

dynamo-ir

  • inputs: #2[(T1s4x3,int),(T1s8x3,int)]

  • shapes: ({0:Dim(batch)},None)

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['s77', 3]
init: name='linear.weight' type=float32 shape=(1, 3) -- array([-0.449,  0.029,  0.372], dtype=float32)
init: name='linear.bias' type=float32 shape=(1,) -- array([-0.522], dtype=float32)
init: name='buff' type=float32 shape=(1,) -- array([0.5], dtype=float32)
init: name='val_3' type=int64 shape=(1,) -- array([1])
init: name='val_7' type=int64 shape=(1,) -- array([2])
Gemm(x, linear.weight, linear.bias, beta=1.00, transB=1, alpha=1.00, transA=0) -> linear
  Sigmoid(linear) -> sigmoid
    Sub(sigmoid, buff) -> sub_2
Slice(x, val_3, val_7, val_3, val_3) -> slice_1
  Add(sub_2, slice_1) -> add_12
output: name='add_12' type=dtype('float32') shape=['s77', 1]

FAILED

Input mismatch, inputs[0]=(T1r2,int) but names=['x'], model=SignatureInt1, export='dynamo-ir'

SignatureInt2

forward

def forward(self, x, i: int = 2):
    return torch.sigmoid(self.linear(x)) - self.buff + x[:, i]

custom

  • inputs: #1[(T1s4x3,int)]

  • shapes: dict(x:{0:Dim(batch)},i:None)

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 3]
init: name='b_buff' type=float32 shape=(1,) -- array([0.5], dtype=float32)-- DynamoInterpret.placeholder.0
init: name='init7_s_1' type=int64 shape=() -- array([1])              -- Opset.make_node.1/Shape
init: name='GemmTransposePattern--p_linear_weight::T10' type=float32 shape=(1, 3) -- array([-0.408, -0.099,  0.345], dtype=float32)-- GraphBuilder.constant_folding.from/fold(init7_s2_1_-1,p_linear_weight::T10)##p_linear_weight::T10/GraphBuilder.constant_folding.from/fold(p_linear_weight)##p_linear_weight/DynamoInterpret.placeholder.1/P(linear.weight)##init7_s2_1_-1/TransposeEqualReshapePattern.apply.new_shape
init: name='linear.bias' type=float32 shape=(1,) -- array([0.426], dtype=float32)-- DynamoInterpret.placeholder.1/P(linear.bias)
Gather(x, init7_s_1, axis=1) -> select
Gemm(x, GemmTransposePattern--p_linear_weight::T10, linear.bias, transB=1) -> linear
  Sigmoid(linear) -> sigmoid
    Sub(sigmoid, b_buff) -> sub
  Add(sub, select) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 'batch']

FAILED

Input mismatch, inputs[0]=(T1r2,int) but names=['x'], model=SignatureInt2, export='custom'

dynamo-ir

  • inputs: #1[(T1s4x3,int)]

  • shapes: dict(x:{0:Dim(batch)},i:None)

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['s77', 3]
init: name='linear.weight' type=float32 shape=(1, 3) -- array([0.253, 0.352, 0.088], dtype=float32)
init: name='linear.bias' type=float32 shape=(1,) -- array([0.445], dtype=float32)
init: name='buff' type=float32 shape=(1,) -- array([0.5], dtype=float32)
init: name='val_12' type=int64 shape=() -- array([1])
Gather(x, val_12, axis=1) -> select
Gemm(x, linear.weight, linear.bias, beta=1.00, transB=1, alpha=1.00, transA=0) -> linear
  Sigmoid(linear) -> sigmoid
    Sub(sigmoid, buff) -> sub_2
  Add(sub_2, select) -> add_14
output: name='add_14' type=dtype('float32') shape=['s77', 's77']

FAILED

Input mismatch, inputs[0]=(T1r2,int) but names=['x'], model=SignatureInt2, export='dynamo-ir'

SignatureListFixedLength

forward

def forward(self, x, lx: list):
    return (
        torch.sigmoid(self.linear(x)) - self.buff + lx[0] * lx[1].sum(axis=1, keepdim=True)
    )

custom

  • inputs: #2[(T1s4x3,#2[T1s4x1,T1s4x2]),(T1s8x3,#2[T1s8x1,T1s8x2])]

  • shapes: dict(x:{0:Dim(batch)},lx:#2[{0:Dim(batch)},{0:Dim(batch)}])

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 3]
input: name='lx_0' type=dtype('float32') shape=['batch', 1]
input: name='lx_1' type=dtype('float32') shape=['batch', 2]
init: name='b_buff' type=float32 shape=(1,) -- array([0.5], dtype=float32)-- DynamoInterpret.placeholder.0
init: name='init7_s1_1' type=int64 shape=(1,) -- array([1])           -- Opset.make_node.1/Shape
init: name='GemmTransposePattern--p_linear_weight::T10' type=float32 shape=(1, 3) -- array([ 0.526,  0.443, -0.365], dtype=float32)-- GraphBuilder.constant_folding.from/fold(init7_s2_1_-1,p_linear_weight::T10)##p_linear_weight::T10/GraphBuilder.constant_folding.from/fold(p_linear_weight)##p_linear_weight/DynamoInterpret.placeholder.1/P(linear.weight)##init7_s2_1_-1/TransposeEqualReshapePattern.apply.new_shape
init: name='linear.bias' type=float32 shape=(1,) -- array([0.262], dtype=float32)-- DynamoInterpret.placeholder.1/P(linear.bias)
Gemm(x, GemmTransposePattern--p_linear_weight::T10, linear.bias, transB=1) -> linear
  Sigmoid(linear) -> sigmoid
    Sub(sigmoid, b_buff) -> sub
ReduceSum(lx_1, init7_s1_1, keepdims=1) -> sum_1
  Mul(lx_0, sum_1) -> mul
    Add(sub, mul) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 1]

dynamo-ir

  • inputs: #2[(T1s4x3,#2[T1s4x1,T1s4x2]),(T1s8x3,#2[T1s8x1,T1s8x2])]

  • shapes: dict(x:{0:Dim(batch)},lx:#2[{0:Dim(batch)},{0:Dim(batch)}])

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 3]
input: name='lx_0' type=dtype('float32') shape=['batch', 1]
input: name='lx_1' type=dtype('float32') shape=['batch', 2]
init: name='linear.weight' type=float32 shape=(1, 3) -- array([ 0.331,  0.458, -0.514], dtype=float32)
init: name='linear.bias' type=float32 shape=(1,) -- array([0.529], dtype=float32)
init: name='buff' type=float32 shape=(1,) -- array([0.5], dtype=float32)
init: name='val_6' type=int64 shape=(1,) -- array([1])
Gemm(x, linear.weight, linear.bias, beta=1.00, transB=1, alpha=1.00, transA=0) -> linear
  Sigmoid(linear) -> sigmoid
    Sub(sigmoid, buff) -> sub_2
ReduceSum(lx_1, val_6, noop_with_empty_axes=0, keepdims=1) -> sum_1
  Mul(lx_0, sum_1) -> mul_4
    Add(sub_2, mul_4) -> add_15
output: name='add_15' type=dtype('float32') shape=['batch', 1]

SignatureListFixedWithNone

forward

def forward(self, lx):
    x = lx[0]
    if lx[1] is not None:
        x += lx[1]
    if lx[2] is not None:
        x += lx[2]
    return x

custom

FAILED

Detected mismatch between the structure of `inputs` and `dynamic_shapes`: `inputs['lx']` has 3 elements, but `dynamic_shapes['lx']` has 2 elements
For more information about this error, see: https://pytorch.org/docs/main/generated/exportdb/index.html#dynamic-shapes-validation

The error above occurred when calling torch.export.export. If you would like to view some more information about this error, and get a list of all other errors that may occur in your export call, you can replace your `export()` call with `draft_export()`.

dynamo-ir

FAILED

Failed to export the model with torch.export. This is step 1/3 of exporting the model to ONNX. Next steps:
- Modify the model code for `torch.export.export` to succeed. Refer to https://pytorch.org/docs/stable/generated/exportdb/index.html for more information.
- Debug `torch.export.export` and summit a PR to PyTorch.
- Create an issue in the PyTorch GitHub repository against the *torch.export* component and attach the full error stack as well as reproduction scripts.

## Exception summary

<class 'torch._dynamo.exc.UserError'>: Detected mismatch between the structure of `inputs` and `dynamic_shapes`: `inputs['lx']` has 3 elements, but `dynamic_shapes['lx']` has 2 elements
For more information about this error, see: https://pytorch.org/docs/main/generated/exportdb/index.html#dynamic-shapes-validation

The error above occurred when calling torch.export.export. If you would like to view some more information about this error, and get a list of all other errors that may occur in your export call, you can replace your `export()` call with `draft_export()`.

(Refer to the full stack trace above for more information.)

SignatureListVariableLength

forward

def forward(self, x, lx: list):
    t = torch.cat(lx, dim=1).sum(axis=1, keepdim=True)
    return torch.sigmoid(self.linear(x)) - self.buff + t

custom

  • inputs: #2[(T1s4x3,#2[T1s4x1,T1s4x2]),(T1s8x3,#3[T1s8x1,T1s8x2,T1s8x3])]

  • shapes: dict(x:{0:Dim(batch)},lx:#2[{0:Dim(batch)},{0:Dim(batch)}])

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 3]
input: name='lx_0' type=dtype('float32') shape=['batch', 1]
input: name='lx_1' type=dtype('float32') shape=['batch', 2]
init: name='b_buff' type=float32 shape=(1,) -- array([0.5], dtype=float32)-- DynamoInterpret.placeholder.0
init: name='init7_s1_1' type=int64 shape=(1,) -- array([1])           -- Opset.make_node.1/Shape
init: name='GemmTransposePattern--p_linear_weight::T10' type=float32 shape=(1, 3) -- array([-0.142, -0.154, -0.08 ], dtype=float32)-- GraphBuilder.constant_folding.from/fold(init7_s2_1_-1,p_linear_weight::T10)##p_linear_weight::T10/GraphBuilder.constant_folding.from/fold(p_linear_weight)##p_linear_weight/DynamoInterpret.placeholder.1/P(linear.weight)##init7_s2_1_-1/TransposeEqualReshapePattern.apply.new_shape
init: name='linear.bias' type=float32 shape=(1,) -- array([-0.015], dtype=float32)-- DynamoInterpret.placeholder.1/P(linear.bias)
Concat(lx_0, lx_1, axis=1) -> cat
  ReduceSum(cat, init7_s1_1, keepdims=1) -> sum_1
Gemm(x, GemmTransposePattern--p_linear_weight::T10, linear.bias, transB=1) -> linear
  Sigmoid(linear) -> sigmoid
    Sub(sigmoid, b_buff) -> sub
    Add(sub, sum_1) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 1]

FAILED

diff.1

dynamo-ir

  • inputs: #2[(T1s4x3,#2[T1s4x1,T1s4x2]),(T1s8x3,#3[T1s8x1,T1s8x2,T1s8x3])]

  • shapes: dict(x:{0:Dim(batch)},lx:#2[{0:Dim(batch)},{0:Dim(batch)}])

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 3]
input: name='lx_0' type=dtype('float32') shape=['batch', 1]
input: name='lx_1' type=dtype('float32') shape=['batch', 2]
init: name='linear.weight' type=float32 shape=(1, 3) -- array([ 0.322, -0.494,  0.448], dtype=float32)
init: name='linear.bias' type=float32 shape=(1,) -- array([0.221], dtype=float32)
init: name='buff' type=float32 shape=(1,) -- array([0.5], dtype=float32)
init: name='val_6' type=int64 shape=(1,) -- array([1])
Concat(lx_0, lx_1, axis=1) -> cat
  ReduceSum(cat, val_6, noop_with_empty_axes=0, keepdims=1) -> sum_1
Gemm(x, linear.weight, linear.bias, beta=1.00, transB=1, alpha=1.00, transA=0) -> linear
  Sigmoid(linear) -> sigmoid
    Sub(sigmoid, buff) -> sub_4
    Add(sub_4, sum_1) -> add_15
output: name='add_15' type=dtype('float32') shape=['batch', 1]

FAILED

diff.1

SignatureShapeAsIndex

forward

def forward(self, x, y):
    t = torch.sigmoid(self.linear(x)) + x
    return t[:, : y.shape[1]]

custom

  • inputs: #1[(T1s4x3,T1s4x2)]

  • shapes: dict(x:{0:Dim(batch)},y:{0:Dim(batch),1:Dim(length)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 3]
input: name='y' type=dtype('float32') shape=['batch', 'length']
init: name='init7_s1_0' type=int64 shape=(1,) -- array([0])           -- Opset.make_node.1/Shape##Opset.make_node.1/Shape
init: name='init7_s1_1' type=int64 shape=(1,) -- array([1])           -- Opset.make_node.1/Shape
init: name='GemmTransposePattern--p_linear_weight::T10' type=float32 shape=(1, 3) -- array([-0.225,  0.382,  0.432], dtype=float32)-- GraphBuilder.constant_folding.from/fold(init7_s2_1_-1,p_linear_weight::T10)##p_linear_weight::T10/GraphBuilder.constant_folding.from/fold(p_linear_weight)##p_linear_weight/DynamoInterpret.placeholder.1/P(linear.weight)##init7_s2_1_-1/TransposeEqualReshapePattern.apply.new_shape
init: name='linear.bias' type=float32 shape=(1,) -- array([0.051], dtype=float32)-- DynamoInterpret.placeholder.1/P(linear.bias)
Gemm(x, GemmTransposePattern--p_linear_weight::T10, linear.bias, transB=1) -> linear
  Sigmoid(linear) -> sigmoid
    Add(sigmoid, x) -> add
Shape(y, end=2, start=1) -> y::Shape1:2
  Slice(add, init7_s1_0, y::Shape1:2, init7_s1_1) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 'length']

dynamo-ir

  • inputs: #1[(T1s4x3,T1s4x2)]

  • shapes: dict(x:{0:Dim(batch)},y:{0:Dim(batch),1:Dim(length)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 3]
input: name='y' type=dtype('float32') shape=['batch', 'length']
init: name='linear.weight' type=float32 shape=(1, 3) -- array([ 0.338,  0.004, -0.118], dtype=float32)
init: name='linear.bias' type=float32 shape=(1,) -- array([0.568], dtype=float32)
init: name='val_1' type=int64 shape=(1,) -- array([0])
init: name='val_8' type=int64 shape=(1,) -- array([1])
Gemm(x, linear.weight, linear.bias, beta=1.00, transB=1, alpha=1.00, transA=0) -> linear
  Sigmoid(linear) -> sigmoid
    Add(sigmoid, x) -> add_6
Shape(y, end=2, start=1) -> val_0
  Slice(add_6, val_1, val_0, val_8, val_8) -> slice_1
output: name='slice_1' type=dtype('float32') shape=['batch', 'length']

TypeBFloat16

forward

def forward(self, x):
    xb = x.to(torch.bfloat16)
    return (xb + xb).to(torch.float32)

custom

  • inputs: #1[(T1s4x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=18
input: name='x' type=dtype('float32') shape=['batch', 4]
Add(x, x) -> add-x
  Cast(add-x, to=16) -> add
    Cast(add, to=1) -> output_0
output: name='output_0' type=dtype('float32') shape=['batch', 4]

dynamo-ir

  • inputs: #1[(T1s4x4,)]

  • shapes: dict(x:{0:Dim(batch)})

opset: domain='' version=20
input: name='x' type=dtype('float32') shape=['batch', 4]
Cast(x, to=16) -> _to_copy
  Add(_to_copy, _to_copy) -> add_3
    Cast(add_3, to=1) -> _to_copy_1
output: name='_to_copy_1' type=dtype('float32') shape=['batch', 4]

FAILED

[ONNXRuntimeError] : 9 : NOT_IMPLEMENTED : Could not find an implementation for Add(14) node with name 'node_add_3'

Vmap

forward

def forward(self, x, y):
    f = lambda x, y: x * y + 1  # noqa: E731
    return torch.vmap(f)(x, y)

custom

FAILED

# no error found for the failure

dynamo-ir

FAILED

Failed to export the model with torch.export. This is step 1/3 of exporting the model to ONNX. Next steps:
- Modify the model code for `torch.export.export` to succeed. Refer to https://pytorch.org/docs/stable/generated/exportdb/index.html for more information.
- Debug `torch.export.export` and summit a PR to PyTorch.
- Create an issue in the PyTorch GitHub repository against the *torch.export* component and attach the full error stack as well as reproduction scripts.

## Exception summary

<class 'AssertionError'>: 

(Refer to the full stack trace above for more information.)

VmapPython

forward

def forward(self, x, y):
    f = lambda x, y: x * y + 1  # noqa: E731
    return patched_vmap(f)(x, y)

custom

FAILED

object of type 'Node' has no len()

dynamo-ir

FAILED

Failed to export the model with torch.export. This is step 1/3 of exporting the model to ONNX. Next steps:
- Modify the model code for `torch.export.export` to succeed. Refer to https://pytorch.org/docs/stable/generated/exportdb/index.html for more information.
- Debug `torch.export.export` and summit a PR to PyTorch.
- Create an issue in the PyTorch GitHub repository against the *torch.export* component and attach the full error stack as well as reproduction scripts.

## Exception summary

<class 'TypeError'>: object of type 'Node' has no len()

(Refer to the full stack trace above for more information.)

Summary