MCPcopy Index your code
hub / github.com/apache/tvm / verify

Function verify

tests/python/contrib/test_coreml_runtime.py:60–83  ·  view source on GitHub ↗
(coreml_model, model_path, dev)

Source from the content-addressed store, hash-verified

58 return coremltools.models.MLModel(builder.spec)
59
60 def verify(coreml_model, model_path, dev):
61 coreml_model = create_coreml_model()
62
63 out_spec = coreml_model.output_description._fd_spec
64 out_names = [spec.name for spec in out_spec]
65
66 # inference via coremltools
67 inputs = {}
68 for in_spec in coreml_model.input_description._fd_spec:
69 name = in_spec.name
70 shape = in_spec.type.multiArrayType.shape
71 inputs[name] = np.random.random_sample(shape)
72
73 coreml_outputs = [coreml_model.predict(inputs)[name] for name in out_names]
74
75 # inference via tvm coreml runtime
76 runtime = coreml_runtime.create("main", model_path, dev)
77 for name in inputs:
78 runtime.set_input(name, tvm.runtime.tensor(inputs[name], dev))
79 runtime.invoke()
80 tvm_outputs = [runtime.get_output(i).numpy() for i in range(runtime.get_num_outputs())]
81
82 for c_out, t_out in zip(coreml_outputs, tvm_outputs):
83 np.testing.assert_almost_equal(c_out, t_out, 3)
84
85 def check_remote(coreml_model):
86 temp = utils.tempdir()

Callers 2

check_remoteFunction · 0.70
check_localFunction · 0.70

Calls 6

create_coreml_modelFunction · 0.85
set_inputMethod · 0.80
numpyMethod · 0.80
invokeMethod · 0.65
predictMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…