From f71f826f9c1d7e443a3fdad1ec5b0707bd45935a Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Tue, 6 Aug 2024 15:39:23 -0600 Subject: [PATCH] Use conj_physical for torch.conj torch.conj sets the conjugation bit, which breaks other libraries. Fixes #173. --- array_api_compat/torch/_aliases.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/array_api_compat/torch/_aliases.py b/array_api_compat/torch/_aliases.py index c2be21f..d0f4a5c 100644 --- a/array_api_compat/torch/_aliases.py +++ b/array_api_compat/torch/_aliases.py @@ -145,6 +145,9 @@ def can_cast(from_: Union[Dtype, array], to: Dtype, /) -> bool: # Basic renames bitwise_invert = torch.bitwise_not newaxis = None +# torch.conj sets the conjugation bit, which breaks conversion to other +# libraries. See https://github.com/data-apis/array-api-compat/issues/173 +conj = torch.conj_physical # Two-arg elementwise functions # These require a wrapper to do the correct type promotion on 0-D tensors