Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
橘蓝
Paddle
提交
2fd1bf2e
P
Paddle
项目概览
橘蓝
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
2fd1bf2e
编写于
9月 10, 2018
作者:
Y
Yan Chunwei
提交者:
GitHub
9月 10, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fea/add color log (#13305)
上级
a39eba77
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
112 addition
and
7 deletion
+112
-7
paddle/fluid/framework/ir/CMakeLists.txt
paddle/fluid/framework/ir/CMakeLists.txt
+1
-1
paddle/fluid/framework/ir/graph_pattern_detector.cc
paddle/fluid/framework/ir/graph_pattern_detector.cc
+6
-1
paddle/fluid/inference/analysis/CMakeLists.txt
paddle/fluid/inference/analysis/CMakeLists.txt
+1
-1
paddle/fluid/inference/analysis/ir_pass_manager.cc
paddle/fluid/inference/analysis/ir_pass_manager.cc
+5
-1
paddle/fluid/inference/analysis/pass_manager.cc
paddle/fluid/inference/analysis/pass_manager.cc
+5
-3
paddle/fluid/string/CMakeLists.txt
paddle/fluid/string/CMakeLists.txt
+2
-0
paddle/fluid/string/pretty_log.cc
paddle/fluid/string/pretty_log.cc
+22
-0
paddle/fluid/string/pretty_log.h
paddle/fluid/string/pretty_log.h
+70
-0
未找到文件。
paddle/fluid/framework/ir/CMakeLists.txt
浏览文件 @
2fd1bf2e
...
...
@@ -19,7 +19,7 @@ function(pass_library TARGET DEST)
endfunction
()
cc_library
(
node SRCS node.cc DEPS proto_desc
)
cc_library
(
graph SRCS graph.cc DEPS node
)
cc_library
(
graph SRCS graph.cc DEPS node
pretty_log
)
cc_library
(
graph_helper SRCS graph_helper.cc DEPS graph
)
cc_library
(
pass SRCS pass.cc DEPS graph node graph_helper
)
cc_library
(
graph_traits SRCS graph_traits.cc DEPS graph
)
...
...
paddle/fluid/framework/ir/graph_pattern_detector.cc
浏览文件 @
2fd1bf2e
...
...
@@ -21,12 +21,17 @@
#include "paddle/fluid/framework/ir/graph_traits.h"
#include "paddle/fluid/framework/ir/graph_viz_pass.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/string/pretty_log.h"
#include "paddle/fluid/string/printf.h"
namespace
paddle
{
namespace
framework
{
namespace
ir
{
using
string
::
PrettyLogEndl
;
using
string
::
PrettyLog
;
using
string
::
Style
;
size_t
PDPattern
::
id_
=
0UL
;
PDNode
*
PDPattern
::
NewNode
(
const
std
::
string
&
name
)
{
...
...
@@ -83,7 +88,7 @@ void GraphPatternDetector::operator()(Graph* graph,
ValidateByNodeRole
(
&
subgraphs
);
if
(
subgraphs
.
empty
())
return
;
LOG
(
INFO
)
<<
"detect "
<<
subgraphs
.
size
()
<<
" subgraph matches the pattern"
;
PrettyLogEndl
(
Style
::
detail
(),
"--- detect %d subgraphs"
,
subgraphs
.
size
())
;
int
id
=
0
;
for
(
auto
&
g
:
subgraphs
)
{
VLOG
(
3
)
<<
"optimizing #"
<<
id
++
<<
" subgraph"
;
...
...
paddle/fluid/inference/analysis/CMakeLists.txt
浏览文件 @
2fd1bf2e
cc_library
(
ir_pass_manager SRCS ir_pass_manager.cc DEPS graph pass
)
set
(
analysis_deps
framework_proto proto_desc ir_pass_manager graph pass paddle_fluid_api executor
)
framework_proto proto_desc ir_pass_manager graph pass paddle_fluid_api executor
pretty_log
)
cc_library
(
analysis SRCS pass_manager.cc node.cc data_flow_graph.cc graph_traits.cc subgraph_splitter.cc
analyzer.cc
...
...
paddle/fluid/inference/analysis/ir_pass_manager.cc
浏览文件 @
2fd1bf2e
...
...
@@ -17,10 +17,14 @@
#include "paddle/fluid/framework/ir/fuse_pass_base.h"
#include "paddle/fluid/framework/ir/graph.h"
#include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/string/pretty_log.h"
namespace
paddle
{
namespace
inference
{
namespace
analysis
{
using
string
::
PrettyLogEndl
;
using
string
::
PrettyLog
;
using
string
::
Style
;
IRPassManager
::
IRPassManager
(
const
ProgramDesc
&
program
,
framework
::
Scope
*
scope
)
...
...
@@ -34,7 +38,7 @@ void IRPassManager::Apply(const std::vector<std::string> &passes) {
// Apply all the passes
std
::
string
pre_pass
;
for
(
const
std
::
string
&
pass_name
:
passes
)
{
LOG
(
WARNING
)
<<
"Running IR pass ["
<<
pass_name
<<
"]"
;
PrettyLogEndl
(
Style
::
H2
(),
"--- Running IR pass [%s]"
,
pass_name
)
;
auto
pass
=
framework
::
ir
::
PassRegistry
::
Instance
().
Get
(
pass_name
);
if
(
pass_name
==
"graph_viz_pass"
)
{
std
::
string
dot_file_path
=
...
...
paddle/fluid/inference/analysis/pass_manager.cc
浏览文件 @
2fd1bf2e
...
...
@@ -14,6 +14,7 @@ limitations under the License. */
#include "paddle/fluid/inference/analysis/pass_manager.h"
#include "paddle/fluid/inference/analysis/fluid_to_data_flow_graph_pass.h"
#include "paddle/fluid/string/pretty_log.h"
namespace
paddle
{
namespace
inference
{
...
...
@@ -22,7 +23,7 @@ namespace analysis {
bool
PassManager
::
Initialize
(
Argument
*
argument
)
{
argument_
=
argument
;
for
(
auto
&
pass
:
data_
)
{
LOG
(
WARNING
)
<<
"Initializing pass ["
<<
pass
->
repr
()
<<
"]"
;
VLOG
(
3
)
<<
"Initializing pass ["
<<
pass
->
repr
()
<<
"]"
;
if
(
!
pass
->
Initialize
(
argument
))
{
LOG
(
ERROR
)
<<
"Failed to initialize pass ["
<<
pass
->
repr
()
<<
"]"
;
return
false
;
...
...
@@ -33,9 +34,10 @@ bool PassManager::Initialize(Argument* argument) {
void
DfgPassManager
::
RunAll
()
{
PADDLE_ENFORCE
(
argument_
);
LOG
(
INFO
)
<<
"Total "
<<
data_
.
size
()
<<
" Analysys passes"
;
VLOG
(
3
)
<<
"Total "
<<
data_
.
size
()
<<
" Analysys passes"
;
for
(
auto
&
pass
:
data_
)
{
LOG
(
WARNING
)
<<
"Running Analysis pass ["
<<
pass
->
repr
()
<<
"]"
;
string
::
PrettyLogEndl
(
string
::
Style
::
H1
(),
"* Running Analysis pass [%s]"
,
pass
->
repr
());
pass
->
Run
(
argument_
->
main_dfg
.
get
());
}
}
...
...
paddle/fluid/string/CMakeLists.txt
浏览文件 @
2fd1bf2e
cc_library
(
stringpiece SRCS piece.cc
)
cc_library
(
pretty_log SRCS pretty_log.cc
)
cc_test
(
test_pretty_log SRCS pretty_log.cc
)
cc_test
(
stringpiece_test SRCS piece_test.cc DEPS stringpiece glog gflags
)
cc_test
(
stringprintf_test SRCS printf_test.cc DEPS glog gflags
)
cc_test
(
to_string_test SRCS to_string_test.cc
)
paddle/fluid/string/pretty_log.cc
0 → 100644
浏览文件 @
2fd1bf2e
// Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/fluid/string/pretty_log.h"
#include <gflags/gflags.h>
DEFINE_bool
(
color
,
true
,
"Whether to turn on pretty log"
);
namespace
paddle
{
namespace
string
{}
// namespace string
}
// namespace paddle
paddle/fluid/string/pretty_log.h
0 → 100644
浏览文件 @
2fd1bf2e
// Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <gflags/gflags.h>
#include <iostream>
#include <sstream>
#include <string>
#include <utility>
#include "paddle/fluid/string/printf.h"
DECLARE_bool
(
color
);
namespace
paddle
{
namespace
string
{
inline
std
::
string
black
()
{
return
FLAGS_color
?
"\e[30m"
:
""
;
}
inline
std
::
string
red
()
{
return
FLAGS_color
?
"\e[31m"
:
""
;
}
inline
std
::
string
b_red
()
{
return
FLAGS_color
?
"\e[41m"
:
""
;
}
inline
std
::
string
green
()
{
return
FLAGS_color
?
"\e[32m"
:
""
;
}
inline
std
::
string
yellow
()
{
return
FLAGS_color
?
"\e[33m"
:
""
;
}
inline
std
::
string
blue
()
{
return
FLAGS_color
?
"\e[34m"
:
""
;
}
inline
std
::
string
purple
()
{
return
FLAGS_color
?
"\e[35m"
:
""
;
}
inline
std
::
string
cyan
()
{
return
FLAGS_color
?
"\e[36m"
:
""
;
}
inline
std
::
string
light_gray
()
{
return
FLAGS_color
?
"\e[37m"
:
""
;
}
inline
std
::
string
white
()
{
return
FLAGS_color
?
"\e[37m"
:
""
;
}
inline
std
::
string
light_red
()
{
return
FLAGS_color
?
"\e[91m"
:
""
;
}
inline
std
::
string
dim
()
{
return
FLAGS_color
?
"\e[2m"
:
""
;
}
inline
std
::
string
bold
()
{
return
FLAGS_color
?
"\e[1m"
:
""
;
}
inline
std
::
string
underline
()
{
return
FLAGS_color
?
"\e[4m"
:
""
;
}
inline
std
::
string
blink
()
{
return
FLAGS_color
?
"\e[5m"
:
""
;
}
inline
std
::
string
reset
()
{
return
FLAGS_color
?
"\e[0m"
:
""
;
}
using
TextBlock
=
std
::
pair
<
std
::
string
,
std
::
string
>
;
struct
Style
{
static
std
::
string
info
()
{
return
black
();
}
static
std
::
string
warn
()
{
return
b_red
();
}
static
std
::
string
suc
()
{
return
green
();
}
static
std
::
string
H1
()
{
return
bold
()
+
purple
();
}
static
std
::
string
H2
()
{
return
green
();
}
static
std
::
string
H3
()
{
return
green
();
}
static
std
::
string
detail
()
{
return
light_gray
();
}
};
template
<
typename
...
Args
>
static
void
PrettyLogEndl
(
const
std
::
string
&
style
,
const
char
*
fmt
,
const
Args
&
...
args
)
{
std
::
cerr
<<
style
<<
Sprintf
(
fmt
,
args
...)
<<
reset
()
<<
std
::
endl
;
}
template
<
typename
...
Args
>
static
void
PrettyLog
(
const
std
::
string
&
style
,
const
char
*
fmt
,
const
Args
&
...
args
)
{
std
::
cerr
<<
style
<<
Sprintf
(
fmt
,
args
...)
<<
reset
();
}
}
// namespace string
}
// namespace paddle
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录