Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c66b296e
提交
c66b296e
authored
2月 21, 2017
作者:
notoraptor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Apply same changes to all ops in `gpuarray/pool.py`.
Cast ws, strides and pads to 64 bits integers into both Python and C code for all these ops.
上级
49eb0c80
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
30 行增加
和
24 行删除
+30
-24
pool.c
theano/gpuarray/pool.c
+3
-3
pool.py
theano/gpuarray/pool.py
+15
-9
pool_ave_grad.c
theano/gpuarray/pool_ave_grad.c
+3
-3
pool_grad_grad.c
theano/gpuarray/pool_grad_grad.c
+3
-3
pool_max_grad.c
theano/gpuarray/pool_max_grad.c
+3
-3
pool_max_rop.c
theano/gpuarray/pool_max_rop.c
+3
-3
没有找到文件。
theano/gpuarray/pool.c
浏览文件 @
c66b296e
...
...
@@ -241,9 +241,9 @@ int APPLY_SPECIFIC(pool)(PyGpuArrayObject *x,
size_t
p
[
3
];
z_dims
[
0
]
=
x_dims
[
0
];
z_dims
[
1
]
=
x_dims
[
1
];
int
nonzero_padding
=
0
;
for
(
int
i
=
0
;
i
<
ndims
;
i
++
)
{
w
[
i
]
=
*
((
npy_int
p
*
)
PyArray_GETPTR1
(
ws
,
i
));
s
[
i
]
=
*
((
npy_int
p
*
)
PyArray_GETPTR1
(
stride
,
i
));
p
[
i
]
=
*
((
npy_int
p
*
)
PyArray_GETPTR1
(
pad
,
i
));
w
[
i
]
=
*
((
npy_int
64
*
)
PyArray_GETPTR1
(
ws
,
i
));
s
[
i
]
=
*
((
npy_int
64
*
)
PyArray_GETPTR1
(
stride
,
i
));
p
[
i
]
=
*
((
npy_int
64
*
)
PyArray_GETPTR1
(
pad
,
i
));
z_dims
[
2
+
i
]
=
OUTPUT_DIMS
(
x_dims
[
2
+
i
]
+
2
*
p
[
i
],
w
[
i
],
s
[
i
]);
if
(
p
[
i
]
>
0
)
{
nonzero_padding
=
1
;
...
...
theano/gpuarray/pool.py
浏览文件 @
c66b296e
...
...
@@ -2,7 +2,6 @@ from __future__ import absolute_import, print_function, division
import
os.path
import
theano
import
numpy
as
np
from
theano
import
Apply
from
theano.tensor.basic
import
as_tensor_variable
from
theano.tensor.signal.pool
import
Pool
...
...
@@ -16,6 +15,8 @@ except ImportError as e:
# To make sure theano is importable
pass
dtype_name_for_casting
=
'int64'
class
GpuPool
(
CGpuKernelBase
):
"""
...
...
@@ -68,9 +69,7 @@ class GpuPool(CGpuKernelBase):
raise
TypeError
(
'Stride parameters must be ints.'
)
if
pad
.
dtype
not
in
theano
.
tensor
.
int_dtypes
:
raise
TypeError
(
'Padding parameters must be ints.'
)
# I can't assume that npy_intp is 64 bits, as it can be 32 bits on some computers (according to NumPy doc),
# so I prefer to use the "bit-width name for this data-type" for casting.
dtype_name_for_casting
=
np
.
dtype
(
np
.
intp
)
.
name
ws
=
theano
.
tensor
.
cast
(
ws
,
dtype_name_for_casting
)
stride
=
theano
.
tensor
.
cast
(
stride
,
dtype_name_for_casting
)
pad
=
theano
.
tensor
.
cast
(
pad
,
dtype_name_for_casting
)
...
...
@@ -191,7 +190,6 @@ class GpuMaxPoolGrad(CGpuKernelBase):
if
pad
.
dtype
not
in
theano
.
tensor
.
int_dtypes
:
raise
TypeError
(
'Padding parameters must be ints.'
)
dtype_name_for_casting
=
np
.
dtype
(
np
.
intp
)
.
name
ws
=
theano
.
tensor
.
cast
(
ws
,
dtype_name_for_casting
)
stride
=
theano
.
tensor
.
cast
(
stride
,
dtype_name_for_casting
)
pad
=
theano
.
tensor
.
cast
(
pad
,
dtype_name_for_casting
)
...
...
@@ -271,7 +269,6 @@ class GpuAveragePoolGrad(CGpuKernelBase):
if
pad
.
dtype
not
in
theano
.
tensor
.
int_dtypes
:
raise
TypeError
(
'Padding parameters must be ints.'
)
dtype_name_for_casting
=
np
.
dtype
(
np
.
intp
)
.
name
ws
=
theano
.
tensor
.
cast
(
ws
,
dtype_name_for_casting
)
stride
=
theano
.
tensor
.
cast
(
stride
,
dtype_name_for_casting
)
pad
=
theano
.
tensor
.
cast
(
pad
,
dtype_name_for_casting
)
...
...
@@ -353,6 +350,11 @@ class GpuDownsampleFactorMaxGradGrad(CGpuKernelBase):
raise
TypeError
(
'Stride parameters must be ints.'
)
if
pad
.
dtype
not
in
theano
.
tensor
.
int_dtypes
:
raise
TypeError
(
'Padding parameters must be ints.'
)
ws
=
theano
.
tensor
.
cast
(
ws
,
dtype_name_for_casting
)
stride
=
theano
.
tensor
.
cast
(
stride
,
dtype_name_for_casting
)
pad
=
theano
.
tensor
.
cast
(
pad
,
dtype_name_for_casting
)
return
Apply
(
self
,
[
inp
,
out
,
out_grad
,
ws
,
stride
,
pad
],
[
inp
.
type
()])
def
get_params
(
self
,
node
):
...
...
@@ -421,13 +423,17 @@ class GpuMaxPoolRop(CGpuKernelBase):
pad
=
as_tensor_variable
(
pad
)
assert
ws
.
ndim
==
stride
.
ndim
and
ws
.
ndim
==
pad
.
ndim
assert
ws
.
ndim
==
1
if
not
ws
.
dtype
.
startswith
(
'int'
)
:
if
ws
.
dtype
not
in
theano
.
tensor
.
int_dtypes
:
raise
TypeError
(
'Window shape parameters must be ints.'
)
if
not
stride
.
dtype
.
startswith
(
'int'
)
:
if
stride
.
dtype
not
in
theano
.
tensor
.
int_dtypes
:
raise
TypeError
(
'Stride parameters must be ints.'
)
if
not
pad
.
dtype
.
startswith
(
'int'
)
:
if
pad
.
dtype
not
in
theano
.
tensor
.
int_dtypes
:
raise
TypeError
(
'Padding parameters must be ints.'
)
ws
=
theano
.
tensor
.
cast
(
ws
,
dtype_name_for_casting
)
stride
=
theano
.
tensor
.
cast
(
stride
,
dtype_name_for_casting
)
pad
=
theano
.
tensor
.
cast
(
pad
,
dtype_name_for_casting
)
return
Apply
(
self
,
[
inp
,
eval_point
,
ws
,
stride
,
pad
],
[
eval_point
.
type
()])
def
get_params
(
self
,
node
):
...
...
theano/gpuarray/pool_ave_grad.c
浏览文件 @
c66b296e
...
...
@@ -138,9 +138,9 @@ int APPLY_SPECIFIC(ave_pool_grad)(PyGpuArrayObject *x,
size_t
s
[
3
];
size_t
p
[
3
];
for
(
int
i
=
0
;
i
<
ndims
;
i
++
)
{
w
[
i
]
=
*
((
npy_int
p
*
)
PyArray_GETPTR1
(
ws
,
i
));
s
[
i
]
=
*
((
npy_int
p
*
)
PyArray_GETPTR1
(
stride
,
i
));
p
[
i
]
=
*
((
npy_int
p
*
)
PyArray_GETPTR1
(
pad
,
i
));
w
[
i
]
=
*
((
npy_int
64
*
)
PyArray_GETPTR1
(
ws
,
i
));
s
[
i
]
=
*
((
npy_int
64
*
)
PyArray_GETPTR1
(
stride
,
i
));
p
[
i
]
=
*
((
npy_int
64
*
)
PyArray_GETPTR1
(
pad
,
i
));
}
int
err
;
...
...
theano/gpuarray/pool_grad_grad.c
浏览文件 @
c66b296e
...
...
@@ -132,9 +132,9 @@ int APPLY_SPECIFIC(pool_grad_grad)(PyGpuArrayObject *x,
size_t
s
[
3
];
size_t
p
[
3
];
for
(
int
i
=
0
;
i
<
ndims
;
i
++
)
{
w
[
i
]
=
*
((
npy_int
p
*
)
PyArray_GETPTR1
(
ws
,
i
));
s
[
i
]
=
*
((
npy_int
p
*
)
PyArray_GETPTR1
(
stride
,
i
));
p
[
i
]
=
*
((
npy_int
p
*
)
PyArray_GETPTR1
(
pad
,
i
));
w
[
i
]
=
*
((
npy_int
64
*
)
PyArray_GETPTR1
(
ws
,
i
));
s
[
i
]
=
*
((
npy_int
64
*
)
PyArray_GETPTR1
(
stride
,
i
));
p
[
i
]
=
*
((
npy_int
64
*
)
PyArray_GETPTR1
(
pad
,
i
));
}
int
err
;
...
...
theano/gpuarray/pool_max_grad.c
浏览文件 @
c66b296e
...
...
@@ -124,9 +124,9 @@ int APPLY_SPECIFIC(max_pool_grad)(PyGpuArrayObject *x,
size_t
s
[
3
];
size_t
p
[
3
];
for
(
int
i
=
0
;
i
<
ndims
;
i
++
)
{
w
[
i
]
=
*
((
npy_int
p
*
)
PyArray_GETPTR1
(
ws
,
i
));
s
[
i
]
=
*
((
npy_int
p
*
)
PyArray_GETPTR1
(
stride
,
i
));
p
[
i
]
=
*
((
npy_int
p
*
)
PyArray_GETPTR1
(
pad
,
i
));
w
[
i
]
=
*
((
npy_int
64
*
)
PyArray_GETPTR1
(
ws
,
i
));
s
[
i
]
=
*
((
npy_int
64
*
)
PyArray_GETPTR1
(
stride
,
i
));
p
[
i
]
=
*
((
npy_int
64
*
)
PyArray_GETPTR1
(
pad
,
i
));
}
int
err
;
...
...
theano/gpuarray/pool_max_rop.c
浏览文件 @
c66b296e
...
...
@@ -137,9 +137,9 @@ int APPLY_SPECIFIC(max_pool_rop)(PyGpuArrayObject *x,
size_t
p
[
3
];
z_dims
[
0
]
=
x_dims
[
0
];
z_dims
[
1
]
=
x_dims
[
1
];
int
nonzero_padding
=
0
;
for
(
int
i
=
0
;
i
<
ndims
;
i
++
)
{
w
[
i
]
=
*
((
npy_int
p
*
)
PyArray_GETPTR1
(
ws
,
i
));
s
[
i
]
=
*
((
npy_int
p
*
)
PyArray_GETPTR1
(
stride
,
i
));
p
[
i
]
=
*
((
npy_int
p
*
)
PyArray_GETPTR1
(
pad
,
i
));
w
[
i
]
=
*
((
npy_int
64
*
)
PyArray_GETPTR1
(
ws
,
i
));
s
[
i
]
=
*
((
npy_int
64
*
)
PyArray_GETPTR1
(
stride
,
i
));
p
[
i
]
=
*
((
npy_int
64
*
)
PyArray_GETPTR1
(
pad
,
i
));
z_dims
[
2
+
i
]
=
OUTPUT_DIMS
(
x_dims
[
2
+
i
]
+
2
*
p
[
i
],
w
[
i
],
s
[
i
]);
if
(
p
[
i
]
>
0
)
{
nonzero_padding
=
1
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论