torch.compiler.is_dynamo_compiling

torch.compiler.is_dynamo_compiling()[源代码]

表示图是否通过TorchDynamo进行跟踪。

它比is_compiling()标志更严格,仅在使用TorchDynamo时才会被设置为True。

示例:

>>> def forward(self, x):
>>>     if not torch.compiler.is_dynamo_compiling():
>>>        pass # ...logic that is not needed in a TorchDynamo-traced graph...
>>>
>>>     # ...rest of the function...
返回类型

bool

本页目录