Gets the current TfLiteQuantization from the legacy fLiteQuantizationParams.
| 54 | |
| 55 | // Gets the current TfLiteQuantization from the legacy fLiteQuantizationParams. |
| 56 | TfLiteQuantization GetQuantizationFromLegacy( |
| 57 | const TfLiteQuantizationParams& legacy_quantization) { |
| 58 | TfLiteQuantization quantization; |
| 59 | quantization.type = kTfLiteAffineQuantization; |
| 60 | auto* affine_quantization = reinterpret_cast<TfLiteAffineQuantization*>( |
| 61 | malloc(sizeof(TfLiteAffineQuantization))); |
| 62 | affine_quantization->scale = TfLiteFloatArrayCreate(1); |
| 63 | affine_quantization->zero_point = TfLiteIntArrayCreate(1); |
| 64 | affine_quantization->scale->data[0] = legacy_quantization.scale; |
| 65 | affine_quantization->zero_point->data[0] = legacy_quantization.zero_point; |
| 66 | quantization.params = affine_quantization; |
| 67 | |
| 68 | return quantization; |
| 69 | } |
| 70 | |
| 71 | } // namespace |
| 72 |
no test coverage detected