code: def tune_and_evaluate():
      print("Begin tuning...")
      tuner = auto_scheduler.TaskScheduler(tasks, task_weights)
      tune_option = auto_scheduler.TuningOptions(
          num_measure_trials=200,  # change this to 20000 to achieve the best performance
          builder=auto_scheduler.LocalBuilder(
              build_func="ndk" if use_ndk else "default"
          ),
          runner=auto_scheduler.RPCRunner(
              device_key,
              host=rpc_host,
              port=rpc_port,
              timeout=30,
              repeat=1,
              min_repeat_ms=200,
              enable_cpu_cache_flush=True,
          ),
          measure_callbacks=[auto_scheduler.RecordToFile(log_file)],
      )
  
      tuner.tune(tune_option)
  
      # Compile with the history best
      print("Compile...")
      with auto_scheduler.ApplyHistoryBest(log_file):
          with tvm.transform.PassContext(
              opt_level=3,
              config={"relay.backend.use_auto_scheduler": True},
          ):
              lib = relay.build(mod, target=target, params=params)
  
      # Export library
      tmp = tempdir()
      if use_ndk:
          from tvm.contrib import ndk
  
          filename = "net.so"
          lib.export_library(
              tmp.relpath(filename), fcompile=ndk.create_shared
          )
      else:
          filename = "net.tar"
          lib.export_library(tmp.relpath(filename))
  
      # Upload module to device
      print("Upload...")
      remote = auto_scheduler.utils.request_remote(
          device_key, rpc_host, rpc_port, timeout=10000
      )
      remote.upload(tmp.relpath(filename))
      rlib = remote.load_module(filename)
  
      # Create graph executor
      dev = remote.cpu()
      module = graph_executor.GraphModule(rlib["default"](dev))
      data_tvm = tvm.nd.array(
          (np.random.uniform(size=input_shape)).astype(dtype)
      )
      module.set_input("data", data_tvm)
  
      # Evaluate
      print("Evaluate inference time cost...")
      print(module.benchmark(dev, repeat=3, min_repeat_ms=500))
  
file_path: tvm/gallery/how_to/tune_with_autoscheduler/tune_network_arm.py
imports: import numpy
  import os
  import tvm
  from tvm import relay, auto_scheduler
  from tvm.relay import data_dep_optimization
  import tvm.relay.testing
  from tvm.contrib import graph_executor
  from tvm.contrib.utils import tempdir
label_desc: Use image node_id 2 for calling a global function with example usage: tune_and_evaluate() without return types