Skip to content

[Relax][TFLite] Fix and test DEPTH_TO_SPACE/SPACE_TO_DEPTH, SELECT ops#19381

Merged
tlopex merged 1 commit intoapache:mainfrom
zhengkezhou1:tests/18971-select-depth-space-to-depth
Apr 10, 2026
Merged

[Relax][TFLite] Fix and test DEPTH_TO_SPACE/SPACE_TO_DEPTH, SELECT ops#19381
tlopex merged 1 commit intoapache:mainfrom
zhengkezhou1:tests/18971-select-depth-space-to-depth

Conversation

@zhengkezhou1
Copy link
Copy Markdown
Contributor

Summary

part of: #18971

  • Fix DEPTH_TO_SPACE and SPACE_TO_DEPTH converters in the TFLite Relax frontend that were calling non-existent relax.op.nn.depth_to_space / relax.op.nn.space_to_depth, causing AttributeError at runtime
  • Add unit tests for SELECT/WHERE, DEPTH_TO_SPACE, and SPACE_TO_DEPTH operators

…tests for SELECT, DEPTH_TO_SPACE, SPACE_TO_DEPTH
block_size = space_to_depth_options.BlockSize()
out = relax.op.nn.space_to_depth(in_expr, block_size, layout="NHWC")

# TFLite uses NHWC layout: (N, H, W, C) -> (N, H/bs, W/bs, C*bs*bs)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

convert_depth_to_space and convert_space_to_depth in tflite_frontend.py call
relax.op.nn.depth_to_space / space_to_depth, but these ops don't exist in Relax,
causing AttributeError at runtime.

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 updates the TFLite frontend for TVM Relax, specifically reimplementing the depth_to_space and space_to_depth operators. Instead of using the high-level Relax operations, these are now implemented using a sequence of reshape and permute_dims to explicitly handle the NHWC layout used by TFLite. Additionally, the PR includes several formatting improvements across the frontend and test suite, and introduces new unit tests for the select, depth_to_space, and space_to_depth operators. I have no feedback to provide as there were no review comments to evaluate.

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. Thank you for the contribution!

@tlopex tlopex merged commit 8932bc6 into apache:main Apr 10, 2026
11 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