Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
cfbe7c3c
提交
cfbe7c3c
authored
5月 20, 2015
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2925 from carriepl/scan_gpuarray_memory_usage
Scan gpuarray memory usage
上级
7359170d
d09f4bb0
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
21 行增加
和
10 行删除
+21
-10
scan.py
theano/scan_module/scan.py
+11
-9
scan_utils.py
theano/scan_module/scan_utils.py
+10
-1
没有找到文件。
theano/scan_module/scan.py
浏览文件 @
cfbe7c3c
...
@@ -962,21 +962,23 @@ def scan(fn,
...
@@ -962,21 +962,23 @@ def scan(fn,
shared_inner_outputs
)
shared_inner_outputs
)
if
condition
is
not
None
:
if
condition
is
not
None
:
inner_outs
.
append
(
condition
)
inner_outs
.
append
(
condition
)
# Cuda
is imported here, instead of being imported on top of the file
# Cuda
and Gpuarray are imported here, instead of being imported on top of
#
because forces on the user some dependencies that we might do not want
#
the file because that would force on the user some dependencies that we
#
to. Currently we are working on removing the dependencies on sandbox
#
might do not want to. Currently we are working on removing the
# code completeley.
#
dependencies on sandbox
code completeley.
from
theano.sandbox
import
cuda
from
theano.sandbox
import
cuda
,
gpuarray
if
cuda
.
cuda_available
:
if
cuda
.
cuda_available
or
gpuarray
.
pygpu_activated
:
# very often we end up in this situation when we want to
# very often we end up in this situation when we want to
# replace w with w_copy, where w is
CudaNdarray
# replace w with w_copy, where w is
a GPU variable
# and w_copy is TensorType. This is caused because shared
# and w_copy is TensorType. This is caused because shared
# variables are put on GPU right aways >:| ,
# variables are put on GPU right aways >:| ,
new_givens
=
OrderedDict
()
new_givens
=
OrderedDict
()
for
w
,
w_copy
in
givens
.
iteritems
():
for
w
,
w_copy
in
givens
.
iteritems
():
if
(
isinstance
(
w
.
type
,
cuda
.
CudaNdarrayType
)
if
((
isinstance
(
w
.
type
,
cuda
.
CudaNdarrayType
)
or
and
isinstance
(
w_copy
.
type
,
tensor
.
TensorType
)):
isinstance
(
w
.
type
,
gpuarray
.
GpuArrayType
))
and
isinstance
(
w_copy
.
type
,
tensor
.
TensorType
)):
for
o
in
inner_outs
:
for
o
in
inner_outs
:
new_givens
=
traverse
(
o
,
w
,
w_copy
,
new_givens
)
new_givens
=
traverse
(
o
,
w
,
w_copy
,
new_givens
)
else
:
else
:
...
...
theano/scan_module/scan_utils.py
浏览文件 @
cfbe7c3c
...
@@ -127,9 +127,13 @@ def traverse(out, x, x_copy, d, visited=None):
...
@@ -127,9 +127,13 @@ def traverse(out, x, x_copy, d, visited=None):
if
out
in
visited
:
if
out
in
visited
:
return
d
return
d
visited
.
add
(
out
)
visited
.
add
(
out
)
import
theano.sandbox.cuda
as
cuda
from
theano.sandbox
import
cuda
,
gpuarray
if
out
==
x
:
if
out
==
x
:
if
isinstance
(
x
.
type
,
cuda
.
CudaNdarrayType
):
d
[
out
]
=
cuda
.
gpu_from_host
(
x_copy
)
d
[
out
]
=
cuda
.
gpu_from_host
(
x_copy
)
else
:
assert
isinstance
(
x
.
type
,
gpuarray
.
GpuArrayType
)
d
[
out
]
=
gpuarray
.
gpu_from_host
(
x_copy
)
return
d
return
d
elif
out
.
owner
is
None
:
elif
out
.
owner
is
None
:
return
d
return
d
...
@@ -138,6 +142,11 @@ def traverse(out, x, x_copy, d, visited=None):
...
@@ -138,6 +142,11 @@ def traverse(out, x, x_copy, d, visited=None):
out
.
owner
.
inputs
==
[
x
]):
out
.
owner
.
inputs
==
[
x
]):
d
[
out
]
=
tensor
.
as_tensor_variable
(
x_copy
)
d
[
out
]
=
tensor
.
as_tensor_variable
(
x_copy
)
return
d
return
d
elif
(
gpuarray
.
pygpu_activated
and
out
.
owner
.
op
==
gpuarray
.
host_from_gpu
and
out
.
owner
.
inputs
==
[
x
]):
d
[
out
]
=
tensor
.
as_tensor_variable
(
x_copy
)
return
d
else
:
else
:
for
inp
in
out
.
owner
.
inputs
:
for
inp
in
out
.
owner
.
inputs
:
d
=
traverse
(
inp
,
x
,
x_copy
,
d
,
visited
)
d
=
traverse
(
inp
,
x
,
x_copy
,
d
,
visited
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论