Skip to content

pt.specify_broadcastable does not work with negative axis values #698

Closed
@tomicapretto

Description

@tomicapretto

Description

If I use pt.specify_broadcastable with the second argument equal to -1 it does not do anything. It needs the value of the axis in order to work. See the example:

import pytensor.tensor as pt

tensor = pt.tensor(shape=(5, 1), broadcastable=(False, False))
print(tensor.broadcastable)

tensor2 = pt.specify_broadcastable(tensor, -1)
print(tensor2.broadcastable)

tensor3 = pt.specify_broadcastable(tensor, 1)
print(tensor3.broadcastable)
(False, False)
(False, False)
(False, True)

I'm using PyTensor version 2.20.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions