快捷方式

torch.compiler.is_compiling

torch.compiler.is_compiling()[source][source]

指示圖是否正在作為 torch.compile() 或 torch.export() 的一部分執行/跟蹤。

請注意,還有另外兩個相關標誌最終將被棄用
  • torch._dynamo.external_utils.is_compiling()

  • torch._utils.is_compiling()

示例

>>> def forward(self, x):
>>>     if not torch.compiler.is_compiling():
>>>        pass # ...logic that is not needed in a compiled/traced graph...
>>>
>>>     # ...rest of the function...
返回型別

bool

文件

查閱 PyTorch 的全面開發者文件

檢視文件

教程

獲取針對初學者和高階開發者的深入教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源