EIDSP_MATRIX_SIZE_MISMATCH on Teensy 4.1

Hello,

I have a sEMG muscular signal classifier project that is designed to be run on the Teensy 4.1 arduino compatible platform. And i’ve decided to use the Edge Impulse platform in order to cut on software developement time and resolve the large time constraints of this one person project. This helps me a lot in freeing up time to focus on the larger hardware part of signal acquisition and movement replication.

The issue i am facing right now is that the code is hitting a EIDSP_MATRIX_SIZE_MISMATCH at runtime of the program .

I will first be writing the steps that were needed to run static buffer example from Arduino Edge Impulse build on Teensy 4.1 and what other changes have been done to get my specific error messages.

  1. Install Arduino 1.8.13 and teensyduino 1.53 on linux (I have Ub18.05) because on Windows 7 the code doesn’t compile at all due to filename length limit.
  2. Get the zip library ( build for arduino platform, the same with EON or without) and use the static buffer example project, where i’ve added a data window from test samples -> raw features -> copy to clipboard.
  3. In cmsis_gcc.h comment the definitions for __STATIC_FORCEINLINE void __disable_irq() and __STATIC_FORCEINLINE void __enable_irq() because these are already defined in the same form in the Teensy 4.1 platform specific files.
  4. After this i can build the project successfully and upload it.
  5. When running on the board for the NN arthitecture in , i get a EIDSP_MATRIX_SIZE_MISMATCH error, triggered at ei_run_dsp.h - line 520.
  6. After hard coding as seen in in order to pass the error above i get the same error on ei_run_dsp.h - line 531-534, with the following Serial output:

Is there a way to fix this, from what i see in the NN arhitecture and the serial error matrix dimensions it appears to be a wrong calculation from the Input layer to Reshape layer.

Any help i can get would be wonderful, thanks.

Hey @moisi.george, it’s a limitation from the on-device DSP code at the moment. It only allows generating a spectrogram from a single axis. I’ll file a ticket to resolve this, but it’s hard to do in a memory efficient way (so maybe the suggestion in the next paragraph will be something we’ll advertise in the studio instead).

A quick workaround is to create a spectrogram block per axis in Create Impulse and have them all feed into a single neural network block. Results should look the same but is supported by the DSP code and can be calculated efficiently.