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...
- 傳回類型