[GitHub] [incubator-tvm] junrushao1994 commented on a change in pull request #5838: [Target] Introduce Target Id Registry

2020-06-19 Thread GitBox


junrushao1994 commented on a change in pull request #5838:
URL: https://github.com/apache/incubator-tvm/pull/5838#discussion_r443085597



##
File path: src/target/target_id.cc
##
@@ -91,38 +91,74 @@ void VerifyTypeInfo(const ObjectRef& obj, const 
TargetIdNode::ValueTypeInfo& inf
   }
 }
 
-TVM_DLL void TargetIdNode::ValidateSchema(const Map& 
config) const {
+void TargetIdNode::ValidateSchema(const Map& config) const {
+  const String kTargetId = "id";
   for (const auto& kv : config) {
-auto it = key2vtype_.find(kv.first);
+const String& name = kv.first;
+const ObjectRef& obj = kv.second;
+if (name == kTargetId) {
+  CHECK(obj->IsInstance())
+  << "AttributeError: \"id\" is not a string, but its type is " << 
obj->GetTypeKey();
+  CHECK(Downcast(obj) == this->name)
+  << "AttributeError: \"id\" = " << obj << " is inconsistent with 
TargetId " << this->name;
+  continue;
+}
+auto it = key2vtype_.find(name);
 if (it == key2vtype_.end()) {
   std::ostringstream os;
-  os << "AttributeError: Invalid config option, cannot recognize \'" << 
kv.first
- << "\' candidates are:";
-  bool is_first = true;
+  os << "AttributeError: Invalid config option, cannot recognize \'" << 
name
+ << "\'. Candidates are:";
   for (const auto& kv : key2vtype_) {
-if (is_first) {
-  is_first = false;
-} else {
-  os << ',';
-}
-os << ' ' << kv.first;
+os << "\n  " << kv.first;
   }
   LOG(FATAL) << os.str();
   throw;
 }
-const auto& obj = kv.second;
 const auto& info = it->second;
 try {
   VerifyTypeInfo(obj, info);
 } catch (const tvm::Error& e) {
-  LOG(FATAL) << "AttributeError: Schema validation failed for TargetId " 
<< name
+  LOG(FATAL) << "AttributeError: Schema validation failed for TargetId " 
<< this->name
  << ", details:\n"
  << e.what() << "\n"
- << "The given config is:\n"
+ << "The config is:\n"
  << config;
   throw;
 }
   }
 }
 
+inline String GetId(const Map& target, const char* name) {
+  const String kTargetId = "id";
+  CHECK(target.count(kTargetId)) << "AttributeError: \"id\" does not exist in 
" << name << "\n"
+ << name << " = " << target;
+  const ObjectRef& obj = target[kTargetId];
+  CHECK(obj->IsInstance()) << "AttributeError: \"id\" is not a 
string in " << name
+  << ", but its type is " << 
obj->GetTypeKey() << "\n"
+  << name << " = " << target;
+  return Downcast(obj);
+}
+
+void TargetValidateSchema(const Map& config) {
+  try {
+const String kTargetHost = "target_host";
+Map target = config;
+Map target_host;
+String target_id = GetId(target, "target");
+String target_host_id;
+if (config.count(kTargetHost)) {
+  target.erase(kTargetHost);
+  target_host = Downcast>(config[kTargetHost]);

Review comment:
   I see your point. However, `target_host` is special cased due to the 
following reason
   1) `target_host` should not be nested: there shouldn't be a target_host 
inside another target_host;
   2) Type `target` may need further refactor to be handled properly in the 
validation





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:
us...@infra.apache.org




[GitHub] [incubator-tvm] junrushao1994 commented on a change in pull request #5838: [Target] Introduce Target Id Registry

2020-06-19 Thread GitBox


junrushao1994 commented on a change in pull request #5838:
URL: https://github.com/apache/incubator-tvm/pull/5838#discussion_r443011655



##
File path: tests/cpp/target_test.cc
##
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+TVM_REGISTER_TARGET_ID("TestTargetId").set_attr("Attr1", 
"Value1");

Review comment:
   Added. Thanks!





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:
us...@infra.apache.org




[GitHub] [incubator-tvm] junrushao1994 commented on a change in pull request #5838: [Target] Introduce Target Id Registry

2020-06-19 Thread GitBox


junrushao1994 commented on a change in pull request #5838:
URL: https://github.com/apache/incubator-tvm/pull/5838#discussion_r442980201



##
File path: include/tvm/target/target_id.h
##
@@ -0,0 +1,298 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file tvm/target/target_id.h
+ * \brief Target id registry
+ */
+#ifndef TVM_TARGET_TARGET_ID_H_
+#define TVM_TARGET_TARGET_ID_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace tvm {
+namespace detail {
+template 
+struct ValueTypeInfoMaker;
+}
+
+template 
+class TargetIdAttrMap;
+
+/*! \brief Target Id, specifies the kind of the target */
+class TargetIdNode : public Object {
+ public:
+  /*! \brief Name of the target id */
+  String name;
+  static constexpr const char* _type_key = "TargetId";
+  TVM_DECLARE_FINAL_OBJECT_INFO(TargetIdNode, Object);
+
+ private:
+  uint32_t AttrRegistryIndex() const { return index_; }
+  std::string AttrRegistryName() const { return name; }
+  /*! \brief Stores the required type_key and type_index of a specific attr of 
a target */
+  struct ValueTypeInfo {
+std::string type_key;
+uint32_t type_index;
+std::unique_ptr key;
+std::unique_ptr val;
+  };
+  /*! \brief A hash table that stores the type information of each attr of the 
target key */
+  std::unordered_map key2vtype_;
+  /*! \brief Index used for internal lookup of attribute registry */
+  uint32_t index_;
+  template 
+  friend class AttrRegistry;
+  template 
+  friend class AttrRegistryMapContainerMap;
+  friend class TargetIdRegEntry;
+  template 
+  friend struct detail::ValueTypeInfoMaker;
+};
+
+/*!
+ * \brief Managed reference class to TargetIdNode
+ * \sa TargetIdNode
+ */
+class TargetId : public ObjectRef {
+ public:
+  /*! \brief Get the attribute map given the attribute name */
+  template 
+  static inline TargetIdAttrMap GetAttrMap(const String& attr_name);
+  /*!
+   * \brief Retrieve the TargetId given its name
+   * \param target_id_name Name of the target id
+   * \return The TargetId requested
+   */
+  TVM_DLL static const TargetId& Get(const String& target_id_name);
+
+  TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(TargetId, ObjectRef, TargetIdNode);
+
+ private:
+  /*! \brief Mutable access to the container class  */
+  TargetIdNode* operator->() { return static_cast(data_.get()); 
}
+
+  TVM_DLL static const AttrRegistryMapContainerMap& 
GetAttrMapContainer(
+  const String& attr_name);
+  template 
+  friend class AttrRegistry;
+  friend class TargetIdRegEntry;
+};
+
+/*!
+ * \brief Map used to store meta-information about 
TargetId
+ * \tparam ValueType The type of the value stored in map
+ */
+template 
+class TargetIdAttrMap : public AttrRegistryMap {
+ public:
+  using TParent = AttrRegistryMap;
+  using TParent::count;
+  using TParent::get;
+  using TParent::operator[];
+  explicit TargetIdAttrMap(const AttrRegistryMapContainerMap& map) : 
TParent(map) {}
+};
+
+/*!
+ * \brief Helper structure to register TargetId
+ * \sa TVM_REGISTER_TARGET_ID
+ */
+class TargetIdRegEntry {
+ public:
+  /*!
+   * \brief Register additional attributes to target_id.
+   * \param attr_name The name of the attribute.
+   * \param value The value to be set.
+   * \param plevel The priority level of this set,
+   *  an higher priority level attribute
+   *  will replace lower priority level attribute.
+   *  Must be bigger than 0.
+   *
+   *  Cannot set with same plevel twice in the code.
+   *
+   * \tparam ValueType The type of the value to be set.
+   */
+  template 
+  inline TargetIdRegEntry& set_attr(const String& attr_name, const ValueType& 
value,
+int plevel = 10);
+  /*!
+   * \brief Register a valid configuration option and its ValueType for 
validation
+   * \param key The configuration key
+   * \tparam ValueType The value type to be registered
+   */
+  template 
+  inline TargetIdRegEntry& add_attr_option(const std::string& key);
+  /*! \brief Set name of the TargetId to be the same as registry if it is 
empty */
+  inline TargetIdRegEntry& set_name();
+  /*!
+   * \brief Register or get a new entry.
+   * 

[GitHub] [incubator-tvm] junrushao1994 commented on a change in pull request #5838: [Target] Introduce Target Id Registry

2020-06-19 Thread GitBox


junrushao1994 commented on a change in pull request #5838:
URL: https://github.com/apache/incubator-tvm/pull/5838#discussion_r442972847



##
File path: include/tvm/target/target_id.h
##
@@ -0,0 +1,298 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file tvm/target/target_id.h
+ * \brief Target id registry
+ */
+#ifndef TVM_TARGET_TARGET_ID_H_
+#define TVM_TARGET_TARGET_ID_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace tvm {
+namespace detail {
+template 
+struct ValueTypeInfoMaker;
+}
+
+template 
+class TargetIdAttrMap;
+
+/*! \brief Target Id, specifies the kind of the target */
+class TargetIdNode : public Object {
+ public:
+  /*! \brief Name of the target id */
+  String name;
+  static constexpr const char* _type_key = "TargetId";
+  TVM_DECLARE_FINAL_OBJECT_INFO(TargetIdNode, Object);
+
+ private:
+  uint32_t AttrRegistryIndex() const { return index_; }
+  std::string AttrRegistryName() const { return name; }
+  /*! \brief Stores the required type_key and type_index of a specific attr of 
a target */
+  struct ValueTypeInfo {
+std::string type_key;
+uint32_t type_index;
+std::unique_ptr key;
+std::unique_ptr val;
+  };
+  /*! \brief A hash table that stores the type information of each attr of the 
target key */
+  std::unordered_map key2vtype_;
+  /*! \brief Index used for internal lookup of attribute registry */
+  uint32_t index_;
+  template 
+  friend class AttrRegistry;
+  template 
+  friend class AttrRegistryMapContainerMap;
+  friend class TargetIdRegEntry;
+  template 
+  friend struct detail::ValueTypeInfoMaker;
+};
+
+/*!
+ * \brief Managed reference class to TargetIdNode
+ * \sa TargetIdNode
+ */
+class TargetId : public ObjectRef {
+ public:
+  /*! \brief Get the attribute map given the attribute name */
+  template 
+  static inline TargetIdAttrMap GetAttrMap(const String& attr_name);
+  /*!
+   * \brief Retrieve the TargetId given its name
+   * \param target_id_name Name of the target id
+   * \return The TargetId requested
+   */
+  TVM_DLL static const TargetId& Get(const String& target_id_name);
+
+  TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(TargetId, ObjectRef, TargetIdNode);
+
+ private:
+  /*! \brief Mutable access to the container class  */
+  TargetIdNode* operator->() { return static_cast(data_.get()); 
}
+
+  TVM_DLL static const AttrRegistryMapContainerMap& 
GetAttrMapContainer(
+  const String& attr_name);
+  template 
+  friend class AttrRegistry;
+  friend class TargetIdRegEntry;
+};
+
+/*!
+ * \brief Map used to store meta-information about 
TargetId
+ * \tparam ValueType The type of the value stored in map
+ */
+template 
+class TargetIdAttrMap : public AttrRegistryMap {
+ public:
+  using TParent = AttrRegistryMap;
+  using TParent::count;
+  using TParent::get;
+  using TParent::operator[];
+  explicit TargetIdAttrMap(const AttrRegistryMapContainerMap& map) : 
TParent(map) {}
+};
+
+/*!
+ * \brief Helper structure to register TargetId
+ * \sa TVM_REGISTER_TARGET_ID
+ */
+class TargetIdRegEntry {
+ public:
+  /*!
+   * \brief Register additional attributes to target_id.
+   * \param attr_name The name of the attribute.
+   * \param value The value to be set.
+   * \param plevel The priority level of this set,
+   *  an higher priority level attribute
+   *  will replace lower priority level attribute.
+   *  Must be bigger than 0.
+   *
+   *  Cannot set with same plevel twice in the code.
+   *
+   * \tparam ValueType The type of the value to be set.
+   */
+  template 
+  inline TargetIdRegEntry& set_attr(const String& attr_name, const ValueType& 
value,
+int plevel = 10);
+  /*!
+   * \brief Register a valid configuration option and its ValueType for 
validation
+   * \param key The configuration key
+   * \tparam ValueType The value type to be registered
+   */
+  template 
+  inline TargetIdRegEntry& add_attr_option(const std::string& key);
+  /*! \brief Set name of the TargetId to be the same as registry if it is 
empty */
+  inline TargetIdRegEntry& set_name();
+  /*!
+   * \brief Register or get a new entry.
+   * 

[GitHub] [incubator-tvm] junrushao1994 commented on a change in pull request #5838: [Target] Introduce Target Id Registry

2020-06-19 Thread GitBox


junrushao1994 commented on a change in pull request #5838:
URL: https://github.com/apache/incubator-tvm/pull/5838#discussion_r442969162



##
File path: include/tvm/target/target_id.h
##
@@ -0,0 +1,298 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file tvm/target/target_id.h
+ * \brief Target id registry
+ */
+#ifndef TVM_TARGET_TARGET_ID_H_
+#define TVM_TARGET_TARGET_ID_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace tvm {
+namespace detail {
+template 
+struct ValueTypeInfoMaker;
+}
+
+template 
+class TargetIdAttrMap;
+
+/*! \brief Target Id, specifies the kind of the target */
+class TargetIdNode : public Object {
+ public:
+  /*! \brief Name of the target id */
+  String name;
+  static constexpr const char* _type_key = "TargetId";
+  TVM_DECLARE_FINAL_OBJECT_INFO(TargetIdNode, Object);
+
+ private:
+  uint32_t AttrRegistryIndex() const { return index_; }
+  std::string AttrRegistryName() const { return name; }

Review comment:
   I replaced all std::string with String too in this PR





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:
us...@infra.apache.org




[GitHub] [incubator-tvm] junrushao1994 commented on a change in pull request #5838: [Target] Introduce Target Id Registry

2020-06-19 Thread GitBox


junrushao1994 commented on a change in pull request #5838:
URL: https://github.com/apache/incubator-tvm/pull/5838#discussion_r442968000



##
File path: include/tvm/target/target_id.h
##
@@ -0,0 +1,298 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file tvm/target/target_id.h
+ * \brief Target id registry
+ */
+#ifndef TVM_TARGET_TARGET_ID_H_
+#define TVM_TARGET_TARGET_ID_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace tvm {
+namespace detail {
+template 
+struct ValueTypeInfoMaker;
+}
+
+template 
+class TargetIdAttrMap;
+
+/*! \brief Target Id, specifies the kind of the target */
+class TargetIdNode : public Object {
+ public:
+  /*! \brief Name of the target id */
+  String name;
+  static constexpr const char* _type_key = "TargetId";
+  TVM_DECLARE_FINAL_OBJECT_INFO(TargetIdNode, Object);
+
+ private:
+  uint32_t AttrRegistryIndex() const { return index_; }
+  std::string AttrRegistryName() const { return name; }

Review comment:
   I agree. Fixed. Finally we should migrate all std::string to String if 
possible.





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:
us...@infra.apache.org




[GitHub] [incubator-tvm] junrushao1994 commented on a change in pull request #5838: [Target] Introduce Target Id Registry

2020-06-19 Thread GitBox


junrushao1994 commented on a change in pull request #5838:
URL: https://github.com/apache/incubator-tvm/pull/5838#discussion_r442959777



##
File path: include/tvm/target/target_id.h
##
@@ -0,0 +1,298 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file tvm/target/target_id.h
+ * \brief Target id registry
+ */
+#ifndef TVM_TARGET_TARGET_ID_H_
+#define TVM_TARGET_TARGET_ID_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace tvm {
+namespace detail {
+template 
+struct ValueTypeInfoMaker;
+}
+
+template 
+class TargetIdAttrMap;
+
+/*! \brief Target Id, specifies the kind of the target */
+class TargetIdNode : public Object {
+ public:
+  /*! \brief Name of the target id */
+  String name;
+  static constexpr const char* _type_key = "TargetId";
+  TVM_DECLARE_FINAL_OBJECT_INFO(TargetIdNode, Object);
+
+ private:
+  uint32_t AttrRegistryIndex() const { return index_; }
+  std::string AttrRegistryName() const { return name; }
+  /*! \brief Stores the required type_key and type_index of a specific attr of 
a target */
+  struct ValueTypeInfo {
+std::string type_key;
+uint32_t type_index;
+std::unique_ptr key;
+std::unique_ptr val;
+  };
+  /*! \brief A hash table that stores the type information of each attr of the 
target key */
+  std::unordered_map key2vtype_;
+  /*! \brief Index used for internal lookup of attribute registry */
+  uint32_t index_;
+  template 
+  friend class AttrRegistry;
+  template 
+  friend class AttrRegistryMapContainerMap;
+  friend class TargetIdRegEntry;
+  template 
+  friend struct detail::ValueTypeInfoMaker;
+};
+
+/*!
+ * \brief Managed reference class to TargetIdNode
+ * \sa TargetIdNode
+ */
+class TargetId : public ObjectRef {
+ public:
+  /*! \brief Get the attribute map given the attribute name */
+  template 
+  static inline TargetIdAttrMap GetAttrMap(const String& attr_name);
+  /*!
+   * \brief Retrieve the TargetId given its name
+   * \param target_id_name Name of the target id
+   * \return The TargetId requested
+   */
+  TVM_DLL static const TargetId& Get(const String& target_id_name);
+
+  TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(TargetId, ObjectRef, TargetIdNode);
+
+ private:
+  /*! \brief Mutable access to the container class  */
+  TargetIdNode* operator->() { return static_cast(data_.get()); 
}
+
+  TVM_DLL static const AttrRegistryMapContainerMap& 
GetAttrMapContainer(
+  const String& attr_name);
+  template 
+  friend class AttrRegistry;
+  friend class TargetIdRegEntry;
+};
+
+/*!
+ * \brief Map used to store meta-information about 
TargetId
+ * \tparam ValueType The type of the value stored in map
+ */
+template 
+class TargetIdAttrMap : public AttrRegistryMap {
+ public:
+  using TParent = AttrRegistryMap;
+  using TParent::count;
+  using TParent::get;
+  using TParent::operator[];
+  explicit TargetIdAttrMap(const AttrRegistryMapContainerMap& map) : 
TParent(map) {}
+};
+
+/*!
+ * \brief Helper structure to register TargetId
+ * \sa TVM_REGISTER_TARGET_ID
+ */
+class TargetIdRegEntry {

Review comment:
   Yeah I think both way are good, but I am trying to follow the convention 
in operator registry: 
https://github.com/apache/incubator-tvm/blob/master/include/tvm/ir/op.h.





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:
us...@infra.apache.org




[GitHub] [incubator-tvm] junrushao1994 commented on a change in pull request #5838: [Target] Introduce Target Id Registry

2020-06-19 Thread GitBox


junrushao1994 commented on a change in pull request #5838:
URL: https://github.com/apache/incubator-tvm/pull/5838#discussion_r442957099



##
File path: include/tvm/target/target_id.h
##
@@ -0,0 +1,298 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file tvm/target/target_id.h
+ * \brief Target id registry
+ */
+#ifndef TVM_TARGET_TARGET_ID_H_
+#define TVM_TARGET_TARGET_ID_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace tvm {
+namespace detail {
+template 
+struct ValueTypeInfoMaker;
+}
+
+template 
+class TargetIdAttrMap;
+
+/*! \brief Target Id, specifies the kind of the target */
+class TargetIdNode : public Object {
+ public:
+  /*! \brief Name of the target id */
+  String name;
+  static constexpr const char* _type_key = "TargetId";
+  TVM_DECLARE_FINAL_OBJECT_INFO(TargetIdNode, Object);
+
+ private:
+  uint32_t AttrRegistryIndex() const { return index_; }
+  std::string AttrRegistryName() const { return name; }
+  /*! \brief Stores the required type_key and type_index of a specific attr of 
a target */
+  struct ValueTypeInfo {
+std::string type_key;
+uint32_t type_index;
+std::unique_ptr key;
+std::unique_ptr val;
+  };
+  /*! \brief A hash table that stores the type information of each attr of the 
target key */
+  std::unordered_map key2vtype_;
+  /*! \brief Index used for internal lookup of attribute registry */
+  uint32_t index_;
+  template 
+  friend class AttrRegistry;
+  template 
+  friend class AttrRegistryMapContainerMap;
+  friend class TargetIdRegEntry;
+  template 
+  friend struct detail::ValueTypeInfoMaker;
+};
+
+/*!
+ * \brief Managed reference class to TargetIdNode
+ * \sa TargetIdNode
+ */
+class TargetId : public ObjectRef {
+ public:
+  /*! \brief Get the attribute map given the attribute name */
+  template 
+  static inline TargetIdAttrMap GetAttrMap(const String& attr_name);
+  /*!
+   * \brief Retrieve the TargetId given its name
+   * \param target_id_name Name of the target id
+   * \return The TargetId requested
+   */
+  TVM_DLL static const TargetId& Get(const String& target_id_name);
+
+  TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(TargetId, ObjectRef, TargetIdNode);
+
+ private:
+  /*! \brief Mutable access to the container class  */
+  TargetIdNode* operator->() { return static_cast(data_.get()); 
}
+
+  TVM_DLL static const AttrRegistryMapContainerMap& 
GetAttrMapContainer(
+  const String& attr_name);
+  template 
+  friend class AttrRegistry;
+  friend class TargetIdRegEntry;
+};
+
+/*!
+ * \brief Map used to store meta-information about 
TargetId
+ * \tparam ValueType The type of the value stored in map
+ */
+template 
+class TargetIdAttrMap : public AttrRegistryMap {
+ public:
+  using TParent = AttrRegistryMap;
+  using TParent::count;
+  using TParent::get;
+  using TParent::operator[];
+  explicit TargetIdAttrMap(const AttrRegistryMapContainerMap& map) : 
TParent(map) {}
+};
+
+/*!
+ * \brief Helper structure to register TargetId
+ * \sa TVM_REGISTER_TARGET_ID
+ */
+class TargetIdRegEntry {
+ public:
+  /*!
+   * \brief Register additional attributes to target_id.
+   * \param attr_name The name of the attribute.
+   * \param value The value to be set.
+   * \param plevel The priority level of this set,
+   *  an higher priority level attribute
+   *  will replace lower priority level attribute.
+   *  Must be bigger than 0.
+   *
+   *  Cannot set with same plevel twice in the code.
+   *
+   * \tparam ValueType The type of the value to be set.
+   */
+  template 
+  inline TargetIdRegEntry& set_attr(const String& attr_name, const ValueType& 
value,
+int plevel = 10);
+  /*!
+   * \brief Register a valid configuration option and its ValueType for 
validation
+   * \param key The configuration key
+   * \tparam ValueType The value type to be registered
+   */
+  template 
+  inline TargetIdRegEntry& add_attr_option(const std::string& key);
+  /*! \brief Set name of the TargetId to be the same as registry if it is 
empty */
+  inline TargetIdRegEntry& set_name();
+  /*!
+   * \brief Register or get a new entry.
+   * 

[GitHub] [incubator-tvm] junrushao1994 commented on a change in pull request #5838: [Target] Introduce Target Id Registry

2020-06-19 Thread GitBox


junrushao1994 commented on a change in pull request #5838:
URL: https://github.com/apache/incubator-tvm/pull/5838#discussion_r442953431



##
File path: include/tvm/target/target_id.h
##
@@ -0,0 +1,298 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file tvm/target/target_id.h
+ * \brief Target id registry
+ */
+#ifndef TVM_TARGET_TARGET_ID_H_
+#define TVM_TARGET_TARGET_ID_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace tvm {
+namespace detail {
+template 
+struct ValueTypeInfoMaker;
+}
+
+template 
+class TargetIdAttrMap;
+
+/*! \brief Target Id, specifies the kind of the target */
+class TargetIdNode : public Object {
+ public:
+  /*! \brief Name of the target id */
+  String name;
+  static constexpr const char* _type_key = "TargetId";
+  TVM_DECLARE_FINAL_OBJECT_INFO(TargetIdNode, Object);
+
+ private:
+  uint32_t AttrRegistryIndex() const { return index_; }
+  std::string AttrRegistryName() const { return name; }
+  /*! \brief Stores the required type_key and type_index of a specific attr of 
a target */
+  struct ValueTypeInfo {
+std::string type_key;
+uint32_t type_index;
+std::unique_ptr key;
+std::unique_ptr val;
+  };
+  /*! \brief A hash table that stores the type information of each attr of the 
target key */
+  std::unordered_map key2vtype_;
+  /*! \brief Index used for internal lookup of attribute registry */
+  uint32_t index_;
+  template 
+  friend class AttrRegistry;
+  template 
+  friend class AttrRegistryMapContainerMap;
+  friend class TargetIdRegEntry;
+  template 
+  friend struct detail::ValueTypeInfoMaker;
+};
+
+/*!
+ * \brief Managed reference class to TargetIdNode
+ * \sa TargetIdNode
+ */
+class TargetId : public ObjectRef {
+ public:
+  /*! \brief Get the attribute map given the attribute name */
+  template 
+  static inline TargetIdAttrMap GetAttrMap(const String& attr_name);
+  /*!
+   * \brief Retrieve the TargetId given its name
+   * \param target_id_name Name of the target id
+   * \return The TargetId requested
+   */
+  TVM_DLL static const TargetId& Get(const String& target_id_name);
+
+  TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(TargetId, ObjectRef, TargetIdNode);
+
+ private:
+  /*! \brief Mutable access to the container class  */
+  TargetIdNode* operator->() { return static_cast(data_.get()); 
}
+
+  TVM_DLL static const AttrRegistryMapContainerMap& 
GetAttrMapContainer(
+  const String& attr_name);
+  template 
+  friend class AttrRegistry;
+  friend class TargetIdRegEntry;
+};
+
+/*!
+ * \brief Map used to store meta-information about 
TargetId
+ * \tparam ValueType The type of the value stored in map
+ */
+template 
+class TargetIdAttrMap : public AttrRegistryMap {
+ public:
+  using TParent = AttrRegistryMap;
+  using TParent::count;
+  using TParent::get;
+  using TParent::operator[];
+  explicit TargetIdAttrMap(const AttrRegistryMapContainerMap& map) : 
TParent(map) {}
+};
+
+/*!
+ * \brief Helper structure to register TargetId
+ * \sa TVM_REGISTER_TARGET_ID
+ */
+class TargetIdRegEntry {
+ public:
+  /*!
+   * \brief Register additional attributes to target_id.
+   * \param attr_name The name of the attribute.
+   * \param value The value to be set.
+   * \param plevel The priority level of this set,

Review comment:
   Yeah you are rignt :-)





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:
us...@infra.apache.org




[GitHub] [incubator-tvm] junrushao1994 commented on a change in pull request #5838: [Target] Introduce Target Id Registry

2020-06-18 Thread GitBox


junrushao1994 commented on a change in pull request #5838:
URL: https://github.com/apache/incubator-tvm/pull/5838#discussion_r442558981



##
File path: include/tvm/target/target_id.h
##
@@ -0,0 +1,228 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file tvm/target/target_id.h
+ * \brief Target id registry
+ */
+#ifndef TVM_TARGET_TARGET_ID_H_
+#define TVM_TARGET_TARGET_ID_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+namespace tvm {
+
+template 
+class TargetIdAttrMap;
+
+/*! \brief Target Id, specifies the kind of the target */
+class TargetIdNode : public Object {
+ public:
+  /*! \brief Name of the target id */
+  String name;
+  static constexpr const char* _type_key = "TargetId";
+  TVM_DECLARE_FINAL_OBJECT_INFO(TargetIdNode, Object);
+
+ private:
+  uint32_t AttrRegistryIndex() const { return index_; }
+  std::string AttrRegistryName() const { return name; }
+  /*! \brief Stores the required type_key and type_index of a specific attr of 
a target */
+  struct ValueTypeInfo {
+std::string type_key;
+uint32_t type_index;
+  };
+  /*!
+   * \brief Register an attribute with the type specified by the type_index
+   * \param key The name of the attribute
+   * \param value_type_index The type index of the value of the attribute
+   */
+  void RegisterAttrOption(const std::string& key, uint32_t value_type_index);
+  /*! \brief A hash table that stores the type information of each attr of the 
target key */
+  std::unordered_map key2vtype_;
+  /*! \brief Index used for internal lookup of attribute registry */
+  uint32_t index_;
+  template 
+  friend class AttrRegistry;
+  friend class TargetIdRegEntry;
+};
+
+/*!
+ * \brief Managed reference class to TargetIdNode
+ * \sa TargetIdNode
+ */
+class TargetId : public ObjectRef {
+ public:
+  /*! \brief Mutable access to the container class  */
+  TargetIdNode* operator->() { return static_cast(data_.get()); 
}
+
+  /*! \brief Get the attribute map given the attribute name. */
+  template 
+  static inline TargetIdAttrMap GetAttrMap(const String& attr_name);
+
+  TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(TargetId, ObjectRef, TargetIdNode);
+
+ private:
+  static const AttrRegistryMapContainerMap& 
GetAttrMapContainer(const String& attr_name);
+  template 
+  friend class AttrRegistry;
+};
+
+/*!
+ * \brief Map used to store meta-information about 
TargetId
+ * \tparam ValueType The type of the value stored in map
+ */
+template 
+class TargetIdAttrMap : public AttrRegistryMap {
+ public:
+  using TParent = AttrRegistryMap;
+  using TParent::count;
+  using TParent::get;
+  using TParent::operator[];
+  explicit TargetIdAttrMap(const AttrRegistryMapContainerMap& map) : 
TParent(map) {}
+};
+
+/*!
+ * \brief Helper structure to register TargetId
+ * \sa TVM_REGISTER_TARGET_ID
+ */
+class TargetIdRegEntry {
+ public:
+  /*!
+   * \brief Register additional attributes to target_id.
+   * \param attr_name The name of the attribute.
+   * \param value The value to be set.
+   * \param plevel The priority level of this set,
+   *  an higher priority level attribute
+   *  will replace lower priority level attribute.
+   *  Must be bigger than 0.
+   *
+   *  Cannot set with same plevel twice in the code.
+   *
+   * \tparam ValueType The type of the value to be set.
+   */
+  template 
+  inline TargetIdRegEntry& set_attr(const String& attr_name, const ValueType& 
value,
+int plevel = 10);
+  /*!
+   * \brief Register a valid configuration option and its ValueType for 
validation
+   * \param key The configuration key
+   * \tparam ValueType The value type to be registered
+   */
+  template 
+  inline TargetIdRegEntry& add_attr_option(const std::string& key);
+  /*! \brief Set name of the TargetId to be the same as registry if it is 
empty */
+  inline TargetIdRegEntry& set_name();
+  /*!
+   * \brief Register or get a new entry.
+   * \param name The name of the TargetId.
+   * \return the corresponding entry.
+   */
+  static TargetIdRegEntry& RegisterOrGet(const String& name);
+
+ private:
+  TargetId id_;
+  String name;
+
+  /*! \brief private const

[GitHub] [incubator-tvm] junrushao1994 commented on a change in pull request #5838: [Target] Introduce Target Id Registry

2020-06-18 Thread GitBox


junrushao1994 commented on a change in pull request #5838:
URL: https://github.com/apache/incubator-tvm/pull/5838#discussion_r442553701



##
File path: include/tvm/target/target_id.h
##
@@ -0,0 +1,228 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file tvm/target/target_id.h
+ * \brief Target id registry
+ */
+#ifndef TVM_TARGET_TARGET_ID_H_
+#define TVM_TARGET_TARGET_ID_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+namespace tvm {
+
+template 
+class TargetIdAttrMap;
+
+/*! \brief Target Id, specifies the kind of the target */
+class TargetIdNode : public Object {
+ public:
+  /*! \brief Name of the target id */
+  String name;
+  static constexpr const char* _type_key = "TargetId";
+  TVM_DECLARE_FINAL_OBJECT_INFO(TargetIdNode, Object);
+
+ private:
+  uint32_t AttrRegistryIndex() const { return index_; }
+  std::string AttrRegistryName() const { return name; }
+  /*! \brief Stores the required type_key and type_index of a specific attr of 
a target */
+  struct ValueTypeInfo {
+std::string type_key;
+uint32_t type_index;
+  };
+  /*!
+   * \brief Register an attribute with the type specified by the type_index
+   * \param key The name of the attribute
+   * \param value_type_index The type index of the value of the attribute
+   */
+  void RegisterAttrOption(const std::string& key, uint32_t value_type_index);
+  /*! \brief A hash table that stores the type information of each attr of the 
target key */
+  std::unordered_map key2vtype_;
+  /*! \brief Index used for internal lookup of attribute registry */
+  uint32_t index_;
+  template 
+  friend class AttrRegistry;
+  friend class TargetIdRegEntry;
+};
+
+/*!
+ * \brief Managed reference class to TargetIdNode
+ * \sa TargetIdNode
+ */
+class TargetId : public ObjectRef {
+ public:
+  /*! \brief Mutable access to the container class  */
+  TargetIdNode* operator->() { return static_cast(data_.get()); 
}

Review comment:
   Let me put this as private, as it is only used by TargetIdRegEntry when 
doing `add_attrs_option`





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:
us...@infra.apache.org




[GitHub] [incubator-tvm] junrushao1994 commented on a change in pull request #5838: [Target] Introduce Target Id Registry

2020-06-18 Thread GitBox


junrushao1994 commented on a change in pull request #5838:
URL: https://github.com/apache/incubator-tvm/pull/5838#discussion_r442552581



##
File path: include/tvm/target/target_id.h
##
@@ -0,0 +1,228 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file tvm/target/target_id.h
+ * \brief Target id registry
+ */
+#ifndef TVM_TARGET_TARGET_ID_H_
+#define TVM_TARGET_TARGET_ID_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+namespace tvm {
+
+template 
+class TargetIdAttrMap;
+
+/*! \brief Target Id, specifies the kind of the target */
+class TargetIdNode : public Object {
+ public:
+  /*! \brief Name of the target id */
+  String name;
+  static constexpr const char* _type_key = "TargetId";
+  TVM_DECLARE_FINAL_OBJECT_INFO(TargetIdNode, Object);
+
+ private:
+  uint32_t AttrRegistryIndex() const { return index_; }
+  std::string AttrRegistryName() const { return name; }
+  /*! \brief Stores the required type_key and type_index of a specific attr of 
a target */
+  struct ValueTypeInfo {
+std::string type_key;
+uint32_t type_index;
+  };
+  /*!
+   * \brief Register an attribute with the type specified by the type_index
+   * \param key The name of the attribute
+   * \param value_type_index The type index of the value of the attribute
+   */
+  void RegisterAttrOption(const std::string& key, uint32_t value_type_index);
+  /*! \brief A hash table that stores the type information of each attr of the 
target key */
+  std::unordered_map key2vtype_;
+  /*! \brief Index used for internal lookup of attribute registry */
+  uint32_t index_;
+  template 
+  friend class AttrRegistry;
+  friend class TargetIdRegEntry;
+};
+
+/*!
+ * \brief Managed reference class to TargetIdNode
+ * \sa TargetIdNode
+ */
+class TargetId : public ObjectRef {
+ public:
+  /*! \brief Mutable access to the container class  */
+  TargetIdNode* operator->() { return static_cast(data_.get()); 
}
+
+  /*! \brief Get the attribute map given the attribute name. */
+  template 
+  static inline TargetIdAttrMap GetAttrMap(const String& attr_name);
+
+  TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(TargetId, ObjectRef, TargetIdNode);
+
+ private:
+  static const AttrRegistryMapContainerMap& 
GetAttrMapContainer(const String& attr_name);
+  template 
+  friend class AttrRegistry;
+};
+
+/*!
+ * \brief Map used to store meta-information about 
TargetId
+ * \tparam ValueType The type of the value stored in map
+ */
+template 
+class TargetIdAttrMap : public AttrRegistryMap {
+ public:
+  using TParent = AttrRegistryMap;
+  using TParent::count;
+  using TParent::get;
+  using TParent::operator[];
+  explicit TargetIdAttrMap(const AttrRegistryMapContainerMap& map) : 
TParent(map) {}
+};
+
+/*!
+ * \brief Helper structure to register TargetId
+ * \sa TVM_REGISTER_TARGET_ID
+ */
+class TargetIdRegEntry {
+ public:
+  /*!
+   * \brief Register additional attributes to target_id.
+   * \param attr_name The name of the attribute.
+   * \param value The value to be set.
+   * \param plevel The priority level of this set,
+   *  an higher priority level attribute
+   *  will replace lower priority level attribute.
+   *  Must be bigger than 0.
+   *
+   *  Cannot set with same plevel twice in the code.
+   *
+   * \tparam ValueType The type of the value to be set.
+   */
+  template 
+  inline TargetIdRegEntry& set_attr(const String& attr_name, const ValueType& 
value,
+int plevel = 10);
+  /*!
+   * \brief Register a valid configuration option and its ValueType for 
validation
+   * \param key The configuration key
+   * \tparam ValueType The value type to be registered
+   */
+  template 
+  inline TargetIdRegEntry& add_attr_option(const std::string& key);
+  /*! \brief Set name of the TargetId to be the same as registry if it is 
empty */
+  inline TargetIdRegEntry& set_name();
+  /*!
+   * \brief Register or get a new entry.
+   * \param name The name of the TargetId.
+   * \return the corresponding entry.
+   */
+  static TargetIdRegEntry& RegisterOrGet(const String& name);
+
+ private:
+  TargetId id_;
+  String name;
+
+  /*! \brief private const