Skip to content

[core] RuntimeError: Item size ... for PEP 3118 buffer format string f does not match the dtype f item size ...

What commit version of aidge do I use

Problem description

When doing an ONNX or STM32 export the code crash with this cryptic error:

RuntimeError: Item size 20736 for PEP 3118 buffer format string f does not match the dtype f item size 4.

Reproducible example code

You can attach code or use code block

# Export a MNIST model to a CPP standalone project

import os
import requests
import numpy as np
import aidge_core
import aidge_onnx


# Download onnx file if it has not been done before
if not os.path.isfile("./lenet_mnist.onnx"):
    response = requests.get("https://huggingface.co/vtemplier/LeNet_MNIST/resolve/main/lenet_mnist.onnx?download=true")
    if response.status_code == 200:
        with open("lenet_mnist.onnx", 'wb') as f:
            f.write(response.content)
        print("ONNX model downloaded successfully.")
    else:
        print("Failed to download ONNX model. Status code:", response.status_code)

# Load the model in Aidge and manipulate it
model = aidge_onnx.load_onnx("lenet_mnist.onnx")
aidge_onnx.export_onnx(model, "lenet_mnist.onnx",
                       inputs_dims={
                           "_feature_feature_0_Conv_output_0": [[1, 1, 28, 28]]
                       })