Aharrypotter opened a new pull request, #20474: URL: https://github.com/apache/tvm/pull/20474
## Summary Follow up on the quantized average-pooling review in #20291. The TFLite frontend currently lowers quantized `AVERAGE_POOL_2D` through integer `R.nn.avg_pool2d`, which does not implement TFLite's nearest-integer rounding. For example, an int8 window averaging `0.5` must produce `1`, and one averaging `-0.5` must produce `-1`. ## Design Lower quantized average pooling through a frontend-local TE computation: accumulate in int32, count only valid input elements at padded boundaries, and round ties away from zero using signed truncating division. Preserve the existing equal-quantization-parameter check and fused activation handling. This keeps the TFLite-specific integer rounding policy out of the generic Relax pooling operator. Floating-point average pooling, max pooling, and L2 pooling are unchanged. ## Tests Replace the cast-only structural check in the existing `test_frontend_tflite.py` with a small numerical regression through the public importer and LLVM VM, comparing integer outputs exactly with the TFLite interpreter. The 16 cases cover int8/uint8, VALID/SAME padding, NONE/RELU6 activation, even/odd window sizes, half ties, dtype limits, and nonzero zero points. No model E2E or separate nightly test file is added. Local validation with a fresh LLVM build: ```text python -m pytest tests/python/relax/test_frontend_tflite.py -k quantized_avg_pool2d_rounding -q 16 passed python -m pytest tests/python/relax/test_frontend_tflite.py -k '(pool2d or quantized) and not quantized_avg_pool2d_rounding' -q 17 passed pre-commit run --all-files Passed ``` As a regression check, restoring only the original `convert_pool2d` implementation makes all 16 new numerical cases fail with output mismatches. The full frontend suite and model E2E were not rerun for this follow-up. ## References - [Follow-up requested in #20291](https://github.com/apache/tvm/pull/20291#pullrequestreview-5149634471) - [TFLite integer average-pooling reference](https://github.com/tensorflow/tensorflow/blob/v2.18.0/tensorflow/lite/kernels/internal/reference/integer_ops/pooling.h#L21-L79) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
