You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by ju...@apache.org on 2022/06/21 00:26:07 UTC
[tvm] branch main updated: [MetaSchedule][Minor] Update CPU Flush ArgParse Type (#11792)
This is an automated email from the ASF dual-hosted git repository.
junrushao 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 25db38105d [MetaSchedule][Minor] Update CPU Flush ArgParse Type (#11792)
25db38105d is described below
commit 25db38105de93705fd67f2b5f3fd7dbd0a428416
Author: Xiyou Zhou <xi...@octoml.ai>
AuthorDate: Mon Jun 20 17:25:56 2022 -0700
[MetaSchedule][Minor] Update CPU Flush ArgParse Type (#11792)
Previously `cpu-flush` option existed as a boolean or integer argument, which is a bit counter-intuitive because for argparse, any non-empty string such as `False` will be parsed to `True` when using as a boolean and integer a little bit vague here IMHO. This PR used a function from `distutils` to directly parse input string to boolean, which makes the usage more stragiht-forward like `--cpu-flush True` or `--cpu-flush False`. Meanwhile it still supports usage of `0/1` and made sure t [...]
---
python/tvm/auto_scheduler/testing/tune_onnx.py | 4 +++-
python/tvm/auto_scheduler/testing/tune_relay.py | 4 +++-
python/tvm/auto_scheduler/testing/tune_te.py | 4 +++-
python/tvm/meta_schedule/testing/tune_onnx.py | 4 +++-
python/tvm/meta_schedule/testing/tune_relay.py | 4 +++-
python/tvm/meta_schedule/testing/tune_te.py | 4 +++-
6 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/python/tvm/auto_scheduler/testing/tune_onnx.py b/python/tvm/auto_scheduler/testing/tune_onnx.py
index 5fbc875d1e..1998f3d2c3 100644
--- a/python/tvm/auto_scheduler/testing/tune_onnx.py
+++ b/python/tvm/auto_scheduler/testing/tune_onnx.py
@@ -19,6 +19,7 @@ import argparse
import json
import os
+from distutils.util import strtobool
import numpy as np # type: ignore
import onnx # type: ignore
import tvm
@@ -96,8 +97,9 @@ def _parse_args():
)
args.add_argument(
"--cpu-flush",
- type=int,
+ type=lambda x: bool(strtobool(x)),
required=True,
+ help="example: `True / False",
)
parsed = args.parse_args()
parsed.target = tvm.target.Target(parsed.target)
diff --git a/python/tvm/auto_scheduler/testing/tune_relay.py b/python/tvm/auto_scheduler/testing/tune_relay.py
index 58ea327ec5..dce29775a7 100644
--- a/python/tvm/auto_scheduler/testing/tune_relay.py
+++ b/python/tvm/auto_scheduler/testing/tune_relay.py
@@ -19,6 +19,7 @@ import argparse
import json
import os
+from distutils.util import strtobool
import numpy as np # type: ignore
import tvm
from tvm import auto_scheduler
@@ -94,8 +95,9 @@ def _parse_args():
)
args.add_argument(
"--cpu-flush",
- type=int,
+ type=lambda x: bool(strtobool(x)),
required=True,
+ help="example: `True / False",
)
parsed = args.parse_args()
parsed.target = tvm.target.Target(parsed.target)
diff --git a/python/tvm/auto_scheduler/testing/tune_te.py b/python/tvm/auto_scheduler/testing/tune_te.py
index 4a6874a53d..c844bb9bf6 100644
--- a/python/tvm/auto_scheduler/testing/tune_te.py
+++ b/python/tvm/auto_scheduler/testing/tune_te.py
@@ -17,6 +17,7 @@
# pylint: disable=missing-docstring
import argparse
import os
+from distutils.util import strtobool
import tvm
from tvm import auto_scheduler
@@ -79,8 +80,9 @@ def _parse_args():
)
args.add_argument(
"--cpu-flush",
- type=int,
+ type=lambda x: bool(strtobool(x)),
required=True,
+ help="example: `True / False",
)
parsed = args.parse_args()
parsed.target = tvm.target.Target(parsed.target)
diff --git a/python/tvm/meta_schedule/testing/tune_onnx.py b/python/tvm/meta_schedule/testing/tune_onnx.py
index 88cb360c01..f8a3f1f0ca 100644
--- a/python/tvm/meta_schedule/testing/tune_onnx.py
+++ b/python/tvm/meta_schedule/testing/tune_onnx.py
@@ -19,6 +19,7 @@ import argparse
import json
import logging
+from distutils.util import strtobool
import numpy as np # type: ignore
import onnx # type: ignore
import tvm
@@ -93,8 +94,9 @@ def _parse_args():
)
args.add_argument(
"--cpu-flush",
- type=int,
+ type=lambda x: bool(strtobool(x)),
required=True,
+ help="example: `True / False",
)
parsed = args.parse_args()
parsed.target = tvm.target.Target(parsed.target)
diff --git a/python/tvm/meta_schedule/testing/tune_relay.py b/python/tvm/meta_schedule/testing/tune_relay.py
index ce15c60c15..611a8cdd7a 100644
--- a/python/tvm/meta_schedule/testing/tune_relay.py
+++ b/python/tvm/meta_schedule/testing/tune_relay.py
@@ -19,6 +19,7 @@ import argparse
import json
import logging
+from distutils.util import strtobool
import numpy as np # type: ignore
import tvm
from tvm import meta_schedule as ms
@@ -91,8 +92,9 @@ def _parse_args():
)
args.add_argument(
"--cpu-flush",
- type=int,
+ type=lambda x: bool(strtobool(x)),
required=True,
+ help="example: `True / False",
)
parsed = args.parse_args()
parsed.target = tvm.target.Target(parsed.target)
diff --git a/python/tvm/meta_schedule/testing/tune_te.py b/python/tvm/meta_schedule/testing/tune_te.py
index 8740d74424..df437838f9 100644
--- a/python/tvm/meta_schedule/testing/tune_te.py
+++ b/python/tvm/meta_schedule/testing/tune_te.py
@@ -19,6 +19,7 @@ import argparse
import logging
from os import cpu_count
from typing import Optional
+from distutils.util import strtobool
import tvm
from tvm import meta_schedule as ms
@@ -81,8 +82,9 @@ def _parse_args():
)
args.add_argument(
"--cpu-flush",
- type=int,
+ type=lambda x: bool(strtobool(x)),
required=True,
+ help="example: `True / False",
)
parsed = args.parse_args()
parsed.target = tvm.target.Target(parsed.target)