Skip to content

[Relax][TFLite] Add test coverage for Reduction operations (#18971)#19370

Merged
tlopex merged 1 commit into
apache:mainfrom
rknastenka:tests
Apr 8, 2026
Merged

[Relax][TFLite] Add test coverage for Reduction operations (#18971)#19370
tlopex merged 1 commit into
apache:mainfrom
rknastenka:tests

Conversation

@rknastenka

@rknastenka rknastenka commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Closes part of #18971


Description

This PR improves the test coverage of the TFLite frontend to Relax converter by adding comprehensive tests for the "Reductions" group.

Operations covered:

  • SUM (tf.reduce_sum)
  • MEAN (tf.reduce_mean)
  • REDUCE_MAX (tf.reduce_max)
  • REDUCE_MIN (tf.reduce_min)
  • REDUCE_PROD (tf.reduce_prod)

Changes made:

  • Added a parameterized testing function (test_reduction_ops) to cover combinations of the aforementioned reduction operators.
  • Covered a variety of axis configurations, including positive scalars, lists of axes, negative indices, and None (global reduction).
  • Tested with different combinations of the keepdims flag (True/False) and dtypes (float32/int32).
  • Handled the representation of global reductions (axis=None) in the expected Relax IR Module _make_reduce_expected utility by expanding it to all input axes, perfectly mirroring the frontend's output graph structure (list(range(len(input_shape)))).

Testing

pytest tests/python/relax/test_frontend_tflite.py::test_reduction_ops
Screenshot 2026-04-08 102859

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive test suite for TFLite reduction operations in the Relax frontend, covering sum, mean, max, min, and product operations. It includes a new helper function, _make_reduce_expected, to generate the expected Relax modules and utilizes parameterized testing to verify various input shapes, reduction axes, data types, and dimension retention settings. I have no feedback to provide.

@tlopex tlopex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tlopex tlopex merged commit 643cf60 into apache:main Apr 8, 2026
11 checks passed
@rknastenka rknastenka deleted the tests branch May 3, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants