Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c028e387
提交
c028e387
authored
5月 21, 2022
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
5月 21, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Increase lock scope in ModuleCache.refresh
上级
9ac18dc1
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
47 行增加
和
0 行删除
+47
-0
cmodule.py
aesara/link/c/cmodule.py
+0
-0
test_cmodule.py
tests/link/c/test_cmodule.py
+47
-0
没有找到文件。
aesara/link/c/cmodule.py
浏览文件 @
c028e387
差异被折叠。
点击展开。
tests/link/c/test_cmodule.py
浏览文件 @
c028e387
...
@@ -5,6 +5,7 @@ But this one tests a current behavior that isn't good: the c_code isn't
...
@@ -5,6 +5,7 @@ But this one tests a current behavior that isn't good: the c_code isn't
deterministic based on the input type and the op.
deterministic based on the input type and the op.
"""
"""
import
logging
import
logging
import
multiprocessing
import
os
import
os
import
tempfile
import
tempfile
from
unittest.mock
import
patch
from
unittest.mock
import
patch
...
@@ -12,6 +13,8 @@ from unittest.mock import patch
...
@@ -12,6 +13,8 @@ from unittest.mock import patch
import
numpy
as
np
import
numpy
as
np
import
pytest
import
pytest
import
aesara
import
aesara.tensor
as
at
from
aesara.compile.function
import
function
from
aesara.compile.function
import
function
from
aesara.compile.ops
import
DeepCopyOp
from
aesara.compile.ops
import
DeepCopyOp
from
aesara.configdefaults
import
config
from
aesara.configdefaults
import
config
...
@@ -139,3 +142,47 @@ def test_linking_patch(listdir_mock, platform):
...
@@ -139,3 +142,47 @@ def test_linking_patch(listdir_mock, platform):
"-lmkl_core"
,
"-lmkl_core"
,
"-lmkl_rt"
,
"-lmkl_rt"
,
]
]
def
test_cache_race_condition
():
with
tempfile
.
TemporaryDirectory
()
as
dir_name
:
@config.change_flags
(
on_opt_error
=
"raise"
,
on_shape_error
=
"raise"
)
def
f_build
(
factor
):
# Some of the caching issues arise during constant folding within the
# optimization passes, so we need these config changes to prevent the
# exceptions from being caught
a
=
at
.
vector
()
f
=
aesara
.
function
([
a
],
factor
*
a
)
return
f
(
np
.
array
([
1
],
dtype
=
config
.
floatX
))
ctx
=
multiprocessing
.
get_context
()
compiledir_prop
=
aesara
.
config
.
_config_var_dict
[
"compiledir"
]
# The module cache must (initially) be `None` for all processes so that
# `ModuleCache.refresh` is called
with
patch
.
object
(
compiledir_prop
,
"val"
,
dir_name
,
create
=
True
),
patch
.
object
(
aesara
.
link
.
c
.
cmodule
,
"_module_cache"
,
None
):
assert
aesara
.
config
.
compiledir
==
dir_name
num_procs
=
30
rng
=
np
.
random
.
default_rng
(
209
)
for
i
in
range
(
10
):
# A random, constant input to prevent caching between runs
factor
=
rng
.
random
()
procs
=
[
ctx
.
Process
(
target
=
f_build
,
args
=
(
factor
,))
for
i
in
range
(
num_procs
)
]
for
proc
in
procs
:
proc
.
start
()
for
proc
in
procs
:
proc
.
join
()
assert
not
any
(
exit_code
!=
0
for
exit_code
in
[
proc
.
exitcode
for
proc
in
procs
]
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论