Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
af1f4045
提交
af1f4045
authored
6月 03, 2015
作者:
ChienliMa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add ```storage_map```argument for Profile_Maker;CLinker new support…
Add ```storage_map```argument for Profile_Maker;CLinker new support ```storage_map```(without testing)
上级
af1e743d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
39 行增加
和
46 行删除
+39
-46
profilemode.py
theano/compile/profilemode.py
+3
-1
cc.py
theano/gof/cc.py
+36
-45
没有找到文件。
theano/compile/profilemode.py
浏览文件 @
af1f4045
...
...
@@ -43,7 +43,9 @@ AddConfigVar('ProfileMode.profile_memory',
class
Profile_Maker
(
FunctionMaker
):
def
create
(
self
,
input_storage
=
None
,
trustme
=
False
):
# storage_map does not work in Profile_Maker
# I just add this argument to fit the interface. -- ChienliMa 03.June.2015
def
create
(
self
,
input_storage
=
None
,
trustme
=
False
,
storage_map
=
None
):
ret
=
super
(
Profile_Maker
,
self
)
.
create
(
input_storage
,
trustme
)
if
(
hasattr
(
theano
,
'sandbox'
)
and
...
...
theano/gof/cc.py
浏览文件 @
af1f4045
...
...
@@ -1069,11 +1069,9 @@ class CLinker(link.Linker):
pass
return
utils
.
uniq
(
ret
)
def
__compile__
(
self
,
input_storage
=
None
,
output_storage
=
None
,
keep_lock
=
False
):
"""
WRITEME
def
__compile__
(
self
,
input_storage
=
None
,
output_storage
=
None
,
storage_map
=
None
,
keep_lock
=
False
):
"""WRITEME
Compiles this linker's fgraph.
Parameters
...
...
@@ -1111,6 +1109,7 @@ class CLinker(link.Linker):
thunk
=
self
.
cthunk_factory
(
error_storage
,
input_storage
,
output_storage
,
storage_map
,
keep_lock
=
keep_lock
)
return
(
thunk
,
[
link
.
Container
(
input
,
storage
)
for
input
,
storage
in
...
...
@@ -1143,10 +1142,8 @@ class CLinker(link.Linker):
return
init_tasks
,
tasks
def
make_thunk
(
self
,
input_storage
=
None
,
output_storage
=
None
,
keep_lock
=
False
):
"""
WRITEME
storage_map
=
None
,
keep_lock
=
False
):
"""WRITEME
Compiles this linker's fgraph and returns a function to perform the
computations, as well as lists of storage cells for both the inputs
and outputs.
...
...
@@ -1157,25 +1154,24 @@ class CLinker(link.Linker):
List of lists of length 1. In order to use
the thunk returned by __compile__, the inputs must be put in
that storage. If None, storage will be allocated.
output_storage: list of lists of length 1
The thunk returned by __compile__ will put the variables of the
computation in these lists. If None, storage will be allocated.
Returns
-------
object
Thunk, input_storage, output_storage.
The return values can be used as follows:
f, istor, ostor = clinker.make_thunk()
istor[0].data = first_input
istor[1].data = second_input
f()
first_output = ostor[0].data
@param output_storage: list of lists of length 1. The thunk returned
by __compile__ will put the variables of the computation in these
lists. If None, storage will be allocated.
@param storage_map: dict that map variables to storages. This is used
when you need to customize the storage of this thunk.
Returns: thunk, input_storage, output_storage
The return values can be used as follows:
f, istor, ostor = clinker.make_thunk()
istor[0].data = first_input
istor[1].data = second_input
f()
first_output = ostor[0].data
"""
init_tasks
,
tasks
=
self
.
get_init_tasks
()
cthunk
,
in_storage
,
out_storage
,
error_storage
=
self
.
__compile__
(
input_storage
,
output_storage
,
input_storage
,
output_storage
,
storage_map
,
keep_lock
=
keep_lock
)
res
=
_CThunk
(
cthunk
,
init_tasks
,
tasks
,
error_storage
)
...
...
@@ -1529,25 +1525,17 @@ class CLinker(link.Linker):
return
self
.
_mod
def
cthunk_factory
(
self
,
error_storage
,
in_storage
,
out_storage
,
keep_lock
=
False
):
"""
WRITEME
Parameters
----------
error_storage : list of length 3
in_storage : list of lists of length 1, one per input
out_storage : list of lists of length 1, one per output
Returns
-------
object
A thunk that points to an instance of a C struct that
can carry on the computation of this linker's fgraph. That thunk,
when executed, will fetch its inputs from in_storage, put its
outputs in out_storage and if an error occurs will put the
type, value and traceback of the exception in error_storage.
storage_map
=
None
,
keep_lock
=
False
):
"""WRITEME
error_storage -> list of length 3
in_storage -> list of lists of length 1, one per input
out_storage -> list of lists of length 1, one per output
Returns a thunk that points to an instance of a C struct that
can carry on the computation of this linker's fgraph. That thunk,
when executed, will fetch its inputs from in_storage, put its
outputs in out_storage and if an error occurs will put the
type, value and traceback of the exception in error_storage.
"""
try
:
key
=
self
.
cmodule_key
()
...
...
@@ -1569,7 +1557,10 @@ class CLinker(link.Linker):
out_storage
=
[
x
for
i
,
x
in
enumerate
(
out_storage
)
if
(
i
+
len
(
in_storage
))
not
in
dupidx
]
in_storage
=
[
x
for
i
,
x
in
enumerate
(
in_storage
)
if
i
not
in
dupidx
]
orphd
=
[[
orphan
.
data
]
for
orphan
in
self
.
orphans
]
if
storage_map
is
None
:
orphd
=
[
storage_map
[
orphan
]
for
orphan
in
self
.
orphans
]
else
:
orphd
=
[[
orphan
.
data
]
for
orphan
in
self
.
orphans
]
ret
=
module
.
instantiate
(
error_storage
,
*
(
in_storage
+
out_storage
+
orphd
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论