Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
d2ee3c98
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d2ee3c98
编写于
11月 29, 2017
作者:
S
sweetsky0901
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
format code
上级
2d42fa74
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
110 addition
and
100 deletion
+110
-100
paddle/operators/math/unpooling.cc
paddle/operators/math/unpooling.cc
+9
-7
paddle/operators/math/unpooling.cu
paddle/operators/math/unpooling.cu
+28
-22
paddle/operators/math/unpooling.h
paddle/operators/math/unpooling.h
+10
-7
paddle/operators/unpool_op.cc
paddle/operators/unpool_op.cc
+56
-58
paddle/operators/unpool_op.cu.cc
paddle/operators/unpool_op.cu.cc
+4
-4
python/paddle/v2/fluid/tests/test_unpool_op.py
python/paddle/v2/fluid/tests/test_unpool_op.py
+3
-2
未找到文件。
paddle/operators/math/unpooling.cc
浏览文件 @
d2ee3c98
...
...
@@ -19,8 +19,8 @@ namespace math {
template
<
typename
T
>
class
Unpool2dMaxFunctor
<
platform
::
CPUPlace
,
T
>
{
public:
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
indices
,
framework
::
Tensor
*
output
)
{
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
input_height
=
input
.
dims
()[
2
];
...
...
@@ -50,10 +50,12 @@ class Unpool2dMaxFunctor<platform::CPUPlace, T> {
template
<
class
T
>
class
Unpool2dMaxGradFunctor
<
platform
::
CPUPlace
,
T
>
{
public:
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
indices
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output_grad
,
framework
::
Tensor
*
input_grad
)
{
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
indices
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output_grad
,
framework
::
Tensor
*
input_grad
)
{
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
input_height
=
input
.
dims
()[
2
];
const
int
input_width
=
input
.
dims
()[
3
];
...
...
paddle/operators/math/unpooling.cu
浏览文件 @
d2ee3c98
...
...
@@ -19,10 +19,12 @@ namespace paddle {
namespace
operators
{
namespace
math
{
template
<
typename
T
>
__global__
void
KernelUnpool2dMax
(
const
int
nthreads
,
const
T
*
input_data
,
const
int
*
indices_data
,
const
int
input_height
,
const
int
input_width
,
const
int
channels
,
T
*
output_data
,
const
int
output_height
,
const
int
output_width
)
{
__global__
void
KernelUnpool2dMax
(
const
int
nthreads
,
const
T
*
input_data
,
const
int
*
indices_data
,
const
int
input_height
,
const
int
input_width
,
const
int
channels
,
T
*
output_data
,
const
int
output_height
,
const
int
output_width
)
{
int
in_n_stride
=
input_height
*
input_width
*
channels
;
int
in_c_stride
=
input_height
*
input_width
;
int
out_n_stride
=
output_height
*
output_width
*
channels
;
...
...
@@ -40,10 +42,11 @@ __global__ void KernelUnpool2dMax(
}
}
template
<
typename
T
>
__global__
void
KernelUnpool2dMaxGrad
(
const
int
nthreads
,
const
T
*
input_data
,
const
int
*
indices_data
,
const
int
input_height
,
const
int
input_width
,
const
int
channels
,
const
T
*
output_data
,
const
T
*
output_grad
,
const
int
output_height
,
__global__
void
KernelUnpool2dMaxGrad
(
const
int
nthreads
,
const
T
*
input_data
,
const
int
*
indices_data
,
const
int
input_height
,
const
int
input_width
,
const
int
channels
,
const
T
*
output_data
,
const
T
*
output_grad
,
const
int
output_height
,
const
int
output_width
,
T
*
input_grad
)
{
int
in_n_stride
=
input_height
*
input_width
*
channels
;
int
in_c_stride
=
input_height
*
input_width
;
...
...
@@ -67,9 +70,9 @@ __global__ void KernelUnpool2dMaxGrad(
template
<
typename
T
>
class
Unpool2dMaxFunctor
<
platform
::
GPUPlace
,
T
>
{
public:
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
indices
,
framework
::
Tensor
*
output
)
{
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
indices
,
framework
::
Tensor
*
output
)
{
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
input_height
=
input
.
dims
()[
2
];
const
int
input_width
=
input
.
dims
()[
3
];
...
...
@@ -81,7 +84,8 @@ class Unpool2dMaxFunctor<platform::GPUPlace, T> {
T
*
output_data
=
output
->
mutable_data
<
T
>
(
context
.
GetPlace
());
int
threads
=
1024
;
int
grid
=
(
input
.
numel
()
+
threads
-
1
)
/
threads
;
KernelUnpool2dMax
<
T
><<<
grid
,
threads
,
0
,
KernelUnpool2dMax
<
T
><<<
grid
,
threads
,
0
,
reinterpret_cast
<
const
platform
::
CUDADeviceContext
&>
(
context
)
.
stream
()
>>>
(
input
.
numel
(),
input_data
,
indices_data
,
input_height
,
input_width
,
output_channels
,
...
...
@@ -113,11 +117,13 @@ class Unpool2dMaxGradFunctor<platform::GPUPlace, T> {
T
*
input_grad_data
=
input_grad
->
mutable_data
<
T
>
(
context
.
GetPlace
());
int
threads
=
1024
;
int
grid
=
(
input
.
numel
()
+
threads
-
1
)
/
threads
;
KernelUnpool2dMaxGrad
<
T
><<<
grid
,
threads
,
0
,
KernelUnpool2dMaxGrad
<
T
><<<
grid
,
threads
,
0
,
reinterpret_cast
<
const
platform
::
CUDADeviceContext
&>
(
context
)
.
stream
()
>>>
(
input
.
numel
(),
input_data
,
indices_data
,
input_height
,
input_width
,
output_channels
,
output_data
,
output_grad_data
,
output_height
,
output_width
,
input_grad_data
);
output_grad_data
,
output_height
,
output_width
,
input_grad_data
);
}
};
template
class
Unpool2dMaxGradFunctor
<
platform
::
GPUPlace
,
float
>;
...
...
paddle/operators/math/unpooling.h
浏览文件 @
d2ee3c98
...
...
@@ -21,17 +21,20 @@ namespace math {
template
<
typename
Place
,
typename
T
>
class
Unpool2dMaxFunctor
{
public:
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
indices
,
framework
::
Tensor
*
output
);
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
indices
,
framework
::
Tensor
*
output
);
};
template
<
typename
Place
,
class
T
>
class
Unpool2dMaxGradFunctor
{
public:
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
indices
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output_grad
,
framework
::
Tensor
*
input_grad
);
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
indices
,
const
framework
::
Tensor
&
output
,
const
framework
::
Tensor
&
output_grad
,
framework
::
Tensor
*
input_grad
);
};
}
// namespace math
}
// namespace operators
...
...
paddle/operators/unpool_op.cc
浏览文件 @
d2ee3c98
...
...
@@ -41,13 +41,11 @@ class Unpool2dOpMaker : public framework::OpProtoAndCheckerMaker {
"ksize"
,
"(vector), the unpooling window size(height, width) "
"of unpooling operator."
);
AddAttr
<
std
::
vector
<
int
>>
(
"strides"
,
AddAttr
<
std
::
vector
<
int
>>
(
"strides"
,
"(vector, default:{1, 1}), "
"strides (height, width) of unpooling operator."
)
.
SetDefault
({
1
,
1
});
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
"(vector defalut:{0,0}), "
"paddings (height, width) of unpooling operator."
)
.
SetDefault
({
0
,
0
});
...
...
paddle/operators/unpool_op.cu.cc
浏览文件 @
d2ee3c98
python/paddle/v2/fluid/tests/test_unpool_op.py
浏览文件 @
d2ee3c98
...
...
@@ -78,5 +78,6 @@ class TestUnpoolOp(OpTest):
self
.
strides
=
[
2
,
2
]
self
.
paddings
=
[
0
,
0
]
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录