// Parameters for asymmetric quantization. Quantized values can be converted
// back to float using:
// real_value = scale * (quantized_value - zero_point);
- //
- // Q: Is this necessary?
TfLiteQuantizationParams quantization;
- quantization.scale = FLOAT_NEAREST_TO_1;
quantization.zero_point = 0;
// On AddTensors(N) call, T/F Lite interpreter creates N tensors whose index is [0 ~ N)
interp.AddTensors(5);
// Configure OFM
+ quantization.scale = 1.0f;
interp.SetTensorParametersReadWrite(0, kTfLiteUInt8 /* type */, "output" /* name */,
{1 /*N*/, OFM_H, OFM_W, OFM_C} /* dims */, quantization);
// Configure IFM
+ quantization.scale = 0.02f;
interp.SetTensorParametersReadWrite(1, kTfLiteUInt8 /* type */, "input" /* name */,
{1 /*N*/, IFM_H, IFM_W, IFM_C} /* dims */, quantization);
2, kTfLiteUInt8 /* type */, "filter" /* name */, {KER_N, KER_H, KER_W, KER_C} /* dims */,
quantization, reinterpret_cast<const char *>(kernel_data), kernel_size * sizeof(uint8_t));
+ quantization.scale *= quantization.scale;
interp.SetTensorParametersReadOnly(
3, kTfLiteInt32 /* type */, "bias" /* name */, {bias_size} /* dims */, quantization,
reinterpret_cast<const char *>(bias_data), bias_size * sizeof(int32_t));
// Parameters for asymmetric quantization. Quantized values can be converted
// back to float using:
// real_value = scale * (quantized_value - zero_point);
- //
- // Q: Is this necessary?
TfLiteQuantizationParams quantization;
- quantization.scale = FLOAT_NEAREST_TO_1;
quantization.zero_point = 0;
// On AddTensors(N) call, T/F Lite interpreter creates N tensors whose index is [0 ~ N)
interp.AddTensors(4);
// Configure OFM
+ quantization.scale = 1.0f;
interp.SetTensorParametersReadWrite(0, kTfLiteUInt8 /* type */, "output" /* name */,
{1 /*N*/, OFM_H, OFM_W, OFM_C} /* dims */, quantization);
// Configure IFM
+ quantization.scale = 0.02f;
interp.SetTensorParametersReadWrite(1, kTfLiteUInt8 /* type */, "input" /* name */,
{1 /*N*/, IFM_H, IFM_W, IFM_C} /* dims */, quantization);
2, kTfLiteUInt8 /* type */, "filter" /* name */, {1, KER_H, KER_W, KER_C} /* dims */,
quantization, reinterpret_cast<const char *>(kernel_data), kernel_size * sizeof(uint8_t));
+ quantization.scale *= quantization.scale;
interp.SetTensorParametersReadOnly(
3, kTfLiteInt32 /* type */, "bias" /* name */, {bias_size} /* dims */, quantization,
reinterpret_cast<const char *>(bias_data), bias_size * sizeof(int32_t));