Skip to content

Torchscript should support union type by "|" introduced in python3.10. #114755

@hzhangxyz

Description

@hzhangxyz

🚀 The feature, motivation and pitch

In python3.10, we can write typing.Union[X, Y] as X | Y directly, which improves the readibility. I hope we can write it in torchscript, but currently torch.jit.script complains that Expression of type | cannot be used in a type expression

See: https://peps.python.org/pep-0604/

Alternatives

No response

Additional context

No response

### Tasks

cc @EikanWang @jgong5 @wenzhe-nrv @sanchitintel

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNot as big of a feature, but technically not a bug. Should be easy to fixoncall: jitAdd this issue/PR to JIT oncall triage queue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions