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...
- 返回型別