To clarify, are you using microTVM with a Zephyr board (e.g. the NUCLEO H743ZI)? If so, which one? It’s possible you’re running out of stack space on your board.
Here’s a more thorough example showing how a project_options
parameter can be passed to create_aot_session
to manually set the stack size. I’ve verified this works on the NUCLEO-L4R5ZI - let me know what output you see.
import numpy as np
from tvm.runtime.executor.aot_executor import AotModule
from tvm.testing.utils import fetch_model_from_url
from tvm.micro.testing import create_aot_session, get_target, predict_labels_aot
PLATFORM = "zephyr"
# Change "nucleo_l4r5zi" to whatever your dev board is!
BOARD = "nucleo_l4r5zi"
URL = "https://github.com/tensorflow/tflite-micro/raw/main/tensorflow/lite/micro/examples/micro_speech/micro_speech.tflite"
SHA256 = "09e5e2a9dfb2d8ed78802bf18ce297bff54281a66ca18e0c23d69ca14f822a83"
mod, params = fetch_model_from_url(URL, "tflite", SHA256)
target = get_target(PLATFORM, BOARD)
options = {"config_main_stack_size": 4096}
with create_aot_session(
PLATFORM, BOARD, target, mod, params, project_options=options
) as session:
aot_executor = AotModule(session.create_aot_executor())
sample = np.random.randint(low=-127, high=128, size=(1, 1960), dtype=np.int8)
predictions = predict_labels_aot(session, aot_executor, [sample], runs_per_sample=10)
_label, runtime = next(predictions)
assert runtime < 1
print(runtime)
Note the runtime we get will be pretty slow, as we aren’t doing any autotuning. If we liked, we could fix this by passing a tune_logs
keyword argument to create_aot_session
.