Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c65fa17f
提交
c65fa17f
authored
11月 08, 2016
作者:
Alexander Matyasko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add gpu max and average pooling
上级
ecfc65ec
全部展开
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
52 行增加
和
0 行删除
+52
-0
blas.py
theano/gpuarray/blas.py
+52
-0
pool.c
theano/gpuarray/pool.c
+0
-0
没有找到文件。
theano/gpuarray/blas.py
浏览文件 @
c65fa17f
...
...
@@ -1550,6 +1550,58 @@ class GpuCorr3dMM_gradInputs(BaseGpuCorr3dMM):
return
[[
1
],
[
1
],
[
0
],
[
0
],
[
0
]]
# no connection to height, width, depth
class
GpuPool
(
CGpuKernelBase
):
"""
Implement the max and average pooling on the gpu.
"""
__props__
=
(
'ignore_border'
,
'mode'
,
'ndim'
)
def
__init__
(
self
,
ignore_border
,
mode
=
'max'
,
ndim
=
2
):
self
.
ndim
=
ndim
self
.
ignore_border
=
ignore_border
if
mode
==
'average'
:
mode
=
'average_inc_pad'
self
.
mode
=
mode
CGpuKernelBase
.
__init__
(
self
,
[
'pool.c'
],
'APPLY_SPECIFIC(pool)'
)
assert
mode
in
(
'max'
,
'sum'
,
'average_inc_pad'
,
'average_exc_pad'
)
assert
self
.
ndim
in
[
2
,
3
]
def
c_headers
(
self
):
return
[
'gpuarray_api.h'
,
'gpuarray_helper.h'
,
'numpy_compat.h'
,
'float.h'
]
def
c_header_dirs
(
self
):
return
[
os
.
path
.
dirname
(
__file__
),
pygpu
.
get_include
()]
def
make_node
(
self
,
inp
,
ws
,
stride
,
pad
):
ctx_name
=
infer_context_name
(
inp
)
inp
=
as_gpuarray_variable
(
inp
,
ctx_name
)
assert
(
inp
.
ndim
in
[
4
,
5
])
ws
=
as_tensor_variable
(
ws
)
stride
=
as_tensor_variable
(
stride
)
pad
=
as_tensor_variable
(
pad
)
assert
ws
.
type
.
ndim
==
stride
.
type
.
ndim
and
ws
.
type
.
ndim
==
pad
.
type
.
ndim
assert
ws
.
type
.
ndim
==
1
return
Apply
(
self
,
[
inp
,
ws
,
stride
,
pad
],
[
inp
.
type
()])
def
get_params
(
self
,
node
):
return
node
.
inputs
[
0
]
.
type
.
context
def
get_op_params
(
self
):
ignore_border
=
int
(
self
.
ignore_border
)
max_pool
=
int
(
self
.
mode
==
'max'
)
inc_pad
=
int
(
self
.
mode
!=
'average_exc_pad'
)
sum_mode
=
int
(
self
.
mode
==
'sum'
)
return
[(
'IGNORE_BORDER'
,
ignore_border
),
(
'INC_PAD'
,
inc_pad
),
(
'MAX_POOL'
,
max_pool
),
(
'SUM_MODE'
,
sum_mode
)]
class
GpuDownsampleFactorMaxGradGrad
(
CGpuKernelBase
):
"""
Implement the grad of downsample with max on the gpu.
...
...
theano/gpuarray/pool.c
0 → 100644
浏览文件 @
c65fa17f
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论