Model with MatMul IR operator leads to std::terminate() on K210
See original GitHub issueI’m experimenting with getting the ONNX model (trained to classify MNIST digits) to work on K210 with all the nice recent updates in nncase and found that all the ops imported seems to work fine during the inference the resulting kmodel on K210 device, except when it contains Gemm
ONNX operator, which is imported to MatMul
operator of nncase IR language and some more operators after all the transformations. Maybe, I miss something, so decided to report this, maybe you would notice the problem.
To Reproduce
- …/install/bin/ncc compile mnist_cnn.onnx mnist_cnn_k210.kmodel -i onnx --dataset …/…/mnist-sample/ -t k210 --dump-ir --dump-dir testdump
- Add the resulting kmodel to the demo program.
Expected behavior Debugging timing output on the UART console.
Origin model and code
The models are uploaded to the demo program, named mnist_cnn_k210.kmodel
and mnist_cnn.onnx
for Kmodel and ONNX formats, respectively.
Environment (please complete the following information):
- OS: Gentoo, x86_64
- nncase version 1.0.0-91413fc-dirty
- DL Framework Pytorch-1.8.1
Additional context Here’s also a snippet on PyTorch to produce the ONNX model like this:
import sys
import torch
from torch import nn
from torchinfo import summary
class Net3(nn.Sequential):
def __init__(self):
super().__init__(
nn.Flatten(),
nn.Linear(784, 64),
nn.ReLU()
)
def main():
model = Net3()
dummy_input = torch.randn(1, 1, 28, 28).to(dtype=torch.float32)
summary(model, input_size=(1, 1, 28, 28))
torch.onnx.export(
model,
dummy_input,
"mnist_cnn.onnx",
input_names=["img"],
output_names=["digit"],
opset_version=11)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
sys.exit(1)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
@aclex Hi, I update the nncase runtime lib in SDK(PR125). Now you can try your model(need recompile with latest nncase).
Thank you very much for the fix, it indeed works just fine now with recent updates! Can confirm it working on K210 as well.