Skip to content

[Relax][Frontend] Add TFLite Frontend Support for CONV_3D_TRANSPOSE#19530

Merged
tlopex merged 1 commit into
apache:mainfrom
weicheng-hsu:relax/tflite-conv3d-transpose
May 11, 2026
Merged

[Relax][Frontend] Add TFLite Frontend Support for CONV_3D_TRANSPOSE#19530
tlopex merged 1 commit into
apache:mainfrom
weicheng-hsu:relax/tflite-conv3d-transpose

Conversation

@weicheng-hsu
Copy link
Copy Markdown
Contributor

This commit adds support for the CONV_3D_TRANSPOSE operator in the Relax TFLite frontend.

Key implementations:

  • Registered CONV_3D_TRANSPOSE to the TFLite op map.
  • Implemented convert_conv3d_transpose which shares Conv3DOptions with regular Conv3D but handles the distinct tensor input layout [output_shape, weight, data, bias] and the DHWOI kernel layout.
  • Added calculation for SAME padding that correctly handles transposed convolution semantics, computing padding and output_padding based on dilated kernel and stride sizes.
  • Added comprehensive unit tests for valid and same padding in test_frontend_tflite.py.

Testing:

  • python3 -m pytest tests/python/relax/test_frontend_tflite.py -k "test_conv3d_transpose"

Related to: #19519

This commit adds support for the CONV_3D_TRANSPOSE operator in the
Relax TFLite frontend.

Key implementations:
- Registered CONV_3D_TRANSPOSE to the TFLite op map.
- Implemented convert_conv3d_transpose which shares Conv3DOptions
  with regular Conv3D but handles the distinct tensor input layout
  [output_shape, weight, data, bias] and the DHWOI kernel layout.
- Added calculation for SAME padding that correctly handles transposed
  convolution semantics, computing padding and output_padding based
  on dilated kernel and stride sizes.
- Added comprehensive unit tests for valid and same padding in
  test_frontend_tflite.py.
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 introduces support for the CONV_3D_TRANSPOSE operator in the TFLite frontend for Relax, including the implementation of the conversion logic and associated unit tests for different padding modes. The feedback recommends minor code cleanups, such as using underscores for unused variables and adopting relax.op.nn.bias_add for better consistency with other convolution implementations.

padding = conv3d_options.Padding()
fused_activation_fn = conv3d_options.FusedActivationFunction()

_, input_d, input_h, input_w, input_c = to_int_list(self.get_tensor_shape(input_tensor))
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.

medium

The variables input_d, input_h, and input_w are extracted from the input tensor shape but are not used in the subsequent logic, including the padding calculations. For clarity and to avoid unused variable warnings, they can be replaced with underscores.

Suggested change
_, input_d, input_h, input_w, input_c = to_int_list(self.get_tensor_shape(input_tensor))
_, _, _, _, input_c = to_int_list(self.get_tensor_shape(input_tensor))

dtype=bias_tensor_type_str,
source_name=bias_tensor.tensor.Name(),
)
out = relax.op.add(out, bias_expr)
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.

medium

While relax.op.add works for adding bias due to broadcasting, using relax.op.nn.bias_add is generally preferred for neural network layers as it explicitly targets the channel dimension and is more robust to layout variations. This would also be consistent with the implementation of convert_transpose_conv (2D) in this frontend.

Suggested change
out = relax.op.add(out, bias_expr)
out = relax.op.nn.bias_add(out, bias_expr, axis=4)

Copy link
Copy Markdown
Member

@tlopex tlopex left a comment

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 2c76c79 into apache:main May 11, 2026
10 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.

2 participants