pytorch
78d37981 - [ONNX] Fix type comparison in utils._need_symbolic_context (#77365)

Commit
2 years ago
[ONNX] Fix type comparison in utils._need_symbolic_context (#77365) In `_need_symbolic_context`, when the annotation is postponed evaluated, the annotation is a string and not a type. We need to use get_type_hints to get the real type. For example, ```python def g(a: int) -> int: return a def f(a: "int") -> "int": return a ``` we will get the correct type `int` for both g and f with `typing.get_type_hints`. Otherwise, the type for `a` in `f` will be a string and is not comparable to the type `int` - `issubclass` will complain. This is necessary as we will use postponed typing evaluation to break circular dependencies. Pull Request resolved: https://github.com/pytorch/pytorch/pull/77365 Approved by: https://github.com/BowenBao
Author
Committer
Parents
Loading