Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
4ffb73fd
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4ffb73fd
编写于
11月 29, 2017
作者:
S
sweetsky0901
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
format ..
上级
5b449b60
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
18 deletion
+15
-18
paddle/operators/math/unpooling.cu
paddle/operators/math/unpooling.cu
+12
-13
paddle/operators/unpool_op.cc
paddle/operators/unpool_op.cc
+3
-5
未找到文件。
paddle/operators/math/unpooling.cu
浏览文件 @
4ffb73fd
...
@@ -21,8 +21,7 @@ namespace math {
...
@@ -21,8 +21,7 @@ namespace math {
template
<
typename
T
>
template
<
typename
T
>
__global__
void
KernelUnpool2dMax
(
const
int
nthreads
,
const
T
*
input_data
,
__global__
void
KernelUnpool2dMax
(
const
int
nthreads
,
const
T
*
input_data
,
const
int
*
indices_data
,
const
int
*
indices_data
,
const
int
input_height
,
const
int
input_height
,
const
int
input_width
,
const
int
input_width
,
const
int
channels
,
T
*
output_data
,
const
int
channels
,
T
*
output_data
,
const
int
output_height
,
const
int
output_height
,
const
int
output_width
)
{
const
int
output_width
)
{
...
@@ -71,8 +70,8 @@ template <typename T>
...
@@ -71,8 +70,8 @@ template <typename T>
class
Unpool2dMaxFunctor
<
platform
::
GPUPlace
,
T
>
{
class
Unpool2dMaxFunctor
<
platform
::
GPUPlace
,
T
>
{
public:
public:
void
operator
()(
const
platform
::
DeviceContext
&
context
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
input
,
const
framework
::
Tensor
&
indices
,
framework
::
Tensor
*
output
)
{
const
framework
::
Tensor
&
indices
,
framework
::
Tensor
*
output
)
{
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
batch_size
=
input
.
dims
()[
0
];
const
int
input_height
=
input
.
dims
()[
2
];
const
int
input_height
=
input
.
dims
()[
2
];
const
int
input_width
=
input
.
dims
()[
3
];
const
int
input_width
=
input
.
dims
()[
3
];
...
@@ -86,10 +85,10 @@ class Unpool2dMaxFunctor<platform::GPUPlace, T> {
...
@@ -86,10 +85,10 @@ class Unpool2dMaxFunctor<platform::GPUPlace, T> {
int
grid
=
(
input
.
numel
()
+
threads
-
1
)
/
threads
;
int
grid
=
(
input
.
numel
()
+
threads
-
1
)
/
threads
;
KernelUnpool2dMax
<
KernelUnpool2dMax
<
T
><<<
grid
,
threads
,
0
,
T
><<<
grid
,
threads
,
0
,
reinterpret_cast
<
const
platform
::
CUDADeviceContext
&>
(
context
)
reinterpret_cast
<
const
platform
::
CUDADeviceContext
&>
(
context
)
.
stream
()
>>>
(
input
.
numel
(),
input_data
,
indices_data
,
.
stream
()
>>>
(
input
.
numel
(),
input_data
,
indices_data
,
input_height
,
input_width
,
output_channels
,
input_height
,
input_width
,
output_channels
,
output_data
,
output_height
,
output_width
);
output_data
,
output_height
,
output_width
);
}
}
};
};
/*
/*
...
@@ -119,11 +118,11 @@ class Unpool2dMaxGradFunctor<platform::GPUPlace, T> {
...
@@ -119,11 +118,11 @@ class Unpool2dMaxGradFunctor<platform::GPUPlace, T> {
int
grid
=
(
input
.
numel
()
+
threads
-
1
)
/
threads
;
int
grid
=
(
input
.
numel
()
+
threads
-
1
)
/
threads
;
KernelUnpool2dMaxGrad
<
KernelUnpool2dMaxGrad
<
T
><<<
grid
,
threads
,
0
,
T
><<<
grid
,
threads
,
0
,
reinterpret_cast
<
const
platform
::
CUDADeviceContext
&>
(
context
)
reinterpret_cast
<
const
platform
::
CUDADeviceContext
&>
(
context
)
.
stream
()
>>>
(
input
.
numel
(),
input_data
,
indices_data
,
.
stream
()
>>>
(
input
.
numel
(),
input_data
,
indices_data
,
input_height
,
input_width
,
output_channels
,
input_height
,
input_width
,
output_channels
,
output_data
,
output_grad_data
,
output_height
,
output_data
,
output_grad_data
,
output_height
,
output_width
,
input_grad_data
);
output_width
,
input_grad_data
);
}
}
};
};
template
class
Unpool2dMaxGradFunctor
<
platform
::
GPUPlace
,
float
>;
template
class
Unpool2dMaxGradFunctor
<
platform
::
GPUPlace
,
float
>;
...
...
paddle/operators/unpool_op.cc
浏览文件 @
4ffb73fd
...
@@ -94,12 +94,11 @@ class UnpoolOp : public framework::OperatorWithKernel {
...
@@ -94,12 +94,11 @@ class UnpoolOp : public framework::OperatorWithKernel {
"Output(Out) of UnpoolOp should not be null."
);
"Output(Out) of UnpoolOp should not be null."
);
auto
in_x_dims
=
ctx
->
GetInputDim
(
"X"
);
auto
in_x_dims
=
ctx
->
GetInputDim
(
"X"
);
auto
in_y_dims
=
ctx
->
GetInputDim
(
"Indices"
);
auto
in_y_dims
=
ctx
->
GetInputDim
(
"Indices"
);
std
::
string
unpooling_type
=
ctx
->
Attrs
()
std
::
string
unpooling_type
=
.
Get
<
std
::
string
>
(
"unpooling_type"
);
ctx
->
Attrs
()
.
Get
<
std
::
string
>
(
"unpooling_type"
);
std
::
vector
<
int
>
ksize
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"ksize"
);
std
::
vector
<
int
>
ksize
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"ksize"
);
std
::
vector
<
int
>
strides
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
strides
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
paddings
=
std
::
vector
<
int
>
paddings
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"paddings"
);
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"paddings"
);
PADDLE_ENFORCE
(
in_x_dims
.
size
()
==
4
,
PADDLE_ENFORCE
(
in_x_dims
.
size
()
==
4
,
"Unpooling intput must be of 4-dimensional."
);
"Unpooling intput must be of 4-dimensional."
);
PADDLE_ENFORCE_EQ
(
in_x_dims
,
in_y_dims
);
PADDLE_ENFORCE_EQ
(
in_x_dims
,
in_y_dims
);
...
@@ -142,4 +141,3 @@ REGISTER_OP_CPU_KERNEL(unpool,
...
@@ -142,4 +141,3 @@ REGISTER_OP_CPU_KERNEL(unpool,
REGISTER_OP_CPU_KERNEL
(
REGISTER_OP_CPU_KERNEL
(
unpool_grad
,
ops
::
UnpoolGradKernel
<
paddle
::
platform
::
CPUPlace
,
float
>
,
unpool_grad
,
ops
::
UnpoolGradKernel
<
paddle
::
platform
::
CPUPlace
,
float
>
,
ops
::
UnpoolGradKernel
<
paddle
::
platform
::
CPUPlace
,
double
>
);
ops
::
UnpoolGradKernel
<
paddle
::
platform
::
CPUPlace
,
double
>
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录