Skip to content

BUG: torch: work around torch.round not supporting complex inputs#408

Merged
ev-br merged 1 commit intodata-apis:mainfrom
ev-br:torch_round
Mar 17, 2026
Merged

BUG: torch: work around torch.round not supporting complex inputs#408
ev-br merged 1 commit intodata-apis:mainfrom
ev-br:torch_round

Conversation

@ev-br
Copy link
Member

@ev-br ev-br commented Mar 17, 2026

closes gh-407

@ev-br ev-br added this to the 1.15 milestone Mar 17, 2026
@ev-br ev-br added the bug Something isn't working label Mar 17, 2026
Copilot AI review requested due to automatic review settings March 17, 2026 09:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a PyTorch-backend compatibility shim so array_api_compat.torch.round works on complex tensors (matching array-api-tests expectations), and removes the corresponding expected-failure entry.

Changes:

  • Add a round() wrapper in array_api_compat/torch/_aliases.py that rounds complex inputs by rounding real/imag parts separately.
  • Export the new alias via _aliases.__all__ so it overrides torch.round in the cloned namespace.
  • Remove test_round from torch-xfails.txt now that complex rounding is supported.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
array_api_compat/torch/_aliases.py Introduces and exports a complex-safe round() wrapper for the torch backend.
torch-xfails.txt Drops the xfail for test_round because the torch backend now supports complex rounding.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ev-br ev-br force-pushed the torch_round branch 2 times, most recently from 349cde4 to d63541d Compare March 17, 2026 10:07
Copy link

@mdhaber mdhaber left a comment

Choose a reason for hiding this comment

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

Thanks!

@ev-br ev-br merged commit 0b251a6 into data-apis:main Mar 17, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

array_api_compat.torch.round raises NotImplementedError for complex input

3 participants