Skip to content

Commit 09d444b

Browse files
committed
[Tutorial][Executor] Fix executors in tutorials
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
1 parent dbfbebe commit 09d444b

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

tutorials/dev/bring_your_own_datatypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ def get_cat_image():
262262
######################################################################
263263
# It's easy to execute MobileNet with native TVM:
264264

265-
ex = tvm.relay.create_executor("graph", mod=module)
265+
ex = tvm.relay.create_executor("graph", mod=module, params=params)
266266
input = get_cat_image()
267-
result = ex.evaluate()(input, **params).numpy()
267+
result = ex.evaluate()(input).numpy()
268268
# print first 10 elements
269269
print(result.flatten()[:10])
270270

tutorials/frontend/from_keras.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@
9898
target = "cuda"
9999
dev = tvm.cuda(0)
100100
with tvm.transform.PassContext(opt_level=3):
101-
executor = relay.build_module.create_executor("graph", mod, dev, target)
101+
executor = relay.build_module.create_executor("graph", mod, dev, target, params).evaluate()
102102

103103
######################################################################
104104
# Execute on TVM
105105
# ---------------
106106
dtype = "float32"
107-
tvm_out = executor.evaluate()(tvm.nd.array(data.astype(dtype)), **params)
107+
tvm_out = executor(tvm.nd.array(data.astype(dtype)))
108108
top1_tvm = np.argmax(tvm_out.numpy()[0])
109109

110110
#####################################################################

tutorials/frontend/from_onnx.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,15 @@
9292
mod, params = relay.frontend.from_onnx(onnx_model, shape_dict)
9393

9494
with tvm.transform.PassContext(opt_level=1):
95-
intrp = relay.build_module.create_executor("graph", mod, tvm.cpu(0), target)
95+
executor = relay.build_module.create_executor(
96+
"graph", mod, tvm.cpu(0), target, params
97+
).evaluate()
9698

9799
######################################################################
98100
# Execute on TVM
99101
# ---------------------------------------------
100102
dtype = "float32"
101-
tvm_output = intrp.evaluate()(tvm.nd.array(x.astype(dtype)), **params).numpy()
103+
tvm_output = executor(tvm.nd.array(x.astype(dtype))).numpy()
102104

103105
######################################################################
104106
# Display results

0 commit comments

Comments
 (0)