Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d8e47500
提交
d8e47500
authored
2月 16, 2015
作者:
Pierre Luc Carrier
提交者:
Pierre Luc Carrier
2月 16, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Correct checks for reuse of preallocated output
上级
b2570e99
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
23 行增加
和
6 行删除
+23
-6
scan_op.py
theano/scan_module/scan_op.py
+23
-6
没有找到文件。
theano/scan_module/scan_op.py
浏览文件 @
d8e47500
...
...
@@ -927,11 +927,14 @@ class Scan(PureOp):
offset
+=
1
# 4. collecting slices where the output should be stored
# 4.1. Collect slices for mitmots
for
idx
in
xrange
(
self
.
n_mit_mot_outs
):
output_storage
[
idx
]
.
storage
[
0
]
=
None
# 4.2. Collect slices for mitsots, sitsots and nitsots
offset
=
self
.
n_mit_mot_outs
if
i
!=
0
and
self
.
n_nit_sot
>
0
:
if
i
!=
0
:
for
idx
in
xrange
(
self
.
n_outs
+
self
.
n_nit_sot
-
self
.
n_mit_mot
):
if
(
store_steps
[
idx
+
self
.
n_mit_mot
]
==
1
or
...
...
@@ -946,15 +949,24 @@ class Scan(PureOp):
self
.
n_mit_mot
):
output_storage
[
idx
+
offset
]
.
storage
[
0
]
=
None
# 4.3. Collect slices for shared outputs
offset
+=
self
.
n_outs
+
self
.
n_nit_sot
-
self
.
n_mit_mot
for
idx
in
xrange
(
self
.
n_shared_outs
):
output_storage
[
idx
+
offset
]
.
storage
[
0
]
=
None
# If condition add it to the mix
# 4.4. If there is a condition add it to the mix
if
self
.
as_while
:
pdx
=
offset
+
self
.
n_shared_outs
output_storage
[
pdx
]
.
storage
[
0
]
=
None
# 4.5. Keep a reference to the variables currently in the
# output_storage to be able to compare them with the actual
# outputs of the inner function after its execution
old_output_storage
=
[
o
.
storage
[
0
]
for
o
in
output_storage
]
# 5. compute outputs
t0_fn
=
time
.
time
()
try
:
fn
()
except
Exception
:
...
...
@@ -974,11 +986,18 @@ class Scan(PureOp):
else
:
# old-style linkers raise their own exceptions
raise
dt_fn
=
time
.
time
()
-
t0_fn
if
self
.
as_while
:
pdx
=
offset
+
self
.
n_shared_outs
cond
=
output_storage
[
pdx
]
.
storage
[
0
]
==
0
# Check which of the pre-allocated outputs (if applicable) have
# been reused by the inner function
output_reused
=
[
old_output_storage
[
o
]
is
output_storage
[
o
]
.
storage
[
0
]
for
o
in
range
(
len
(
output_storage
))]
t_fn
+=
dt_fn
offset_out
=
0
# 5.1 Copy over the values for mit_mot outputs
...
...
@@ -995,8 +1014,7 @@ class Scan(PureOp):
for
j
in
xrange
(
begin
,
end
):
if
(
store_steps
[
j
]
==
1
or
self
.
vector_outs
[
j
]
or
outs
[
j
][
0
][
pos
[
j
]]
is
not
output_storage
[
offset_out
+
j
]
.
storage
[
0
]):
not
output_reused
[
offset_out
+
j
]):
outs
[
j
][
0
][
pos
[
j
]]
=
\
output_storage
[
offset_out
+
j
]
.
storage
[
0
]
...
...
@@ -1020,8 +1038,7 @@ 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
outs
[
j
][
0
][
pos
[
j
]]
is
not
output_storage
[
j
+
offset_out
]
.
storage
[
0
]):
not
output_reused
[
offset_out
+
j
]):
outs
[
j
][
0
][
pos
[
j
]]
=
\
output_storage
[
j
+
offset_out
]
.
storage
[
0
]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论