Remove int16->int32 quantization from dequantize op. This logic has been moved into the quantize op.
PiperOrigin-RevId: 351514744 Change-Id: I92e0a6d7007008abc125790444f37cb2a2fd6493
This commit is contained in:
parent
bbc7e7bfa0
commit
a439e53437
@ -53,7 +53,6 @@ void CreateBenchmarkRunner() {
|
||||
// We allocate the KeywordOpResolver from a global buffer because the object's
|
||||
// lifetime must exceed that of the KeywordBenchmarkRunner object.
|
||||
KeywordOpResolver* op_resolver = new (op_resolver_buffer) KeywordOpResolver();
|
||||
op_resolver->AddDequantize();
|
||||
op_resolver->AddFullyConnected(tflite::Register_FULLY_CONNECTED_INT8());
|
||||
op_resolver->AddQuantize();
|
||||
op_resolver->AddSoftmax();
|
||||
|
||||
@ -116,14 +116,6 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
|
||||
int flat_size = MatchingFlatSize(tflite::micro::GetTensorShape(input),
|
||||
tflite::micro::GetTensorShape(output));
|
||||
switch (input->type) {
|
||||
case kTfLiteInt16: {
|
||||
reference_ops::Requantize(
|
||||
tflite::micro::GetTensorData<int16_t>(input), flat_size,
|
||||
data->output_multiplier, data->output_shift,
|
||||
data->quantization_params.zero_point, data->output_zero_point,
|
||||
tflite::micro::GetTensorData<int32_t>(output));
|
||||
break;
|
||||
}
|
||||
case kTfLiteInt8: {
|
||||
reference_ops::Requantize(
|
||||
tflite::micro::GetTensorData<int8_t>(input), flat_size,
|
||||
|
||||
@ -139,40 +139,4 @@ TF_LITE_MICRO_TEST(DequantizeOpTestInt16) {
|
||||
zero_point, dims, values, output);
|
||||
}
|
||||
|
||||
TF_LITE_MICRO_TEST(DequantizeOpTestInt8ToInt32) {
|
||||
const int length = 10;
|
||||
const int dims[] = {2, 5, 2};
|
||||
const float input_float[] = {-63.5, -63, -62.5, -62, -61.5,
|
||||
62, 62.5, 63, 63.5, 64};
|
||||
const int32_t golden[] = {-630, -625, -620, -615, -610,
|
||||
625, 630, 635, 640, 645};
|
||||
const float input_scale = 0.5f;
|
||||
const int input_zero_point = -1;
|
||||
const float output_scale = 0.1f;
|
||||
const int output_zero_point = 5;
|
||||
int8_t input_quantized[length];
|
||||
int32_t output[length];
|
||||
tflite::testing::TestDequantizeToInt32(
|
||||
dims, input_float, input_quantized, input_scale, input_zero_point, dims,
|
||||
golden, output_scale, output_zero_point, output);
|
||||
}
|
||||
|
||||
TF_LITE_MICRO_TEST(DequantizeOpTestInt16ToInt32) {
|
||||
const int length = 10;
|
||||
const int dims[] = {2, 5, 2};
|
||||
const float input_float[] = {-63.5, -63, -62.5, -62, -61.5,
|
||||
62, 62.5, 63, 63.5, 64};
|
||||
const int32_t golden[] = {-630, -625, -620, -615, -610,
|
||||
625, 630, 635, 640, 645};
|
||||
const float input_scale = 0.5f;
|
||||
const int input_zero_point = -1;
|
||||
const float output_scale = 0.1f;
|
||||
const int output_zero_point = 5;
|
||||
int16_t input_quantized[length];
|
||||
int32_t output[length];
|
||||
tflite::testing::TestDequantizeToInt32(
|
||||
dims, input_float, input_quantized, input_scale, input_zero_point, dims,
|
||||
golden, output_scale, output_zero_point, output);
|
||||
}
|
||||
|
||||
TF_LITE_MICRO_TESTS_END
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user