• 文档 >
  • 特性开关 (Python)
快捷方式

特性开关 (Python)

稳定 API

class fbgemm_gpu.config.FeatureGateName(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

FBGEMM_GPU 特性开关枚举 (Python)。

代码示例

from fbgemm_gpu.config import FeatureGateName

def foo():
    if FeatureGateName.TBE_V2.is_enabled():

        # Do something if feature is enabled
        ...
    else:
        # Do something different if feature is disabled
        ...

注意

虽然不是必需的,但最好在 C++ 中(位于 fbgemm_gpu/config/feature_gates.h)镜像这些枚举值。

对于 fbcode:枚举名称必须与 UI 中的 JK knob 名称完全匹配。对于开源版本 (OSS):环境变量将被解析为 f”FBGEMM_{ENUM}”

class fbgemm_gpu.config.FeatureGate[source]

FBGEMM_GPU 特性开关。

存在此类的原因是在将枚举打包到模型中时,无法调用枚举上定义的方法(其机制尚不明确)。

代码示例

from deeplearning.fbgemm.fbgemm_gpu.config import FeatureGate, FeatureGateName

FeatureGate.is_enabled(FeatureGateName.TBE_V2)

文档

查阅 PyTorch 全面的开发者文档

查看文档

教程

获取针对初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得问题解答

查看资源