Skip to content

Commit

Permalink
Enable optimized dequantize on HIFI3 (#2560)
Browse files Browse the repository at this point in the history
BUG=none
  • Loading branch information
rascani authored May 3, 2024
1 parent ed36c46 commit cf10f94
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tensorflow/lite/micro/kernels/xtensa/dequantize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ limitations under the License.
#include "tensorflow/lite/kernels/kernel_util.h"
#include "tensorflow/lite/micro/kernels/dequantize.h"
#include "tensorflow/lite/micro/kernels/kernel_util.h"
#include "tensorflow/lite/micro/kernels/xtensa/xtensa.h"
#include "tensorflow/lite/micro/micro_log.h"

namespace tflite {
Expand All @@ -46,7 +47,7 @@ TfLiteStatus DequantizeEval(TfLiteContext* context, TfLiteNode* node) {

switch (input->type) {
case kTfLiteInt8: {
#if HIFI_VFPU && (defined(HIFI5) || defined(HIFI4))
#if HIFI_VFPU && (defined(HIFI5) || defined(HIFI4) || defined(HIFI3))
int err;
const int8_t* input_data_ptr;
float* output_data_ptr;
Expand All @@ -60,17 +61,17 @@ TfLiteStatus DequantizeEval(TfLiteContext* context, TfLiteNode* node) {
output_data_ptr, input_data_ptr, data->quantization_params.zero_point,
data->quantization_params.scale, flat_size);
TF_LITE_ENSURE(context, (err == 0));
#else // HIFI_VFPU && (defined(HIFI5) || defined(HIFI4))
#else // HIFI_VFPU && (defined(HIFI5) || defined(HIFI4) || defined(HIFI3))
reference_ops::Dequantize(data->quantization_params,
tflite::micro::GetTensorShape(input),
tflite::micro::GetTensorData<int8_t>(input),
tflite::micro::GetTensorShape(output),
tflite::micro::GetTensorData<float>(output));
#endif // HIFI_VFPU && (defined(HIFI5) || defined(HIFI4))
#endif // HIFI_VFPU && (defined(HIFI5) || defined(HIFI4) || defined(HIFI3))
break;
}
case kTfLiteInt16: {
#if HIFI_VFPU && (defined(HIFI5) || defined(HIFI4))
#if HIFI_VFPU && (defined(HIFI5) || defined(HIFI4) || defined(HIFI3))
int err;
const int16_t* input_data_ptr;
float* output_data_ptr;
Expand All @@ -83,13 +84,13 @@ TfLiteStatus DequantizeEval(TfLiteContext* context, TfLiteNode* node) {
output_data_ptr, input_data_ptr, data->quantization_params.zero_point,
data->quantization_params.scale, flat_size);
TF_LITE_ENSURE(context, (err == 0));
#else // HIFI_VFPU && (defined(HIFI5) || defined(HIFI4))
#else // HIFI_VFPU && (defined(HIFI5) || defined(HIFI4) || defined(HIFI3))
reference_ops::Dequantize(data->quantization_params,
tflite::micro::GetTensorShape(input),
tflite::micro::GetTensorData<int16_t>(input),
tflite::micro::GetTensorShape(output),
tflite::micro::GetTensorData<float>(output));
#endif // HIFI_VFPU && (defined(HIFI5) || defined(HIFI4))
#endif // HIFI_VFPU && (defined(HIFI5) || defined(HIFI4) || defined(HIFI3))
break;
}
case kTfLiteUInt8:
Expand Down

0 comments on commit cf10f94

Please sign in to comment.