Feature Gates (C++)¶
- 
enum class FeatureGateName¶
- Enum class definition for feature gates, generated using the X-macro pattern. - Values: - 
enumerator X¶
 - 
enumerator ENUMERATE_ALL_FEATURE_FLAGS¶
 
- 
enumerator X¶
- 
std::string to_string(const FeatureGateName &value)¶
- Get the string value of the - FeatureGateNameenum.
- 
bool check_feature_gate_key(const std::string &key)¶
- Look up the feature gate value for the given key. 
- 
bool is_feature_enabled(const FeatureGateName &feature)¶
- For the given - FeatureGateName, check if the corresponding feature is enabled.
- 
bool is_feature_enabled_from_env(const FeatureGateName &feature)¶
- For the given - FeatureGateName, check if the corresponding feature is enabled in the env vars only.
- 
ENUMERATE_ALL_FEATURE_FLAGS¶
- FBGEMM_GPU feature gates enum (C++). - Feature gates are used to enable/disable experimental features based on environment settings. - ENUMs are defined using the X-macro pattern. To add a feature gate, simply append - X(FEATURE_NAME)to the- ENUMERATE_ALL_FEATURE_FLAGSmacro. Then, to use the feature gate, see example below.- Example: - 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 ... } } - While not required, it is best to mirror the enum values in Python, in - fbgemm_gpu.config.FeatureGateName- For fbcode: The ENUM name must match EXACTLY with the JK knob name in the UI. - For OSS: The environment variable will be evaluated as f”FBGEMM_{ENUM}” - Note