Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d2b623a9
提交
d2b623a9
authored
4月 30, 2015
作者:
--global
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Apply memory reuse in Scan's Cython backend
上级
11964f0a
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
37 行增加
和
8 行删除
+37
-8
scan_perform.c
theano/scan_module/scan_perform.c
+0
-0
scan_perform.pyx
theano/scan_module/scan_perform.pyx
+36
-7
scan_perform_ext.py
theano/scan_module/scan_perform_ext.py
+1
-1
没有找到文件。
theano/scan_module/scan_perform.c
浏览文件 @
d2b623a9
This source diff could not be displayed because it is too large. You can
view the blob
instead.
theano/scan_module/scan_perform.pyx
浏览文件 @
d2b623a9
...
@@ -62,7 +62,7 @@ import copy
...
@@ -62,7 +62,7 @@ import copy
def get_version():
def get_version():
return 0.28
5
return 0.28
6
@cython.boundscheck(False)
@cython.boundscheck(False)
def perform(
def perform(
...
@@ -255,6 +255,8 @@ def perform(
...
@@ -255,6 +255,8 @@ def perform(
other_args = args[offset:]
other_args = args[offset:]
input_storage = fnct.input_storage
input_storage = fnct.input_storage
output_storage = fnct.output_storage
output_storage = fnct.output_storage
old_output_storage = [None] * len_output_storage
old_output_data = [None] * len_output_storage
offset = n_seqs
offset = n_seqs
for idx in range(n_outs):
for idx in range(n_outs):
offset += tap_array_len[idx]
offset += tap_array_len[idx]
...
@@ -339,9 +341,19 @@ def perform(
...
@@ -339,9 +341,19 @@ def perform(
output_storage[<unsigned int>pdx].storage[0] = None
output_storage[<unsigned int>pdx].storage[0] = None
# 4.5. Keep a reference to the variables currently in the
# 4.5. Keep a reference to the variables currently in the
# output_storage to be able to compare them with the actual
# output_storage, and their data, to be able to compare them with
# outputs of the inner function after its execution
# the actual outputs of the inner function after its execution
old_output_storage = [o.storage[0] for o in output_storage]
for idx in range(len_output_storage):
var = output_storage[idx].storage[0]
old_output_storage[idx] = var
if hasattr(var, 'gpudata'):
old_output_data[idx] = var.gpudata
elif hasattr(var, 'data'):
old_output_data[idx] = var.data
else:
old_output_data[idx] = None
# 5. compute outputs
# 5. compute outputs
t0_fn = time.time()
t0_fn = time.time()
...
@@ -366,9 +378,26 @@ def perform(
...
@@ -366,9 +378,26 @@ def perform(
# Check which of the pre-allocated outputs (if applicable) have
# Check which of the pre-allocated outputs (if applicable) have
# been reused by the inner function
# been reused by the inner function
for j in range(len_output_storage):
for idx in range(len_output_storage):
output_reused[j] = (old_output_storage[j] is
# If the storage map does not contain the same object, then
output_storage[j].storage[0])
# 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
offset_out = 0
offset_out = 0
# 5.1 Copy over the values for mit_mot outputs
# 5.1 Copy over the values for mit_mot outputs
...
...
theano/scan_module/scan_perform_ext.py
浏览文件 @
d2b623a9
...
@@ -16,7 +16,7 @@ from theano.gof import cmodule
...
@@ -16,7 +16,7 @@ from theano.gof import cmodule
_logger
=
logging
.
getLogger
(
'theano.scan_module.scan_perform'
)
_logger
=
logging
.
getLogger
(
'theano.scan_module.scan_perform'
)
version
=
0.28
5
# must match constant returned in function get_version()
version
=
0.28
6
# must match constant returned in function get_version()
need_reload
=
False
need_reload
=
False
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论