Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix][TIR] Patch for PR#13269 to support Python 3.10 #13350

Merged
merged 2 commits into from
Nov 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions python/tvm/tir/schedule/_type_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,24 @@
import inspect
from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union
import typing
import sys


def _is_none_type(type_: Any) -> bool:
return type_ is None or type_ is type(None)


def get_python_version():
return sys.version_info[:3]


if hasattr(typing, "_GenericAlias"):
# For python versions 3.7 onward, check the __origin__ attribute.

class _Subtype:
@staticmethod
def _origin(type_: Any) -> Any:
if get_python_version() >= (3, 9, 0):
if hasattr(typing, "_SpecialGenericAlias"):
if isinstance(type_, typing._SpecialGenericAlias): # type: ignore # pylint: disable=protected-access
return type_.__origin__
else:
if isinstance(type_, typing._GenericAlias): # type: ignore # pylint: disable=protected-access
return type_.__origin__

if isinstance(type_, typing._GenericAlias): # type: ignore # pylint: disable=protected-access
return type_.__origin__
return None

@staticmethod
Expand Down