Skip to content

support for scalars in logical_(and|not|or|xor) #58740

@pmeier

Description

@pmeier

The array API specification stipulates that the operators logical_(and|not|or|xor) should accept one scalar the same way arithmetic functions do.

PyTorch currently does not support that, although the magic methods seem to work just fine:

import torch

a = torch.tensor(True)
b = True

assert a & b
assert torch.logical_and(a, b)
tensor(True)
TypeError: logical_and(): argument 'other' (position 2) must be Tensor, not bool

cc @mruberry @rgommers @pmeier

Metadata

Metadata

Assignees

No one assigned

    Labels

    triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions