Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4a99b673
提交
4a99b673
authored
3月 13, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
3月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix Elemwise dimension checks for Python implementations
上级
c6dbdccb
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
35 行删除
+17
-35
elemwise.py
aesara/tensor/elemwise.py
+3
-24
test_vm.py
tests/link/test_vm.py
+14
-11
没有找到文件。
aesara/tensor/elemwise.py
浏览文件 @
4a99b673
...
@@ -736,30 +736,9 @@ second dimension
...
@@ -736,30 +736,9 @@ second dimension
# should be disabled.
# should be disabled.
super
()
.
perform
(
node
,
inputs
,
output_storage
)
super
()
.
perform
(
node
,
inputs
,
output_storage
)
for
dims
in
zip
(
for
d
,
dim_shapes
in
enumerate
(
zip
(
*
(
i
.
shape
for
i
in
inputs
))):
*
[
if
len
(
set
(
dim_shapes
)
-
{
1
})
>
1
:
list
(
zip
(
input
.
shape
,
sinput
.
type
.
broadcastable
))
raise
ValueError
(
f
"Shapes on dimension {d} do not match: {dim_shapes}"
)
for
input
,
sinput
in
zip
(
inputs
,
node
.
inputs
)
]
):
if
max
(
d
for
d
,
b
in
dims
)
!=
1
and
(
1
,
False
)
in
dims
:
# yes there may be more compact ways to write this code,
# but please maintain python 2.4 compatibility
# (no "x if c else y")
msg
=
[]
assert
len
(
inputs
)
==
len
(
node
.
inputs
)
for
input
,
sinput
in
zip
(
inputs
,
node
.
inputs
):
assert
len
(
input
.
shape
)
==
len
(
sinput
.
type
.
broadcastable
)
msg2
=
[]
for
d
,
b
in
zip
(
input
.
shape
,
sinput
.
type
.
broadcastable
):
if
b
:
msg2
+=
[
"*"
]
else
:
msg2
+=
[
str
(
d
)]
msg
.
append
(
f
"({', '.join(msg2)})"
)
base_exc_str
=
f
"Dimension mismatch; shapes are {', '.join(msg)}"
raise
ValueError
(
base_exc_str
)
# Determine the shape of outputs
# Determine the shape of outputs
out_shape
=
[]
out_shape
=
[]
...
...
tests/link/test_vm.py
浏览文件 @
4a99b673
...
@@ -57,24 +57,27 @@ class TestCallbacks:
...
@@ -57,24 +57,27 @@ class TestCallbacks:
assert
self
.
n_callbacks
[
"IfElse"
]
==
2
assert
self
.
n_callbacks
[
"IfElse"
]
==
2
def
test_c_thunks
():
def
test_use_c_thunks
():
a
=
scalars
(
"a"
)
a_at
=
scalars
(
"a"
)
b
,
c
=
vectors
(
"bc"
)
b_at
=
vectors
(
"b"
)
a
=
np
.
array
(
0.0
)
.
astype
(
config
.
floatX
)
b
=
np
.
array
([
2.0
])
.
astype
(
config
.
floatX
)
cases
=
[
False
]
cases
=
[
False
]
if
config
.
cxx
:
if
config
.
cxx
:
cases
.
append
(
True
)
cases
.
append
(
True
)
for
c_thunks
in
cases
:
for
use_c_thunks
in
cases
:
f
=
function
(
f
=
function
(
[
a
,
b
,
c
],
[
a
_at
,
b_at
],
ifelse
(
a
,
a
*
b
,
b
*
c
)
,
a_at
*
b_at
,
mode
=
Mode
(
mode
=
Mode
(
optimizer
=
None
,
linker
=
VMLinker
(
c_thunks
=
c_thunks
,
use_cloop
=
False
)
optimizer
=
None
,
linker
=
VMLinker
(
c_thunks
=
use_
c_thunks
,
use_cloop
=
False
)
),
),
)
)
f
(
1
,
[
2
],
[
3
,
2
])
assert
np
.
array_equal
(
a
*
b
,
f
(
a
,
b
))
with
pytest
.
raises
(
ValueError
):
assert
any
([
hasattr
(
t
,
"cthunk"
)
for
t
in
f
.
fn
.
thunks
])
==
use_c_thunks
f
(
0
,
[
2
],
[
3
,
4
])
assert
any
([
hasattr
(
t
,
"cthunk"
)
for
t
in
f
.
fn
.
thunks
])
==
c_thunks
@pytest.mark.skipif
(
@pytest.mark.skipif
(
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论