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/12/10 00:55:30 UTC

[GitHub] [tvm] mkatanbaf commented on a diff in pull request #13514: [microTVM] tuning on micro targets with meta-schedule

mkatanbaf commented on code in PR #13514:
URL: https://github.com/apache/tvm/pull/13514#discussion_r1044936260


##########
python/tvm/contrib/micro/meta_schedule/local_builder_micro.py:
##########
@@ -0,0 +1,83 @@
+# 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.
+"""Local builder for microTVM projects.that compile on the local host"""
+
+import os
+import tempfile
+from typing import Optional, Dict
+from tvm.ir import IRModule
+from tvm.runtime import NDArray
+from tvm.target import Target
+from tvm.meta_schedule.builder import LocalBuilder
+from tvm.driver.build_module import OperatorModule
+from tvm import micro
+from tvm.contrib.tar import tar
+from tvm.relay.backend import Runtime
+from tvm.driver import build as tvm_build
+from tvm.tir.transform import RemoveWeightLayoutRewriteBlock
+
+
+def get_micro_local_builder():
+    """Return micro-compatible Builder for meta schedule."""
+
+    def micro_build(
+        mod: IRModule, target: Target, _params: Optional[Dict[str, NDArray]]
+    ) -> OperatorModule:
+        """build function for micro targets.
+
+        Parameters
+        ----------
+        mod : IRModule
+            The IRModule to be built.
+        target : Target
+            The target to be built.
+        _params : Optional[Dict[str, NDArray]]
+            The parameters to be used for the build. Must be None.
+
+        Returns
+        -------
+        rt_mod : OperatorModule
+            The built Module.
+        """
+
+        # Note: changing the global symbol is necessary for micro targets,
+        # since the generated projects already include a main function.
+        prim_func = mod["main"].with_attr("global_symbol", "default_function")

Review Comment:
   tvm_build assigns "global_symbol" to the name of generated C function. I updated the note.



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