Skip to content

[relax][frontend][tflite] Add tests for fully_connected/depthwise_conv2d/transpose_conv/l2_pool2d#19372

Merged
tlopex merged 6 commits intoapache:mainfrom
0xjah:pr/tflite-relax-conv-linear-pooling-tests
Apr 12, 2026
Merged

[relax][frontend][tflite] Add tests for fully_connected/depthwise_conv2d/transpose_conv/l2_pool2d#19372
tlopex merged 6 commits intoapache:mainfrom
0xjah:pr/tflite-relax-conv-linear-pooling-tests

Conversation

@0xjah
Copy link
Copy Markdown
Contributor

@0xjah 0xjah commented Apr 8, 2026

This PR adds Relax TFLite frontend test coverage for:

  • FULLY_CONNECTED
  • DEPTHWISE_CONV_2D
  • TRANSPOSE_CONV
  • L2_POOL_2D

Part of fixing #18971.

Copy link
Copy Markdown
Contributor

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

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 adds new test cases for the TFLite frontend, covering the fully_connected, depthwise_conv2d, transpose_conv, and l2_pool2d operators. It is recommended to include structural checks with expected IR modules in these tests to verify the correct lowering of operators and enhance test robustness.

Comment thread tests/python/relax/test_frontend_tflite.py Outdated
…ility

- Fix test_depthwise_conv2d: Correct kernel shape from (3,3,2,2) to (3,3,1,2)
  - For depthwise convolution with 2 input channels and grouping, kernel should have shape
    (height, width, input_channels_per_group, depth_multiplier) = (3, 3, 1, 2)
  - This matches the format required by tf.nn.depthwise_conv2d

- Fix test_l2_pool2d: Replace deprecated tf.compat.v1.nn.l2_pool with tf.nn.pool
  - tf.compat.v1.nn.l2_pool is no longer available in current TensorFlow versions
  - Use tf.nn.pool with AVG pooling type and appropriate window shape and strides
@tlopex
Copy link
Copy Markdown
Member

tlopex commented Apr 9, 2026

Please have a look at the CI and fix it as well :)

Changed kernel shape from (3,3,1,2) to (3,3,2,1) because:
- Input shape is (1,8,8,2) with 2 channels
- depthwise_conv2d filter format: [height, width, in_channels, depth_multiplier]
- With 2 input channels, third dimension must be 2 (not 1)
- Using (3,3,2,1) means 2 output channels (one multiplier per input channel)
@OmarAzizi
Copy link
Copy Markdown
Contributor

The CI is failing because tflite_frontend.py:3093 calls relax.op.nn.conv2d_transpose() with channels= which is not a valid parameter. The correct keyword argument is out_channels=.

Please fix convert_transpose_conv in tflite_frontend.py to use out_channels= instead, otherwise this test will never pass.

0xjah and others added 2 commits April 11, 2026 20:38
@tlopex tlopex merged commit e5d4c55 into apache:main Apr 12, 2026
8 checks passed
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.

3 participants