Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
17003369
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
未验证
提交
17003369
编写于
9月 01, 2023
作者:
H
huangjiyi
提交者:
GitHub
9月 01, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
export flags defined in phi on windows (#56848)
* update * update
上级
4abea956
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
65 addition
and
81 deletion
+65
-81
paddle/phi/core/flags.h
paddle/phi/core/flags.h
+65
-81
未找到文件。
paddle/phi/core/flags.h
浏览文件 @
17003369
...
...
@@ -32,10 +32,9 @@
#define PHI_IMPORT_FLAG
#endif // _WIN32
// We redefine the flags macro for exporting flags defined in phi
#ifdef PADDLE_WITH_GFLAGS
// We redefine the gflags' macro for exporting global variable
// ----------------------------DECLARE FLAGS----------------------------
// clang-format off
#define PHI_DECLARE_VARIABLE(type, shorttype, name) \
namespace fL##shorttype { \
...
...
@@ -44,35 +43,10 @@
using fL##shorttype::FLAGS_##name
// clang-format on
#define PHI_DECLARE_bool(name) PHI_DECLARE_VARIABLE(bool, B, name)
#define PHI_DECLARE_int32(name) \
PHI_DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int32, I, name)
#define PHI_DECLARE_uint32(name) \
PHI_DECLARE_VARIABLE(::GFLAGS_NAMESPACE::uint32, U, name)
#define PHI_DECLARE_int64(name) \
PHI_DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int64, I64, name)
#define PHI_DECLARE_uint64(name) \
PHI_DECLARE_VARIABLE(::GFLAGS_NAMESPACE::uint64, U64, name)
#define PHI_DECLARE_double(name) PHI_DECLARE_VARIABLE(double, D, name)
#define PHI_DECLARE_string(name) \
/* We always want to import declared variables, dll or no */
\
namespace fLS { \
extern PHI_IMPORT_FLAG ::fLS::clstring& FLAGS_##name; \
} \
using fLS::FLAGS_##name
// ----------------------------DEFINE FLAGS----------------------------
#define PHI_DEFINE_VARIABLE(type, shorttype, name, value, help) \
namespace fL##shorttype { \
static const type FLAGS_nono##name = value; \
PHI_EXPORT_FLAG type FLAGS_##name = FLAGS_nono##name; \
static type FLAGS_no##name = FLAGS_nono##name; \
PHI_EXPORT_FLAG type FLAGS_##name = value; \
static type FLAGS_no##name = value; \
static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \
#name, \
MAYBE_STRIPPED_HELP(help), \
...
...
@@ -82,67 +56,77 @@
}
/* NOLINT */
\
using fL##shorttype::FLAGS_##name
#define PHI_DEFINE_bool(name, val, txt) \
namespace fLB { \
typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool
/* NOLINT */
\
[(sizeof(::fLB::IsBoolFlag(val)) != sizeof(double)) ? 1 : -1]; \
} \
PHI_DEFINE_VARIABLE(bool, B, name, val, txt)
#else // PADDLE_WITH_GFLAGS
#define PHI_DEFINE_int32(name, val, txt) \
PHI_DEFINE_VARIABLE(GFLAGS_NAMESPACE::int32, I, name, val, txt)
#define PHI_DECLARE_VARIABLE(type, shorttype, name) \
namespace paddle { \
namespace flags { \
extern PHI_IMPORT_FLAG type FLAGS_##name; \
} \
} \
using paddle::flags::FLAGS_##name
#define PHI_DEFINE_VARIABLE(type, shorttype, name, default_value, description) \
namespace paddle { \
namespace flags { \
static const type FLAGS_##name##_default = default_value; \
PHI_EXPORT_FLAG type FLAGS_##name = default_value; \
/* Register FLAG */
\
static ::paddle::flags::FlagRegisterer flag_##name##_registerer( \
#name, description, __FILE__, &FLAGS_##name##_default, &FLAGS_##name); \
} \
} \
using paddle::flags::FLAGS_##name
#define PHI_DEFINE_uint32(name, val, txt) \
PHI_DEFINE_VARIABLE(GFLAGS_NAMESPACE::uint32, U, name, val, txt)
#endif
#define PHI_DEFINE_int64(name, val, txt) \
PHI_DEFINE_VARIABLE(GFLAGS_NAMESPACE::int64, I64, name, val, txt)
// ----------------------------DECLARE FLAGS----------------------------
#define PHI_DECLARE_bool(name) PHI_DECLARE_VARIABLE(bool, B, name)
#define PHI_DECLARE_int32(name) PHI_DECLARE_VARIABLE(int32_t, I, name)
#define PHI_DECLARE_uint32(name) PHI_DECLARE_VARIABLE(uint32_t, U, name)
#define PHI_DECLARE_int64(name) PHI_DECLARE_VARIABLE(int64_t, I64, name)
#define PHI_DECLARE_uint64(name) PHI_DECLARE_VARIABLE(uint64_t, U64, name)
#define PHI_DECLARE_double(name) PHI_DECLARE_VARIABLE(double, D, name)
// ----------------------------DEFINE FLAGS-----------------------------
#define PHI_DEFINE_bool(name, val, txt) \
PHI_DEFINE_VARIABLE(bool, B, name, val, txt)
#define PHI_DEFINE_int32(name, val, txt) \
PHI_DEFINE_VARIABLE(int32_t, I, name, val, txt)
#define PHI_DEFINE_uint32(name, val, txt) \
PHI_DEFINE_VARIABLE(uint32_t, U, name, val, txt)
#define PHI_DEFINE_int64(name, val, txt) \
PHI_DEFINE_VARIABLE(int64_t, I64, name, val, txt)
#define PHI_DEFINE_uint64(name, val, txt) \
PHI_DEFINE_VARIABLE(GFLAGS_NAMESPACE::uint64, U64, name, val, txt)
PHI_DEFINE_VARIABLE(uint64_t, U64, name, val, txt)
#define PHI_DEFINE_double(name, val, txt) \
PHI_DEFINE_VARIABLE(double, D, name, val, txt)
#define PHI_DEFINE_string(name, val, txt) \
namespace fLS { \
using ::fLS::clstring; \
using ::fLS::StringFlagDestructor; \
static union {
/* NOLINT */
\
void* align; \
std::array<char, sizeof(clstring)> s; \
} s_##name[2];
/* NOLINT */
\
clstring* const FLAGS_no##name = \
::fLS::dont_pass0toDEFINE_string(s_##name[0].s.data(), val); \
static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \
#name, \
MAYBE_STRIPPED_HELP(txt), \
__FILE__, \
FLAGS_no##name, \
new (s_##name[1].s.data()) clstring(*FLAGS_no##name)); \
static StringFlagDestructor d_##name(s_##name[0].s.data(), \
s_##name[1].s.data()); \
extern PHI_EXPORT_FLAG clstring& FLAGS_##name; \
using fLS::FLAGS_##name; \
clstring& FLAGS_##name = *FLAGS_no##name; \
}
/* NOLINT */
\
#ifdef PADDLE_WITH_GFLAGS
#define PHI_DECLARE_string(name) \
namespace fLS { \
extern PHI_IMPORT_FLAG ::fLS::clstring& FLAGS_##name; \
} \
using fLS::FLAGS_##name
#else // PADDLE_WITH_GFLAGS
#define PHI_DEFINE_bool(name, val, txt) PD_DEFINE_bool(name, val, txt)
#define PHI_DEFINE_int32(name, val, txt) PD_DEFINE_int32(name, val, txt)
#define PHI_DEFINE_uint32(name, val, txt) PD_DEFINE_uint32(name, val, txt)
#define PHI_DEFINE_int64(name, val, txt) PD_DEFINE_int64(name, val, txt)
#define PHI_DEFINE_uint64(name, val, txt) PD_DEFINE_uint64(name, val, txt)
#define PHI_DEFINE_double(name, val, txt) PD_DEFINE_double(name, val, txt)
#define PHI_DEFINE_string(name, val, txt) PD_DEFINE_string(name, val, txt)
#define PHI_DECLARE_bool(name) PD_DECLARE_bool(name)
#define PHI_DECLARE_int32(name) PD_DECLARE_int32(name)
#define PHI_DECLARE_uint32(name) PD_DECLARE_uint32(name)
#define PHI_DECLARE_int64(name) PD_DECLARE_int64(name)
#define PHI_DECLARE_uint64(name) PD_DECLARE_uint64(name)
#define PHI_DECLARE_double(name) PD_DECLARE_double(name)
#define PHI_DECLARE_string(name) PD_DECLARE_string(name)
#define PHI_DEFINE_string(name, val, txt) \
namespace fLS { \
using ::fLS::clstring; \
clstring FLAGS_##name##_default = val; \
clstring FLAGS_##name##_current = val; \
static GFLAGS_NAMESPACE::FlagRegisterer o_##name(#name, \
MAYBE_STRIPPED_HELP(txt), \
__FILE__, \
&FLAGS_##name##_current, \
&FLAGS_##name##_default); \
PHI_EXPORT_FLAG clstring& FLAGS_##name = FLAGS_##name##_current; \
}
/* NOLINT */
\
using ::fLS::FLAGS_##name
#else
#define PHI_DECLARE_string(name) PHI_DECLARE_VARIABLE(std::string, S, name)
#define PHI_DEFINE_string(name, val, txt) \
PHI_DEFINE_VARIABLE(std::string, S, name, val, txt)
#endif
namespace
phi
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录