From 17f49862e367e2ddd7fd43af87f440c166a2364d Mon Sep 17 00:00:00 2001 From: LiuYuanqiang Date: Thu, 25 Jan 2024 20:01:41 +0800 Subject: [PATCH 1/2] [FxImporter] make FxImporter to fit python<=3.9 --- python/torch_mlir/extras/fx_importer.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/torch_mlir/extras/fx_importer.py b/python/torch_mlir/extras/fx_importer.py index 9ec90e766c46..1db31857d5d3 100644 --- a/python/torch_mlir/extras/fx_importer.py +++ b/python/torch_mlir/extras/fx_importer.py @@ -5,10 +5,16 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. +from sys import version_info +if version_info.major == 3 and version_info.minor >= 10: + from types import NoneType +else: + NoneType = type(None) + import logging import operator import re -from types import NoneType, BuiltinMethodType, BuiltinFunctionType +from types import BuiltinMethodType, BuiltinFunctionType from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Union import weakref From c3cfb9d7d390169bd9a0dec561fe2740d680684c Mon Sep 17 00:00:00 2001 From: LiuYuanqiang Date: Fri, 26 Jan 2024 01:05:39 +0800 Subject: [PATCH 2/2] update --- python/torch_mlir/extras/fx_importer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/torch_mlir/extras/fx_importer.py b/python/torch_mlir/extras/fx_importer.py index 1db31857d5d3..d799d61f6a92 100644 --- a/python/torch_mlir/extras/fx_importer.py +++ b/python/torch_mlir/extras/fx_importer.py @@ -5,10 +5,10 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. -from sys import version_info -if version_info.major == 3 and version_info.minor >= 10: +try: from types import NoneType -else: +except ImportError: + # python less than 3.10 doesn't have NoneType NoneType = type(None) import logging