Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5248aa9a
提交
5248aa9a
authored
7月 15, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
7月 15, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug in broadcast_shape_iter when all dims are broadcastable
上级
95deb922
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
16 行增加
和
20 行删除
+16
-20
extra_ops.py
aesara/tensor/extra_ops.py
+2
-2
test_extra_ops.py
tests/tensor/test_extra_ops.py
+14
-18
没有找到文件。
aesara/tensor/extra_ops.py
浏览文件 @
5248aa9a
...
...
@@ -1560,11 +1560,11 @@ def broadcast_shape_iter(
non_bcast_vec
=
aet
.
as_tensor
(
maybe_non_bcast_shapes
)
non_bcast_vec
=
aet
.
switch
(
eq
(
non_bcast_vec
,
1
),
-
one_at
,
non_bcast_vec
)
dim_max
=
aet_
max
(
non_bcast_vec
)
dim_max
=
aet_
abs
(
aet_max
(
non_bcast_vec
)
)
assert_dim
=
Assert
(
"Could not broadcast dimensions"
)
assert_cond
=
aet_all
(
or_
(
eq
(
non_bcast_vec
,
-
one_at
),
eq
(
non_bcast_vec
,
aet_abs
(
dim_max
)
))
or_
(
eq
(
non_bcast_vec
,
-
one_at
),
eq
(
non_bcast_vec
,
dim_max
))
)
bcast_dim
=
assert_dim
(
dim_max
,
assert_cond
)
...
...
tests/tensor/test_extra_ops.py
浏览文件 @
5248aa9a
...
...
@@ -1073,29 +1073,25 @@ def test_broadcast_shape_basic():
[
((
2
,
2
),
(
1
,
2
),
(
2
,
2
)),
((
0
,
2
),
(
1
,
2
),
(
0
,
2
)),
((
1
,
2
,
1
),
(
2
,
1
,
2
,
1
),
(
2
,
1
,
2
,
1
)),
],
)
@config.change_flags
(
compute_test_value
=
"raise"
)
def
test_broadcast_shape_symbolic
(
s1_vals
,
s2_vals
,
exp_res
):
s1_1
,
s1_2
=
aet
.
lscalars
(
"s1_1"
,
"s1_2"
)
s2_1
,
s2_2
=
aet
.
lscalars
(
"s2_1"
,
"s2_2"
)
s1_1
.
tag
.
test_value
=
s1_vals
[
0
]
s1_2
.
tag
.
test_value
=
s1_vals
[
1
]
s2_1
.
tag
.
test_value
=
s2_vals
[
0
]
s2_2
.
tag
.
test_value
=
s2_vals
[
1
]
res
=
broadcast_shape
((
s1_1
,
s1_2
),
(
s2_1
,
s2_2
),
arrays_are_shapes
=
True
)
s1s
=
aet
.
lscalars
(
len
(
s1_vals
))
eval_point
=
{}
for
s
,
s_val
in
zip
(
s1s
,
s1_vals
):
eval_point
[
s
]
=
s_val
s
.
tag
.
test_value
=
s_val
s2s
=
aet
.
lscalars
(
len
(
s2_vals
))
for
s
,
s_val
in
zip
(
s2s
,
s2_vals
):
eval_point
[
s
]
=
s_val
s
.
tag
.
test_value
=
s_val
res
=
broadcast_shape
(
s1s
,
s2s
,
arrays_are_shapes
=
True
)
res
=
aet
.
as_tensor
(
res
)
assert
(
tuple
(
res
.
eval
(
{
s1_1
:
s1_vals
[
0
],
s1_2
:
s1_vals
[
1
],
s2_1
:
s2_vals
[
0
],
s2_2
:
s2_vals
[
1
]}
)
)
==
exp_res
)
assert
tuple
(
res
.
eval
(
eval_point
))
==
exp_res
class
TestBroadcastTo
(
utt
.
InferShapeTester
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论