Skip to content

Commit 8d9c142

Browse files
committed
when shape or broadcasting specified do not set the default shape and broadcasting
1 parent b5a5024 commit 8d9c142

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pytensor/tensor/type.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,14 @@ def __init__(
144144
def clone(
145145
self, dtype=None, shape=None, broadcastable=None, **kwargs
146146
) -> "TensorType":
147-
if broadcastable is None:
147+
if broadcastable is None and shape is None:
148+
# only default to passby broadcast when shape is also None
149+
# otherwise shape changes affect broadcasting patterns and
150+
# inconsistencies
148151
broadcastable = self.broadcastable
152+
shape = self.shape
149153
if dtype is None:
150154
dtype = self.dtype
151-
if shape is None:
152-
shape = self.shape
153155
return type(self)(dtype, shape, name=self.name, broadcastable=broadcastable)
154156

155157
def filter(self, data, strict=False, allow_downcast=None):

0 commit comments

Comments
 (0)