giuseros commented on a change in pull request #7070:
URL: https://github.com/apache/tvm/pull/7070#discussion_r540412352



##########
File path: python/tvm/driver/tvmc/common.py
##########
@@ -36,6 +36,93 @@ class TVMCException(Exception):
     """TVMC Exception"""
 
 
+def add_tuning_options(parser):

Review comment:
       File has been deleted

##########
File path: python/tvm/driver/tvmc/autoscheduler.py
##########
@@ -0,0 +1,212 @@
+# 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 auto-tuning networks using AutoScheduler.
+"""
+import logging
+
+from urllib.parse import urlparse
+
+from tvm import auto_scheduler
+from tvm.auto_scheduler.auto_schedule import HardwareParams
+
+from . import common, frontends
+from .common import add_tuning_options
+from .main import register_parser
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")
+
+
+@register_parser
+def add_autoscheduler_parser(subparsers):
+    """ Include parser for 'autoschedule' subcommand """
+    parser = subparsers.add_parser("autoschedule", help="auto-schedule a 
model")
+    parser.set_defaults(func=drive_autoschedule)
+    add_tuning_options(parser)
+
+    parser.add_argument(
+        "--cache-line-bytes",
+        default=64,
+        help="the size of cache line in bytes",
+    )
+    parser.add_argument(
+        "--num-cores",
+        default=4,
+        help="the number of device cores",
+    )
+    parser.add_argument(
+        "--vector-unit-bytes",
+        default=16,
+        help="the width of vector units in bytes",
+    )
+    parser.add_argument(
+        "--model-format",
+        choices=frontends.get_frontend_names(),
+        help="specify input model format",
+    )
+
+
+def drive_autoschedule(args):
+    """Invoke auto-scheduling with command line arguments
+
+    Parameters
+    ----------
+    args: argparse.Namespace
+        Arguments from command line parser.
+    """
+
+    # extra arguments validation before importing the model, so that obvious 
errors
+    # are pointed in advance.
+    if args.rpc_tracker:
+        parsed_url = urlparse("//%s" % args.rpc_tracker)
+        rpc_hostname = parsed_url.hostname
+        rpc_port = parsed_url.port or 9090
+        logger.info("RPC tracker hostname: %s", rpc_hostname)
+        logger.info("RPC tracker port: %s", rpc_port)
+
+        if not args.rpc_key:
+            raise common.TVMCException(
+                "need to provide an RPC tracker key (--rpc-key) for remote 
tuning"
+            )
+
+    target = common.target_from_cli(args.target)
+    mod, params = frontends.load_model(args.FILE, args.model_format)
+
+    # min_repeat_ms should be:
+    # a. the value provided by the user, if any, or
+    # b. 0ms in case target is "cpu"; otherwise 1000ms
+    if args.min_repeat_ms is not None:
+        min_repeat_ms = args.min_repeat_ms
+    else:
+        min_repeat_ms = 0 if target.keys[0] == "cpu" else 1000
+        logger.debug("Default --min-repeat-ms for this target is %s", 
min_repeat_ms)

Review comment:
       File has been deleted




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


Reply via email to