comaniac commented on a change in pull request #8253:
URL: https://github.com/apache/tvm/pull/8253#discussion_r652165844
##########
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):
+ """Set a PassContext configuration value according to its value"""
+
+ if config_type == "IntImm":
+ # "Bool" configurations in the PassContext are recognized as
+ # IntImm, so deal with this case here
+ mapping_values = {
+ "false": False,
+ "true": True,
+ }
+
+ if value.isdigit():
+ parsed_value = int(value)
+ else:
+ # if not an int, accept only values on the mapping table, case
insensitive
+ parsed_value = mapping_values.get(value.lower(), None)
+
+ if parsed_value is None:
+ raise TVMCException(f"Invalid value '{value}' for configuration
'{name}'. ")
+
+ if config_type == "runtime.String":
+ parsed_value = value
Review comment:
Hmm you already processed int so I don't think it would be an issue
here. Anyways, I don't have a strong preference of using `json` so I'll commit.
--
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]