Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3aff3d2f
提交
3aff3d2f
authored
9月 22, 2022
作者:
Ricardo Vieira
提交者:
Brandon T. Willard
9月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add tests for shared updates in JAX and NUMBA backends
* Also fixes bug in JITCompiler when first output of inner fgraph is an input variable, as can happen in some specific functions with updates
上级
864ee339
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
36 行增加
和
4 行删除
+36
-4
basic.py
aesara/link/basic.py
+3
-3
utils.py
aesara/link/utils.py
+1
-1
test_basic.py
tests/link/jax/test_basic.py
+16
-0
test_basic.py
tests/link/numba/test_basic.py
+16
-0
没有找到文件。
aesara/link/basic.py
浏览文件 @
3aff3d2f
...
...
@@ -641,7 +641,8 @@ class JITLinker(PerformLinker):
The JITed function that performs the computations.
"""
output_nodes
=
[
o
.
owner
for
o
in
self
.
fgraph
.
outputs
]
# This is a bit hackish, but we only return one of the output nodes
output_nodes
=
[
o
.
owner
for
o
in
self
.
fgraph
.
outputs
if
o
.
owner
is
not
None
][:
1
]
converted_fgraph
=
self
.
fgraph_convert
(
self
.
fgraph
,
...
...
@@ -678,8 +679,7 @@ class JITLinker(PerformLinker):
thunks
.
append
(
thunk
)
# This is a bit hackish, but we only return one of the output nodes
return
thunks
,
output_nodes
[:
1
],
fgraph_jit
return
thunks
,
output_nodes
,
fgraph_jit
def
make_all
(
self
,
input_storage
=
None
,
output_storage
=
None
,
storage_map
=
None
):
fgraph
=
self
.
fgraph
...
...
aesara/link/utils.py
浏览文件 @
3aff3d2f
...
...
@@ -243,7 +243,7 @@ def gc_helper(node_list: List[Apply]):
-------
2-tuple
FIRST, the set of Variable instances which are computed by node_list,
and SECOND a dictionary that maps each Variable instance to
a
the last
and SECOND a dictionary that maps each Variable instance to the last
node to use Variable as an input.
Extended Summary
...
...
tests/link/jax/test_basic.py
浏览文件 @
3aff3d2f
...
...
@@ -182,6 +182,22 @@ def test_shared():
np
.
testing
.
assert_allclose
(
jax_res
,
new_a_value
*
2
)
def
test_shared_updates
():
a
=
shared
(
0
)
aesara_jax_fn
=
function
([],
a
,
updates
=
{
a
:
a
+
1
},
mode
=
"JAX"
)
res1
,
res2
=
aesara_jax_fn
(),
aesara_jax_fn
()
assert
res1
==
0
assert
res2
==
1
assert
a
.
get_value
()
==
2
a
.
set_value
(
5
)
res1
,
res2
=
aesara_jax_fn
(),
aesara_jax_fn
()
assert
res1
==
5
assert
res2
==
6
assert
a
.
get_value
()
==
7
def
test_jax_ifelse
():
true_vals
=
np
.
r_
[
1
,
2
,
3
]
...
...
tests/link/numba/test_basic.py
浏览文件 @
3aff3d2f
...
...
@@ -837,6 +837,22 @@ def test_shared():
np
.
testing
.
assert_allclose
(
numba_res
,
new_a_value
*
2
)
def
test_shared_updates
():
a
=
shared
(
0
)
aesara_numba_fn
=
function
([],
a
,
updates
=
{
a
:
a
+
1
},
mode
=
"NUMBA"
)
res1
,
res2
=
aesara_numba_fn
(),
aesara_numba_fn
()
assert
res1
==
0
assert
res2
==
1
assert
a
.
get_value
()
==
2
a
.
set_value
(
5
)
res1
,
res2
=
aesara_numba_fn
(),
aesara_numba_fn
()
assert
res1
==
5
assert
res2
==
6
assert
a
.
get_value
()
==
7
# We were seeing some weird results in CI where the following two almost
# sign-swapped results were being return from Numba and Python, respectively.
# The issue might be related to https://github.com/numba/numba/issues/4519.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论