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...
- Тип возвращаемого значения:
© 2026, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://docs.pytorch.org/docs/2.14/generated/torch.compiler.is_compiling.html