You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/07/11 18:30:50 UTC

[GitHub] [tvm] gbonik commented on a diff in pull request #11977: [TVMScript] Add ObjectPath class

gbonik commented on code in PR #11977:
URL: https://github.com/apache/tvm/pull/11977#discussion_r918236015


##########
src/node/object_path.cc:
##########
@@ -0,0 +1,322 @@
+/*
+ * 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 <tvm/node/object_path.h>
+#include <tvm/node/repr_printer.h>
+#include <tvm/runtime/memory.h>
+#include <tvm/runtime/registry.h>
+
+#include <algorithm>
+#include <cstring>
+
+using namespace tvm::runtime;
+
+namespace tvm {
+
+// ============== ObjectPathNode ==============
+
+ObjectPathNode::ObjectPathNode(ObjectPathNode* parent)
+    : parent_(GetRef<ObjectRef>(parent)), length_(parent == nullptr ? 1 : parent->length_ + 1) {}
+
+// --- GetParent ---
+
+ObjectPath ObjectPathNode::GetParent() const { return Downcast<ObjectPath>(parent_); }
+
+TVM_REGISTER_GLOBAL("node.ObjectPathGetParent").set_body_typed([](const ObjectPath& path) {
+  return path->GetParent();
+});

Review Comment:
   Unfortunately this gives me a compile error:
   
   ```
   include/tvm/runtime/registry.h:201:30: error: cannot declare parameter ‘target’ to be of abstract type ‘tvm::ObjectPathNode’
     201 |     auto fwrap = [f](const T target, Args... params) -> R {
         |                      ~~~~~~~~^~~~~~
   
   ```
   
   I think it may work only if the method was on the `ObjectPath` class.



-- 
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-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org