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