Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
12886abb
提交
12886abb
authored
7月 04, 2017
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
flake8 and better doc
上级
2348c3c2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
32 行增加
和
10 行删除
+32
-10
test_vm.py
theano/gof/tests/test_vm.py
+2
-2
vm.py
theano/gof/vm.py
+30
-8
没有找到文件。
theano/gof/tests/test_vm.py
浏览文件 @
12886abb
...
@@ -443,6 +443,6 @@ def test_reallocation():
...
@@ -443,6 +443,6 @@ def test_reallocation():
def
test_no_recycling
():
def
test_no_recycling
():
x
=
theano
.
tensor
.
vector
()
x
=
theano
.
tensor
.
vector
()
mode
=
theano
.
Mode
(
optimizer
=
'fast_compile'
)
mode
=
theano
.
Mode
(
optimizer
=
'fast_compile'
)
f
=
theano
.
function
([
x
],
x
+
1
,
mode
=
mode
)
f
=
theano
.
function
([
x
],
x
+
1
,
mode
=
mode
)
f2
=
theano
.
function
([
x
],
(
x
+
1
)
*
2
,
mode
=
mode
)
f2
=
theano
.
function
([
x
],
(
x
+
1
)
*
2
,
mode
=
mode
)
theano
.
printing
.
debugprint
([
f
,
f2
])
theano
.
printing
.
debugprint
([
f
,
f2
])
theano/gof/vm.py
浏览文件 @
12886abb
...
@@ -748,8 +748,7 @@ class VM_Linker(link.LocalLinker):
...
@@ -748,8 +748,7 @@ class VM_Linker(link.LocalLinker):
self
.
schedule
=
schedule
self
.
schedule
=
schedule
def
accept
(
self
,
fgraph
,
no_recycling
=
None
,
profile
=
None
):
def
accept
(
self
,
fgraph
,
no_recycling
=
None
,
profile
=
None
):
"""
"""Check if fgraph is the first FunctionGraph that has ever been
Check if fgraph is the first FunctionGraph that has ever been
associated to self, else, create a new VM_Linker
associated to self, else, create a new VM_Linker
associated to fgraph
associated to fgraph
...
@@ -758,8 +757,33 @@ class VM_Linker(link.LocalLinker):
...
@@ -758,8 +757,33 @@ class VM_Linker(link.LocalLinker):
fgraph
fgraph
A PerformLinker can have accepted one FunctionGraph instance
A PerformLinker can have accepted one FunctionGraph instance
at a time.
at a time.
no_recycling
no_recycling
WRITEME
no_recycling is a list of storage (list of 1 element, the
value corresponding to one variable). Those variable
storage should not be reused after the call that created
them.
This happen for example for output of the graph that we
give to the user. We don't want to reuse those object in
case the user have kept it.
VM_Linker make sure this happen by setting the list
element to None at the start of each call.
Older Linker use not exactly the same mechanism. They will
also modify the c code to don't look up the value in the
storage. This cause duplicate c code compilation for the
same op if they are in the middle of the graph or in the
no_recycling. We don't want that, so compile all c code
the same (middle of the graph vs output).
TODO: change the logic to remove the reference at the end
of the call instead of the start. This will request all VM
implementation (Loop, LoopGC, Stack, CVM).__call__ to
return the user outputs as Function.__call__ won't be able
to find them anymore.
Returns
Returns
-------
-------
...
@@ -1021,7 +1045,6 @@ class VM_Linker(link.LocalLinker):
...
@@ -1021,7 +1045,6 @@ class VM_Linker(link.LocalLinker):
):
):
fgraph
=
self
.
fgraph
fgraph
=
self
.
fgraph
order
=
self
.
schedule
(
fgraph
)
order
=
self
.
schedule
(
fgraph
)
no_recycling
=
self
.
no_recycling
input_storage
,
output_storage
,
storage_map
=
link
.
map_storage
(
input_storage
,
output_storage
,
storage_map
=
link
.
map_storage
(
fgraph
,
order
,
input_storage
,
output_storage
,
storage_map
)
fgraph
,
order
,
input_storage
,
output_storage
,
storage_map
)
...
@@ -1051,13 +1074,12 @@ class VM_Linker(link.LocalLinker):
...
@@ -1051,13 +1074,12 @@ class VM_Linker(link.LocalLinker):
for
node
in
order
:
for
node
in
order
:
try
:
try
:
thunk_start
=
time
.
time
()
thunk_start
=
time
.
time
()
# no-recycling is done at each VM.__call__ So there is
# no need to cause duplicate c code by passing
# no_recycling here.
thunks
.
append
(
node
.
op
.
make_thunk
(
node
,
thunks
.
append
(
node
.
op
.
make_thunk
(
node
,
storage_map
,
storage_map
,
compute_map
,
compute_map
,
# The no recycling is done at the VM.__call__
# implementation at the next call with the
# pre_call_clear. So there is no need to cause
# duplicate c code by passing no_recycling here.
no_recycling
=
[],
no_recycling
=
[],
impl
=
impl
))
impl
=
impl
))
linker_make_thunk_time
[
node
]
=
time
.
time
()
-
thunk_start
linker_make_thunk_time
[
node
]
=
time
.
time
()
-
thunk_start
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论