MCX N947 TFLM Modelrunner Inference of Neutron Converted Models

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCX N947 TFLM Modelrunner Inference of Neutron Converted Models

272 Views
Laurens26
Contributor I

I want to benchmark a bunch of tflite models (<500KB in size) on my FRDM MCXN947 (CPU vs. NPU) via the TFLM modelrunner using HTTP.

The problem: CPU inference does not work for all models and NPU inference not at all.

hardware:
- FRDM-MCXN947 development board (connected to my windows machine via USB and Ethernet)

software and tool setup:
- host: windows 11 machine
- eIQ Neutron SDK: eiq-neutron-sdk-windows-3.0.1
- MCUXpresso SDK: SDK_26_03_00_FRDM-MCXN947
- Project from SDK: frdmmcxn947_tflm_modelrunner_cm33_core0

ML models for CPU inference:
- ad01_int8.tflite
- kws_ref_model.tflite
- pretrainedResnet_quant.tflite
- vww_96_int8.tflite

ML models neutron converted with Neutron Converter (part of eIQ Neutron SDK) for NPU inference:
eiq-neutron-sdk-windows-3.0.1\bin
neutron-converter --target mcxn94x --input ad01_int8.tflite --output ad01_int8_converted_3_0_1.tflite

- ad01_int8_converted_3_0_1.tflite
- kws_ref_model_converted_3_0_1.tflite
- pretrainedResnet_quant_converted_3_0_1.tflite
- vww_96_int8_converted_3_0_1.tflite

Steps performed
1. Update eIQ Projects with the Latest eIQ Neutron SDK Libraries
Copy from:
eiq-neutron-sdk-windows-3.0.1\target\mcxn94x\common\include\NeutronErrors.h
eiq-neutron-sdk-windows-3.0.1\target\mcxn94x\driver\include\NeutronDriver.h
eiq-neutron-sdk-windows-3.0.1\target\mcxn94x\mcxn\libNeutronDriver.a
eiq-neutron-sdk-windows-3.0.1\target\mcxn94x\mcxn\libNeutronFirmware.a

to:
frdmmcxn947_tflm_modelrunner_cm33_core0\include\NeutronErrors.h
frdmmcxn947_tflm_modelrunner_cm33_core0\driver_include\NeutronDriver.h
frdmmcxn947_tflm_modelrunner_cm33_core0\mcxn\libNeutronDriver.a
frdmmcxn947_tflm_modelrunner_cm33_core0\mcxn\libNeutronFirmware.a

2. Build and flash the project "frdmmcxn947_tflm_modelrunner_cm33_core0" with vscode

3. Run inference via HTTP using the flashed TFLM Modelrunner
Command:
curl -X PUT http://192.168.178.75:10818/v1 -F "block_content=@C:\<mypath>\ad01_int8.tflite"

Output via Serial Monitor:
....
run ms: 6.167000

Command:
curl -X PUT http://192.168.178.75:10818/v1 -F "block_content=@C:\<mypath>\vww_96_int8.tflite"

Output via Serial Monitor:
....
run ms: 182.042000

 

For any of the other models it doesnt work

Output: 
a) No inference after flashing:
FLASH 0x104000 Erased, Program at 104000: 16384 bytes ==
FLASH 0x108000 Erased, Program at 108000: 16384 bytes ==
FLASH 0x10c000 Erased, Program at 10c000: 16384 bytes ==
FLASH 0x110000 Erased, Program at 110000: 16384 bytes ==
FLASH 0x114000 Erased, Program at 114000: 16384 bytes ==
FLASH 0x118000 Erased, Program at 118000: 16384 bytes ==
FLASH 0x11c000 Erased, Program at 11c000: 16384 bytes ==
FLASH 0x120000 Erased, Program at 120000: 16384 bytes ==
FLASH 0x124000 Erased, Program at 124000: 16384 bytes ==
FLASH 0x128000 Erased, Program at 128000: 16384 bytes ==
FLASH 0x12c000 Erased, Program at 12c000: 16384 bytes ==
FLASH 0x130000 Erased, Program at 130000: 16384 bytes ==
FLASH 0x134000 Erased, Program at 134000: 16384 bytes ==
FLASH 0x138000 Erased, Program at 138000: 544 bytes ==

b) no flashing process at all

c) Error HardFault_Handler

Line 343: ldr r0,=HardFault_Handler
in 
SDK_26_03_00_FRDM-MCXN947\mcuxsdk\devices\MCX\MCXN\MCXN947\gcc\startup_MCXN947_cm33_core0.S
stopped by debugger


Any hints are highly appreciated!

Labels (1)
Tags (1)
0 Kudos
Reply
1 Reply

157 Views
Harry_Zhang
NXP Employee
NXP Employee

Hi @Laurens26 

I think the problem is more likely a mix of version alignment, rather than a pure “model size” issue.

I think you can refer to this link.

How to Update eIQ Projects with the Latest eIQ Neutron SDK Libraries

BR

Harry

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2382593%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EMCX%20N947%20TFLM%20Modelrunner%20Inference%20of%20Neutron%20Converted%20Models%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2382593%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20want%20to%20benchmark%20a%20bunch%20of%20tflite%20models%20(%26lt%3B500KB%20in%20size)%20on%20my%20FRDM%20MCXN947%20(CPU%20vs.%20NPU)%20via%20the%20TFLM%20modelrunner%20using%20HTTP.%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20problem%3A%20CPU%20inference%20does%20not%20work%20for%20all%20models%20and%20NPU%20inference%20not%20at%20all.%3CBR%20%2F%3E%3CBR%20%2F%3Ehardware%3A%3CBR%20%2F%3E-%20FRDM-MCXN947%20development%20board%20(connected%20to%20my%20windows%20machine%20via%20USB%20and%20Ethernet)%3CBR%20%2F%3E%3CBR%20%2F%3Esoftware%20and%20tool%20setup%3A%3CBR%20%2F%3E-%20host%3A%20windows%2011%20machine%3CBR%20%2F%3E-%20eIQ%20Neutron%20SDK%3A%20eiq-neutron-sdk-windows-3.0.1%3CBR%20%2F%3E-%26nbsp%3BMCUXpresso%20SDK%3A%26nbsp%3BSDK_26_03_00_FRDM-MCXN947%3CBR%20%2F%3E-%20Project%20from%20SDK%3A%26nbsp%3Bfrdmmcxn947_tflm_modelrunner_cm33_core0%3CBR%20%2F%3E%3CBR%20%2F%3EML%20models%20for%20CPU%20inference%3A%3CBR%20%2F%3E-%26nbsp%3Bad01_int8.tflite%3CBR%20%2F%3E-%26nbsp%3Bkws_ref_model.tflite%3CBR%20%2F%3E-%26nbsp%3BpretrainedResnet_quant.tflite%3CBR%20%2F%3E-%26nbsp%3Bvww_96_int8.tflite%3CBR%20%2F%3E%3CBR%20%2F%3EML%20models%20neutron%20converted%20with%20Neutron%20Converter%20(part%20of%20eIQ%20Neutron%20SDK)%20for%20NPU%20inference%3A%3CBR%20%2F%3Eeiq-neutron-sdk-windows-3.0.1%5Cbin%3CBR%20%2F%3Eneutron-converter%20--target%20mcxn94x%20--input%20ad01_int8.tflite%20--output%20ad01_int8_converted_3_0_1.tflite%3CBR%20%2F%3E%3CBR%20%2F%3E-%26nbsp%3Bad01_int8_converted_3_0_1.tflite%3CBR%20%2F%3E-%26nbsp%3Bkws_ref_model_converted_3_0_1.tflite%3CBR%20%2F%3E-%26nbsp%3BpretrainedResnet_quant_converted_3_0_1.tflite%3CBR%20%2F%3E-%26nbsp%3Bvww_96_int8_converted_3_0_1.tflite%3CBR%20%2F%3E%3CBR%20%2F%3ESteps%20performed%3CBR%20%2F%3E1.%26nbsp%3BUpdate%20eIQ%20Projects%20with%20the%20Latest%20eIQ%20Neutron%20SDK%20Libraries%3CBR%20%2F%3ECopy%20from%3A%3CBR%20%2F%3Eeiq-neutron-sdk-windows-3.0.1%5Ctarget%5Cmcxn94x%5Ccommon%5Cinclude%5CNeutronErrors.h%3CBR%20%2F%3Eeiq-neutron-sdk-windows-3.0.1%5Ctarget%5Cmcxn94x%5Cdriver%5Cinclude%5CNeutronDriver.h%3CBR%20%2F%3Eeiq-neutron-sdk-windows-3.0.1%5Ctarget%5Cmcxn94x%5Cmcxn%5ClibNeutronDriver.a%3CBR%20%2F%3Eeiq-neutron-sdk-windows-3.0.1%5Ctarget%5Cmcxn94x%5Cmcxn%5ClibNeutronFirmware.a%3CBR%20%2F%3E%3CBR%20%2F%3Eto%3A%3CBR%20%2F%3Efrdmmcxn947_tflm_modelrunner_cm33_core0%5Cinclude%5CNeutronErrors.h%3CBR%20%2F%3Efrdmmcxn947_tflm_modelrunner_cm33_core0%5Cdriver_include%5CNeutronDriver.h%3CBR%20%2F%3Efrdmmcxn947_tflm_modelrunner_cm33_core0%5Cmcxn%5ClibNeutronDriver.a%3CBR%20%2F%3Efrdmmcxn947_tflm_modelrunner_cm33_core0%5Cmcxn%5ClibNeutronFirmware.a%3CBR%20%2F%3E%3CBR%20%2F%3E2.%20Build%20and%20flash%20the%20project%20%22frdmmcxn947_tflm_modelrunner_cm33_core0%22%20with%20vscode%3CBR%20%2F%3E%3CBR%20%2F%3E3.%20Run%20inference%20via%20HTTP%20using%20the%20flashed%20TFLM%20Modelrunner%3CBR%20%2F%3ECommand%3A%3CBR%20%2F%3Ecurl%20-X%20PUT%20%3CA%20href%3D%22http%3A%2F%2F192.168.178.75%3A10818%2Fv1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttp%3A%2F%2F192.168.178.75%3A10818%2Fv1%3C%2FA%3E%20-F%20%22block_content%3D%40C%3A%5C%3CMYPATH%3E%5Cad01_int8.tflite%22%3C%2FMYPATH%3E%3C%2FP%3E%3CP%3EOutput%20via%20Serial%20Monitor%3A%3CBR%20%2F%3E....%3CBR%20%2F%3Erun%20ms%3A%206.167000%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3ECommand%3A%3CBR%20%2F%3Ecurl%20-X%20PUT%20%3CA%20href%3D%22http%3A%2F%2F192.168.178.75%3A10818%2Fv1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttp%3A%2F%2F192.168.178.75%3A10818%2Fv1%3C%2FA%3E%20-F%20%22block_content%3D%40C%3A%5C%3CMYPATH%3E%5Cvww_96_int8.tflite%22%3CBR%20%2F%3E%3CBR%20%2F%3EOutput%20via%20Serial%20Monitor%3A%3CBR%20%2F%3E....%3CBR%20%2F%3Erun%20ms%3A%20182.042000%3C%2FMYPATH%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EFor%20any%20of%20the%20other%20models%20it%20doesnt%20work%3CBR%20%2F%3E%3CBR%20%2F%3EOutput%3A%26nbsp%3B%3CBR%20%2F%3Ea)%20No%20inference%20after%20flashing%3A%3CBR%20%2F%3EFLASH%200x104000%20Erased%2C%20Program%20at%20104000%3A%2016384%20bytes%20%3D%3D%3CBR%20%2F%3EFLASH%200x108000%20Erased%2C%20Program%20at%20108000%3A%2016384%20bytes%20%3D%3D%3CBR%20%2F%3EFLASH%200x10c000%20Erased%2C%20Program%20at%2010c000%3A%2016384%20bytes%20%3D%3D%3CBR%20%2F%3EFLASH%200x110000%20Erased%2C%20Program%20at%20110000%3A%2016384%20bytes%20%3D%3D%3CBR%20%2F%3EFLASH%200x114000%20Erased%2C%20Program%20at%20114000%3A%2016384%20bytes%20%3D%3D%3CBR%20%2F%3EFLASH%200x118000%20Erased%2C%20Program%20at%20118000%3A%2016384%20bytes%20%3D%3D%3CBR%20%2F%3EFLASH%200x11c000%20Erased%2C%20Program%20at%2011c000%3A%2016384%20bytes%20%3D%3D%3CBR%20%2F%3EFLASH%200x120000%20Erased%2C%20Program%20at%20120000%3A%2016384%20bytes%20%3D%3D%3CBR%20%2F%3EFLASH%200x124000%20Erased%2C%20Program%20at%20124000%3A%2016384%20bytes%20%3D%3D%3CBR%20%2F%3EFLASH%200x128000%20Erased%2C%20Program%20at%20128000%3A%2016384%20bytes%20%3D%3D%3CBR%20%2F%3EFLASH%200x12c000%20Erased%2C%20Program%20at%2012c000%3A%2016384%20bytes%20%3D%3D%3CBR%20%2F%3EFLASH%200x130000%20Erased%2C%20Program%20at%20130000%3A%2016384%20bytes%20%3D%3D%3CBR%20%2F%3EFLASH%200x134000%20Erased%2C%20Program%20at%20134000%3A%2016384%20bytes%20%3D%3D%3CBR%20%2F%3EFLASH%200x138000%20Erased%2C%20Program%20at%20138000%3A%20544%20bytes%20%3D%3D%3CBR%20%2F%3E%3CBR%20%2F%3Eb)%20no%20flashing%20process%20at%20all%3CBR%20%2F%3E%3CBR%20%2F%3Ec)%20Error%26nbsp%3BHardFault_Handler%3C%2FP%3E%3CP%3ELine%20343%3A%20ldr%20r0%2C%3DHardFault_Handler%3CBR%20%2F%3Ein%26nbsp%3B%3CBR%20%2F%3ESDK_26_03_00_FRDM-MCXN947%5Cmcuxsdk%5Cdevices%5CMCX%5CMCXN%5CMCXN947%5Cgcc%5Cstartup_MCXN947_cm33_core0.S%3CBR%20%2F%3Estopped%20by%20debugger%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EAny%20hints%20are%20highly%20appreciated!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2382593%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EMCXN%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2383838%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MCX%20N947%20TFLM%20Modelrunner%20Inference%20of%20Neutron%20Converted%20Models%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2383838%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F263875%22%20target%3D%22_blank%22%3E%40Laurens26%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20think%20the%20problem%20is%20more%20likely%20a%20mix%20of%20version%20alignment%2C%20rather%20than%20a%20pure%20%E2%80%9Cmodel%20size%E2%80%9D%20issue.%3C%2FP%3E%0A%3CP%3EI%20think%20you%20can%20refer%20to%20this%20link.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-RT-Crossover-MCUs-Knowledge%2FHow-to-Update-eIQ-Projects-with-the-Latest-eIQ-Neutron-SDK%2Fta-p%2F2270833%22%20target%3D%22_blank%22%3EHow%20to%20Update%20eIQ%20Projects%20with%20the%20Latest%20eIQ%20Neutron%20SDK%20Libraries%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EBR%3C%2FP%3E%0A%3CP%3EHarry%3C%2FP%3E%3C%2FLINGO-BODY%3E