[Tracking Issue][TFLite] Expand unit test coverage for supported non-quantized operators
We just rebuilt the TFLite frontend.
Today, tests/python/relax/test_frontend_tflite.py already covers a subset of operators, including some via parametrized tests (for example RELU, RELU6, TANH, SOFTMAX, LOGISTIC, ARG_MIN, and ARG_MAX). However, its test coverage is still not enough.
This issue tracks adding operator-focused unit tests for supported non-quantized operators that are still under-tested or currently have no explicit coverage in the Relax TFLite frontend.
Candidate operators to cover
The list below is based on the current Relax frontend implementation and the current contents of tests/python/relax/test_frontend_tflite.py.
Shape / indexing / layout
- [x]
SQUEEZE - [x]
STRIDED_SLICE - [x]
SLICE - [x]
SHAPE - [x]
SELECT/WHERE - [x]
GATHER - [x]
GATHER_ND - [x]
REVERSE_V2 - [x]
REVERSE_SEQUENCE - [x]
TILE - [x]
UNPACK - [x]
ZEROS_LIKE - [x]
RANGE - [x]
SPLIT_V - [x]
SPACE_TO_BATCH_ND - [x]
BATCH_TO_SPACE_ND - [x]
DEPTH_TO_SPACE - [x]
SPACE_TO_DEPTH
Elementwise / activation / comparison / normalization
- [x]
HARD_SWISH - [x]
LEAKY_RELU - [x]
RELU_N1_TO_1 - [x]
PRELU - [x]
LOG - [x]
LOG_SOFTMAX - [x]
SQUARED_DIFFERENCE - [x]
GREATER - [x]
GREATER_EQUAL - [x]
L2_NORMALIZATION - [x]
LOCAL_RESPONSE_NORMALIZATION
Reductions
- [x]
MEAN - [x]
REDUCE_MAX - [x]
REDUCE_MIN - [x]
REDUCE_PROD - [x]
SUM
Resize
- [x]
RESIZE_BILINEAR - [x]
RESIZE_NEAREST_NEIGHBOR
Convolution / linear / pooling
- [x]
FULLY_CONNECTED - [x]
DEPTHWISE_CONV_2D - [x]
TRANSPOSE_CONV - [x]
L2_POOL_2D
Padding / sparse / other
- [x]
PAD - [x]
PADV2 - [x]
MIRROR_PAD - [x]
ONE_HOT - [x]
MATRIX_DIAG - [x]
MATRIX_SET_DIAG - [x]
TOPK_V2 - [x]
SPARSE_TO_DENSE - [x]
DENSIFY(sparse-to-dense tensor; may need a network-level test rather than a simple unit test)
Suggested contribution style
- Small PRs are welcome. A PR can add coverage for one operator or a small related group of operators.
- Please reuse the existing test style in
tests/python/relax/test_frontend_tflite.py. - For simple conversions, checking the generated Relax IR with
tvm.ir.assert_structural_equalis preferred. We really appreciate you provideExpected IRModuleto test those ops - For larger operators, using the existing
verify(...)helper pattern is also fine, following current tests in the file. - Numerical E2E checks should continue to follow the current nightly-only behavior guarded
by
CI_ENV_NIGHTLY.
Useful reference
The old Relay test file is a good source of test shapes, edge cases, and operator-specific scenarios:
tests/python/frontend/tflite/test_forward.pyat commit292ecfd210
Notes for contributors
This is a good-first-issue / parallelizable tracking issue:
- each operator test is mostly independent
- multiple PRs can land in parallel
- contributors can reference this issue and check off the operator(s) covered by their PR
If you pick this up, please mention which operator(s) your PR adds coverage for. And if you find some issues with existed ops when adding tests, you're welcome to fix them as well!
cc @leandron
Hi @tlopex — I’d like to pick up Relax TFLite frontend test coverage for these five non-quantized ops: GREATER, GREATER_EQUAL, LOG, SQUEEZE, and ZEROS_LIKE. I’ll follow the existing style in tests/python/relax/test_frontend_tflite.py (structural verify / Expected IR where reasonable). Please let me know if any of these already have an open PR. Thanks!
Hi @tlopex, I would like to work on the activation/elementwise group. I will add test coverage for HARD_SWISH, LEAKY_RELU, RELU_N1_TO_1, PRELU, LOG, and LOG_SOFTMAX in a single PR. Following the existing assert_structural_equal style with explicit Expected IRModules.
Hi @tlopex , i'd like to work on the "Reductions" Group: SUM, MEAN, REDUCE_MAX, REDUCE_MIN, REDUCE_PROD
i'll cover them in one PR
Hi @tlopex, I want to claim RESIZE_BILINEAR and RESIZE_NEAREST_NEIGHBOR
hey @tlopex I'd claim L2_NORMALIZATION
SLICE, REVERSE_V2
Hi @tlopex, I'd like to claim SHAPE, TILE, and RANGE.
I'll submit them together in a single PR.
hey @tlopex I'd claim L2_NORMALIZATION
SLICE, REVERSE_V2 and Convolution / linear / pooling I’ll submit the pr soon
Hi @tlopex, I want to clain SQUARED_DIFFERENCE and LOCAL_RESPONSE_NORMALIZATION
Hi, I'd like to contribute coverage for the following operators from the Padding / Sparse / Other category:
PADPADV2MIRROR_PAD(REFLECT mode)TOPK_V2ONE_HOT
I also found and fixed two bugs in the existing converter implementations while writing the tests:
convert_mirror_pad: calledrelax.op.nn.mirror_padwhich does not exist in the Relax op namespace. Fixed to userelax.op.nn.padwithpad_mode="reflect"for REFLECT mode.convert_one_hot: passedon_value/off_valueasExpr(constant tensors) where the op signature requiresPrimValue, and passed an extradtypeargument that the function does not accept. Fixed to extract the scalar value and wrap inrelax.PrimValue.
I'll open a PR shortly.
Hi @tlopex, I'd like to claim the following three operators:
- SELECT / WHERE
- DEPTH_TO_SPACE
- SPACE_TO_DEPTH
I'll submit them together in a single PR.
Hi @tlopex , I would like to claim and work on the following operators:
MATRIX_DIAGMATRIX_SET_DIAGSPARSE_TO_DENSEDENSIFY(I noted the requirement that this might need a network-level test rather than a simple unit test, and I will look into it.)
I will add test coverage by PR one by one, following the existing assert_structural_equal style with explicit Expected IRModules.
hi @tlopex I would like to work on GATHER and GATHER_ND
hi @tlopex I'd claim PRELU LOCAL_RESPONSE_NORMALIZATION SQUARED_DIFFERENCE
hey @tlopex I'd claim and work on STRIDED_SLICE and SPLIT_V
Hi @tlopex, I'd like to claim the remaining shape/layout ops: REVERSE_SEQUENCE, UNPACK, SPACE_TO_BATCH_ND, and BATCH_TO_SPACE_ND.
Hi @tlopex, I’d like to pick up TFLite GATHER and GATHER_ND coverage in tests/python/relax/test_frontend_tflite.py (tracking issue #18971). I’ll follow the existing style in the file (explicit expected IRModules + tvm.ir.assert_structural_equal, using verify() if needed) and send a single PR.
Hi @tlopex, I’d like to pick up the remaining unchecked TFLite non-quantized operator coverage items in this tracking issue:
SQUEEZEREVERSE_SEQUENCEUNPACKZEROS_LIKE
I’ll add them together in one PR, following the existing tests/python/relax/test_frontend_tflite.py style with explicit Expected IRModules / structural equality where practical.
Thanks everyone for the contributions and discussions! The issue is now resolved.