Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
53f9768d
P
Paddle
项目概览
Crayon鑫
/
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看板
未验证
提交
53f9768d
编写于
9月 28, 2021
作者:
L
Leo Chen
提交者:
GitHub
9月 28, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[re-submit] auto read all public envs from flags_map in paddle_gtest_main (#36121)
* read envs in flags_map * add flags to undefok
上级
c719add7
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
18 addition
and
32 deletion
+18
-32
paddle/testing/paddle_gtest_main.cc
paddle/testing/paddle_gtest_main.cc
+18
-32
未找到文件。
paddle/testing/paddle_gtest_main.cc
浏览文件 @
53f9768d
...
@@ -15,6 +15,7 @@ limitations under the License. */
...
@@ -15,6 +15,7 @@ limitations under the License. */
#include "gflags/gflags.h"
#include "gflags/gflags.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "paddle/fluid/memory/allocation/allocator_strategy.h"
#include "paddle/fluid/memory/allocation/allocator_strategy.h"
#include "paddle/fluid/platform/flags.h"
#include "paddle/fluid/platform/init.h"
#include "paddle/fluid/platform/init.h"
#include "paddle/fluid/platform/npu_info.h"
#include "paddle/fluid/platform/npu_info.h"
...
@@ -22,7 +23,6 @@ int main(int argc, char** argv) {
...
@@ -22,7 +23,6 @@ int main(int argc, char** argv) {
paddle
::
memory
::
allocation
::
UseAllocatorStrategyGFlag
();
paddle
::
memory
::
allocation
::
UseAllocatorStrategyGFlag
();
testing
::
InitGoogleTest
(
&
argc
,
argv
);
testing
::
InitGoogleTest
(
&
argc
,
argv
);
std
::
vector
<
char
*>
new_argv
;
std
::
vector
<
char
*>
new_argv
;
std
::
string
gflags_env
;
for
(
int
i
=
0
;
i
<
argc
;
++
i
)
{
for
(
int
i
=
0
;
i
<
argc
;
++
i
)
{
new_argv
.
push_back
(
argv
[
i
]);
new_argv
.
push_back
(
argv
[
i
]);
}
}
...
@@ -38,35 +38,23 @@ int main(int argc, char** argv) {
...
@@ -38,35 +38,23 @@ int main(int argc, char** argv) {
}
}
#endif
#endif
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) || \
const
auto
&
flag_map
=
paddle
::
platform
::
GetExportedFlagInfoMap
();
defined(PADDLE_WITH_ASCEND_CL)
for
(
const
auto
&
pair
:
flag_map
)
{
envs
.
push_back
(
"fraction_of_gpu_memory_to_use"
);
const
std
::
string
&
name
=
pair
.
second
.
name
;
envs
.
push_back
(
"initial_gpu_memory_in_mb"
);
// NOTE(zhiqiu): some names may not linked in some tests, so add to
envs
.
push_back
(
"reallocate_gpu_memory_in_mb"
);
// `undefok`.
envs
.
push_back
(
"allocator_strategy"
);
// One way to handle that is to check each flag item by item, and put it in
envs
.
push_back
(
"selected_gpus"
);
// `envs` or `undefok`;
#elif __clang__
// another way is to add all flags to `envs` and `undeok`, basically it is
envs
.
push_back
(
"use_mkldnn"
);
// not a good design,
envs
.
push_back
(
"initial_cpu_memory_in_mb"
);
// but it can simplify the procedure of creating new flag and seems no side
envs
.
push_back
(
"allocator_strategy"
);
// effects.
// see details: https://gflags.github.io/gflags/#special
undefok
.
push_back
(
"use_mkldnn"
);
if
(
pair
.
second
.
is_writable
)
{
// means public
undefok
.
push_back
(
"initial_cpu_memory_in_mb"
);
envs
.
push_back
(
name
);
#else
undefok
.
push_back
(
name
);
envs
.
push_back
(
"use_pinned_memory"
);
}
envs
.
push_back
(
"use_mkldnn"
);
}
envs
.
push_back
(
"initial_cpu_memory_in_mb"
);
envs
.
push_back
(
"allocator_strategy"
);
undefok
.
push_back
(
"use_pinned_memory"
);
undefok
.
push_back
(
"use_mkldnn"
);
undefok
.
push_back
(
"initial_cpu_memory_in_mb"
);
#endif
#if defined(PADDLE_WITH_ASCEND_CL)
envs
.
push_back
(
"selected_npus"
);
envs
.
push_back
(
"npu_config_path"
);
#endif
char
*
env_str
=
nullptr
;
char
*
env_str
=
nullptr
;
if
(
envs
.
size
()
>
0
)
{
if
(
envs
.
size
()
>
0
)
{
...
@@ -103,9 +91,7 @@ int main(int argc, char** argv) {
...
@@ -103,9 +91,7 @@ int main(int argc, char** argv) {
#ifdef PADDLE_WITH_ASCEND_CL
#ifdef PADDLE_WITH_ASCEND_CL
paddle
::
platform
::
AclInstance
::
Instance
().
Finalize
();
paddle
::
platform
::
AclInstance
::
Instance
().
Finalize
();
#endif
#endif
if
(
env_str
)
free
(
env_str
);
if
(
env_str
)
free
(
env_str
);
if
(
undefok_str
)
free
(
undefok_str
);
if
(
undefok_str
)
free
(
undefok_str
);
return
ret
;
return
ret
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录