gromero commented on a change in pull request #8253:
URL: https://github.com/apache/tvm/pull/8253#discussion_r651373115
##########
File path: python/tvm/driver/tvmc/common.py
##########
@@ -415,3 +415,86 @@ def parse_shape_string(inputs_string):
shape_dict[name] = shape
return shape_dict
+
+
+def set_config_value(name, value, config_type):
Review comment:
Just a semantic nit here: it seems it's more a "get" than a "set"
function? Like `get_pass_config_value` (also taking into account the suggestion
from @comaniac about using `pass-config` flag instead of `config`, which I
liked :)
##########
File path: python/tvm/driver/tvmc/compiler.py
##########
@@ -42,6 +42,13 @@ def add_compile_parser(subparsers):
parser = subparsers.add_parser("compile", help="compile a model.")
parser.set_defaults(func=drive_compile)
+ parser.add_argument(
+ "--config",
+ action="append",
+ metavar=("name=value"),
+ help="configurations to be used at compile time. A subset of options
provided "
+ "by TVM are supported. e.g. 'relay.backend.use_auto_scheduler=0'",
Review comment:
I'm wondering if it would make sense to enhance the help message a bit
more so users don't try to do something like:
`--config="tir.disable_vectorize=true,tir.disable_assert=true"` instead of
`--config=tir.disable_vectorize=true --config=tir.disable_assert=true"`,
i.e. know easily that multiple `--config` flags can be used and will be
appended.
I also see duplicated and even conflicting flags don't generate any error or
warning. Should we treat them too? Like:
```
$ python3 . compile --target="llvm" --config "tir.disable_vectorize=true"
--config "tir.disable_vectorize=false" --config "tir.disable_assert=true"
./sine_model.tflite
One or more operators have not been tuned. Please tune your model for better
performance. Use DEBUG logging level to see more details.
$
```
and
```
$ python3 . compile --target="llvm" --config "tir.disable_vectorize=true"
--config "tir.disable_vectorize=true" --config "tir.disable_assert=true"
./sine_model.tflite
One or more operators have not been tuned. Please tune your model for better
performance. Use DEBUG logging level to see more details.
$
```
##########
File path: tests/python/driver/tvmc/test_tvmc_common.py
##########
@@ -306,3 +306,49 @@ def test_parse_quotes_and_separators_on_options():
assert len(targets_double_quote) == 1
assert "+v1.0x,+value" == targets_double_quote[0]["opts"]["option1"]
+
+
+def test_config_invalid_format():
+ with pytest.raises(TVMCException):
+ _ =
tvmc.common.parse_configs(["relay.backend.use_auto_scheduler.missing.value"])
+
+
+def test_config_missing_from_tvm():
+ with pytest.raises(TVMCException):
+ _ =
tvmc.common.parse_configs(["relay.backend.use_auto_scheduler.missing.value=1234"])
+
+
+def test_config_unsupported_tvmc_config():
+ with pytest.raises(TVMCException):
+ _ = tvmc.common.parse_configs(["tir.LoopPartition=value"])
+
+
+def test_config_empty():
+ with pytest.raises(TVMCException):
+ _ = tvmc.common.parse_configs([""])
+
+
+def test_config_valid_config_bool():
+ configs =
tvmc.common.parse_configs(["relay.backend.use_auto_scheduler=true"])
+
+ assert len(configs) == 1
+ assert "relay.backend.use_auto_scheduler" in configs.keys()
+ assert configs["relay.backend.use_auto_scheduler"] == True
+
+
+def test_config_valid_multiple_configs():
+ configs = tvmc.common.parse_configs(
+ [
+ "relay.backend.use_auto_scheduler=false",
+ "tir.detect_global_barrier=10",
+ "relay.ext.vitis_ai.options.build_dir=mystring",
Review comment:
CI complains about it. I believe `relay.ext.vitis_ai.options.build_dir`
is neither `IntImm` nor `runtime.String` type?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]