Skip to content

Support PyTorch angle and trig ops (deg2rad, rad2deg, hypot) - #2817

Open
jaseem-kurikkal wants to merge 1 commit into
apple:mainfrom
jaseem-kurikkal:feat/support-trig-deg2rad-rad2deg-hypot
Open

Support PyTorch angle and trig ops (deg2rad, rad2deg, hypot)#2817
jaseem-kurikkal wants to merge 1 commit into
apple:mainfrom
jaseem-kurikkal:feat/support-trig-deg2rad-rad2deg-hypot

Conversation

@jaseem-kurikkal

Copy link
Copy Markdown
Contributor

Summary

Adds support for PyTorch angle and trigonometric operators (deg2rad, rad2deg, and hypot) in the PyTorch converter frontend.

Context / Motivation

torch.deg2rad, torch.rad2deg, and torch.hypot are standard PyTorch operators commonly used in 3D computer vision, robotics, coordinate transformations, and audio processing. Previously, converting models utilizing these operators raised NotImplementedError.

Changes

  • Implemented deg2rad converter via mb.mul(x, pi / 180.0).
  • Implemented rad2deg converter via mb.mul(x, 180.0 / pi).
  • Implemented hypot converter via mb.sqrt(x^2 + y^2) with input dtype promotion.
  • Added parameterized unit test classes TestDeg2Rad, TestRad2Deg, and TestHypot in test_torch_ops.py covering TorchScript and TorchExport across all backend and compute unit permutations.

Testing

Ran:

pytest coremltools/converters/mil/frontend/torch/test/test_torch_ops.py -k "TestDeg2Rad or TestRad2Deg or TestHypot"

@TobyRoseman

Copy link
Copy Markdown
Collaborator

This change looks good.

CI: https://gitlab.com/coremltools1/coremltools/-/pipelines/2767302112

@TobyRoseman

Copy link
Copy Markdown
Collaborator

There are some unit test failures. Looks like some of these operations are not supported by executorch. Please skip the failed tests for that frontend.

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