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/02/05 09:32:59 UTC

[GitHub] [tvm] manupa-arm commented on a change in pull request #7304: [TVMC] Add custom codegen (BYOC) passes for compilation and tuning

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



##########
File path: python/tvm/driver/tvmc/byoc.py
##########
@@ -0,0 +1,191 @@
+# 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.
+"""
+Provides support to Bring Your Own Codegen (BYOC) on TVMC.
+"""
+import logging
+
+from abc import ABC
+from abc import abstractmethod
+
+import tvm
+
+from tvm import relay
+
+from tvm.relay.op.contrib import get_pattern_table
+
+from .common import TVMCException
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")

Review comment:
       nit: just curious why we have to disable the linter here? In the same time, should this be LOGGER ?

##########
File path: tests/python/driver/tvmc/test_compiler.py
##########
@@ -65,7 +67,7 @@ def test_cross_compile_aarch64_tflite_module(tflite_mobilenet_v1_1_quant):
 
     graph, lib, params, dumps = tvmc.compiler.compile_model(
         tflite_mobilenet_v1_1_quant,
-        target="llvm -device=arm_cpu -mtriple=aarch64-linux-gnu -mattr=+neon",
+        target="llvm -device=arm_cpu -mtriple=aarch64-linux-gnu -mattr='+neon'",

Review comment:
       Dont you think the user should be able to provide compiler arguments with or without quotes when they only have a single element ? I think I understand the requirement comes because mattr here expects a list. However, I think it could be something handled by the parser.

##########
File path: python/tvm/driver/tvmc/compiler.py
##########
@@ -191,22 +198,21 @@ def compile_model(
 
         if use_autoscheduler:
             with auto_scheduler.ApplyHistoryBest(tuning_records):
-                with tvm.transform.PassContext(
-                    opt_level=3, config={"relay.backend.use_auto_scheduler": True}
-                ):
+                config["relay.backend.use_auto_scheduler"] = True
+                with tvm.transform.PassContext(opt_level=3, config=config):
                     logger.debug("building relay graph with autoscheduler")
                     graph_module = relay.build(
                         mod, target=target, params=params, target_host=target_host
                     )
         else:
             with autotvm.apply_history_best(tuning_records):
-                with tvm.transform.PassContext(opt_level=3):
+                with tvm.transform.PassContext(opt_level=3, config=config):
                     logger.debug("building relay graph with tuning records")
                     graph_module = relay.build(
                         mod, tvm_target, params=params, target_host=target_host
                     )
     else:
-        with tvm.transform.PassContext(opt_level=3):
+        with tvm.transform.PassContext(opt_level=3, config=config):

Review comment:
       [Suggestion] I think the setting the config should be tested for additional arguments of byoc targets.




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