-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Target] Add target_parser to TargetKind #12119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This adds the `target_parser` as described in apache/tvm-rfcs#71, which parses an incoming `TargetJSON` and produces a new configuration for generating the final `Target` object from. Marks `set_attrs_preprocessor` as deprecated and errors if both `set_attrs_preprocessor` and `set_target_parser` exist together.
| static ObjectPtr<Object> FromConfigString(const String& config_str); | ||
| static ObjectPtr<Object> FromRawString(const String& target_str); | ||
| static ObjectPtr<Object> FromConfig(std::unordered_map<String, ObjectRef> config); | ||
| static ObjectPtr<Object> FromConfig(Map<String, ObjectRef> config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this takes Map<> explicitly instead of TargetJSON, are there any conditions that a config map must meet before it can be considered a target JSON?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kparzysz-quic not that I know of, I made an internal assumption here that config is another name for the JSON - maybe @areusch or @junrushao1994 knows more?
| // Run JSON Parser over JSON input | ||
| if (target->kind->target_parser != nullptr) { | ||
| VLOG(9) << "TargetInternal::FromConfig - Running target_parser"; | ||
| config = target->kind->target_parser(config); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be executed at the end, so that the parser "has the last word" on what the returned target will look like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the parser goes from TargetJSON to TargetJSON it has to go first and produce a new config - the rest of this function unpacks the config values into a Target object but shouldn't change any of the values in config.
This adds the `target_parser` as described in apache/tvm-rfcs#71, which parses an incoming `TargetJSON` and produces a new configuration for generating the final `Target` object from. Marks `set_attrs_preprocessor` as deprecated and errors if both `set_attrs_preprocessor` and `set_target_parser` exist together.
This adds the `target_parser` as described in apache/tvm-rfcs#71, which parses an incoming `TargetJSON` and produces a new configuration for generating the final `Target` object from. Marks `set_attrs_preprocessor` as deprecated and errors if both `set_attrs_preprocessor` and `set_target_parser` exist together.
This adds the
target_parseras described in apache/tvm-rfcs#71, which parses an incomingTargetJSONand produces a new configuration for generating the finalTargetobject from.Marks
set_attrs_preprocessoras deprecated and errors if bothset_attrs_preprocessorandset_target_parserexist together.