Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
312da2df
提交
312da2df
authored
7月 09, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move more reduction to the GPU.
上级
e52009c7
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
49 行增加
和
0 行删除
+49
-0
opt.py
theano/sandbox/cuda/opt.py
+49
-0
没有找到文件。
theano/sandbox/cuda/opt.py
浏览文件 @
312da2df
...
...
@@ -86,6 +86,29 @@ register_opt()(theano.tensor.opt.local_track_shape_i)
register_opt
(
name
=
'gpu_constant_folding'
)(
tensor
.
opt
.
constant_folding
)
# This is a partial list of CPU ops that can be in some circonstance
# moved to the GPU. This list is used by an optimization.
# Hopefully, we can keep this list up to date.
import
theano.tensor.signal.downsample
import
theano.sandbox.neighbours
cpu_ops_moved_to_gpu
=
[
tensor
.
blas
.
Dot22
,
tensor
.
blas
.
Dot22Scalar
,
tensor
.
blas
.
Gemm
,
tensor
.
blas
.
Gemv
,
tensor
.
blas
.
Ger
,
tensor
.
nnet
.
conv
.
ConvOp
,
tensor
.
signal
.
downsample
.
DownsampleFactorMax
,
tensor
.
signal
.
downsample
.
DownsampleFactorMaxGrad
,
theano
.
sandbox
.
neighbours
.
Images2Neibs
,
tensor
.
nnet
.
CrossentropySoftmaxArgmax1HotWithBias
,
tensor
.
nnet
.
CrossentropySoftmax1HotWithBiasDx
,
tensor
.
nnet
.
Softmax
,
tensor
.
nnet
.
SoftmaxWithBias
,
tensor
.
Elemwise
,
tensor
.
DimShuffle
,
tensor
.
CAReduce
,
tensor
.
elemwise
.
All
,
tensor
.
elemwise
.
Any
,
tensor
.
elemwise
.
CAReduceDtype
,
tensor
.
elemwise
.
Sum
,
tensor
.
elemwise
.
Prod
,
tensor
.
elemwise
.
ProdWithoutZeros
,
tensor
.
Reshape
,
tensor
.
Flatten
,
tensor
.
Subtensor
,
tensor
.
AdvancedSubtensor1
,
tensor
.
AdvancedIncSubtensor1
,
tensor
.
IncSubtensor
,
tensor
.
Shape
,
tensor
.
Join
,
tensor
.
Alloc
,
tensor
.
Eye
]
class
InputToGpuOptimizer
(
Optimizer
):
"""
...
...
@@ -617,7 +640,33 @@ def local_gpu_careduce(node):
if
isinstance
(
node
.
op
.
scalar_op
,
(
scal
.
Add
,
scal
.
Mul
,
scal
.
Maximum
,
scal
.
Minimum
)):
x
,
=
node
.
inputs
replace
=
False
if
x
.
owner
and
isinstance
(
x
.
owner
.
op
,
HostFromGpu
):
replace
=
True
elif
(
all
([
c
!=
"output"
and
isinstance
(
c
.
op
,
GpuFromHost
)
for
c
,
i
in
node
.
outputs
[
0
]
.
clients
])
and
x
.
owner
and
x
.
owner
.
op
.
__class__
in
cpu_ops_moved_to_gpu
):
# It is not always good to transfer the reduction to
# the GPU when the clients are on the GPU but not the
# reduction input. It mean we will transfer the
# (bigger) input to the GPU instead of the
# output(smaller) if we stop optimization there. Most
# of the time, we will also move to the GPU what
# created the input of the reduction. In that case, we
# don't introduce a bigger transfer. It is hard to
# know if after all optimization we will do the bigger
# transfer or not. I'm guessing an heuristic to find
# that. I suppose that if the input of the recution is
# generated by an op that we can in some cases move to
# the GPU, that we will move it. If some CPU ops are
# supported only in some cases on the GPU, this will
# move to the GPU the reduction when it wasn't a good
# idea.
replace
=
True
if
replace
:
if
node
.
op
.
axis
is
None
:
reduce_mask
=
[
1
]
*
x
.
type
.
ndim
else
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论