功能门(C++)¶
-
enum class FeatureGateName¶
用于功能门的枚举类定义,使用 X-macro 模式生成。
值
-
enumerator X¶
-
enumerator ENUMERATE_ALL_FEATURE_FLAGS¶
-
enumerator X¶
-
std::string to_string(const FeatureGateName &value)¶
获取
FeatureGateName枚举的字符串值。
-
bool check_feature_gate_key(const std::string &key)¶
查找给定键的功能门值。
-
bool is_feature_enabled(const FeatureGateName &feature)¶
对于给定的
FeatureGateName,检查相应的功能是否已启用。
-
bool is_feature_enabled_from_env(const FeatureGateName &feature)¶
对于给定的
FeatureGateName,仅检查在环境变量中是否启用了相应的功能。
-
ENUMERATE_ALL_FEATURE_FLAGS¶
FBGEMM_GPU 功能门枚举(C++)。
功能门用于根据环境设置启用/禁用实验性功能。
枚举是通过 X-macro 模式定义的。要添加功能门,只需将
X(FEATURE_NAME)追加到ENUMERATE_ALL_FEATURE_FLAGS宏即可。然后,要使用功能门,请参阅以下示例。示例
namespace config = fbgemm_gpu::config; void foo() { if (config::is_feature_enabled(config::FeatureGateName::FEATURE_NAME)) { // Do something if feature is enabled ... } else { // Do something different if feature is disabled ... } }
虽然不是必需的,但最好在 Python 中镜像枚举值,在
fbgemm_gpu.config.FeatureGateName中。对于 fbcode:枚举名称必须与 UI 中的 JK knob 名称完全匹配。
对于 OSS:环境变量将被评估为 f”FBGEMM_{ENUM}”
注意