Add MLX op handler for aten.hardtanh#18986
Conversation
Adds a decomposed handler for aten.hardtanh that uses the existing ClipNode to implement bounded activation on Metal GPU. hardtanh(x, min_val=-1, max_val=1) = clamp(x, min_val, max_val) Fixes: pytorch#18921
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18986
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 19 New Failures, 2 Cancelled Jobs, 1 PendingAs of commit bed3054 with merge base 9ca0ff1 ( NEW FAILURES - The following jobs have failed:
CANCELLED JOBS - The following jobs were cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
|
@claude review |
|
Claude finished @nil-is-all's task in 3m 26s —— View job Review of PR #18986: Add MLX op handler for aten.hardtanh
Issue: Unrelated
|
| Item | Severity |
|---|---|
BitwiseOrNode line must be removed (breaks import) |
Blocking |
| Missing metadata should raise, not silently default | Medium |
| Verbose docstring | Nit |
| No test for custom min/max bounds | Minor |
The core hardtanh implementation is correct and well-structured. The main blocker is the unrelated bitwise_or line that will cause a runtime failure.
|
Overall looks great @Jah-yee! Can you address the comment on testing the min/max value bounds? Also copy/paste the output of your test run (python -m executorch.backends.mlx.test.run_all_tests -k hardtanh) in PR summary. |
metascroy
left a comment
There was a problem hiding this comment.
Add test cases for min/max value, and paste test output in PR summary :)
|
@Jah-yee, are you opening another PR to address this? |
Good day
This PR adds support for
aten.hardtanhin the MLX delegate backend, addressing issue #18921.Summary
Add a decomposed handler for
aten.hardtanhthat uses the existingClipNodeto implement bounded activation on Metal GPU.Changes
_hardtanh_handlerinbackends/mlx/ops.pyusing the decomposition:hardtanh(x, min_val, max_val) = clamp(x, min_val, max_val)Testing
References
aten.hardtanh#18921Thank you for your attention. If there are any issues or suggestions, please leave a comment and I will address them promptly.
Warmly,
RoomWithOutRoof
cc @metascroy