Skip to content

[Relax][Frontend][TFLite] Add ATAN2 op and TFLite mapping#19485

Merged
tlopex merged 1 commit into
apache:mainfrom
as4230:feat/relax-atan2-op
May 1, 2026
Merged

[Relax][Frontend][TFLite] Add ATAN2 op and TFLite mapping#19485
tlopex merged 1 commit into
apache:mainfrom
as4230:feat/relax-atan2-op

Conversation

@as4230

@as4230 as4230 commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

This PR adds the ATAN2 operator to the Relax TFLite frontend.

Introduces relax.op.atan2 as a new binary elementwise primitive (TOPI broadcast op, Relax registration, legalization to topi.atan2, script parser support) and registers ATAN2 in the TFLite convert_map. It reuses the TIR primitive tvm::atan2 so this PR is the higher-layer plumbing.

Validation:
python -m pytest tests/python/relax/test_op_binary.py
python -m pytest tests/python/relax/test_frontend_tflite.py -k binary

Addresses the ATAN2 item under #19412.

@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 the atan2 operator with auto-broadcasting support across TVM's Relax and TOPI frameworks, including TFLite frontend integration, operator legalization, and comprehensive testing. The review feedback focuses on improving the documentation in broadcast.h, binary.py, and broadcast.py to explicitly clarify the parameter order as atan2(y, x), aligning with standard mathematical conventions to prevent potential misuse.

Comment thread include/tvm/topi/broadcast.h Outdated
Comment thread python/tvm/relax/op/binary.py Outdated
Comment thread python/tvm/topi/broadcast.py Outdated
@as4230 as4230 force-pushed the feat/relax-atan2-op branch from 28261c8 to ac3f586 Compare April 30, 2026 23:02

@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.

Overalll LGTM! Please add legalize tests for atan2 in tests/python/relax/test_transform_legalize_ops_binary.py as well

This PR adds the ATAN2 operator to the Relax TFLite frontend.

Introduces relax.op.atan2 as a new binary elementwise primitive (TOPI
broadcast op, Relax registration, legalization to topi.atan2, script
parser support) and registers ATAN2 in the TFLite convert_map.
It reuses the TIR primitive tvm::atan2 so this PR is the higher-layer plumbing.

Validation:
    python -m pytest tests/python/relax/test_op_binary.py
    python -m pytest tests/python/relax/test_frontend_tflite.py -k binary

Addresses the ATAN2 item under apache#19412.
@as4230 as4230 force-pushed the feat/relax-atan2-op branch from ac3f586 to b3d83c7 Compare May 1, 2026 02:43
@as4230

as4230 commented May 1, 2026

Copy link
Copy Markdown
Contributor Author

Overalll LGTM! Please add legalize tests for atan2 in tests/python/relax/test_transform_legalize_ops_binary.py as well

Done. I added test_atan2, test_atan2_symbolic, and test_atan2_primvalue in test_transform_legalize_ops_binary.py.

@as4230 as4230 requested a review from tlopex May 1, 2026 02:46
@tlopex tlopex merged commit 772857d into apache:main May 1, 2026
9 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