Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b66e7c56
提交
b66e7c56
authored
9月 29, 2015
作者:
carriepl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Limit checks for whether outputs have been reused in Scan python backend
上级
e0ceda00
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
39 行增加
和
29 行删除
+39
-29
scan_op.py
theano/scan_module/scan_op.py
+39
-29
没有找到文件。
theano/scan_module/scan_op.py
浏览文件 @
b66e7c56
...
...
@@ -1339,33 +1339,10 @@ class Scan(PureOp):
storage
.
data
=
output_storage
[
offset_out
]
.
data
offset_out
-=
1
# 5.3. Check which of the pre-allocated outputs (if applicable)
# have been reused by the inner function
for
idx
in
xrange
(
len
(
output_storage
)):
# If the storage map does not contain the same object, then
# the pre-allocated output has not been reused
new_var
=
output_storage
[
idx
]
.
storage
[
0
]
if
old_output_storage
[
idx
]
is
new_var
:
# The pre-allocated output is only considered as having
# been reused if it still points to the same data as it
# did before the execution of the inner function
if
old_output_data
[
idx
]
is
None
:
output_reused
[
idx
]
=
False
else
:
if
hasattr
(
new_var
,
'gpudata'
):
output_reused
[
idx
]
=
(
new_var
.
gpudata
==
old_output_data
[
idx
])
elif
hasattr
(
new_var
,
'data'
):
output_reused
[
idx
]
=
(
new_var
.
data
==
old_output_data
[
idx
])
else
:
output_reused
[
idx
]
=
False
t_fn
+=
dt_fn
offset_out
=
0
# 5.
4
Copy over the values for mit_mot outputs
# 5.
3
Copy over the values for mit_mot outputs
mitmot_inp_offset
=
0
mitmot_out_idx
=
0
for
j
in
xrange
(
self
.
n_mit_mot
):
...
...
@@ -1407,21 +1384,54 @@ class Scan(PureOp):
mitmot_inp_offset
+=
len
(
self
.
tap_array
[
j
])
# 5.
5
Copy over the values for mit_sot/sit_sot outputs
# 5.
4
Copy over the values for mit_sot/sit_sot outputs
begin
=
self
.
n_mit_mot
end
=
self
.
n_outs
offset_out
-=
self
.
n_mit_mot
for
j
in
xrange
(
begin
,
end
):
# Check whether the initialization of the output storage map
# for this output has been reused.
old_var
=
old_output_storage
[
offset_out
+
j
]
old_data
=
old_output_data
[
offset_out
+
j
]
new_var
=
output_storage
[
offset_out
+
j
]
.
storage
[
0
]
if
old_var
is
new_var
:
if
old_data
is
None
:
output_reused
=
False
elif
hasattr
(
new_var
,
'gpudata'
):
output_reused
=
(
new_var
.
gpudata
==
old_data
)
elif
hasattr
(
new_var
,
'data'
):
output_reused
=
(
new_var
.
data
==
old_data
)
else
:
output_reused
=
False
# Copy the output value to `outs`, if necessary
if
(
store_steps
[
j
]
==
1
or
self
.
vector_outs
[
j
]
or
not
output_reused
[
offset_out
+
j
]
):
not
output_reused
):
outs
[
j
][
0
][
pos
[
j
]]
=
\
output_storage
[
offset_out
+
j
]
.
storage
[
0
]
# 5.
6
Copy over the values for nit_sot outputs
# 5.
5
Copy over the values for nit_sot outputs
begin
=
end
end
+=
self
.
n_nit_sot
for
j
in
xrange
(
begin
,
end
):
# Check whether the initialization of the output storage map
# for this output has been reused.
old_var
=
old_output_storage
[
offset_out
+
j
]
old_data
=
old_output_data
[
offset_out
+
j
]
new_var
=
output_storage
[
offset_out
+
j
]
.
storage
[
0
]
if
old_var
is
new_var
:
if
old_data
is
None
:
output_reused
=
False
elif
hasattr
(
new_var
,
'gpudata'
):
output_reused
=
(
new_var
.
gpudata
==
old_data
)
elif
hasattr
(
new_var
,
'data'
):
output_reused
=
(
new_var
.
data
==
old_data
)
else
:
output_reused
=
False
if
i
==
0
:
jout
=
j
+
offset_out
shape
=
(
store_steps
[
j
],)
+
\
...
...
@@ -1438,11 +1448,11 @@ class Scan(PureOp):
outs
[
j
][
0
]
=
outs
[
j
][
0
][:
store_steps
[
j
]]
outs
[
j
][
0
][
pos
[
j
]]
=
output_storage
[
jout
]
.
storage
[
0
]
elif
(
store_steps
[
j
]
==
1
or
self
.
vector_outs
[
j
]
or
not
output_reused
[
offset_out
+
j
]
):
not
output_reused
):
outs
[
j
][
0
][
pos
[
j
]]
=
\
output_storage
[
j
+
offset_out
]
.
storage
[
0
]
# 5.
7
Copy over the values for outputs corresponding to shared
# 5.
6
Copy over the values for outputs corresponding to shared
# variables
begin
=
end
end
+=
self
.
n_shared_outs
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论