Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
715d8628
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
715d8628
编写于
1月 15, 2021
作者:
石
石晓伟
提交者:
GitHub
1月 15, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
export global google flags to users, test=develop (#30448)
上级
88fc7a7d
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
35 addition
and
65 deletion
+35
-65
cmake/external/gflags.cmake
cmake/external/gflags.cmake
+4
-2
cmake/external/glog.cmake
cmake/external/glog.cmake
+3
-5
paddle/fluid/distributed/service/communicator.cc
paddle/fluid/distributed/service/communicator.cc
+1
-1
paddle/fluid/distributed/service/service.cc
paddle/fluid/distributed/service/service.cc
+3
-3
paddle/fluid/inference/api/api.cc
paddle/fluid/inference/api/api.cc
+1
-1
paddle/fluid/inference/api/demo_ci/simple_on_word2vec.cc
paddle/fluid/inference/api/demo_ci/simple_on_word2vec.cc
+1
-1
paddle/fluid/inference/api/demo_ci/trt_mobilenet_demo.cc
paddle/fluid/inference/api/demo_ci/trt_mobilenet_demo.cc
+1
-1
paddle/fluid/inference/api/demo_ci/vis_demo.cc
paddle/fluid/inference/api/demo_ci/vis_demo.cc
+1
-1
paddle/fluid/inference/api/demo_ci/windows_mobilenet.cc
paddle/fluid/inference/api/demo_ci/windows_mobilenet.cc
+1
-1
paddle/fluid/inference/check_symbol.sh
paddle/fluid/inference/check_symbol.sh
+1
-1
paddle/fluid/inference/paddle_fluid.map
paddle/fluid/inference/paddle_fluid.map
+1
-0
paddle/fluid/memory/detail/buddy_allocator.cc
paddle/fluid/memory/detail/buddy_allocator.cc
+1
-0
paddle/fluid/operators/jit/benchmark.cc
paddle/fluid/operators/jit/benchmark.cc
+1
-1
paddle/fluid/platform/enforce.h
paddle/fluid/platform/enforce.h
+1
-0
paddle/fluid/platform/init.cc
paddle/fluid/platform/init.cc
+2
-2
paddle/fluid/train/imdb_demo/demo_trainer.cc
paddle/fluid/train/imdb_demo/demo_trainer.cc
+1
-1
paddle/testing/paddle_gtest_main.cc
paddle/testing/paddle_gtest_main.cc
+11
-44
未找到文件。
cmake/external/gflags.cmake
浏览文件 @
715d8628
...
...
@@ -19,7 +19,7 @@ SET(GFLAGS_SOURCE_DIR ${THIRD_PARTY_PATH}/gflags/src/extern_gflags)
SET
(
GFLAGS_INSTALL_DIR
${
THIRD_PARTY_PATH
}
/install/gflags
)
SET
(
GFLAGS_INCLUDE_DIR
"
${
GFLAGS_INSTALL_DIR
}
/include"
CACHE PATH
"gflags include directory."
FORCE
)
set
(
GFLAGS_REPOSITORY
${
GIT_URL
}
/gflags/gflags.git
)
set
(
GFLAGS_TAG
77592648e3f3be87d6c7123eb81cbad75f9aef5a
)
set
(
GFLAGS_TAG
"v2.2.2"
)
IF
(
WIN32
)
set
(
GFLAGS_LIBRARIES
"
${
GFLAGS_INSTALL_DIR
}
/lib/gflags_static.lib"
CACHE FILEPATH
"GFLAGS_LIBRARIES"
FORCE
)
ELSE
(
WIN32
)
...
...
@@ -30,6 +30,8 @@ ENDIF(WIN32)
INCLUDE_DIRECTORIES
(
${
GFLAGS_INCLUDE_DIR
}
)
set
(
GFLAGS_NAMESPACE
"paddle_gflags"
)
cache_third_party
(
extern_gflags
REPOSITORY
${
GFLAGS_REPOSITORY
}
TAG
${
GFLAGS_TAG
}
...
...
@@ -44,7 +46,6 @@ ExternalProject_Add(
SOURCE_DIR
${
GFLAGS_SOURCE_DIR
}
BUILD_COMMAND
${
BUILD_COMMAND
}
INSTALL_COMMAND
${
INSTALL_COMMAND
}
UPDATE_COMMAND
""
CMAKE_ARGS -DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
-DCMAKE_C_COMPILER=
${
CMAKE_C_COMPILER
}
-DCMAKE_CXX_FLAGS=
${
CMAKE_CXX_FLAGS
}
...
...
@@ -58,6 +59,7 @@ ExternalProject_Add(
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DBUILD_TESTING=OFF
-DCMAKE_BUILD_TYPE=
${
THIRD_PARTY_BUILD_TYPE
}
-DGFLAGS_NAMESPACE=
${
GFLAGS_NAMESPACE
}
${
EXTERNAL_OPTIONAL_ARGS
}
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=
${
GFLAGS_INSTALL_DIR
}
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
...
...
cmake/external/glog.cmake
浏览文件 @
715d8628
...
...
@@ -19,7 +19,7 @@ SET(GLOG_SOURCE_DIR ${THIRD_PARTY_PATH}/glog/src/extern_glog)
SET
(
GLOG_INSTALL_DIR
${
THIRD_PARTY_PATH
}
/install/glog
)
SET
(
GLOG_INCLUDE_DIR
"
${
GLOG_INSTALL_DIR
}
/include"
CACHE PATH
"glog include directory."
FORCE
)
SET
(
GLOG_REPOSITORY
${
GIT_URL
}
/google/glog.git
)
SET
(
GLOG_TAG v0.
3.5
)
SET
(
GLOG_TAG v0.
4.0
)
IF
(
WIN32
)
SET
(
GLOG_LIBRARIES
"
${
GLOG_INSTALL_DIR
}
/lib/glog.lib"
CACHE FILEPATH
"glog library."
FORCE
)
...
...
@@ -45,7 +45,6 @@ ExternalProject_Add(
DEPENDS gflags
PREFIX
${
GLOG_PREFIX_DIR
}
SOURCE_DIR
${
GLOG_SOURCE_DIR
}
UPDATE_COMMAND
""
CMAKE_ARGS -DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
-DCMAKE_C_COMPILER=
${
CMAKE_C_COMPILER
}
-DCMAKE_CXX_FLAGS=
${
GLOG_CMAKE_CXX_FLAGS
}
...
...
@@ -57,8 +56,7 @@ ExternalProject_Add(
-DCMAKE_INSTALL_PREFIX=
${
GLOG_INSTALL_DIR
}
-DCMAKE_INSTALL_LIBDIR=
${
GLOG_INSTALL_DIR
}
/lib
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DWITH_GFLAGS=ON
-Dgflags_DIR=
${
GFLAGS_INSTALL_DIR
}
/lib/cmake/gflags
-DWITH_GFLAGS=OFF
-DBUILD_TESTING=OFF
-DCMAKE_BUILD_TYPE=
${
THIRD_PARTY_BUILD_TYPE
}
${
EXTERNAL_OPTIONAL_ARGS
}
...
...
@@ -71,4 +69,4 @@ ExternalProject_Add(
ADD_LIBRARY
(
glog STATIC IMPORTED GLOBAL
)
SET_PROPERTY
(
TARGET glog PROPERTY IMPORTED_LOCATION
${
GLOG_LIBRARIES
}
)
ADD_DEPENDENCIES
(
glog extern_glog gflags
)
LINK_LIBRARIES
(
glog
gflags
)
LINK_LIBRARIES
(
glog
)
paddle/fluid/distributed/service/communicator.cc
浏览文件 @
715d8628
...
...
@@ -68,7 +68,7 @@ void Communicator::init_gflag(const std::string &gflags) {
}
int
params_cnt
=
flags
.
size
();
char
**
params_ptr
=
&
(
flags_ptr
[
0
]);
::
google
::
ParseCommandLineFlags
(
&
params_cnt
,
&
params_ptr
,
true
);
::
GFLAGS_NAMESPACE
::
ParseCommandLineFlags
(
&
params_cnt
,
&
params_ptr
,
true
);
}
std
::
once_flag
Communicator
::
init_flag_
;
...
...
paddle/fluid/distributed/service/service.cc
浏览文件 @
715d8628
...
...
@@ -21,7 +21,7 @@
#include "paddle/fluid/distributed/service/communicator.h"
#include "paddle/fluid/string/string_helper.h"
using
namespace
std
;
using
namespace
std
;
// NOLINT
namespace
paddle
{
namespace
distributed
{
...
...
@@ -59,11 +59,11 @@ void PSCore::init_gflag(const std::string& gflags) {
flags
.
insert
(
it
,
"exe default"
);
char
*
flags_ptr
[
flags
.
size
()];
for
(
size_t
i
=
0
;
i
<
flags
.
size
();
++
i
)
{
flags_ptr
[
i
]
=
(
char
*
)(
flags
[
i
].
c_str
());
flags_ptr
[
i
]
=
(
char
*
)(
flags
[
i
].
c_str
());
// NOLINT
}
int
params_cnt
=
flags
.
size
();
char
**
params_ptr
=
&
(
flags_ptr
[
0
]);
::
google
::
ParseCommandLineFlags
(
&
params_cnt
,
&
params_ptr
,
true
);
::
GFLAGS_NAMESPACE
::
ParseCommandLineFlags
(
&
params_cnt
,
&
params_ptr
,
true
);
}
int
PSCore
::
init_server
(
...
...
paddle/fluid/inference/api/api.cc
浏览文件 @
715d8628
...
...
@@ -136,7 +136,7 @@ std::string UpdateDllFlag(const char *name, const char *value) {
LOG
(
WARNING
)
<<
"The function
\"
UpdateDllFlag
\"
is only used to update the flag "
"on the Windows shared library"
;
ret
=
google
::
SetCommandLineOption
(
name
,
value
);
ret
=
::
GFLAGS_NAMESPACE
::
SetCommandLineOption
(
name
,
value
);
PADDLE_ENFORCE_EQ
(
ret
.
empty
(),
false
,
...
...
paddle/fluid/inference/api/demo_ci/simple_on_word2vec.cc
浏览文件 @
715d8628
...
...
@@ -131,7 +131,7 @@ void MainThreads(int num_threads, bool use_gpu) {
}
// namespace paddle
int
main
(
int
argc
,
char
**
argv
)
{
google
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
::
GFLAGS_NAMESPACE
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
paddle
::
demo
::
Main
(
false
/* use_gpu*/
);
paddle
::
demo
::
MainThreads
(
1
,
false
/* use_gpu*/
);
paddle
::
demo
::
MainThreads
(
4
,
false
/* use_gpu*/
);
...
...
paddle/fluid/inference/api/demo_ci/trt_mobilenet_demo.cc
浏览文件 @
715d8628
...
...
@@ -73,7 +73,7 @@ void Main() {
}
// namespace paddle
int
main
(
int
argc
,
char
**
argv
)
{
google
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
::
GFLAGS_NAMESPACE
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
paddle
::
demo
::
Main
();
return
0
;
}
paddle/fluid/inference/api/demo_ci/vis_demo.cc
浏览文件 @
715d8628
...
...
@@ -82,7 +82,7 @@ void Main(bool use_gpu) {
}
// namespace paddle
int
main
(
int
argc
,
char
**
argv
)
{
google
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
::
GFLAGS_NAMESPACE
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
if
(
FLAGS_use_gpu
)
{
paddle
::
demo
::
Main
(
true
/*use_gpu*/
);
}
else
{
...
...
paddle/fluid/inference/api/demo_ci/windows_mobilenet.cc
浏览文件 @
715d8628
...
...
@@ -84,7 +84,7 @@ void RunAnalysis() {
}
// namespace paddle
int
main
(
int
argc
,
char
**
argv
)
{
google
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
::
GFLAGS_NAMESPACE
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
paddle
::
demo
::
RunAnalysis
();
std
::
cout
<<
"=========================Runs successfully===================="
<<
std
::
endl
;
...
...
paddle/fluid/inference/check_symbol.sh
浏览文件 @
715d8628
...
...
@@ -18,7 +18,7 @@ lib=$1
if
[
$#
-ne
1
]
;
then
echo
"No input library"
;
exit
-1
;
fi
num_paddle_syms
=
$(
nm
-D
"
${
lib
}
"
|
grep
-c
paddle
)
num_google_syms
=
$(
nm
-D
"
${
lib
}
"
|
grep
google |
grep
-v
paddle |
grep
-v
brpc |
grep
-c
"T "
)
num_google_syms
=
$(
nm
-D
"
${
lib
}
"
|
grep
google |
grep
-v
paddle |
grep
-v
brpc |
grep
-
v
fL |
grep
-
c
"T "
)
if
[
$num_paddle_syms
-le
0
]
;
then
echo
"Have no paddle symbols"
;
exit
-1
;
fi
if
[
$num_google_syms
-ge
1
]
;
then
echo
"Have some google symbols"
;
exit
-1
;
fi
...
...
paddle/fluid/inference/paddle_fluid.map
浏览文件 @
715d8628
...
...
@@ -3,6 +3,7 @@
*paddle*;
*Pass*;
*profile*;
*fL*;
local:
*;
};
...
...
paddle/fluid/memory/detail/buddy_allocator.cc
浏览文件 @
715d8628
...
...
@@ -15,6 +15,7 @@ limitations under the License. */
#include "paddle/fluid/memory/detail/buddy_allocator.h"
#include <algorithm>
#include <utility>
#include "gflags/gflags.h"
#include "glog/logging.h"
#ifdef PADDLE_WITH_CUDA
...
...
paddle/fluid/operators/jit/benchmark.cc
浏览文件 @
715d8628
...
...
@@ -567,7 +567,7 @@ BENCH_FP32_CPU(VBroadcast);
// --max_size: the max size would be tested
// --filter: the bench name would be run
int
main
(
int
argc
,
char
*
argv
[])
{
gflags
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
::
GFLAGS_NAMESPACE
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
google
::
InitGoogleLogging
(
argv
[
0
]);
LOG
(
INFO
)
<<
"Burning "
<<
FLAGS_burning
<<
" times, Repeat "
<<
FLAGS_repeat
<<
" times."
;
...
...
paddle/fluid/platform/enforce.h
浏览文件 @
715d8628
...
...
@@ -52,6 +52,7 @@ limitations under the License. */
#endif
#define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h
#include "gflags/gflags.h"
#include "glog/logging.h"
#include "paddle/fluid/platform/errors.h"
#include "paddle/fluid/platform/macros.h"
...
...
paddle/fluid/platform/init.cc
浏览文件 @
715d8628
...
...
@@ -55,7 +55,7 @@ namespace paddle {
namespace
platform
{
void
ParseCommandLineFlags
(
int
argc
,
char
**
argv
,
bool
remove
)
{
google
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
remove
);
::
GFLAGS_NAMESPACE
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
remove
);
}
}
// namespace platform
...
...
@@ -93,7 +93,7 @@ bool InitGflags(std::vector<std::string> args) {
<<
", Init commandline: "
<<
line
;
char
**
arr
=
argv
.
data
();
google
::
ParseCommandLineFlags
(
&
argc
,
&
arr
,
true
);
::
GFLAGS_NAMESPACE
::
ParseCommandLineFlags
(
&
argc
,
&
arr
,
true
);
successed
=
true
;
VLOG
(
1
)
<<
"After Parse: argc is "
<<
argc
;
...
...
paddle/fluid/train/imdb_demo/demo_trainer.cc
浏览文件 @
715d8628
...
...
@@ -80,7 +80,7 @@ bool IsPersistable(const paddle::framework::VarDesc* var) {
}
// namespace paddle
int
main
(
int
argc
,
char
*
argv
[])
{
gflags
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
::
GFLAGS_NAMESPACE
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
std
::
cerr
<<
"filelist: "
<<
FLAGS_filelist
<<
std
::
endl
;
std
::
cerr
<<
"data_proto_desc: "
<<
FLAGS_data_proto_desc
<<
std
::
endl
;
...
...
paddle/testing/paddle_gtest_main.cc
浏览文件 @
715d8628
...
...
@@ -20,41 +20,10 @@ limitations under the License. */
int
main
(
int
argc
,
char
**
argv
)
{
paddle
::
memory
::
allocation
::
UseAllocatorStrategyGFlag
();
testing
::
InitGoogleTest
(
&
argc
,
argv
);
// Because the dynamic library libpaddle_fluid.so clips the symbol table, the
// external program cannot recognize the flag inside the so, and the flag
// defined by the external program cannot be accessed inside the so.
// Therefore, the ParseCommandLine function needs to be called separately
// inside and outside.
std
::
vector
<
char
*>
external_argv
;
std
::
vector
<
char
*>
internal_argv
;
// ParseNewCommandLineFlags in gflags.cc starts processing
// commandline strings from idx 1.
// The reason is, it assumes that the first one (idx 0) is
// the filename of executable file.
external_argv
.
push_back
(
argv
[
0
]);
internal_argv
.
push_back
(
argv
[
0
]);
std
::
vector
<
google
::
CommandLineFlagInfo
>
all_flags
;
std
::
vector
<
std
::
string
>
external_flags_name
;
google
::
GetAllFlags
(
&
all_flags
);
for
(
size_t
i
=
0
;
i
<
all_flags
.
size
();
++
i
)
{
external_flags_name
.
push_back
(
all_flags
[
i
].
name
);
}
std
::
vector
<
char
*>
new_argv
;
std
::
string
gflags_env
;
for
(
int
i
=
0
;
i
<
argc
;
++
i
)
{
bool
flag
=
true
;
std
::
string
tmp
(
argv
[
i
]);
for
(
size_t
j
=
0
;
j
<
external_flags_name
.
size
();
++
j
)
{
if
(
tmp
.
find
(
external_flags_name
[
j
])
!=
std
::
string
::
npos
)
{
external_argv
.
push_back
(
argv
[
i
]);
flag
=
false
;
break
;
}
}
if
(
flag
)
{
internal_argv
.
push_back
(
argv
[
i
]);
}
new_argv
.
push_back
(
argv
[
i
]);
}
std
::
vector
<
std
::
string
>
envs
;
...
...
@@ -62,7 +31,8 @@ int main(int argc, char** argv) {
#if defined(PADDLE_WITH_DISTRIBUTE) && !defined(PADDLE_WITH_GRPC) && \
!defined(PADDLE_WITH_PSLIB)
std
::
string
str_max_body_size
;
if
(
google
::
GetCommandLineOption
(
"max_body_size"
,
&
str_max_body_size
))
{
if
(
::
GFLAGS_NAMESPACE
::
GetCommandLineOption
(
"max_body_size"
,
&
str_max_body_size
))
{
setenv
(
"FLAGS_max_body_size"
,
"2147483647"
,
1
);
envs
.
push_back
(
"max_body_size"
);
}
...
...
@@ -99,7 +69,7 @@ int main(int argc, char** argv) {
}
env_string
=
env_string
.
substr
(
0
,
env_string
.
length
()
-
1
);
env_str
=
strdup
(
env_string
.
c_str
());
internal
_argv
.
push_back
(
env_str
);
new
_argv
.
push_back
(
env_str
);
VLOG
(
1
)
<<
"gtest env_string:"
<<
env_string
;
}
...
...
@@ -111,17 +81,14 @@ int main(int argc, char** argv) {
}
undefok_string
=
undefok_string
.
substr
(
0
,
undefok_string
.
length
()
-
1
);
undefok_str
=
strdup
(
undefok_string
.
c_str
());
internal
_argv
.
push_back
(
undefok_str
);
new
_argv
.
push_back
(
undefok_str
);
VLOG
(
1
)
<<
"gtest undefok_string:"
<<
undefok_string
;
}
int
new_argc
=
static_cast
<
int
>
(
external_argv
.
size
());
char
**
external_argv_address
=
external_argv
.
data
();
google
::
ParseCommandLineFlags
(
&
new_argc
,
&
external_argv_address
,
false
);
int
internal_argc
=
internal_argv
.
size
();
char
**
arr
=
internal_argv
.
data
();
paddle
::
platform
::
ParseCommandLineFlags
(
internal_argc
,
arr
,
true
);
int
new_argc
=
static_cast
<
int
>
(
new_argv
.
size
());
char
**
new_argv_address
=
new_argv
.
data
();
::
GFLAGS_NAMESPACE
::
ParseCommandLineFlags
(
&
new_argc
,
&
new_argv_address
,
false
);
paddle
::
framework
::
InitDevices
();
int
ret
=
RUN_ALL_TESTS
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录