This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 7c9969bbdf Remove and replace deprecated `distutils.util.strtobool()`
(#17185)
7c9969bbdf is described below
commit 7c9969bbdfc7f032f270f9f75eeb53bf6e78ff7b
Author: Masahiro Hiramori <[email protected]>
AuthorDate: Wed Jul 24 00:33:06 2024 +0900
Remove and replace deprecated `distutils.util.strtobool()` (#17185)
remove and replace deprecated distutils.util.strtobool
---
python/tvm/auto_scheduler/testing/tune_onnx.py | 2 +-
python/tvm/auto_scheduler/testing/tune_relay.py | 2 +-
python/tvm/auto_scheduler/testing/tune_te.py | 2 +-
python/tvm/autotvm/testing/tune_relay.py | 2 +-
python/tvm/meta_schedule/testing/tune_onnx.py | 2 +-
python/tvm/meta_schedule/testing/tune_relay.py | 2 +-
python/tvm/meta_schedule/testing/tune_te.py | 2 +-
python/tvm/meta_schedule/testing/validate_database.py | 2 +-
python/tvm/testing/utils.py | 15 +++++++++++++++
9 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/python/tvm/auto_scheduler/testing/tune_onnx.py
b/python/tvm/auto_scheduler/testing/tune_onnx.py
index a3299c05bb..334b5d6726 100644
--- a/python/tvm/auto_scheduler/testing/tune_onnx.py
+++ b/python/tvm/auto_scheduler/testing/tune_onnx.py
@@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
# pylint: disable=missing-docstring
-from distutils.util import strtobool
import argparse
import json
import os
@@ -30,6 +29,7 @@ from tvm.meta_schedule.testing.tune_utils import
generate_input_data, create_tim
from tvm.meta_schedule.utils import cpu_count
from tvm.relay.frontend import from_onnx
from tvm.support import describe
+from tvm.testing.utils import strtobool
def _parse_args():
diff --git a/python/tvm/auto_scheduler/testing/tune_relay.py
b/python/tvm/auto_scheduler/testing/tune_relay.py
index 9773fbbc65..babec2cf50 100644
--- a/python/tvm/auto_scheduler/testing/tune_relay.py
+++ b/python/tvm/auto_scheduler/testing/tune_relay.py
@@ -18,7 +18,6 @@
import argparse
import json
import os
-from distutils.util import strtobool
import tvm
from tvm import auto_scheduler
@@ -29,6 +28,7 @@ from tvm.meta_schedule.testing.relay_workload import
get_network
from tvm.meta_schedule.testing.tune_utils import create_timer,
generate_input_data
from tvm.meta_schedule.utils import cpu_count
from tvm.support import describe
+from tvm.testing.utils import strtobool
def _parse_args():
diff --git a/python/tvm/auto_scheduler/testing/tune_te.py
b/python/tvm/auto_scheduler/testing/tune_te.py
index da3584512d..9452d88a4e 100644
--- a/python/tvm/auto_scheduler/testing/tune_te.py
+++ b/python/tvm/auto_scheduler/testing/tune_te.py
@@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
# pylint: disable=missing-docstring
-from distutils.util import strtobool
import argparse
import os
@@ -25,6 +24,7 @@ from tvm import meta_schedule as ms
from tvm.meta_schedule.testing.te_workload import CONFIGS
from tvm.meta_schedule.utils import cpu_count
from tvm.support import describe
+from tvm.testing.utils import strtobool
def _parse_args():
diff --git a/python/tvm/autotvm/testing/tune_relay.py
b/python/tvm/autotvm/testing/tune_relay.py
index 96e42fbea0..916b2a800b 100644
--- a/python/tvm/autotvm/testing/tune_relay.py
+++ b/python/tvm/autotvm/testing/tune_relay.py
@@ -19,7 +19,6 @@ import argparse
import json
import os
import warnings
-from distutils.util import strtobool
import tvm
from tvm import autotvm
@@ -31,6 +30,7 @@ from tvm.meta_schedule.testing.custom_builder_runner import
run_module_via_rpc
from tvm.meta_schedule.testing.relay_workload import get_network
from tvm.meta_schedule.testing.tune_utils import create_timer,
generate_input_data
from tvm.support import describe
+from tvm.testing.utils import strtobool
def _parse_args():
diff --git a/python/tvm/meta_schedule/testing/tune_onnx.py
b/python/tvm/meta_schedule/testing/tune_onnx.py
index a7c177afdc..2100f0e7c9 100644
--- a/python/tvm/meta_schedule/testing/tune_onnx.py
+++ b/python/tvm/meta_schedule/testing/tune_onnx.py
@@ -18,7 +18,6 @@
import argparse
import json
import logging
-from distutils.util import strtobool
import onnx # type: ignore
import tvm
@@ -26,6 +25,7 @@ from tvm import meta_schedule as ms
from tvm.meta_schedule.testing.custom_builder_runner import run_module_via_rpc
from tvm.relay.frontend import from_onnx
from tvm.support import describe
+from tvm.testing.utils import strtobool
from .tune_utils import create_timer, generate_input_data
diff --git a/python/tvm/meta_schedule/testing/tune_relay.py
b/python/tvm/meta_schedule/testing/tune_relay.py
index de1668c1dd..98eddf793f 100644
--- a/python/tvm/meta_schedule/testing/tune_relay.py
+++ b/python/tvm/meta_schedule/testing/tune_relay.py
@@ -18,7 +18,6 @@
import argparse
import json
import logging
-from distutils.util import strtobool
from typing import Dict
import numpy as np # type: ignore
@@ -28,6 +27,7 @@ from tvm.meta_schedule.testing.custom_builder_runner import
run_module_via_rpc
from tvm.meta_schedule.testing.relay_workload import get_network
from tvm.meta_schedule.testing.tune_utils import create_timer,
generate_input_data
from tvm.support import describe
+from tvm.testing.utils import strtobool
def _parse_args():
diff --git a/python/tvm/meta_schedule/testing/tune_te.py
b/python/tvm/meta_schedule/testing/tune_te.py
index 4bbfd8b151..de80d7108d 100644
--- a/python/tvm/meta_schedule/testing/tune_te.py
+++ b/python/tvm/meta_schedule/testing/tune_te.py
@@ -17,7 +17,6 @@
# pylint: disable=missing-docstring
import argparse
import logging
-from distutils.util import strtobool
from typing import Optional
import tvm
@@ -25,6 +24,7 @@ from tvm import meta_schedule as ms
from tvm import tir
from tvm.meta_schedule.testing.te_workload import create_te_workload
from tvm.support import describe
+from tvm.testing.utils import strtobool
def _parse_args():
diff --git a/python/tvm/meta_schedule/testing/validate_database.py
b/python/tvm/meta_schedule/testing/validate_database.py
index a5981a78d6..a790bb49f7 100644
--- a/python/tvm/meta_schedule/testing/validate_database.py
+++ b/python/tvm/meta_schedule/testing/validate_database.py
@@ -20,7 +20,6 @@ import logging
import warnings
import itertools
from statistics import mean
-from distutils.util import strtobool
from typing import Callable, Tuple, Union, List, Any
import numpy as np # type: ignore
@@ -35,6 +34,7 @@ from tvm.tir.schedule import Trace
from tvm.meta_schedule.utils import remove_build_dir
from tvm.meta_schedule.testing.tune_utils import generate_input_data
from tvm.tir.tensor_intrin import * # type: ignore # pylint:
disable=wildcard-import,unused-wildcard-import
+from tvm.testing.utils import strtobool
DELIMITOR = "\n" + "-" * 30 + "\n"
diff --git a/python/tvm/testing/utils.py b/python/tvm/testing/utils.py
index 8fd64d8ab7..64eaccb410 100644
--- a/python/tvm/testing/utils.py
+++ b/python/tvm/testing/utils.py
@@ -1913,6 +1913,21 @@ def skip_parameterizations(*skip_params, reason):
return _mark_parameterizations(*skip_params, marker_fn=pytest.skip,
reason=reason)
+def strtobool(val):
+ """Convert a string representation of truth to true (1) or false (0).
+ True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
+ are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
+ 'val' is anything else.
+ """
+ val = val.lower()
+ if val in ("y", "yes", "t", "true", "on", "1"):
+ return 1
+ elif val in ("n", "no", "f", "false", "off", "0"):
+ return 0
+ else:
+ raise ValueError(f"invalid truth value {val!r}")
+
+
def main():
test_file = inspect.getsourcefile(sys._getframe(1))
sys.exit(pytest.main([test_file] + sys.argv[1:]))