diff --git a/python/tvm/relay/_parser.py b/python/tvm/relay/_parser.py index eba92bf0c848..71e5bfaadff0 100644 --- a/python/tvm/relay/_parser.py +++ b/python/tvm/relay/_parser.py @@ -21,9 +21,21 @@ import sys from ast import literal_eval -from typing import Any, Deque, Dict, List, Optional, TypeVar, Tuple, Union from collections import deque +try: + # no typing.Deque in Python 3.5 + # https://bugs.python.org/issue29011 + from typing import Any, Dict, List, Optional, TypeVar, Tuple, Union, MutableSequence, T, Deque +except ImportError: + class Deque(deque, MutableSequence[T], extra=deque): + + def __new__(cls, *args, **kwds): + if _geqv(cls, Deque): + raise TypeError("Type Deque cannot be instantiated; " + "use deque() instead") + return deque.__new__(cls, *args, **kwds) + import tvm from . import module