ARM-software / CMSIS_5

CMSIS Version 5 Development Repository
http://arm-software.github.io/CMSIS_5/index.html
Apache License 2.0
1.33k stars 1.08k forks source link

[Feature request] Support for BNN #525

Open dizcza opened 5 years ago

dizcza commented 5 years ago

I'd like to see a binary neural network (BNN) implementation as a good example of CMSIS NN package.

In BNNs you can pack 8 binary values in a single int8_t value and then use XOR operation that replaces convolution. The authors state that it reduces CPU cycles in x8 times and memory footprint in x32 times.

alessandrocapotondi commented 5 years ago

Dear @dizcza,

we did it so far for our research purposes, but it is not integrated into the mainstream.

You can have a look here: https://github.com/EEESlab/CMSIS_NN-INTQ

The library supports also int-8, int-4, int-2, BIN (int-1). There is not so much documentation, but you can find the sources of the new kernels here: https://github.com/EEESlab/CMSIS_NN-INTQ/tree/master/CMSIS/NN/Source/ConvolutionFunctions

Here the paper associated (https://dl.acm.org/citation.cfm?id=3283580). If you are interest to use it or you find some problem on the usage of it you can directly rise issues on the repo.

Best, Alessandro

alessandrocapotondi commented 5 years ago

Dear @dizcza,

if you are interested you just release a mobilenet over CMSIS-NN for STM32H7. https://github.com/EEESlab/mobilenet_v1_stm32_cmsis_nn

The application rely on an extended CMSIS implemetation which support an asymmetric quantization uint8 (as it done by tensorflow).

You can find the library here: https://github.com/EEESlab/CMSIS_NN-INTQ/tree/intq-v2.0.1

And a short article here: https://medium.com/@manuele.rusci/running-mobilenet-on-stm32-mcus-at-the-edge-e217db934f83

dizcza commented 5 years ago

@alessandrocapotondi It looks very interesting! I have STM32F429 board but since you use CubeMX to generate the project (special thanks for this), it should be possible to migrate your solution on other boards as well.

I'll leave this channel open for general discussion and fire issues on your direct git projects if I get any implementation-specific questions.

In the meanwhile, have you tried to compare CMSIS NN solutions (including yours) with https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/micro? It'd interesting to compare the benefits one solution brings over the other.