Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
12214124
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看板
提交
12214124
编写于
4月 19, 2018
作者:
S
Siddharth Goyal
提交者:
Abhinav Arora
4月 19, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix cpplint for print_op (#10070)
* Fix print op cpplint errors * Remove commented code
上级
8113de94
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
18 addition
and
17 deletion
+18
-17
paddle/fluid/operators/print_op.cc
paddle/fluid/operators/print_op.cc
+18
-17
未找到文件。
paddle/fluid/operators/print_op.cc
浏览文件 @
12214124
...
...
@@ -23,15 +23,15 @@ namespace operators {
#define CLOG std::cout
const
std
::
string
kForward
=
"FORWARD"
;
const
std
::
string
kBackward
=
"BACKWARD"
;
const
std
::
string
kBoth
=
"BOTH"
;
const
char
kForward
[]
=
"FORWARD"
;
const
char
kBackward
[]
=
"BACKWARD"
;
const
char
kBoth
[]
=
"BOTH"
;
struct
Formater
{
std
::
string
message
;
std
::
string
name
;
std
::
vector
<
int
>
dims
;
std
::
type_index
dtype
{
typeid
(
char
)};
std
::
type_index
dtype
{
typeid
(
c
onst
c
har
)};
framework
::
LoD
lod
;
int
summarize
;
void
*
data
{
nullptr
};
...
...
@@ -62,7 +62,7 @@ struct Formater {
}
}
void
PrintDtype
()
{
if
(
dtype
.
hash_code
()
!=
typeid
(
char
).
hash_code
())
{
if
(
dtype
.
hash_code
()
!=
typeid
(
c
onst
c
har
).
hash_code
())
{
CLOG
<<
"
\t
dtype: "
<<
dtype
.
name
()
<<
std
::
endl
;
}
}
...
...
@@ -83,15 +83,15 @@ struct Formater {
void
PrintData
(
size_t
size
)
{
PADDLE_ENFORCE_NOT_NULL
(
data
);
// print float
if
(
dtype
.
hash_code
()
==
typeid
(
float
).
hash_code
())
{
if
(
dtype
.
hash_code
()
==
typeid
(
const
float
).
hash_code
())
{
Display
<
float
>
(
size
);
}
else
if
(
dtype
.
hash_code
()
==
typeid
(
double
).
hash_code
())
{
}
else
if
(
dtype
.
hash_code
()
==
typeid
(
const
double
).
hash_code
())
{
Display
<
double
>
(
size
);
}
else
if
(
dtype
.
hash_code
()
==
typeid
(
int
).
hash_code
())
{
}
else
if
(
dtype
.
hash_code
()
==
typeid
(
const
int
).
hash_code
())
{
Display
<
int
>
(
size
);
}
else
if
(
dtype
.
hash_code
()
==
typeid
(
int64_t
).
hash_code
())
{
}
else
if
(
dtype
.
hash_code
()
==
typeid
(
const
int64_t
).
hash_code
())
{
Display
<
int64_t
>
(
size
);
}
else
if
(
dtype
.
hash_code
()
==
typeid
(
bool
).
hash_code
())
{
}
else
if
(
dtype
.
hash_code
()
==
typeid
(
const
bool
).
hash_code
())
{
Display
<
bool
>
(
size
);
}
else
{
CLOG
<<
"
\t
data: unprintable type: "
<<
dtype
.
name
()
<<
std
::
endl
;
...
...
@@ -100,7 +100,7 @@ struct Formater {
template
<
typename
T
>
void
Display
(
size_t
size
)
{
auto
*
d
=
(
T
*
)
data
;
auto
*
d
=
reinterpret_cast
<
T
*>
(
data
)
;
CLOG
<<
"
\t
data: "
;
if
(
summarize
!=
-
1
)
{
summarize
=
std
::
min
(
size
,
(
size_t
)
summarize
);
...
...
@@ -135,7 +135,7 @@ class TensorPrintOp : public framework::OperatorBase {
void
RunImpl
(
const
framework
::
Scope
&
scope
,
const
platform
::
Place
&
place
)
const
override
{
const
framework
::
Variable
*
in_var_ptr
=
nullptr
;
std
::
string
phase
=
kForward
;
std
::
string
phase
(
kForward
)
;
std
::
string
printed_var_name
=
""
;
auto
&
inputs
=
Inputs
();
...
...
@@ -146,7 +146,7 @@ class TensorPrintOp : public framework::OperatorBase {
!
Inputs
(
"In@GRAD"
).
empty
())
{
in_var_ptr
=
scope
.
FindVar
(
Input
(
"In@GRAD"
));
printed_var_name
=
Inputs
(
"In@GRAD"
).
front
();
phase
=
kBackward
;
phase
=
std
::
string
(
kBackward
)
;
}
else
{
PADDLE_THROW
(
"Unknown phase, should be forward or backward."
);
}
...
...
@@ -163,7 +163,7 @@ class TensorPrintOp : public framework::OperatorBase {
out_tensor
.
set_lod
(
in_tensor
.
lod
());
std
::
string
print_phase
=
Attr
<
std
::
string
>
(
"print_phase"
);
if
(
print_phase
!=
phase
&&
print_phase
!=
kBoth
)
{
if
(
print_phase
!=
phase
&&
print_phase
!=
std
::
string
(
kBoth
)
)
{
return
;
}
...
...
@@ -199,7 +199,7 @@ class TensorPrintOp : public framework::OperatorBase {
formater
.
lod
=
printed_tensor
.
lod
();
}
formater
.
summarize
=
Attr
<
int
>
(
"summarize"
);
formater
.
data
=
(
void
*
)
printed_tensor
.
data
<
void
>
(
);
formater
.
data
=
reinterpret_cast
<
void
*>
(
printed_tensor
.
data
<
void
>
()
);
formater
(
printed_tensor
.
numel
());
}
...
...
@@ -223,8 +223,9 @@ class PrintOpProtoAndCheckMaker : public framework::OpProtoAndCheckerMaker {
"print_phase"
,
"(string, default 'BOTH') Which phase to display including 'FORWARD' "
"'BACKWARD' and 'BOTH'."
)
.
SetDefault
(
kBoth
)
.
InEnum
({
kForward
,
kBackward
,
kBoth
});
.
SetDefault
(
std
::
string
(
kBoth
))
.
InEnum
({
std
::
string
(
kForward
),
std
::
string
(
kBackward
),
std
::
string
(
kBoth
)});
AddOutput
(
"Out"
,
"Output tensor with same data as input tensor."
);
AddComment
(
R"DOC(
Creates a print op that will print when a tensor is accessed.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录