Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e88f1ac3
提交
e88f1ac3
authored
7月 29, 2015
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix comments about transfer optimizations
上级
9b31f7b0
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
22 行增加
和
9 行删除
+22
-9
abstract_conv2d.py
theano/tensor/nnet/abstract_conv2d.py
+22
-9
没有找到文件。
theano/tensor/nnet/abstract_conv2d.py
浏览文件 @
e88f1ac3
...
@@ -11,6 +11,7 @@ import numpy
...
@@ -11,6 +11,7 @@ import numpy
import
theano
import
theano
from
theano.tensor
import
(
as_tensor_variable
,
blas
,
get_scalar_constant_value
,
from
theano.tensor
import
(
as_tensor_variable
,
blas
,
get_scalar_constant_value
,
patternbroadcast
,
NotScalarConstantError
)
patternbroadcast
,
NotScalarConstantError
)
from
theano.tensor
import
TensorType
from
theano.gof
import
Apply
,
Op
from
theano.gof
import
Apply
,
Op
from
theano.gof
import
local_optimizer
from
theano.gof
import
local_optimizer
...
@@ -345,36 +346,48 @@ def local_conv2d_gpu_conv(node):
...
@@ -345,36 +346,48 @@ def local_conv2d_gpu_conv(node):
conv
=
host_input
.
owner
.
op
conv
=
host_input
.
owner
.
op
inps
=
list
(
host_input
.
owner
.
inputs
)
inps
=
list
(
host_input
.
owner
.
inputs
)
inps
[
0
]
=
gpu_from_host
(
inps
[
0
])
inps
[
0
]
=
as_cuda_ndarray_variable
(
inps
[
0
])
inps
[
1
]
=
gpu_from_host
(
inps
[
1
])
inps
[
1
]
=
as_cuda_ndarray_variable
(
inps
[
1
])
out
=
conv
(
*
inps
)
out
=
conv
(
*
inps
)
out
=
theano
.
tensor
.
patternbroadcast
(
gpu_from_host
(
out
),
# out is on the GPU because both inputs are.
out
=
theano
.
tensor
.
patternbroadcast
(
out
,
node
.
outputs
[
0
]
.
broadcastable
)
node
.
outputs
[
0
]
.
broadcastable
)
out
.
values_eq_approx
=
values_eq_approx_high_tol
out
.
values_eq_approx
=
values_eq_approx_high_tol
return
[
out
]
return
[
out
]
if
isinstance
(
node
.
op
,
BaseAbstractConv2d
):
if
isinstance
(
node
.
op
,
BaseAbstractConv2d
):
#conv(host_from_gpu) -> host_from_gpu(gpu_conv)
#
conv(host_from_gpu) -> host_from_gpu(gpu_conv)
inp1
=
node
.
inputs
[
0
]
inp1
=
node
.
inputs
[
0
]
inp2
=
node
.
inputs
[
1
]
inp2
=
node
.
inputs
[
1
]
inp1_on_gpu
=
(
inp1
.
owner
and
isinstance
(
inp1
.
owner
.
op
,
HostFromGpu
))
if
((
isinstance
(
inp1
.
type
,
CudaNdarrayType
)
and
inp2_on_gpu
=
(
inp2
.
owner
and
isinstance
(
inp2
.
owner
.
op
,
HostFromGpu
))
isinstance
(
inp2
.
type
,
CudaNdarrayType
))):
# Both inputs are already directly on the GPU, nothing to do
return
inp1_on_gpu
=
(
isinstance
(
inp1
.
type
,
CudaNdarrayType
)
or
(
inp1
.
owner
and
isinstance
(
inp1
.
owner
.
op
,
HostFromGpu
)))
inp2_on_gpu
=
(
isinstance
(
inp2
.
type
,
CudaNdarrayType
)
or
(
inp2
.
owner
and
isinstance
(
inp2
.
owner
.
op
,
HostFromGpu
)))
if
inp1_on_gpu
or
inp2_on_gpu
:
if
inp1_on_gpu
or
inp2_on_gpu
:
conv
=
node
.
op
conv
=
node
.
op
inps
=
list
(
node
.
inputs
)
inps
=
list
(
node
.
inputs
)
inps
[
0
]
=
gpu_from_host
(
inps
[
0
])
inps
[
0
]
=
as_cuda_ndarray_variable
(
inps
[
0
])
inps
[
1
]
=
gpu_from_host
(
inps
[
1
])
inps
[
1
]
=
as_cuda_ndarray_variable
(
inps
[
1
])
out
=
conv
(
*
inps
)
out
=
conv
(
*
inps
)
# out is on the GPU because both inputs are.
out
=
theano
.
tensor
.
patternbroadcast
(
out
=
theano
.
tensor
.
patternbroadcast
(
out
,
out
,
node
.
outputs
[
0
]
.
broadcastable
)
node
.
outputs
[
0
]
.
broadcastable
)
out
.
values_eq_approx
=
values_eq_approx_high_tol
out
.
values_eq_approx
=
values_eq_approx_high_tol
# If the original output was on CPU, we have to transfer it
if
isinstance
(
node
.
outputs
[
0
],
TensorType
):
return
[
as_tensor_variable
(
out
)]
return
[
as_tensor_variable
(
out
)]
else
:
return
[
out
]
register_gpu
()(
local_conv2d_gpu_conv
)
register_gpu
()(
local_conv2d_gpu_conv
)
### Cudnn Opt
### Cudnn Opt
@local_optimizer
([
AbstractConv2d
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradInputs
])
@local_optimizer
([
AbstractConv2d
,
AbstractConv2d_gradWeights
,
AbstractConv2d_gradInputs
])
def
local_conv2d_cudnn
(
node
):
def
local_conv2d_cudnn
(
node
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论