tensorflow / tensorflow

An Open Source Machine Learning Framework for Everyone
https://tensorflow.org
Apache License 2.0
186.32k stars 74.3k forks source link

Tensorflow lite for microcontroller not support the model with float32 input/output and int8 weights. #56626

Open FragrantRookie opened 2 years ago

FragrantRookie commented 2 years ago
Click to expand! ### Issue Type Feature Request ### Source source ### Tensorflow Version tf 2.9 ### Custom Code No ### OS Platform and Distribution ubuntu20 ### Mobile device _No response_ ### Python version 3.9 ### Bazel version _No response_ ### GCC/Compiler version _No response_ ### CUDA/cuDNN version _No response_ ### GPU model and memory _No response_ ### Current Behaviour? ```shell Tensorflow lite for microcontroller not support the model with float32 input/output and int8 weights. ``` ### Standalone code to reproduce the issue ```shell Tensorflow lite for microcontroller not support the model with float32 input/output and int8 weights. ``` ### Relevant log output _No response_
mohantym commented 2 years ago

Hi @FragrantRookie ! Could you also post a minimal standalone code to understand the feature request . Thank you!

FragrantRookie commented 2 years ago

Hi @FragrantRookie ! Could you also post a minimal standalone code to understand the feature request . Thank you!

Sorry, I didn't give enough information.I am doing some tests so that I can better describe my problem.I am deploying the model to DSP or MCU. This model was mentioned in the previous question. This is the link: https://github.com/breizhn/DTLN or https://github.com/tensorflow/tensorflow/issues/56505 Because some layers in TF Lite for micro do not support int16, and the main object of computing power consumption in the target model is the full connection layer, I am going to use float type input and output and int8 type weights. However, the problem is that the full connection layer(micro) currently does not support the mixed model of float and int8, so I modified the code myself. At present, the mixed model has been able to get the correct inference result. Because the way I make the hybrid model work is to transform int8 back to float32, the new problem is that the computational power consumption is huge. Another approach is that I consider quantifying the input to int16 only in the full connection layer. The problem with this is that when the model contains multiple fully connected layers, I cannot accurately know the input range of each fully connected layer, so I cannot accurately quantify the input of each layer. Another idea is to use F16.But I don't know how to make TF Lite for micro support F16.Or I don't think F16 of TF Lite for micro is a real floating-point type. Its definition is:

typedef struct TfLiteFloat16 {
uint16_ t data;
} TfLiteFloat16;
mohantym commented 2 years ago

Ok @FragrantRookie ! Thanks for the update. @sachinprasadhs ! Could you please look at this issue. Thank you!