提交 ac52d689 authored 作者: Ricardo's avatar Ricardo 提交者: Brandon T. Willard

Remove use of unbroadcast in broadcast_like

This change was introduced in 9a453338 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
上级 2066065d
......@@ -64,7 +64,6 @@ from aesara.tensor.basic import (
stack,
switch,
tensor_copy,
unbroadcast,
zeros,
zeros_like,
)
......@@ -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
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论