Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d7688cea
提交
d7688cea
authored
6月 22, 2016
作者:
sentient07
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cached GpuFromHost
上级
44480978
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
17 行增加
和
9 行删除
+17
-9
basic_ops.py
theano/gpuarray/basic_ops.py
+10
-2
opt.py
theano/gpuarray/opt.py
+3
-3
type.py
theano/gpuarray/type.py
+2
-2
scan_utils.py
theano/scan_module/scan_utils.py
+2
-2
没有找到文件。
theano/gpuarray/basic_ops.py
浏览文件 @
d7688cea
...
@@ -70,7 +70,7 @@ def as_gpuarray_variable(x, context_name):
...
@@ -70,7 +70,7 @@ def as_gpuarray_variable(x, context_name):
# If we couldn't deal with transfers, then maybe it's a tensor
# If we couldn't deal with transfers, then maybe it's a tensor
if
isinstance
(
x
.
type
,
tensor
.
TensorType
):
if
isinstance
(
x
.
type
,
tensor
.
TensorType
):
return
GpuFromH
ost
(
context_name
)(
x
)
return
gpu_from_h
ost
(
context_name
)(
x
)
# Try _as_GpuArrayVariable if possible
# Try _as_GpuArrayVariable if possible
if
hasattr
(
x
,
'_as_GpuArrayVariable'
):
if
hasattr
(
x
,
'_as_GpuArrayVariable'
):
...
@@ -544,7 +544,7 @@ class HostFromGpu(Op):
...
@@ -544,7 +544,7 @@ class HostFromGpu(Op):
def
grad
(
self
,
inputs
,
grads
):
def
grad
(
self
,
inputs
,
grads
):
gz
,
=
grads
gz
,
=
grads
return
[
GpuFromH
ost
(
inputs
[
0
]
.
type
.
context_name
)(
gz
)]
return
[
gpu_from_h
ost
(
inputs
[
0
]
.
type
.
context_name
)(
gz
)]
def
R_op
(
self
,
inputs
,
eval_points
):
def
R_op
(
self
,
inputs
,
eval_points
):
ev
,
=
eval_points
ev
,
=
eval_points
...
@@ -647,6 +647,14 @@ class GpuFromHost(Op):
...
@@ -647,6 +647,14 @@ class GpuFromHost(Op):
return
(
9
,)
return
(
9
,)
# Caching GPUAlloc
def
gpu_from_host
(
ctx
):
if
ctx
not
in
gpu_alloc
.
cache
:
gpu_from_host
.
cache
[
ctx
]
=
GpuFromHost
(
ctx
)
return
gpu_from_host
.
cache
[
ctx
]
gpu_from_host
.
cache
=
{}
class
GpuToGpu
(
Op
):
class
GpuToGpu
(
Op
):
"""
"""
Transfer data between GPUs.
Transfer data between GPUs.
...
...
theano/gpuarray/opt.py
浏览文件 @
d7688cea
...
@@ -36,7 +36,7 @@ from .basic_ops import (as_gpuarray_variable, infer_context_name,
...
@@ -36,7 +36,7 @@ from .basic_ops import (as_gpuarray_variable, infer_context_name,
HostFromGpu
,
GpuFromHost
,
HostFromGpu
,
GpuFromHost
,
GpuSplit
,
GpuContiguous
,
gpu_contiguous
,
GpuSplit
,
GpuContiguous
,
gpu_contiguous
,
GpuAlloc
,
GpuAllocEmpty
,
GpuReshape
,
GpuAlloc
,
GpuAllocEmpty
,
GpuReshape
,
GpuEye
,
gpu_join
,
GpuJoin
,
gpu_alloc_empty
,
gpu_alloc
)
GpuEye
,
gpu_join
,
GpuJoin
,
gpu_alloc_empty
,
gpu_alloc
,
gpu_from_host
)
from
.blas
import
(
gpu_dot22
,
GpuGemm
,
GpuGer
,
GpuGemmBatch
,
from
.blas
import
(
gpu_dot22
,
GpuGemm
,
GpuGer
,
GpuGemmBatch
,
gpugemm_no_inplace
,
gpugemm_inplace
,
gpugemmbatch_no_inplace
,
gpugemm_no_inplace
,
gpugemm_inplace
,
gpugemmbatch_no_inplace
,
gpugemv_no_inplace
,
gpugemv_inplace
)
gpugemv_no_inplace
,
gpugemv_inplace
)
...
@@ -148,7 +148,7 @@ gpu_optimizer.register('local_remove_all_assert',
...
@@ -148,7 +148,7 @@ gpu_optimizer.register('local_remove_all_assert',
def
safe_to_gpu
(
x
,
ctx_name
):
def
safe_to_gpu
(
x
,
ctx_name
):
if
isinstance
(
x
.
type
,
tensor
.
TensorType
):
if
isinstance
(
x
.
type
,
tensor
.
TensorType
):
return
GpuFromH
ost
(
ctx_name
)(
x
)
return
gpu_from_h
ost
(
ctx_name
)(
x
)
else
:
else
:
return
x
return
x
...
@@ -251,7 +251,7 @@ class InputToGpuOptimizer(Optimizer):
...
@@ -251,7 +251,7 @@ class InputToGpuOptimizer(Optimizer):
continue
continue
try
:
try
:
new_input
=
host_from_gpu
(
GpuFromH
ost
(
target
)(
input
))
new_input
=
host_from_gpu
(
gpu_from_h
ost
(
target
)(
input
))
fgraph
.
replace_validate
(
input
,
new_input
,
fgraph
.
replace_validate
(
input
,
new_input
,
"InputToGpuOptimizer"
)
"InputToGpuOptimizer"
)
except
TypeError
:
except
TypeError
:
...
...
theano/gpuarray/type.py
浏览文件 @
d7688cea
...
@@ -233,7 +233,7 @@ class GpuArrayType(Type):
...
@@ -233,7 +233,7 @@ class GpuArrayType(Type):
return
data
return
data
def
filter_variable
(
self
,
other
,
allow_convert
=
True
):
def
filter_variable
(
self
,
other
,
allow_convert
=
True
):
from
theano.gpuarray
import
GpuFromH
ost
from
theano.gpuarray
.basic_ops
import
gpu_from_h
ost
if
hasattr
(
other
,
'_as_GpuArrayVariable'
):
if
hasattr
(
other
,
'_as_GpuArrayVariable'
):
other
=
other
.
_as_GpuArrayVariable
(
self
.
context_name
)
other
=
other
.
_as_GpuArrayVariable
(
self
.
context_name
)
...
@@ -265,7 +265,7 @@ class GpuArrayType(Type):
...
@@ -265,7 +265,7 @@ class GpuArrayType(Type):
str
(
self
.
broadcastable
)))
str
(
self
.
broadcastable
)))
other
=
other2
other
=
other2
return
GpuFromH
ost
(
self
.
context_name
)(
other
)
return
gpu_from_h
ost
(
self
.
context_name
)(
other
)
@staticmethod
@staticmethod
def
values_eq
(
a
,
b
,
force_same_dtype
=
True
):
def
values_eq
(
a
,
b
,
force_same_dtype
=
True
):
...
...
theano/scan_module/scan_utils.py
浏览文件 @
d7688cea
...
@@ -152,13 +152,13 @@ def traverse(out, x, x_copy, d, visited=None):
...
@@ -152,13 +152,13 @@ def traverse(out, x, x_copy, d, visited=None):
return
d
return
d
visited
.
add
(
out
)
visited
.
add
(
out
)
from
theano.sandbox
import
cuda
from
theano.sandbox
import
cuda
from
theano
import
gpuarray
from
theano
.gpuarray.basic_ops
import
gpu_from_host
if
out
==
x
:
if
out
==
x
:
if
isinstance
(
x
.
type
,
cuda
.
CudaNdarrayType
):
if
isinstance
(
x
.
type
,
cuda
.
CudaNdarrayType
):
d
[
out
]
=
cuda
.
gpu_from_host
(
x_copy
)
d
[
out
]
=
cuda
.
gpu_from_host
(
x_copy
)
else
:
else
:
assert
isinstance
(
x
.
type
,
gpuarray
.
GpuArrayType
)
assert
isinstance
(
x
.
type
,
gpuarray
.
GpuArrayType
)
d
[
out
]
=
gpu
array
.
GpuFromH
ost
(
x
.
type
.
context_name
)(
x_copy
)
d
[
out
]
=
gpu
_from_h
ost
(
x
.
type
.
context_name
)(
x_copy
)
return
d
return
d
elif
out
.
owner
is
None
:
elif
out
.
owner
is
None
:
return
d
return
d
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论