Skip to content

Commit

Permalink
Remove use of unbroadcast in broadcast_like
Browse files Browse the repository at this point in the history
This change was introduced in 9a45333 and did not include specific tests. It was likely introduced to cope with the old restrictions regarding rewrite substitution of variables with different static broadcastable shape information, which was alleviated in #711
  • Loading branch information
Ricardo authored and brandonwillard committed Jul 7, 2022
1 parent 2066065 commit ac52d68
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions aesara/tensor/basic_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
stack,
switch,
tensor_copy,
unbroadcast,
zeros,
zeros_like,
)
Expand Down Expand Up @@ -151,26 +150,8 @@ def broadcast_like(value, template, fgraph, dtype=None):
else:
new_shape = template.shape
rval = alloc(value, *new_shape)
# the template may have 1s in its shape without being broadcastable
if rval.broadcastable != template.broadcastable:
rval = unbroadcast(
rval,
*[
i
for i in range(rval.ndim)
if rval.broadcastable[i] and not template.broadcastable[i]
],
)
assert rval.type.dtype == dtype

if rval.type.broadcastable != template.broadcastable:
raise AssertionError(
"rval.type.broadcastable is "
+ str(rval.type.broadcastable)
+ " but template.broadcastable is"
+ str(template.broadcastable)
)

return rval


Expand Down

0 comments on commit ac52d68

Please sign in to comment.