From e73c5368fb26ea80ad4ba495f699b92cb4f2bc73 Mon Sep 17 00:00:00 2001
From: Yuanqiang Liu <liuyuanqiang.yqliu@bytedance.com>
Date: Fri, 26 Jan 2024 09:01:47 +0800
Subject: [PATCH] [FxImporter] make FxImporter to fit python<=3.9 (#2802)

As that torch with py3.9 is also used widely.
---
 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..d799d61f6a92 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.
 
+try:
+    from types import NoneType
+except ImportError:
+    # python less than 3.10 doesn't have NoneType
+    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