code: def test_graph_tuner_layout_transform():
      log_file = "%s/test_tuner.log" % (os.getcwd())
      target = "llvm"
      dshape = (1, 3, 8, 8)
      dtype = "float32"
      layout = "NCHW"
      conv2d = relay.op.get("nn.conv2d")
      target_ops = [conv2d]
  
      g, records, ltf_records, ltf_keys, _ = _create_data(
          target, dshape, dtype, layout
      )
      executor = DPTuner(
          g,
          {"data": dshape},
          records,
          target_ops,
          target=target,
          log_file=log_file,
      )
      executor.benchmark_layout_transform(
          layout_records=ltf_records, infer_layout=True
      )
      out = executor._layout_transform_perf_records
  
      num_flops = 0
      total_time = 0
      for record in ltf_records:
          ltf_wkl = record[0].task.workload
          input_shape = ltf_wkl[1][1]
          flops = np.prod(input_shape)
          num_flops += flops
          total_time += record[1].costs[0]
      avg_time = total_time / num_flops
  
      for ltf_workload in out:
          input_shape = ltf_workload[1][1]
          flops = 1
          for i in input_shape:
              flops *= i
          expected_time = flops * avg_time
          out_time = out[ltf_workload][1].costs[0]
          assert expected_time == out_time, (
              "Inferred layout transformation time mismatch for %s: "
              "expecting %f but got %f"
              % (
                  str(ltf_workload),
                  expected_time,
                  out_time,
              )
          )
  
file_path: tvm/tests/python/autotvm/test_autotvm_graph_tuner_core.py
imports: import os
  import copy
  import numpy
  import tvm
  from tvm import te
  import tvm.relay.testing
  from tvm import autotvm
  from tvm import relay
  from tvm.autotvm.task import ConfigEntity
  from tvm.autotvm.measure import MeasureResult, MeasureInput
  from tvm.autotvm.graph_tuner import DPTuner, PBQPTuner
label_desc: Use image node_id 3 for calling a global function with example usage: test_graph_tuner_layout_transform() without return types