Mousius commented on code in PR #12119: URL: https://github.com/apache/tvm/pull/12119#discussion_r923569220
########## src/target/target.cc: ########## @@ -716,17 +716,27 @@ ObjectPtr<Object> TargetInternal::FromRawString(const String& target_str) { return TargetInternal::FromConfig(config); } -ObjectPtr<Object> TargetInternal::FromConfig(std::unordered_map<String, ObjectRef> config) { +ObjectPtr<Object> TargetInternal::FromConfig(Map<String, ObjectRef> config) { const String kKind = "kind"; const String kTag = "tag"; const String kKeys = "keys"; const String kDeviceName = "device"; const String kHost = "host"; ObjectPtr<TargetNode> target = make_object<TargetNode>(); + // parse 'kind' if (config.count(kKind)) { if (const auto* kind = config[kKind].as<StringObj>()) { target->kind = GetTargetKind(GetRef<String>(kind)); + ICHECK(!(target->kind->preprocessor != nullptr && target->kind->target_parser != nullptr)) + << "Cannot use both set_attrs_preprocessor and set_target_parser"; + + // 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); + } Review Comment: 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 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. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org