Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ffbe1f76
提交
ffbe1f76
authored
12月 28, 2020
作者:
Michael Osthege
提交者:
Brandon T. Willard
1月 02, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove keep_lock argument in theano.compile.compilelock.lock_ctx
上级
3e475958
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
15 行增加
和
25 行删除
+15
-25
compilelock.py
theano/compile/compilelock.py
+2
-3
basic.py
theano/link/c/basic.py
+8
-15
cmodule.py
theano/link/c/cmodule.py
+5
-7
没有找到文件。
theano/compile/compilelock.py
浏览文件 @
ffbe1f76
...
@@ -43,11 +43,10 @@ def force_unlock():
...
@@ -43,11 +43,10 @@ def force_unlock():
@contextmanager
@contextmanager
def
lock_ctx
(
lock_dir
=
None
,
keep_lock
=
False
,
**
kw
):
def
lock_ctx
(
lock_dir
=
None
,
**
kw
):
get_lock
(
lock_dir
=
lock_dir
,
**
kw
)
get_lock
(
lock_dir
=
lock_dir
,
**
kw
)
yield
yield
if
not
keep_lock
:
release_lock
()
release_lock
()
# We define this name with an underscore so that python shutdown
# We define this name with an underscore so that python shutdown
...
...
theano/link/c/basic.py
浏览文件 @
ffbe1f76
...
@@ -1174,7 +1174,10 @@ class CLinker(Linker):
...
@@ -1174,7 +1174,10 @@ class CLinker(Linker):
return
[
r
for
r
in
uniq
(
ret
)
if
r
]
return
[
r
for
r
in
uniq
(
ret
)
if
r
]
def
__compile__
(
def
__compile__
(
self
,
input_storage
=
None
,
output_storage
=
None
,
storage_map
=
None
,
keep_lock
=
False
self
,
input_storage
=
None
,
output_storage
=
None
,
storage_map
=
None
,
):
):
"""
"""
Compiles this linker's fgraph.
Compiles this linker's fgraph.
...
@@ -1216,7 +1219,6 @@ class CLinker(Linker):
...
@@ -1216,7 +1219,6 @@ class CLinker(Linker):
input_storage
,
input_storage
,
output_storage
,
output_storage
,
storage_map
,
storage_map
,
keep_lock
=
keep_lock
,
)
)
return
(
return
(
thunk
,
thunk
,
...
@@ -1248,9 +1250,7 @@ class CLinker(Linker):
...
@@ -1248,9 +1250,7 @@ class CLinker(Linker):
id
+=
2
id
+=
2
return
init_tasks
,
tasks
return
init_tasks
,
tasks
def
make_thunk
(
def
make_thunk
(
self
,
input_storage
=
None
,
output_storage
=
None
,
storage_map
=
None
):
self
,
input_storage
=
None
,
output_storage
=
None
,
storage_map
=
None
,
keep_lock
=
False
):
"""
"""
Compiles this linker's fgraph and returns a function to perform the
Compiles this linker's fgraph and returns a function to perform the
computations, as well as lists of storage cells for both the inputs
computations, as well as lists of storage cells for both the inputs
...
@@ -1269,9 +1269,6 @@ class CLinker(Linker):
...
@@ -1269,9 +1269,6 @@ class CLinker(Linker):
storage_map: dict that map variables to storages.
storage_map: dict that map variables to storages.
This is used when you need to customize the storage of
This is used when you need to customize the storage of
this thunk
this thunk
keep_lock:
If True, we won't release the lock on the compiledir
at the end of this function call.
Returns: thunk, input_storage, output_storage
Returns: thunk, input_storage, output_storage
The return values can be used as follows:
The return values can be used as follows:
...
@@ -1283,7 +1280,7 @@ class CLinker(Linker):
...
@@ -1283,7 +1280,7 @@ class CLinker(Linker):
"""
"""
init_tasks
,
tasks
=
self
.
get_init_tasks
()
init_tasks
,
tasks
=
self
.
get_init_tasks
()
cthunk
,
module
,
in_storage
,
out_storage
,
error_storage
=
self
.
__compile__
(
cthunk
,
module
,
in_storage
,
out_storage
,
error_storage
=
self
.
__compile__
(
input_storage
,
output_storage
,
storage_map
,
keep_lock
=
keep_lock
input_storage
,
output_storage
,
storage_map
)
)
res
=
_CThunk
(
cthunk
,
init_tasks
,
tasks
,
error_storage
,
module
)
res
=
_CThunk
(
cthunk
,
init_tasks
,
tasks
,
error_storage
,
module
)
...
@@ -1685,9 +1682,7 @@ class CLinker(Linker):
...
@@ -1685,9 +1682,7 @@ class CLinker(Linker):
self
.
_mod
=
mod
self
.
_mod
=
mod
return
self
.
_mod
return
self
.
_mod
def
cthunk_factory
(
def
cthunk_factory
(
self
,
error_storage
,
in_storage
,
out_storage
,
storage_map
=
None
):
self
,
error_storage
,
in_storage
,
out_storage
,
storage_map
=
None
,
keep_lock
=
False
):
"""
"""
Returns a thunk that points to an instance of a C struct that
Returns a thunk that points to an instance of a C struct that
can carry on the computation of this linker's fgraph
can carry on the computation of this linker's fgraph
...
@@ -1715,9 +1710,7 @@ class CLinker(Linker):
...
@@ -1715,9 +1710,7 @@ class CLinker(Linker):
# Set compute_map as None as clinker do not support lazy evaluation
# Set compute_map as None as clinker do not support lazy evaluation
for
node
in
self
.
node_order
:
for
node
in
self
.
node_order
:
node
.
op
.
prepare_node
(
node
,
storage_map
,
None
,
"c"
)
node
.
op
.
prepare_node
(
node
,
storage_map
,
None
,
"c"
)
module
=
get_module_cache
()
.
module_from_key
(
module
=
get_module_cache
()
.
module_from_key
(
key
=
key
,
lnk
=
self
)
key
=
key
,
lnk
=
self
,
keep_lock
=
keep_lock
)
vars
=
self
.
inputs
+
self
.
outputs
+
self
.
orphans
vars
=
self
.
inputs
+
self
.
outputs
+
self
.
orphans
# List of indices that should be ignored when passing the arguments
# List of indices that should be ignored when passing the arguments
...
...
theano/link/c/cmodule.py
浏览文件 @
ffbe1f76
...
@@ -1051,11 +1051,11 @@ class ModuleCache:
...
@@ -1051,11 +1051,11 @@ class ModuleCache:
return
None
return
None
return
self
.
_get_module
(
name
)
return
self
.
_get_module
(
name
)
def
_get_from_hash
(
self
,
module_hash
,
key
,
keep_lock
=
False
):
def
_get_from_hash
(
self
,
module_hash
,
key
):
if
module_hash
in
self
.
module_hash_to_key_data
:
if
module_hash
in
self
.
module_hash_to_key_data
:
key_data
=
self
.
module_hash_to_key_data
[
module_hash
]
key_data
=
self
.
module_hash_to_key_data
[
module_hash
]
module
=
self
.
_get_from_key
(
None
,
key_data
)
module
=
self
.
_get_from_key
(
None
,
key_data
)
with
lock_ctx
(
keep_lock
=
keep_lock
):
with
lock_ctx
():
try
:
try
:
key_data
.
add_key
(
key
,
save_pkl
=
bool
(
key
[
0
]))
key_data
.
add_key
(
key
,
save_pkl
=
bool
(
key
[
0
]))
key_broken
=
False
key_broken
=
False
...
@@ -1130,7 +1130,7 @@ class ModuleCache:
...
@@ -1130,7 +1130,7 @@ class ModuleCache:
self
.
_update_mappings
(
key
,
key_data
,
module
.
__file__
,
not
key_broken
)
self
.
_update_mappings
(
key
,
key_data
,
module
.
__file__
,
not
key_broken
)
return
key_data
return
key_data
def
module_from_key
(
self
,
key
,
lnk
=
None
,
keep_lock
=
False
):
def
module_from_key
(
self
,
key
,
lnk
=
None
):
"""
"""
Return a module from the cache, compiling it if necessary.
Return a module from the cache, compiling it if necessary.
...
@@ -1144,8 +1144,6 @@ class ModuleCache:
...
@@ -1144,8 +1144,6 @@ class ModuleCache:
the `get_src_code()` and `compile_cmodule(location)` functions. The
the `get_src_code()` and `compile_cmodule(location)` functions. The
first one returns the source code of the module to load/compile and
first one returns the source code of the module to load/compile and
the second performs the actual compilation.
the second performs the actual compilation.
keep_lock : bool
If True, the compilation lock will not be released if taken.
"""
"""
# Is the module in the cache?
# Is the module in the cache?
...
@@ -1156,11 +1154,11 @@ class ModuleCache:
...
@@ -1156,11 +1154,11 @@ class ModuleCache:
src_code
=
lnk
.
get_src_code
()
src_code
=
lnk
.
get_src_code
()
# Is the source code already in the cache?
# Is the source code already in the cache?
module_hash
=
get_module_hash
(
src_code
,
key
)
module_hash
=
get_module_hash
(
src_code
,
key
)
module
=
self
.
_get_from_hash
(
module_hash
,
key
,
keep_lock
=
keep_lock
)
module
=
self
.
_get_from_hash
(
module_hash
,
key
)
if
module
is
not
None
:
if
module
is
not
None
:
return
module
return
module
with
lock_ctx
(
keep_lock
=
keep_lock
):
with
lock_ctx
():
# 1) Maybe somebody else compiled it for us while we
# 1) Maybe somebody else compiled it for us while we
# where waiting for the lock. Try to load it again.
# where waiting for the lock. Try to load it again.
# 2) If other repo that import Theano have Theano ops defined,
# 2) If other repo that import Theano have Theano ops defined,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论