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 2021/12/21 09:44:27 UTC

[GitHub] [tvm] manupa-arm commented on a change in pull request #9469: [microNPU][2a] Add CascaderGraph for cascading analysis

manupa-arm commented on a change in pull request #9469:
URL: https://github.com/apache/tvm/pull/9469#discussion_r772974832



##########
File path: cmake/modules/contrib/EthosU.cmake
##########
@@ -18,7 +18,8 @@
 if(USE_ETHOSU)
   file(GLOB COMPILER_ETHOSU_SRCS
        CONFIGURE_DEPENDS src/relay/backend/contrib/ethosu/*
-       CONFIGURE_DEPENDS src/contrib/ethosu/cascader/*)
+       CONFIGURE_DEPENDS src/contrib/ethosu/cascader/*

Review comment:
       If we have source files that defines object definitions, we need to include the irrespective of cmake config.
   See here : https://github.com/apache/tvm/pull/9630

##########
File path: python/tvm/contrib/ethosu/cascader/graph.py
##########
@@ -0,0 +1,170 @@
+# 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.
+"""Graph objects to define compute graphs for the NPU cascader."""
+from typing import List
+from collections import namedtuple
+import tvm._ffi
+
+from tvm.runtime import Object
+
+from .stripe_config import StripeConfig
+from . import _ffi_api
+
+
+TESubgraph = namedtuple("TESubgraph", ["input_tensors", "output_tensor"])
+
+
+@tvm._ffi.register_object("contrib.ethosu.cascader.PerformanceInfo")
+class PerformanceInfo(Object):

Review comment:
       As mentioned in the CMake file, the c-source that defines the object needs to be compiled irrespective of cmake config and this applies to other Object definitions as well.

##########
File path: src/contrib/ethosu/cascader/graph.cc
##########
@@ -0,0 +1,245 @@
+/*
+ * 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 "graph.h"
+
+#include <tvm/node/reflection.h>
+#include <tvm/runtime/container/array.h>
+#include <tvm/runtime/object.h>
+#include <tvm/runtime/registry.h>
+
+#include <algorithm>
+#include <stack>
+#include <unordered_set>
+#include <utility>
+#include <vector>
+
+#include "common.h"
+#include "stripe_config.h"
+
+namespace tvm {
+namespace contrib {
+namespace ethosu {
+namespace cascader {
+
+void PerformanceInfoNode::VisitAttrs(AttrVisitor* v) {
+  v->Visit("_compute_cycles", &compute_cycles);
+  Array<Integer> tmp_reads = make_array(read_bytes);
+  v->Visit("_read_bytes", &tmp_reads);
+  v->Visit("_write_bytes", &write_bytes);
+}
+
+TVM_REGISTER_NODE_TYPE(PerformanceInfoNode);

Review comment:
       It is good if we can attach TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) to be able to print these from python side for debugging. We could do that in a follow up.




-- 
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