Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
f6aba39d
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f6aba39d
编写于
11月 19, 2019
作者:
S
sangoly
提交者:
GitHub
11月 19, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Android] make log info display in android test=develop (#2450)
上级
f9930fc1
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
102 addition
and
29 deletion
+102
-29
lite/core/device_info.cc
lite/core/device_info.cc
+2
-2
lite/tools/build.sh
lite/tools/build.sh
+8
-2
lite/utils/logging.cc
lite/utils/logging.cc
+4
-4
lite/utils/logging.h
lite/utils/logging.h
+31
-0
lite/utils/replace_stl/stream.cc
lite/utils/replace_stl/stream.cc
+42
-15
lite/utils/replace_stl/stream.h
lite/utils/replace_stl/stream.h
+15
-6
未找到文件。
lite/core/device_info.cc
浏览文件 @
f6aba39d
...
@@ -1039,7 +1039,7 @@ int DeviceInfo::Setup() {
...
@@ -1039,7 +1039,7 @@ int DeviceInfo::Setup() {
<<
", max freq: "
<<
max_freqs_
[
i
]
<<
", max freq: "
<<
max_freqs_
[
i
]
<<
", min freq: "
<<
min_freqs_
[
i
]
<<
", min freq: "
<<
min_freqs_
[
i
]
<<
", cluster ID: "
<<
cluster_ids_
[
core_ids_
[
i
]]
<<
", cluster ID: "
<<
cluster_ids_
[
core_ids_
[
i
]]
<<
", CPU ARCH: A"
<<
archs_
[
i
]
;
<<
", CPU ARCH: A"
<<
static_cast
<
int
>
(
archs_
[
i
])
;
}
}
LOG
(
INFO
)
<<
"L1 DataCache size is: "
;
LOG
(
INFO
)
<<
"L1 DataCache size is: "
;
for
(
int
i
=
0
;
i
<
core_num_
;
++
i
)
{
for
(
int
i
=
0
;
i
<
core_num_
;
++
i
)
{
...
@@ -1093,7 +1093,7 @@ void DeviceInfo::SetRunMode(lite_api::PowerMode mode, int thread_num) {
...
@@ -1093,7 +1093,7 @@ void DeviceInfo::SetRunMode(lite_api::PowerMode mode, int thread_num) {
RequestPowerRandLowMode
(
shift_num
,
thread_num
);
RequestPowerRandLowMode
(
shift_num
,
thread_num
);
break
;
break
;
default:
default:
LOG
(
FATAL
)
<<
"Unsupported power mode: "
<<
mode
;
LOG
(
FATAL
)
<<
"Unsupported power mode: "
<<
static_cast
<
int
>
(
mode
)
;
break
;
break
;
}
}
if
(
active_ids_
.
empty
())
{
if
(
active_ids_
.
empty
())
{
...
...
lite/tools/build.sh
浏览文件 @
f6aba39d
...
@@ -20,6 +20,7 @@ BUILD_DIR=$(pwd)
...
@@ -20,6 +20,7 @@ BUILD_DIR=$(pwd)
OPTMODEL_DIR
=
""
OPTMODEL_DIR
=
""
BUILD_TAILOR
=
OFF
BUILD_TAILOR
=
OFF
BUILD_CV
=
OFF
BUILD_CV
=
OFF
SHUTDOWN_LOG
=
ON
readonly
THIRDPARTY_TAR
=
https://paddle-inference-dist.bj.bcebos.com/PaddleLite/third-party-05b862.tar.gz
readonly
THIRDPARTY_TAR
=
https://paddle-inference-dist.bj.bcebos.com/PaddleLite/third-party-05b862.tar.gz
...
@@ -93,7 +94,7 @@ function make_tiny_publish_so {
...
@@ -93,7 +94,7 @@ function make_tiny_publish_so {
-DWITH_TESTING
=
OFF
\
-DWITH_TESTING
=
OFF
\
-DLITE_WITH_JAVA
=
$BUILD_JAVA
\
-DLITE_WITH_JAVA
=
$BUILD_JAVA
\
-DLITE_WITH_PYTHON
=
$BUILD_PYTHON
\
-DLITE_WITH_PYTHON
=
$BUILD_PYTHON
\
-DLITE_SHUTDOWN_LOG
=
ON
\
-DLITE_SHUTDOWN_LOG
=
$SHUTDOWN_LOG
\
-DLITE_ON_TINY_PUBLISH
=
ON
\
-DLITE_ON_TINY_PUBLISH
=
ON
\
-DANDROID_STL_TYPE
=
$android_stl
\
-DANDROID_STL_TYPE
=
$android_stl
\
-DLITE_BUILD_EXTRA
=
$BUILD_EXTRA
\
-DLITE_BUILD_EXTRA
=
$BUILD_EXTRA
\
...
@@ -136,7 +137,7 @@ function make_full_publish_so {
...
@@ -136,7 +137,7 @@ function make_full_publish_so {
-DWITH_TESTING
=
OFF
\
-DWITH_TESTING
=
OFF
\
-DLITE_WITH_JAVA
=
$BUILD_JAVA
\
-DLITE_WITH_JAVA
=
$BUILD_JAVA
\
-DLITE_WITH_PYTHON
=
$BUILD_PYTHON
\
-DLITE_WITH_PYTHON
=
$BUILD_PYTHON
\
-DLITE_SHUTDOWN_LOG
=
ON
\
-DLITE_SHUTDOWN_LOG
=
$SHUTDOWN_LOG
\
-DANDROID_STL_TYPE
=
$android_stl
\
-DANDROID_STL_TYPE
=
$android_stl
\
-DLITE_BUILD_EXTRA
=
$BUILD_EXTRA
\
-DLITE_BUILD_EXTRA
=
$BUILD_EXTRA
\
-DLITE_WITH_CV
=
$BUILD_CV
\
-DLITE_WITH_CV
=
$BUILD_CV
\
...
@@ -290,6 +291,7 @@ function print_usage {
...
@@ -290,6 +291,7 @@ function print_usage {
echo
-e
" ./build.sh --arm_os=<os> --arm_abi=<abi> --arm_lang=<lang> test"
echo
-e
" ./build.sh --arm_os=<os> --arm_abi=<abi> --arm_lang=<lang> test"
echo
echo
echo
-e
"optional argument:"
echo
-e
"optional argument:"
echo
-e
"--shutdown_log: (OFF|ON); controls whether to shutdown log, default is ON"
echo
-e
"--build_extra: (OFF|ON); controls whether to publish extra operators and kernels for (sequence-related model such as OCR or NLP)"
echo
-e
"--build_extra: (OFF|ON); controls whether to publish extra operators and kernels for (sequence-related model such as OCR or NLP)"
echo
-e
"--build_python: (OFF|ON); controls whether to publish python api lib (ANDROID and IOS is not supported)"
echo
-e
"--build_python: (OFF|ON); controls whether to publish python api lib (ANDROID and IOS is not supported)"
echo
-e
"--build_java: (OFF|ON); controls whether to publish java api lib (Only ANDROID is supported)"
echo
-e
"--build_java: (OFF|ON); controls whether to publish java api lib (Only ANDROID is supported)"
...
@@ -366,6 +368,10 @@ function main {
...
@@ -366,6 +368,10 @@ function main {
BUILD_TAILOR
=
"
${
i
#*=
}
"
BUILD_TAILOR
=
"
${
i
#*=
}
"
shift
shift
;;
;;
--shutdown_log
=
*
)
SHUTDOWN_LOG
=
"
${
i
#*=
}
"
shift
;;
tiny_publish
)
tiny_publish
)
make_tiny_publish_so
$ARM_OS
$ARM_ABI
$ARM_LANG
$ANDROID_STL
make_tiny_publish_so
$ARM_OS
$ARM_ABI
$ARM_LANG
$ANDROID_STL
shift
shift
...
...
lite/utils/logging.cc
浏览文件 @
f6aba39d
...
@@ -43,10 +43,10 @@ void gen_log(STL::ostream& log_stream_,
...
@@ -43,10 +43,10 @@ void gen_log(STL::ostream& log_stream_,
gettimeofday
(
&
tv
,
NULL
);
gettimeofday
(
&
tv
,
NULL
);
// print date / time
// print date / time
log_stream_
<<
'['
<<
level
<<
' '
<<
std
::
setw
(
2
)
<<
1
+
tm_time
.
tm_mon
log_stream_
<<
'['
<<
level
<<
' '
<<
STL
::
setw
(
2
)
<<
1
+
tm_time
.
tm_mon
<<
'/'
<<
std
::
setw
(
2
)
<<
tm_time
.
tm_mday
<<
' '
<<
std
::
setw
(
2
)
<<
'/'
<<
STL
::
setw
(
2
)
<<
tm_time
.
tm_mday
<<
' '
<<
STL
::
setw
(
2
)
<<
tm_time
.
tm_hour
<<
':'
<<
std
::
setw
(
2
)
<<
tm_time
.
tm_min
<<
':'
<<
tm_time
.
tm_hour
<<
':'
<<
STL
::
setw
(
2
)
<<
tm_time
.
tm_min
<<
':'
<<
std
::
setw
(
2
)
<<
tm_time
.
tm_sec
<<
'.'
<<
std
::
setw
(
3
)
<<
STL
::
setw
(
2
)
<<
tm_time
.
tm_sec
<<
'.'
<<
STL
::
setw
(
3
)
<<
tv
.
tv_usec
/
1000
<<
" "
;
<<
tv
.
tv_usec
/
1000
<<
" "
;
if
(
len
>
kMaxLen
)
{
if
(
len
>
kMaxLen
)
{
...
...
lite/utils/logging.h
浏览文件 @
f6aba39d
...
@@ -30,6 +30,18 @@
...
@@ -30,6 +30,18 @@
#include <string>
#include <string>
#include "lite/utils/replace_stl/stream.h"
#include "lite/utils/replace_stl/stream.h"
#ifdef LITE_WITH_ANDROID
#include <android/log.h>
// Android log macors
#define ANDROID_LOG_TAG "Paddle-Lite"
#define ANDROID_LOG_I(msg) \
__android_log_print(ANDROID_LOG_INFO, ANDROID_LOG_TAG, msg)
#define ANDROID_LOG_W(msg) \
__android_log_print(ANDROID_LOG_WARN, ANDROID_LOG_TAG, msg)
#define ANDROID_LOG_F(msg) \
__android_log_print(ANDROID_LOG_FATAL, ANDROID_LOG_TAG, msg)
#endif
// NOLINTFILE()
// NOLINTFILE()
// LOG()
// LOG()
...
@@ -93,11 +105,22 @@ class LogMessage {
...
@@ -93,11 +105,22 @@ class LogMessage {
const
char
*
func
,
const
char
*
func
,
int
lineno
,
int
lineno
,
const
char
*
level
=
"I"
)
{
const
char
*
level
=
"I"
)
{
level_
=
level
;
paddle
::
lite
::
gen_log
(
log_stream_
,
file
,
func
,
lineno
,
level
);
paddle
::
lite
::
gen_log
(
log_stream_
,
file
,
func
,
lineno
,
level
);
}
}
~
LogMessage
()
{
~
LogMessage
()
{
log_stream_
<<
'\n'
;
log_stream_
<<
'\n'
;
#ifdef LITE_WITH_ANDROID
if
(
level_
==
"I"
)
{
ANDROID_LOG_I
(
log_stream_
.
str
().
c_str
());
}
else
if
(
level_
==
"W"
)
{
ANDROID_LOG_W
(
log_stream_
.
str
().
c_str
());
}
else
{
fprintf
(
stderr
,
"Unsupported log level: %s"
,
level_
.
c_str
());
assert
(
false
);
}
#endif
fprintf
(
stderr
,
"%s"
,
log_stream_
.
str
().
c_str
());
fprintf
(
stderr
,
"%s"
,
log_stream_
.
str
().
c_str
());
}
}
...
@@ -105,6 +128,7 @@ class LogMessage {
...
@@ -105,6 +128,7 @@ class LogMessage {
protected:
protected:
STL
::
stringstream
log_stream_
;
STL
::
stringstream
log_stream_
;
std
::
string
level_
;
LogMessage
(
const
LogMessage
&
)
=
delete
;
LogMessage
(
const
LogMessage
&
)
=
delete
;
void
operator
=
(
const
LogMessage
&
)
=
delete
;
void
operator
=
(
const
LogMessage
&
)
=
delete
;
...
@@ -121,7 +145,11 @@ class LogMessageFatal : public LogMessage {
...
@@ -121,7 +145,11 @@ class LogMessageFatal : public LogMessage {
~
LogMessageFatal
()
{
~
LogMessageFatal
()
{
log_stream_
<<
'\n'
;
log_stream_
<<
'\n'
;
#ifdef LITE_WITH_ANDROID
ANDROID_LOG_F
(
log_stream_
.
str
().
c_str
());
#endif
fprintf
(
stderr
,
"%s"
,
log_stream_
.
str
().
c_str
());
fprintf
(
stderr
,
"%s"
,
log_stream_
.
str
().
c_str
());
#ifndef LITE_ON_TINY_PUBLISH
#ifndef LITE_ON_TINY_PUBLISH
abort
();
abort
();
#else
#else
...
@@ -152,6 +180,9 @@ class VLogMessage {
...
@@ -152,6 +180,9 @@ class VLogMessage {
return
;
return
;
}
}
log_stream_
<<
'\n'
;
log_stream_
<<
'\n'
;
#ifdef LITE_WITH_ANDROID
ANDROID_LOG_I
(
log_stream_
.
str
().
c_str
());
#endif
fprintf
(
stderr
,
"%s"
,
log_stream_
.
str
().
c_str
());
fprintf
(
stderr
,
"%s"
,
log_stream_
.
str
().
c_str
());
}
}
...
...
lite/utils/replace_stl/stream.cc
浏览文件 @
f6aba39d
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
// limitations under the License.
// limitations under the License.
#include "lite/utils/replace_stl/stream.h"
#include "lite/utils/replace_stl/stream.h"
#include <stdio.h>
#ifdef LITE_ON_TINY_PUBLISH
#ifdef LITE_ON_TINY_PUBLISH
...
@@ -20,93 +21,119 @@ namespace paddle {
...
@@ -20,93 +21,119 @@ namespace paddle {
namespace
lite
{
namespace
lite
{
namespace
replace_stl
{
namespace
replace_stl
{
void
ostream
::
pad
(
const
std
::
string
&
text
)
{
if
(
display_width_
>
0
)
{
if
(
display_width_
<
text
.
size
())
{
fprintf
(
stderr
,
"Replace STL IO display length less than text
\n
"
);
assert
(
false
);
}
else
{
for
(
int
i
=
0
;
i
<
display_width_
-
text
.
size
();
++
i
)
{
data_
.
push_back
(
' '
);
}
display_width_
=
-
1
;
}
}
}
#ifdef LITE_SHUTDOWN_LOG
#ifdef LITE_SHUTDOWN_LOG
#define ADD_DATA_AS_STRING(data_, obj_)
#define ADD_DATA_AS_STRING(data_, obj_)
#else
#else
#define ADD_DATA_AS_STRING(data_, obj_) data_ = data_ + std::to_string(obj_)
#define ADD_DATA_AS_STRING(data_, obj_) \
std::string text = std::to_string(obj_); \
pad(text); \
data_ = data_ + text;
#endif
#endif
template
<
>
template
<
>
ostream
&
ostream
::
operator
<<
(
const
char
*
obj
)
{
ostream
&
ostream
::
operator
<<
(
const
char
*
obj
)
{
_data
=
_data
+
std
::
string
(
obj
);
data_
=
data_
+
std
::
string
(
obj
);
return
*
this
;
return
*
this
;
}
}
template
<
>
template
<
>
ostream
&
ostream
::
operator
<<
(
const
char
&
obj
)
{
ostream
&
ostream
::
operator
<<
(
const
char
&
obj
)
{
_data
=
_data
+
obj
;
data_
=
data_
+
obj
;
return
*
this
;
return
*
this
;
}
}
template
<
>
template
<
>
ostream
&
ostream
::
operator
<<
(
const
std
::
string
&
obj
)
{
ostream
&
ostream
::
operator
<<
(
const
std
::
string
&
obj
)
{
_data
=
_data
+
obj
;
data_
=
data_
+
obj
;
return
*
this
;
return
*
this
;
}
}
template
<
>
template
<
>
ostream
&
ostream
::
operator
<<
(
const
int16_t
&
obj
)
{
ostream
&
ostream
::
operator
<<
(
const
int16_t
&
obj
)
{
ADD_DATA_AS_STRING
(
_data
,
obj
);
ADD_DATA_AS_STRING
(
data_
,
obj
);
return
*
this
;
return
*
this
;
}
}
template
<
>
template
<
>
ostream
&
ostream
::
operator
<<
(
const
int
&
obj
)
{
ostream
&
ostream
::
operator
<<
(
const
int
&
obj
)
{
ADD_DATA_AS_STRING
(
_data
,
obj
);
ADD_DATA_AS_STRING
(
data_
,
obj
);
return
*
this
;
return
*
this
;
}
}
template
<
>
template
<
>
ostream
&
ostream
::
operator
<<
(
const
bool
&
obj
)
{
ostream
&
ostream
::
operator
<<
(
const
bool
&
obj
)
{
ADD_DATA_AS_STRING
(
_data
,
obj
);
ADD_DATA_AS_STRING
(
data_
,
obj
);
return
*
this
;
return
*
this
;
}
}
template
<
>
template
<
>
ostream
&
ostream
::
operator
<<
(
const
long
&
obj
)
{
// NOLINT
ostream
&
ostream
::
operator
<<
(
const
long
&
obj
)
{
// NOLINT
ADD_DATA_AS_STRING
(
_data
,
obj
);
ADD_DATA_AS_STRING
(
data_
,
obj
);
return
*
this
;
return
*
this
;
}
}
template
<
>
template
<
>
ostream
&
ostream
::
operator
<<
(
const
long
long
&
obj
)
{
// NOLINT
ostream
&
ostream
::
operator
<<
(
const
long
long
&
obj
)
{
// NOLINT
ADD_DATA_AS_STRING
(
_data
,
obj
);
ADD_DATA_AS_STRING
(
data_
,
obj
);
return
*
this
;
return
*
this
;
}
}
template
<
>
template
<
>
ostream
&
ostream
::
operator
<<
(
const
unsigned
&
obj
)
{
ostream
&
ostream
::
operator
<<
(
const
unsigned
&
obj
)
{
ADD_DATA_AS_STRING
(
_data
,
obj
);
ADD_DATA_AS_STRING
(
data_
,
obj
);
return
*
this
;
return
*
this
;
}
}
template
<
>
template
<
>
ostream
&
ostream
::
operator
<<
(
const
unsigned
long
&
obj
)
{
// NOLINT
ostream
&
ostream
::
operator
<<
(
const
unsigned
long
&
obj
)
{
// NOLINT
ADD_DATA_AS_STRING
(
_data
,
obj
);
ADD_DATA_AS_STRING
(
data_
,
obj
);
return
*
this
;
return
*
this
;
}
}
template
<
>
template
<
>
ostream
&
ostream
::
operator
<<
(
const
unsigned
long
long
&
obj
)
{
// NOLINT
ostream
&
ostream
::
operator
<<
(
const
unsigned
long
long
&
obj
)
{
// NOLINT
ADD_DATA_AS_STRING
(
_data
,
obj
);
ADD_DATA_AS_STRING
(
data_
,
obj
);
return
*
this
;
return
*
this
;
}
}
template
<
>
template
<
>
ostream
&
ostream
::
operator
<<
(
const
float
&
obj
)
{
ostream
&
ostream
::
operator
<<
(
const
float
&
obj
)
{
ADD_DATA_AS_STRING
(
_data
,
obj
);
ADD_DATA_AS_STRING
(
data_
,
obj
);
return
*
this
;
return
*
this
;
}
}
template
<
>
template
<
>
ostream
&
ostream
::
operator
<<
(
const
double
&
obj
)
{
ostream
&
ostream
::
operator
<<
(
const
double
&
obj
)
{
ADD_DATA_AS_STRING
(
_data
,
obj
);
ADD_DATA_AS_STRING
(
data_
,
obj
);
return
*
this
;
return
*
this
;
}
}
template
<
>
template
<
>
ostream
&
ostream
::
operator
<<
(
const
long
double
&
obj
)
{
ostream
&
ostream
::
operator
<<
(
const
long
double
&
obj
)
{
ADD_DATA_AS_STRING
(
_data
,
obj
);
ADD_DATA_AS_STRING
(
data_
,
obj
);
return
*
this
;
}
template
<
>
ostream
&
ostream
::
operator
<<
(
const
LiteIoWidth
&
obj
)
{
int
width
=
obj
.
width
;
assert
(
width
>
0
);
display_width_
=
width
;
return
*
this
;
return
*
this
;
}
}
...
...
lite/utils/replace_stl/stream.h
浏览文件 @
f6aba39d
...
@@ -29,18 +29,25 @@ namespace lite {
...
@@ -29,18 +29,25 @@ namespace lite {
namespace
replace_stl
{
namespace
replace_stl
{
struct
LiteIoWidth
{
explicit
LiteIoWidth
(
int
value
)
:
width
(
value
)
{}
int
width
;
};
static
LiteIoWidth
setw
(
int
width
)
{
return
LiteIoWidth
(
width
);
}
class
ostream
{
class
ostream
{
public:
public:
ostream
()
{}
ostream
()
{}
explicit
ostream
(
const
std
::
string
&
x
)
:
_data
(
x
)
{}
explicit
ostream
(
const
std
::
string
&
x
)
:
data_
(
x
)
{}
~
ostream
()
{}
~
ostream
()
{}
const
char
*
c_str
()
{
return
_data
.
c_str
();
}
const
char
*
c_str
()
{
return
data_
.
c_str
();
}
const
std
::
string
&
str
()
{
return
_data
;
}
const
std
::
string
&
str
()
{
return
data_
;
}
const
std
::
string
&
str
(
const
std
::
string
&
x
)
{
const
std
::
string
&
str
(
const
std
::
string
&
x
)
{
_data
=
x
;
data_
=
x
;
return
_data
;
return
data_
;
}
}
template
<
typename
T
>
template
<
typename
T
>
...
@@ -50,7 +57,9 @@ class ostream {
...
@@ -50,7 +57,9 @@ class ostream {
ostream
&
operator
<<
(
const
T
*
obj
);
ostream
&
operator
<<
(
const
T
*
obj
);
private:
private:
std
::
string
_data
;
void
pad
(
const
std
::
string
&
text
);
std
::
string
data_
;
int
display_width_
{
-
1
};
// -1 refers to no setting
};
};
class
stringstream
:
public
ostream
{
class
stringstream
:
public
ostream
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录