I am building a model using the AoT executor and the CRT runtime, trying to run the model in a host driven manner, because I want to compare it with the Graph executor (I noticed @alanmacd added this to the CRT runtime, so perhaps he can give me a hint).
What I am doing is the following:
...
RUNTIME = tvm.relay.backend.Runtime("crt", {"system-lib": True})
TARGET = tvm.target.target.Target({"kind": "c", "link-params": True})
if executor == "aot":
EXECUTOR = tvm.relay.backend.Executor("aot",options={'interface-api': 'c','unpacked-api': 1})
elif executor == "graph":
EXECUTOR = tvm.relay.backend.Executor("graph")
with tvm.transform.PassContext(opt_level=3, disabled_pass=["AlterOpLayout"]):
module = relay.build(mod, executor=EXECUTOR ,runtime=RUNTIME, target=TARGET, params=params)
...
with tvm.micro.Session(generated_project.transport()) as session:
if executor == "graph":
module_executor = tvm.micro.create_local_graph_executor(
module.get_graph_json(), session.get_system_lib(), session.device
)
else:
module_executor = tvm.runtime.executor.aot_executor.AotModule(session.create_aot_executor())
module_executor.set_input("predict_images:0",np.expand_dims(img,0))
module_executor.run()
...
When using the Graph executor, the model works fine. But when selecting the AoT executor, I get the following error:
[14:23:48] .../tvm/src/runtime/micro/micro_session.cc:368: remote: .../generated-project/src/standalone_crt/src/runtime/crt/aot_executor/aot_executor.c:81: Check failed: rv >= 0: cannot find 'predict_images:0' among input.
[14:23:48] .../tvm/src/runtime/micro/micro_session.cc:368: remote: TVMPlatformAbort: 0x00000500
I see this output when running the “with” clause:
...
[14:23:48] .../tvm/src/runtime/micro/micro_session.cc:368: remote: DumpMetadata:
[14:23:48] .../tvm/src/runtime/micro/micro_session.cc:368: remote: mod_name=tvmgen_default
[14:23:48] .../tvm/src/runtime/micro/micro_session.cc:368: remote: version=1
[14:23:48] .../tvm/src/runtime/micro/micro_session.cc:368: remote: num_inputs=0
[14:23:48] .../tvm/src/runtime/micro/micro_session.cc:368: remote: num_outputs=0
[14:23:48] .../tvm/src/runtime/micro/micro_session.cc:368: remote: num_workspace_pools=0
[14:23:48] .../tvm/src/runtime/micro/micro_session.cc:368: remote: num_constant_pools=0
...
So the question is:
- Am I using it correctly?
- Does the AoT executor change the name of the input of the model?
- Is there any step I am missing?