Skip to content

Custom TypeVar doesn't work if it's inside a function #805

Open
@titaiwangms

Description

@titaiwangms

Found this is testing,

Works:

TCustomFloat = TypeVar("TCustomFloat", bound=Union[FLOAT16, FLOAT, DOUBLE, BFLOAT16])

@onnxscript.script(custom_domain)
def test_custom_op(x: TCustomFloat, y: TCustomFloat) -> TCustomFloat:
    return op.Add(x, y)

No:

def test_something(self):
  TCustomFloat = TypeVar("TCustomFloat", bound=Union[FLOAT16, FLOAT, DOUBLE, BFLOAT16])
  
  @onnxscript.script(custom_domain)
  def test_custom_op(x: TCustomFloat, y: TCustomFloat) -> TCustomFloat:
      return op.Add(x, y)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions