Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
0417e4e4
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
694
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0417e4e4
编写于
9月 22, 2017
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix framework::LoDTensor => Tensor
上级
6f61b5df
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
16 addition
and
19 deletion
+16
-19
paddle/operators/math/pooling.h
paddle/operators/math/pooling.h
+11
-15
paddle/operators/pool_op.cc
paddle/operators/pool_op.cc
+2
-2
paddle/operators/pool_op.h
paddle/operators/pool_op.h
+1
-2
paddle/platform/hostdevice.h
paddle/platform/hostdevice.h
+2
-0
未找到文件。
paddle/operators/math/pooling.h
浏览文件 @
0417e4e4
...
...
@@ -16,17 +16,13 @@ limitations under the License. */
#include "paddle/framework/eigen.h"
#include "paddle/framework/tensor.h"
#include "paddle/platform/device_context.h"
#include "paddle/platform/hostdevice.h"
namespace
paddle
{
namespace
operators
{
namespace
math
{
//////////////////////
#ifdef __NVCC__
#define HL_DEVICE __device__
#else
#define HL_DEVICE
#endif
#define FLT_MAX __FLT_MAX__
/////////////////////
...
...
@@ -34,11 +30,11 @@ namespace pool {
template
<
class
T
>
class
maxPool
{
public:
HL_DEVICE
inline
T
initial
()
{
return
-
(
T
)(
FLT_MAX
);
}
HL_
DEVICE
inline
void
process
(
T
&
y
,
const
T
&
x
)
{
y
=
y
>
x
?
y
:
x
;
}
HL_
DEVICE
inline
void
finalize
(
T
&
y
,
const
T
&
poo_size
)
{}
HL_
DEVICE
inline
void
gradProcess
(
const
T
&
x
,
const
T
&
y
,
const
T
&
dy
,
T
&
dx
,
T
scale
)
{
DEVICE
inline
T
initial
()
{
return
static_cast
<
T
>
(
-
FLT_MAX
);
}
DEVICE
inline
void
process
(
T
&
y
,
const
T
&
x
)
{
y
=
y
>
x
?
y
:
x
;
}
DEVICE
inline
void
finalize
(
T
&
y
,
const
T
&
poo_size
)
{}
DEVICE
inline
void
gradProcess
(
const
T
&
x
,
const
T
&
y
,
const
T
&
dy
,
T
&
dx
,
T
scale
)
{
dx
+=
dy
*
(
x
==
y
);
}
};
...
...
@@ -46,11 +42,11 @@ class maxPool {
template
<
class
T
>
class
avePool
{
public:
HL_DEVICE
inline
T
initial
()
{
return
0
;
}
HL_
DEVICE
inline
void
process
(
T
&
y
,
const
T
&
x
)
{
y
+=
x
;
}
HL_
DEVICE
inline
void
finalize
(
T
&
y
,
const
T
&
poo_size
)
{
y
/=
poo_size
;
}
HL_
DEVICE
inline
void
gradProcess
(
const
T
&
x
,
const
T
&
y
,
const
T
&
dy
,
T
&
dx
,
T
scale
)
{
DEVICE
inline
T
initial
()
{
return
static_cast
<
T
>
(
0
)
;
}
DEVICE
inline
void
process
(
T
&
y
,
const
T
&
x
)
{
y
+=
x
;
}
DEVICE
inline
void
finalize
(
T
&
y
,
const
T
&
poo_size
)
{
y
/=
poo_size
;
}
DEVICE
inline
void
gradProcess
(
const
T
&
x
,
const
T
&
y
,
const
T
&
dy
,
T
&
dx
,
T
scale
)
{
dx
+=
(
scale
*
dy
);
}
};
...
...
paddle/operators/pool_op.cc
浏览文件 @
0417e4e4
...
...
@@ -37,7 +37,7 @@ class PoolOp : public framework::OperatorWithKernel {
// PADDLE_ENFORCE_NOT_NULL(Attr<std::vector<int>>("ksize"), "ksize should
// not be null.");
auto
in_X
=
ctx
.
Input
<
Tensor
>
(
"X"
);
auto
out
=
ctx
.
Output
<
framework
::
LoD
Tensor
>
(
"Out"
);
auto
out
=
ctx
.
Output
<
Tensor
>
(
"Out"
);
int
global_pooling
=
Attr
<
int
>
(
"globalPooling"
);
std
::
string
pooling_type
=
Attr
<
std
::
string
>
(
"poolingType"
);
std
::
vector
<
int
>
ksize
=
Attr
<
std
::
vector
<
int
>>
(
"ksize"
);
...
...
@@ -78,7 +78,7 @@ class PoolOpGrad : public framework::OperatorWithKernel {
protected:
void
InferShape
(
const
framework
::
InferShapeContext
&
ctx
)
const
override
{
auto
in
=
ctx
.
Input
<
Tensor
>
(
"X"
);
auto
d_in
=
ctx
.
Output
<
framework
::
LoD
Tensor
>
(
framework
::
GradVarName
(
"X"
));
auto
d_in
=
ctx
.
Output
<
Tensor
>
(
framework
::
GradVarName
(
"X"
));
if
(
d_in
)
d_in
->
Resize
(
in
->
dims
());
}
};
...
...
paddle/operators/pool_op.h
浏览文件 @
0417e4e4
...
...
@@ -90,8 +90,7 @@ class PoolGradKernel : public framework::OpKernel {
const
Tensor
*
out
=
context
.
Input
<
Tensor
>
(
"Out"
);
const
Tensor
*
out_grad
=
context
.
Input
<
Tensor
>
(
framework
::
GradVarName
(
"Out"
));
Tensor
*
in_X_grad
=
context
.
Output
<
framework
::
LoDTensor
>
(
framework
::
GradVarName
(
"X"
));
Tensor
*
in_X_grad
=
context
.
Output
<
Tensor
>
(
framework
::
GradVarName
(
"X"
));
int
global_pooling
=
context
.
Attr
<
int
>
(
"globalPooling"
);
std
::
string
pooling_type
=
context
.
Attr
<
std
::
string
>
(
"poolingType"
);
...
...
paddle/platform/hostdevice.h
浏览文件 @
0417e4e4
...
...
@@ -2,8 +2,10 @@
#ifdef __CUDACC__
#define HOSTDEVICE __host__ __device__
#define DEVICE __device__
#define HOST __host__
#else
#define HOSTDEVICE
#define DEVICE
#define HOST
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录