code: def run_tvm_graph(
      coreml_model,
      target,
      device,
      input_data,
      input_name,
      output_shape,
      output_dtype="float32",
  ):
      """Generic function to compile on relay and execute on tvm"""
      if isinstance(input_data, list):
          shape_dict = {}
          dtype_dict = {}
          for i, inp in enumerate(input_name):
              shape_dict[inp] = input_data[i].shape
              dtype_dict[inp] = input_data[i].dtype
      else:
          shape_dict = {input_name: input_data.shape}
          dtype_dict = {input_name: input_data.dtype}
  
      mod, params = relay.frontend.from_coreml(coreml_model, shape_dict)
      with tvm.transform.PassContext(opt_level=3):
          lib = relay.build(mod, target, params=params)
  
      m = graph_executor.GraphModule(lib["default"](device))
      # set inputs
      if isinstance(input_data, list):
          for i, inp in enumerate(input_name):
              m.set_input(
                  inp,
                  tvm.nd.array(
                      input_data[i].astype(input_data[i].dtype)
                  ),
              )
      else:
          m.set_input(
              input_name,
              tvm.nd.array(input_data.astype(input_data.dtype)),
          )
  
      # execute
      m.run()
      # get outputs
      if isinstance(output_shape, list) and isinstance(
          output_dtype, list
      ):
          tvm_output_list = []
          for i, s in enumerate(output_shape):
              tvm_output = m.get_output(
                  i, tvm.nd.empty((s), output_dtype[i])
              )
              tvm_output_list.append(tvm_output.numpy())
          return tvm_output_list
      else:
          if not output_shape:
              tvm_output = m.get_output(0)
          else:
              tvm_output = m.get_output(
                  0, tvm.nd.empty((output_shape), output_dtype)
              )
          return tvm_output.numpy()
  
imports: from os import path
  from enum import Enum
  import tempfile
  import numpy
  import model_zoo
  import coremltools
  from coremltools.models.neural_network import NeuralNetworkBuilder
  from coremltools.models import datatypes
  from tensorflow import keras
  import tvm
  import tvm.topi.testing
  import tvm.testing
  from tvm.contrib import graph_executor
  from tvm.topi.testing import conv2d_nchw_python
  from tvm import relay
label_desc: Use image node_id 5 for calling a global function with example usage: run_tvm_graph(coreml_model, target, device, input_data, input_name, output_shape, output_dtype) and returns: tvm_output_list, tvm_output