Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
8691b31a
提交
8691b31a
authored
6月 05, 2017
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix offsets for pooling.
上级
26890672
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
114 行增加
和
60 行删除
+114
-60
pool.c
theano/gpuarray/pool.c
+32
-20
pool_ave_grad.c
theano/gpuarray/pool_ave_grad.c
+19
-10
pool_grad_grad.c
theano/gpuarray/pool_grad_grad.c
+22
-10
pool_max_grad.c
theano/gpuarray/pool_max_grad.c
+22
-10
pool_max_rop.c
theano/gpuarray/pool_max_rop.c
+19
-10
没有找到文件。
theano/gpuarray/pool.c
浏览文件 @
8691b31a
#section kernels
#kernel max_pool2d_kernel : size, size, size, size, size, size, size, *, size, size, size, size, size, size,
*
:
#kernel max_pool2d_kernel : size, size, size, size, size, size, size, *, size, size, size, size, size, size,
size, *, size
:
// (borrowed from Caffe: https://github.com/BVLC/caffe/blob/master/src/caffe/layers/pooling_layer.cu)
KERNEL
void
max_pool2d_kernel
(
const
ga_size
nthreads
,
const
ga_size
num
,
const
ga_size
channels
,
const
ga_size
pooled_height
,
const
ga_size
pooled_width
,
const
ga_size
height
,
const
ga_size
width
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
kernel_h
,
const
ga_size
kernel_w
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
x_off
,
const
ga_size
kernel_h
,
const
ga_size
kernel_w
,
const
ga_size
stride_h
,
const
ga_size
stride_w
,
const
ga_size
pad_h
,
const
ga_size
pad_w
,
GLOBAL_MEM
DTYPE_OUTPUT_0
*
z
)
GLOBAL_MEM
DTYPE_OUTPUT_0
*
z
,
const
ga_size
z_off
)
{
x
=
(
GLOBAL_MEM
DTYPE_INPUT_0
*
)(((
char
*
)
x
)
+
x_off
);
z
=
(
GLOBAL_MEM
DTYPE_OUTPUT_0
*
)(((
char
*
)
z
)
+
z_off
);
// grid stride looping
for
(
ga_size
index
=
GID_0
*
LDIM_0
+
LID_0
;
index
<
nthreads
;
...
...
@@ -41,18 +43,20 @@ KERNEL void max_pool2d_kernel(const ga_size nthreads,
}
}
#kernel max_pool3d_kernel : size, size, size, size, size, size, size, size, size, *, size, size, size, size, size, size, size, size, size,
*
:
#kernel max_pool3d_kernel : size, size, size, size, size, size, size, size, size, *, size, size, size, size, size, size, size, size, size,
size, *, size
:
// (adopted from Caffe: https://github.com/BVLC/caffe/blob/master/src/caffe/layers/pooling_layer.cu)
KERNEL
void
max_pool3d_kernel
(
const
ga_size
nthreads
,
const
ga_size
num
,
const
ga_size
channels
,
const
ga_size
pooled_depth
,
const
ga_size
pooled_height
,
const
ga_size
pooled_width
,
const
ga_size
depth
,
const
ga_size
height
,
const
ga_size
width
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
kernel_d
,
const
ga_size
kernel_h
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
x_off
,
const
ga_size
kernel_d
,
const
ga_size
kernel_h
,
const
ga_size
kernel_w
,
const
ga_size
stride_d
,
const
ga_size
stride_h
,
const
ga_size
stride_w
,
const
ga_size
pad_d
,
const
ga_size
pad_h
,
const
ga_size
pad_w
,
GLOBAL_MEM
DTYPE_OUTPUT_0
*
z
)
GLOBAL_MEM
DTYPE_OUTPUT_0
*
z
,
const
ga_size
z_off
)
{
x
=
(
GLOBAL_MEM
DTYPE_INPUT_0
*
)(((
char
*
)
x
)
+
x_off
);
z
=
(
GLOBAL_MEM
DTYPE_OUTPUT_0
*
)(((
char
*
)
z
)
+
z_off
);
// grid stride looping
for
(
ga_size
index
=
GID_0
*
LDIM_0
+
LID_0
;
index
<
nthreads
;
...
...
@@ -90,17 +94,19 @@ KERNEL void max_pool3d_kernel(const ga_size nthreads,
}
}
#kernel ave_pool2d_kernel : size, size, size, size, size, size, size, *, size, size, size, size, size, size, size, size,
*
:
#kernel ave_pool2d_kernel : size, size, size, size, size, size, size, *, size, size, size, size, size, size, size, size,
size, *, size
:
// (adopted from Caffe: https://github.com/BVLC/caffe/blob/master/src/caffe/layers/pooling_layer.cu)
KERNEL
void
ave_pool2d_kernel
(
const
ga_size
nthreads
,
const
ga_size
num
,
const
ga_size
channels
,
const
ga_size
pooled_height
,
const
ga_size
pooled_width
,
const
ga_size
height
,
const
ga_size
width
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
kernel_h
,
const
ga_size
kernel_w
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
x_off
,
const
ga_size
kernel_h
,
const
ga_size
kernel_w
,
const
ga_size
stride_h
,
const
ga_size
stride_w
,
const
ga_size
pad_h
,
const
ga_size
pad_w
,
const
ga_bool
inc_pad
,
const
ga_bool
sum_mode
,
GLOBAL_MEM
DTYPE_OUTPUT_0
*
z
)
GLOBAL_MEM
DTYPE_OUTPUT_0
*
z
,
const
ga_size
z_off
)
{
x
=
(
GLOBAL_MEM
DTYPE_INPUT_0
*
)(((
char
*
)
x
)
+
x_off
);
z
=
(
GLOBAL_MEM
DTYPE_OUTPUT_0
*
)(((
char
*
)
z
)
+
z_off
);
// grid stride looping
for
(
ga_size
index
=
GID_0
*
LDIM_0
+
LID_0
;
index
<
nthreads
;
...
...
@@ -143,20 +149,22 @@ KERNEL void ave_pool2d_kernel(const ga_size nthreads,
}
}
#kernel ave_pool3d_kernel : size, size, size, size, size, size, size, size, size, *, size, size, size, size, size, size, size, size, size, size, size,
*
:
#kernel ave_pool3d_kernel : size, size, size, size, size, size, size, size, size, *, size, size, size, size, size, size, size, size, size, size, size,
size, *, size
:
// (adopted from Caffe: https://github.com/BVLC/caffe/blob/master/src/caffe/layers/pooling_layer.cu)
KERNEL
void
ave_pool3d_kernel
(
const
ga_size
nthreads
,
const
ga_size
num
,
const
ga_size
channels
,
const
ga_size
pooled_depth
,
const
ga_size
pooled_height
,
const
ga_size
pooled_width
,
const
ga_size
depth
,
const
ga_size
height
,
const
ga_size
width
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
kernel_d
,
const
ga_size
kernel_h
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
x_off
,
const
ga_size
kernel_d
,
const
ga_size
kernel_h
,
const
ga_size
kernel_w
,
const
ga_size
stride_d
,
const
ga_size
stride_h
,
const
ga_size
stride_w
,
const
ga_size
pad_d
,
const
ga_size
pad_h
,
const
ga_size
pad_w
,
const
ga_bool
inc_pad
,
const
ga_bool
sum_mode
,
GLOBAL_MEM
DTYPE_OUTPUT_0
*
z
)
GLOBAL_MEM
DTYPE_OUTPUT_0
*
z
,
const
ga_size
z_off
)
{
// grid stride looping
x
=
(
GLOBAL_MEM
DTYPE_INPUT_0
*
)(((
char
*
)
x
)
+
x_off
);
z
=
(
GLOBAL_MEM
DTYPE_OUTPUT_0
*
)(((
char
*
)
z
)
+
z_off
);
for
(
ga_size
index
=
GID_0
*
LDIM_0
+
LID_0
;
index
<
nthreads
;
index
+=
LDIM_0
*
GDIM_0
)
{
...
...
@@ -273,8 +281,8 @@ int APPLY_SPECIFIC(pool)(PyGpuArrayObject *x,
err
=
max_pool2d_kernel_scall
(
1
,
&
num_kernels
,
0
,
num_kernels
,
z_dims
[
0
],
z_dims
[
1
],
z_dims
[
2
],
z_dims
[
3
],
x_dims
[
2
],
x_dims
[
3
],
x
->
ga
.
data
,
w
[
0
],
w
[
1
],
s
[
0
],
s
[
1
],
p
[
0
],
p
[
1
],
(
*
z
)
->
ga
.
data
);
x
->
ga
.
data
,
x
->
ga
.
offset
,
w
[
0
],
w
[
1
],
s
[
0
],
s
[
1
],
p
[
0
],
p
[
1
],
(
*
z
)
->
ga
.
data
,
(
*
z
)
->
ga
.
offset
);
if
(
err
!=
GA_NO_ERROR
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"GpuPool: max_pool2d_kernel %s."
,
...
...
@@ -285,8 +293,10 @@ int APPLY_SPECIFIC(pool)(PyGpuArrayObject *x,
err
=
ave_pool2d_kernel_scall
(
1
,
&
num_kernels
,
0
,
num_kernels
,
z_dims
[
0
],
z_dims
[
1
],
z_dims
[
2
],
z_dims
[
3
],
x_dims
[
2
],
x_dims
[
3
],
x
->
ga
.
data
,
w
[
0
],
w
[
1
],
s
[
0
],
s
[
1
],
p
[
0
],
p
[
1
],
INC_PAD
,
SUM_MODE
,
(
*
z
)
->
ga
.
data
);
x
->
ga
.
data
,
x
->
ga
.
offset
,
w
[
0
],
w
[
1
],
s
[
0
],
s
[
1
],
p
[
0
],
p
[
1
],
INC_PAD
,
SUM_MODE
,
(
*
z
)
->
ga
.
data
,
(
*
z
)
->
ga
.
offset
);
if
(
err
!=
GA_NO_ERROR
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"GpuPool: ave_pool2d_kernel %s."
,
...
...
@@ -301,8 +311,8 @@ int APPLY_SPECIFIC(pool)(PyGpuArrayObject *x,
err
=
max_pool3d_kernel_scall
(
1
,
&
num_kernels
,
0
,
num_kernels
,
z_dims
[
0
],
z_dims
[
1
],
z_dims
[
2
],
z_dims
[
3
],
z_dims
[
4
],
x_dims
[
2
],
x_dims
[
3
],
x_dims
[
4
],
x
->
ga
.
data
,
w
[
0
],
w
[
1
],
w
[
2
],
s
[
0
],
s
[
1
],
s
[
2
],
p
[
0
],
p
[
1
],
p
[
2
],
(
*
z
)
->
ga
.
data
);
x
->
ga
.
data
,
x
->
ga
.
offset
,
w
[
0
],
w
[
1
],
w
[
2
],
s
[
0
],
s
[
1
],
s
[
2
],
p
[
0
],
p
[
1
],
p
[
2
],
(
*
z
)
->
ga
.
data
,
(
*
z
)
->
ga
.
offset
);
if
(
err
!=
GA_NO_ERROR
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"GpuPool: max_pool3d_kernel %s."
,
...
...
@@ -313,9 +323,11 @@ int APPLY_SPECIFIC(pool)(PyGpuArrayObject *x,
err
=
ave_pool3d_kernel_scall
(
1
,
&
num_kernels
,
0
,
num_kernels
,
z_dims
[
0
],
z_dims
[
1
],
z_dims
[
2
],
z_dims
[
3
],
z_dims
[
4
],
x_dims
[
2
],
x_dims
[
3
],
x_dims
[
4
],
x
->
ga
.
data
,
w
[
0
],
w
[
1
],
w
[
2
],
s
[
0
],
s
[
1
],
s
[
2
],
x
->
ga
.
data
,
x
->
ga
.
offset
,
w
[
0
],
w
[
1
],
w
[
2
],
s
[
0
],
s
[
1
],
s
[
2
],
p
[
0
],
p
[
1
],
p
[
2
],
INC_PAD
,
SUM_MODE
,
(
*
z
)
->
ga
.
data
);
INC_PAD
,
SUM_MODE
,
(
*
z
)
->
ga
.
data
,
(
*
z
)
->
ga
.
offset
);
if
(
err
!=
GA_NO_ERROR
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"GpuPool: ave_pool3d_kernel %s."
,
...
...
theano/gpuarray/pool_ave_grad.c
浏览文件 @
8691b31a
#section kernels
#kernel ave_pool2d_grad_kernel : size, size, size, size, size, size, size, *,
*, size, size, size, size, size, size, size, size, *
:
#kernel ave_pool2d_grad_kernel : size, size, size, size, size, size, size, *,
size, *, size, size, size, size, size, size, size, size, size, *, size
:
// (adopted from Caffe: https://github.com/BVLC/caffe/blob/master/src/caffe/layers/pooling_layer.cu)
KERNEL
void
ave_pool2d_grad_kernel
(
const
ga_size
nthreads
,
const
ga_size
num
,
const
ga_size
channels
,
const
ga_size
height
,
const
ga_size
width
,
const
ga_size
pooled_height
,
const
ga_size
pooled_width
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
gz
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
x_off
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
gz
,
const
ga_size
gz_off
,
const
ga_size
kernel_h
,
const
ga_size
kernel_w
,
const
ga_size
stride_h
,
const
ga_size
stride_w
,
const
ga_size
pad_h
,
const
ga_size
pad_w
,
const
ga_bool
inc_pad
,
const
ga_bool
sum_mode
,
GLOBAL_MEM
DTYPE_OUTPUT_0
*
gx
)
GLOBAL_MEM
DTYPE_OUTPUT_0
*
gx
,
const
ga_size
gx_off
)
{
x
=
(
GLOBAL_MEM
const
DTYPE_INPUT_0
*
)(((
char
*
)
x
)
+
x_off
);
gz
=
(
GLOBAL_MEM
const
DTYPE_INPUT_1
*
)(((
char
*
)
gz
)
+
gz_off
);
gx
=
(
GLOBAL_MEM
DTYPE_OUTPUT_0
*
)(((
char
*
)
gx
)
+
gx_off
);
// grid stride looping
for
(
ga_size
index
=
GID_0
*
LDIM_0
+
LID_0
;
index
<
nthreads
;
index
+=
LDIM_0
*
GDIM_0
)
{
...
...
@@ -46,19 +49,22 @@ KERNEL void ave_pool2d_grad_kernel(const ga_size nthreads,
}
}
#kernel ave_pool3d_grad_kernel : size, size, size, size, size, size, size, size, size, *,
*, size, size, size, size, size, size, size, size, size, size, size, *
:
#kernel ave_pool3d_grad_kernel : size, size, size, size, size, size, size, size, size, *,
size, *, size, size, size, size, size, size, size, size, size, size, size, size, *, size
:
// (adopted from Caffe: https://github.com/BVLC/caffe/blob/master/src/caffe/layers/pooling_layer.cu)
KERNEL
void
ave_pool3d_grad_kernel
(
const
ga_size
nthreads
,
const
ga_size
num
,
const
ga_size
channels
,
const
ga_size
depth
,
const
ga_size
height
,
const
ga_size
width
,
const
ga_size
pooled_depth
,
const
ga_size
pooled_height
,
const
ga_size
pooled_width
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
gz
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
x_off
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
gz
,
const
ga_size
gz_off
,
const
ga_size
kernel_d
,
const
ga_size
kernel_h
,
const
ga_size
kernel_w
,
const
ga_size
stride_d
,
const
ga_size
stride_h
,
const
ga_size
stride_w
,
const
ga_size
pad_d
,
const
ga_size
pad_h
,
const
ga_size
pad_w
,
const
ga_bool
inc_pad
,
const
ga_bool
sum_mode
,
GLOBAL_MEM
DTYPE_OUTPUT_0
*
gx
)
const
ga_bool
inc_pad
,
const
ga_bool
sum_mode
,
GLOBAL_MEM
DTYPE_OUTPUT_0
*
gx
,
const
ga_size
gx_off
)
{
x
=
(
GLOBAL_MEM
const
DTYPE_INPUT_0
*
)(((
char
*
)
x
)
+
x_off
);
gz
=
(
GLOBAL_MEM
const
DTYPE_INPUT_1
*
)(((
char
*
)
gz
)
+
gz_off
);
gx
=
(
GLOBAL_MEM
DTYPE_OUTPUT_0
*
)(((
char
*
)
gx
)
+
gx_off
);
// grid stride looping
for
(
ga_size
index
=
GID_0
*
LDIM_0
+
LID_0
;
index
<
nthreads
;
index
+=
LDIM_0
*
GDIM_0
)
{
...
...
@@ -152,9 +158,11 @@ int APPLY_SPECIFIC(ave_pool_grad)(PyGpuArrayObject *x,
err
=
ave_pool2d_grad_kernel_scall
(
1
,
&
num_kernels
,
0
,
num_kernels
,
x_dims
[
0
],
x_dims
[
1
],
x_dims
[
2
],
x_dims
[
3
],
z_dims
[
2
],
z_dims
[
3
],
x
->
ga
.
data
,
gz
->
ga
.
data
,
x
->
ga
.
data
,
x
->
ga
.
offset
,
gz
->
ga
.
data
,
gz
->
ga
.
offset
,
w
[
0
],
w
[
1
],
s
[
0
],
s
[
1
],
p
[
0
],
p
[
1
],
INC_PAD
,
SUM_MODE
,
(
*
gx
)
->
ga
.
data
);
INC_PAD
,
SUM_MODE
,
(
*
gx
)
->
ga
.
data
,
(
*
gx
)
->
ga
.
offset
);
if
(
err
!=
GA_NO_ERROR
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"GpuAveragePoolGrad: ave_pool2d_grad_kernel %s."
,
...
...
@@ -166,10 +174,11 @@ int APPLY_SPECIFIC(ave_pool_grad)(PyGpuArrayObject *x,
err
=
ave_pool3d_grad_kernel_scall
(
1
,
&
num_kernels
,
0
,
num_kernels
,
x_dims
[
0
],
x_dims
[
1
],
x_dims
[
2
],
x_dims
[
3
],
x_dims
[
4
],
z_dims
[
2
],
z_dims
[
3
],
z_dims
[
4
],
x
->
ga
.
data
,
gz
->
ga
.
data
,
x
->
ga
.
data
,
x
->
ga
.
offset
,
gz
->
ga
.
data
,
gz
->
ga
.
offset
,
w
[
0
],
w
[
1
],
w
[
2
],
s
[
0
],
s
[
1
],
s
[
2
],
p
[
0
],
p
[
1
],
p
[
2
],
INC_PAD
,
SUM_MODE
,
(
*
gx
)
->
ga
.
data
);
(
*
gx
)
->
ga
.
data
,
(
*
gx
)
->
ga
.
offset
);
if
(
err
!=
GA_NO_ERROR
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"GpuAveragePoolGrad: ave_pool3d_grad_kernel %s."
,
...
...
theano/gpuarray/pool_grad_grad.c
浏览文件 @
8691b31a
#section kernels
#kernel max_pool2d_grad_grad_kernel : size, size, size, size, size, size, size, *,
*, *, size, size, size, size, size, size, *
:
#kernel max_pool2d_grad_grad_kernel : size, size, size, size, size, size, size, *,
size, *, size, *, size, size, size, size, size, size, size, *, size
:
KERNEL
void
max_pool2d_grad_grad_kernel
(
const
ga_size
nthreads
,
const
ga_size
num
,
const
ga_size
channels
,
const
ga_size
pooled_height
,
const
ga_size
pooled_width
,
const
ga_size
height
,
const
ga_size
width
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
z
,
GLOBAL_MEM
const
DTYPE_INPUT_2
*
gx
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
x_off
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
z
,
const
ga_size
z_off
,
GLOBAL_MEM
const
DTYPE_INPUT_2
*
gx
,
const
ga_size
gx_off
,
const
ga_size
kernel_h
,
const
ga_size
kernel_w
,
const
ga_size
stride_h
,
const
ga_size
stride_w
,
const
ga_size
pad_h
,
const
ga_size
pad_w
,
GLOBAL_MEM
DTYPE_OUTPUT_0
*
gz
)
GLOBAL_MEM
DTYPE_OUTPUT_0
*
gz
,
const
ga_size
gz_off
)
{
x
=
(
GLOBAL_MEM
DTYPE_INPUT_0
*
)(((
char
*
)
x
)
+
x_off
);
z
=
(
GLOBAL_MEM
DTYPE_INPUT_1
*
)(((
char
*
)
z
)
+
z_off
);
gx
=
(
GLOBAL_MEM
DTYPE_INPUT_2
*
)(((
char
*
)
gx
)
+
gx_off
);
gz
=
(
GLOBAL_MEM
DTYPE_OUTPUT_0
*
)(((
char
*
)
gz
)
+
gz_off
);
// grid stride looping
for
(
ga_size
index
=
GID_0
*
LDIM_0
+
LID_0
;
index
<
nthreads
;
index
+=
LDIM_0
*
GDIM_0
)
{
...
...
@@ -42,18 +46,22 @@ KERNEL void max_pool2d_grad_grad_kernel(const ga_size nthreads,
}
}
#kernel max_pool3d_grad_grad_kernel : size, size, size, size, size, size, size, size, size, *,
*, *, size, size, size, size, size, size, size, size, size, *
:
#kernel max_pool3d_grad_grad_kernel : size, size, size, size, size, size, size, size, size, *,
size, *, size, *, size, size, size, size, size, size, size, size, size, size, *, size
:
KERNEL
void
max_pool3d_grad_grad_kernel
(
const
ga_size
nthreads
,
const
ga_size
num
,
const
ga_size
channels
,
const
ga_size
pooled_depth
,
const
ga_size
pooled_height
,
const
ga_size
pooled_width
,
const
ga_size
depth
,
const
ga_size
height
,
const
ga_size
width
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
z
,
GLOBAL_MEM
const
DTYPE_INPUT_2
*
gx
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
x_off
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
z
,
const
ga_size
z_off
,
GLOBAL_MEM
const
DTYPE_INPUT_2
*
gx
,
const
ga_size
gx_off
,
const
ga_size
kernel_d
,
const
ga_size
kernel_h
,
const
ga_size
kernel_w
,
const
ga_size
stride_d
,
const
ga_size
stride_h
,
const
ga_size
stride_w
,
const
ga_size
pad_d
,
const
ga_size
pad_h
,
const
ga_size
pad_w
,
GLOBAL_MEM
DTYPE_OUTPUT_0
*
gz
)
GLOBAL_MEM
DTYPE_OUTPUT_0
*
gz
,
const
ga_size
gz_off
)
{
x
=
(
GLOBAL_MEM
DTYPE_INPUT_0
*
)(((
char
*
)
x
)
+
x_off
);
z
=
(
GLOBAL_MEM
DTYPE_INPUT_1
*
)(((
char
*
)
z
)
+
z_off
);
gx
=
(
GLOBAL_MEM
DTYPE_INPUT_2
*
)(((
char
*
)
gx
)
+
gx_off
);
gz
=
(
GLOBAL_MEM
DTYPE_OUTPUT_0
*
)(((
char
*
)
gz
)
+
gz_off
);
// grid stride looping
for
(
ga_size
index
=
GID_0
*
LDIM_0
+
LID_0
;
index
<
nthreads
;
index
+=
LDIM_0
*
GDIM_0
)
{
...
...
@@ -146,9 +154,11 @@ int APPLY_SPECIFIC(pool_grad_grad)(PyGpuArrayObject *x,
err
=
max_pool2d_grad_grad_kernel_scall
(
1
,
&
num_kernels
,
0
,
num_kernels
,
z_dims
[
0
],
z_dims
[
1
],
z_dims
[
2
],
z_dims
[
3
],
x_dims
[
2
],
x_dims
[
3
],
x
->
ga
.
data
,
z
->
ga
.
data
,
gx
->
ga
.
data
,
x
->
ga
.
data
,
x
->
ga
.
offset
,
z
->
ga
.
data
,
z
->
ga
.
offset
,
gx
->
ga
.
data
,
gx
->
ga
.
offset
,
w
[
0
],
w
[
1
],
s
[
0
],
s
[
1
],
p
[
0
],
p
[
1
],
(
*
gz
)
->
ga
.
data
);
(
*
gz
)
->
ga
.
data
,
(
*
gz
)
->
ga
.
offset
);
if
(
err
!=
GA_NO_ERROR
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"GpuPoolingGradGrad: max_pool2d_grad_grad_kernel %s."
,
...
...
@@ -161,9 +171,11 @@ int APPLY_SPECIFIC(pool_grad_grad)(PyGpuArrayObject *x,
err
=
max_pool3d_grad_grad_kernel_scall
(
1
,
&
num_kernels
,
0
,
num_kernels
,
z_dims
[
0
],
z_dims
[
1
],
z_dims
[
2
],
z_dims
[
3
],
z_dims
[
4
],
x_dims
[
2
],
x_dims
[
3
],
x_dims
[
4
],
x
->
ga
.
data
,
z
->
ga
.
data
,
gx
->
ga
.
data
,
x
->
ga
.
data
,
x
->
ga
.
offset
,
z
->
ga
.
data
,
z
->
ga
.
offset
,
gx
->
ga
.
data
,
gx
->
ga
.
offset
,
w
[
0
],
w
[
1
],
w
[
2
],
s
[
0
],
s
[
1
],
s
[
2
],
p
[
0
],
p
[
1
],
p
[
2
],
(
*
gz
)
->
ga
.
data
);
(
*
gz
)
->
ga
.
data
,
(
*
gz
)
->
ga
.
offset
);
if
(
err
!=
GA_NO_ERROR
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"GpuPoolingGradGrad: max_pool3d_grad_grad_kernel %s."
,
...
...
theano/gpuarray/pool_max_grad.c
浏览文件 @
8691b31a
#section kernels
#kernel max_pool2d_grad_kernel : size, size, size, size, size, size, size, *,
*, *, size, size, size, size, size, size, *
:
#kernel max_pool2d_grad_kernel : size, size, size, size, size, size, size, *,
size, *, size, *, size, size, size, size, size, size, size, *, size
:
// (borrowed from Caffe: https://github.com/BVLC/caffe/blob/master/src/caffe/layers/pooling_layer.cu)
KERNEL
void
max_pool2d_grad_kernel
(
const
ga_size
nthreads
,
const
ga_size
num
,
const
ga_size
channels
,
const
ga_size
height
,
const
ga_size
width
,
const
ga_size
pooled_height
,
const
ga_size
pooled_width
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
z
,
GLOBAL_MEM
const
DTYPE_INPUT_2
*
gz
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
x_off
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
z
,
const
ga_size
z_off
,
GLOBAL_MEM
const
DTYPE_INPUT_2
*
gz
,
const
ga_size
gz_off
,
const
ga_size
kernel_h
,
const
ga_size
kernel_w
,
const
ga_size
stride_h
,
const
ga_size
stride_w
,
const
ga_size
pad_h
,
const
ga_size
pad_w
,
GLOBAL_MEM
DTYPE_OUTPUT_0
*
gx
)
const
ga_size
pad_h
,
const
ga_size
pad_w
,
GLOBAL_MEM
DTYPE_OUTPUT_0
*
gx
,
const
ga_size
gx_off
)
{
x
=
(
GLOBAL_MEM
const
DTYPE_INPUT_0
*
)(((
char
*
)
x
)
+
x_off
);
z
=
(
GLOBAL_MEM
const
DTYPE_INPUT_1
*
)(((
char
*
)
z
)
+
z_off
);
gz
=
(
GLOBAL_MEM
const
DTYPE_INPUT_2
*
)(((
char
*
)
gz
)
+
gz_off
);
gx
=
(
GLOBAL_MEM
DTYPE_OUTPUT_0
*
)(((
char
*
)
gx
)
+
gx_off
);
// grid stride looping
for
(
ga_size
index
=
GID_0
*
LDIM_0
+
LID_0
;
index
<
nthreads
;
index
+=
LDIM_0
*
GDIM_0
)
{
...
...
@@ -38,19 +42,23 @@ KERNEL void max_pool2d_grad_kernel(const ga_size nthreads,
}
}
#kernel max_pool3d_grad_kernel : size, size, size, size, size, size, size, size, size, *,
*, *, size, size, size, size, size, size, size, size, size, *
:
#kernel max_pool3d_grad_kernel : size, size, size, size, size, size, size, size, size, *,
size, *, size, *, size, size, size, size, size, size, size, size, size, size, *, size
:
// (adopted from Caffe: https://github.com/BVLC/caffe/blob/master/src/caffe/layers/pooling_layer.cu)
KERNEL
void
max_pool3d_grad_kernel
(
const
ga_size
nthreads
,
const
ga_size
num
,
const
ga_size
channels
,
const
ga_size
depth
,
const
ga_size
height
,
const
ga_size
width
,
const
ga_size
pooled_depth
,
const
ga_size
pooled_height
,
const
ga_size
pooled_width
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
z
,
GLOBAL_MEM
const
DTYPE_INPUT_2
*
gz
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
x_off
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
z
,
const
ga_size
z_off
,
GLOBAL_MEM
const
DTYPE_INPUT_2
*
gz
,
const
ga_size
gz_off
,
const
ga_size
kernel_d
,
const
ga_size
kernel_h
,
const
ga_size
kernel_w
,
const
ga_size
stride_d
,
const
ga_size
stride_h
,
const
ga_size
stride_w
,
const
ga_size
pad_d
,
const
ga_size
pad_h
,
const
ga_size
pad_w
,
GLOBAL_MEM
DTYPE_OUTPUT_0
*
gx
)
GLOBAL_MEM
DTYPE_OUTPUT_0
*
gx
,
const
ga_size
gx_off
)
{
x
=
(
GLOBAL_MEM
const
DTYPE_INPUT_0
*
)(((
char
*
)
x
)
+
x_off
);
z
=
(
GLOBAL_MEM
const
DTYPE_INPUT_1
*
)(((
char
*
)
z
)
+
z_off
);
gz
=
(
GLOBAL_MEM
const
DTYPE_INPUT_2
*
)(((
char
*
)
gz
)
+
gz_off
);
gx
=
(
GLOBAL_MEM
DTYPE_OUTPUT_0
*
)(((
char
*
)
gx
)
+
gx_off
);
// grid stride looping
for
(
ga_size
index
=
GID_0
*
LDIM_0
+
LID_0
;
index
<
nthreads
;
index
+=
LDIM_0
*
GDIM_0
)
{
...
...
@@ -138,9 +146,11 @@ int APPLY_SPECIFIC(max_pool_grad)(PyGpuArrayObject *x,
err
=
max_pool2d_grad_kernel_scall
(
1
,
&
num_kernels
,
0
,
num_kernels
,
x_dims
[
0
],
x_dims
[
1
],
x_dims
[
2
],
x_dims
[
3
],
z_dims
[
2
],
z_dims
[
3
],
x
->
ga
.
data
,
z
->
ga
.
data
,
gz
->
ga
.
data
,
x
->
ga
.
data
,
x
->
ga
.
offset
,
z
->
ga
.
data
,
z
->
ga
.
offset
,
gz
->
ga
.
data
,
gz
->
ga
.
offset
,
w
[
0
],
w
[
1
],
s
[
0
],
s
[
1
],
p
[
0
],
p
[
1
],
(
*
gx
)
->
ga
.
data
);
(
*
gx
)
->
ga
.
data
,
(
*
gx
)
->
ga
.
offset
);
if
(
err
!=
GA_NO_ERROR
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"GpuMaxPoolGrad: max_pool2d_grad_kernel %s."
,
...
...
@@ -152,9 +162,11 @@ int APPLY_SPECIFIC(max_pool_grad)(PyGpuArrayObject *x,
err
=
max_pool3d_grad_kernel_scall
(
1
,
&
num_kernels
,
0
,
num_kernels
,
x_dims
[
0
],
x_dims
[
1
],
x_dims
[
2
],
x_dims
[
3
],
x_dims
[
4
],
z_dims
[
2
],
z_dims
[
3
],
z_dims
[
4
],
x
->
ga
.
data
,
z
->
ga
.
data
,
gz
->
ga
.
data
,
x
->
ga
.
data
,
x
->
ga
.
offset
,
z
->
ga
.
data
,
z
->
ga
.
offset
,
gz
->
ga
.
data
,
gz
->
ga
.
offset
,
w
[
0
],
w
[
1
],
w
[
2
],
s
[
0
],
s
[
1
],
s
[
2
],
p
[
0
],
p
[
1
],
p
[
2
],
(
*
gx
)
->
ga
.
data
);
p
[
0
],
p
[
1
],
p
[
2
],
(
*
gx
)
->
ga
.
data
,
(
*
gx
)
->
ga
.
offset
);
if
(
err
!=
GA_NO_ERROR
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"GpuMaxPoolGrad: max_pool3d_grad_kernel %s."
,
...
...
theano/gpuarray/pool_max_rop.c
浏览文件 @
8691b31a
#section kernels
#kernel max_pool2d_rop_kernel : size, size, size, size, size, size, size, *,
*, size, size, size, size, size, size, *
:
#kernel max_pool2d_rop_kernel : size, size, size, size, size, size, size, *,
size, *, size, size, size, size, size, size, size, *, size
:
// (borrowed from Caffe: https://github.com/BVLC/caffe/blob/master/src/caffe/layers/pooling_layer.cu)
KERNEL
void
max_pool2d_rop_kernel
(
const
ga_size
nthreads
,
const
ga_size
num
,
const
ga_size
channels
,
const
ga_size
pooled_height
,
const
ga_size
pooled_width
,
const
ga_size
height
,
const
ga_size
width
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
ex
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
x_off
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
ex
,
const
ga_size
ex_off
,
const
ga_size
kernel_h
,
const
ga_size
kernel_w
,
const
ga_size
stride_h
,
const
ga_size
stride_w
,
const
ga_size
pad_h
,
const
ga_size
pad_w
,
GLOBAL_MEM
DTYPE_OUTPUT_0
*
z
)
GLOBAL_MEM
DTYPE_OUTPUT_0
*
z
,
const
ga_size
z_off
)
{
x
=
(
GLOBAL_MEM
DTYPE_INPUT_0
*
x
)(((
char
*
)
x
)
+
x_off
);
ex
=
(
GLOBAL_MEM
DTYPE_INPUT_1
*
x
)(((
char
*
)
ex
)
+
ex_off
);
z
=
(
GLOBAL_MEM
DTYPE_OUTPUT_0
*
x
)(((
char
*
)
z
)
+
z_off
);
// grid stride looping
for
(
ga_size
index
=
GID_0
*
LDIM_0
+
LID_0
;
index
<
nthreads
;
...
...
@@ -46,19 +49,22 @@ KERNEL void max_pool2d_rop_kernel(const ga_size nthreads,
}
}
#kernel max_pool3d_rop_kernel : size, size, size, size, size, size, size, size, size, *,
*, size, size, size, size, size, size, size, size, size, *
:
#kernel max_pool3d_rop_kernel : size, size, size, size, size, size, size, size, size, *,
size, *, size, size, size, size, size, size, size, size, size, size, *, size
:
// (adopted from Caffe: https://github.com/BVLC/caffe/blob/master/src/caffe/layers/pooling_layer.cu)
KERNEL
void
max_pool3d_rop_kernel
(
const
ga_size
nthreads
,
const
ga_size
num
,
const
ga_size
channels
,
const
ga_size
pooled_depth
,
const
ga_size
pooled_height
,
const
ga_size
pooled_width
,
const
ga_size
depth
,
const
ga_size
height
,
const
ga_size
width
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
ex
,
GLOBAL_MEM
const
DTYPE_INPUT_0
*
x
,
const
ga_size
x_off
,
GLOBAL_MEM
const
DTYPE_INPUT_1
*
ex
,
const
ga_size
ex_off
,
const
ga_size
kernel_d
,
const
ga_size
kernel_h
,
const
ga_size
kernel_w
,
const
ga_size
stride_d
,
const
ga_size
stride_h
,
const
ga_size
stride_w
,
const
ga_size
pad_d
,
const
ga_size
pad_h
,
const
ga_size
pad_w
,
GLOBAL_MEM
DTYPE_OUTPUT_0
*
z
)
GLOBAL_MEM
DTYPE_OUTPUT_0
*
z
,
const
ga_size
x_off
)
{
x
=
(
GLOBAL_MEM
DTYPE_INPUT_0
*
x
)(((
char
*
)
x
)
+
x_off
);
ex
=
(
GLOBAL_MEM
DTYPE_INPUT_1
*
x
)(((
char
*
)
ex
)
+
ex_off
);
z
=
(
GLOBAL_MEM
DTYPE_OUTPUT_0
*
x
)(((
char
*
)
z
)
+
z_off
);
// grid stride looping
for
(
ga_size
index
=
GID_0
*
LDIM_0
+
LID_0
;
index
<
nthreads
;
...
...
@@ -167,9 +173,10 @@ int APPLY_SPECIFIC(max_pool_rop)(PyGpuArrayObject *x,
err
=
max_pool2d_rop_kernel_scall
(
1
,
&
num_kernels
,
0
,
num_kernels
,
z_dims
[
0
],
z_dims
[
1
],
z_dims
[
2
],
z_dims
[
3
],
x_dims
[
2
],
x_dims
[
3
],
x
->
ga
.
data
,
ex
->
ga
.
data
,
x
->
ga
.
data
,
x
->
ga
.
offset
,
ex
->
ga
.
data
,
ex
->
ga
.
offset
,
w
[
0
],
w
[
1
],
s
[
0
],
s
[
1
],
p
[
0
],
p
[
1
],
(
*
z
)
->
ga
.
data
);
(
*
z
)
->
ga
.
data
,
(
*
z
)
->
ga
.
offset
);
if
(
err
!=
GA_NO_ERROR
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"GpuMaxPoolRop: max_pool2d_rop_kernel %s."
,
...
...
@@ -182,9 +189,11 @@ int APPLY_SPECIFIC(max_pool_rop)(PyGpuArrayObject *x,
err
=
max_pool3d_rop_kernel_scall
(
1
,
&
num_kernels
,
0
,
num_kernels
,
z_dims
[
0
],
z_dims
[
1
],
z_dims
[
2
],
z_dims
[
3
],
z_dims
[
4
],
x_dims
[
2
],
x_dims
[
3
],
x_dims
[
4
],
x
->
ga
.
data
,
ex
->
ga
.
data
,
x
->
ga
.
data
,
x
->
ga
.
offset
,
ex
->
ga
.
data
,
ex
->
ga
.
offset
,
w
[
0
],
w
[
1
],
w
[
2
],
s
[
0
],
s
[
1
],
s
[
2
],
p
[
0
],
p
[
1
],
p
[
2
],
(
*
z
)
->
ga
.
data
);
p
[
0
],
p
[
1
],
p
[
2
],
(
*
z
)
->
ga
.
data
,
(
*
z
)
->
ga
.
offset
);
if
(
err
!=
GA_NO_ERROR
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"GpuMaxPoolRop: max_pool3d_rop_kernel %s."
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论