Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
74f460fd
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
74f460fd
编写于
9月 14, 2017
作者:
D
dangqingqing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix specialization of template member functions in the non-template class in GCC 5.0.
上级
f6b518c9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
24 addition
and
9 deletion
+24
-9
paddle/framework/operator.cc
paddle/framework/operator.cc
+4
-3
paddle/framework/operator.h
paddle/framework/operator.h
+17
-3
paddle/operators/sequence_avg_pool_op.cc
paddle/operators/sequence_avg_pool_op.cc
+1
-1
paddle/operators/sequence_avg_pool_op.h
paddle/operators/sequence_avg_pool_op.h
+2
-2
未找到文件。
paddle/framework/operator.cc
浏览文件 @
74f460fd
...
...
@@ -209,8 +209,7 @@ const std::vector<const Tensor*> InferShapeContext::MultiInput<Tensor>(
template
<
>
Tensor
*
ExecutionContext
::
Output
<
Tensor
>
(
const
std
::
string
&
name
)
const
{
auto
*
var
=
OutputVar
(
name
);
if
(
var
==
nullptr
)
return
nullptr
;
return
GetTensorFromVar
(
var
);
return
var
==
nullptr
?
nullptr
:
const_cast
<
Tensor
*>
(
GetTensorFromVar
(
var
));
}
template
<
>
...
...
@@ -222,7 +221,9 @@ std::vector<Tensor*> ExecutionContext::MultiOutput<Tensor>(
std
::
transform
(
names
.
begin
(),
names
.
end
(),
std
::
back_inserter
(
res
),
[
&
](
const
std
::
string
&
sub_name
)
{
auto
var
=
scope
().
FindVar
(
sub_name
);
return
var
==
nullptr
?
nullptr
:
GetTensorFromVar
(
var
);
return
var
==
nullptr
?
nullptr
:
const_cast
<
Tensor
*>
(
GetTensorFromVar
(
var
));
});
return
res
;
}
...
...
paddle/framework/operator.h
浏览文件 @
74f460fd
...
...
@@ -327,13 +327,13 @@ class InferShapeContext {
return
res
;
}
Tensor
*
GetTensorFromVar
(
const
Variable
*
var
)
const
{
const
Tensor
*
GetTensorFromVar
(
const
Variable
*
var
)
const
{
if
(
var
->
IsType
<
LoDTensor
>
())
{
return
const_cast
<
LoDTensor
*>
(
&
var
->
Get
<
LoDTensor
>
()
);
return
&
var
->
Get
<
LoDTensor
>
(
);
}
PADDLE_ENFORCE
(
var
->
IsType
<
Tensor
>
(),
"The Input(%s) must be LoDTensor or Tensor."
);
return
const_cast
<
Tensor
*>
(
&
var
->
Get
<
Tensor
>
()
);
return
&
var
->
Get
<
Tensor
>
(
);
}
private:
...
...
@@ -341,6 +341,13 @@ class InferShapeContext {
const
Scope
&
scope_
;
};
template
<>
const
Tensor
*
InferShapeContext
::
Input
<
Tensor
>
(
const
std
::
string
&
name
)
const
;
template
<>
const
std
::
vector
<
const
Tensor
*>
InferShapeContext
::
MultiInput
<
Tensor
>
(
const
std
::
string
&
name
)
const
;
template
<
typename
T
>
struct
EigenDeviceConverter
;
...
...
@@ -397,6 +404,13 @@ class ExecutionContext : public InferShapeContext {
const
platform
::
DeviceContext
*
device_context_
;
};
template
<>
Tensor
*
ExecutionContext
::
Output
<
Tensor
>
(
const
std
::
string
&
name
)
const
;
template
<>
std
::
vector
<
Tensor
*>
ExecutionContext
::
MultiOutput
<
Tensor
>
(
const
std
::
string
&
name
)
const
;
class
OpKernel
{
public:
/**
...
...
paddle/operators/sequence_avg_pool_op.cc
浏览文件 @
74f460fd
...
...
@@ -66,7 +66,7 @@ class SequenceAvgPoolGradOp : public framework::OperatorWithKernel {
auto
x_dims
=
ctx
.
Input
<
framework
::
LoDTensor
>
(
"X"
)
->
dims
();
PADDLE_ENFORCE_EQ
(
og_dims
.
size
(),
x_dims
.
size
(),
"The rank of output grad must equal to Input(X)."
);
for
(
size
_t
i
=
1
;
i
<
og_dims
.
size
();
++
i
)
{
for
(
int64
_t
i
=
1
;
i
<
og_dims
.
size
();
++
i
)
{
PADDLE_ENFORCE_EQ
(
og_dims
[
i
],
x_dims
[
i
],
"The dimension mismatch."
);
}
auto
*
x_grad
=
...
...
paddle/operators/sequence_avg_pool_op.h
浏览文件 @
74f460fd
...
...
@@ -38,7 +38,7 @@ class SequenceAvgPoolKernel : public framework::OpKernel {
out
->
mutable_data
<
T
>
(
context
.
GetPlace
());
auto
place
=
context
.
GetEigenDevice
<
Place
>
();
for
(
int
i
=
0
;
i
<
lod
[
0
].
size
(
)
-
1
;
++
i
)
{
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
lod
[
0
].
size
()
)
-
1
;
++
i
)
{
Tensor
in_t
=
in
->
Slice
<
T
>
(
static_cast
<
int
>
(
lod
[
0
][
i
]),
static_cast
<
int
>
(
lod
[
0
][
i
+
1
]));
Tensor
out_t
=
out
->
Slice
<
T
>
(
i
,
i
+
1
);
...
...
@@ -64,7 +64,7 @@ class SequenceAvgPoolGradKernel : public framework::OpKernel {
in_g
->
mutable_data
<
T
>
(
context
.
GetPlace
());
auto
place
=
context
.
GetEigenDevice
<
Place
>
();
for
(
int
i
=
0
;
i
<
lod
[
0
].
size
(
)
-
1
;
++
i
)
{
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
lod
[
0
].
size
()
)
-
1
;
++
i
)
{
auto
in_g_t
=
in_g
->
Slice
<
T
>
(
static_cast
<
int
>
(
lod
[
0
][
i
]),
static_cast
<
int
>
(
lod
[
0
][
i
+
1
]));
auto
out_g_t
=
out_g
->
Slice
<
T
>
(
i
,
i
+
1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录