快捷鍵

torch.compiler.is_compiling

torch.compiler.is_compiling()[來源][來源]

指出圖形是否作為 torch.compile() 或 torch.export() 的一部分執行/追蹤。

請注意,還有另外 2 個相關的標記最終應該被棄用
  • 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 的完整開發者文件

檢視文件

教學

取得針對初學者和進階開發者的深度教學

檢視教學

資源

尋找開發資源並獲得您的問題解答

檢視資源