jwfromm commented on a change in pull request #7823:
URL: https://github.com/apache/tvm/pull/7823#discussion_r616375882



##########
File path: python/tvm/driver/tvmc/autotuner.py
##########
@@ -255,97 +388,113 @@ def drive_tune(args):
     # 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:
+    if min_repeat_ms is None:
         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)
 
-    if args.rpc_tracker:
-        runner_ctor = auto_scheduler.RPCRunner if args.enable_autoscheduler 
else autotvm.RPCRunner
+    if rpc_key:
+        if hostname is None or port is None:
+            raise common.TVMCException(
+                "You must provide a hostname and port to connect to a remote 
RPC device."
+            )
+        if isinstance(port, str):
+            port = int(port)
+
+        runner_ctor = auto_scheduler.RPCRunner if enable_autoscheduler else 
autotvm.RPCRunner
         runner = runner_ctor(
-            key=args.rpc_key,
-            host=rpc_hostname,
-            port=rpc_port,
-            number=args.number,
-            repeat=args.repeat,
-            n_parallel=args.parallel,
-            timeout=args.timeout,
+            key=rpc_key,
+            host=hostname,
+            port=port,
+            number=number,
+            repeat=repeat,
+            n_parallel=parallel,
+            timeout=timeout,
             min_repeat_ms=min_repeat_ms,
         )
     else:
         logger.info("starting localhost tuning")
         runner_ctor = (
-            auto_scheduler.LocalRunner if args.enable_autoscheduler else 
autotvm.LocalRunner
+            auto_scheduler.LocalRPCMeasureContext if enable_autoscheduler else 
autotvm.LocalRunner
         )
-        runner = runner_ctor(
-            number=args.number,
-            repeat=args.repeat,
-            timeout=args.timeout,
+        local_server = runner_ctor(
+            number=number,
+            repeat=repeat,
+            timeout=timeout,
             min_repeat_ms=min_repeat_ms,
         )
 
-    if args.enable_autoscheduler:
-        # Specify hardware parameters
-        hardware_params = auto_scheduler.HardwareParams(
-            args.num_cores,
-            args.vector_unit_bytes,
-            args.cache_line_bytes,
-            args.max_shared_memory_per_block,
-            args.max_local_memory_per_block,
-            args.max_threads_per_block,
-            args.max_vthread_extent,
-            args.warp_size,
-        )
+        # For autoscheduling on some devices, we need to maintain a 
LocalRPCMeasureContext object.
+        if enable_autoscheduler:
+            runner = local_server.runner
+        else:
+            runner = local_server
+
+    if enable_autoscheduler:
+
         tasks, weights = autoscheduler_get_tuning_tasks(
             mod=mod,
             params=params,
             target=target,
-            alter_layout=args.desired_layout,
+            alter_layout=desired_layout,
             hardware_params=hardware_params,
-            include_simple_tasks=args.include_simple_tasks,
+            include_simple_tasks=include_simple_tasks,
         )
 
+        # If not specified, choose a number of trials likely to produce good 
results.
+        if trials is None:
+            trials = 10000
+
         # Create the autoscheduler tuning options
         tuning_options = auto_scheduler.TuningOptions(
-            num_measure_trials=args.trials,
-            measure_callbacks=[auto_scheduler.RecordToFile(args.output)],
+            num_measure_trials=trials,
+            measure_callbacks=[auto_scheduler.RecordToFile(tuning_records)],
             runner=runner,
-            early_stopping=args.early_stopping,
+            early_stopping=early_stopping,
         )
 
         # Schedule the tasks (i.e., produce a schedule for each task)
-        schedule_tasks(
-            tasks, weights, tuning_options, args.tuning_records, 
args.log_estimated_latency
-        )
+        schedule_tasks(tasks, weights, tuning_options, prior_records, 
log_estimated_latency)
     else:
         tasks = autotvm_get_tuning_tasks(
             mod=mod,
             params=params,
             target=target,
-            alter_layout=args.desired_layout,
+            alter_layout=desired_layout,
         )
 
+        # If trails isn't specified, default to a number likely to produce good
+        # results without taking too much time.
+        if trials is None:
+            trials = 1000

Review comment:
       Yes I agree that unifying them in tvmc is ideal. Do you have a 
preference for total trials vs per-task trials? I lean towards total trials 
being more intuitive.




-- 
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:
[email protected]


Reply via email to