Shortcuts

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
const std::string to_string(const FeatureGateName &value)

Get the string value of the FeatureGateName enum.

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.

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_FLAGS macro. 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

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources