Shortcuts

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():
>>>        ...逻辑  TorchDynamo-traced graph  不需要...
>>>
>>>     ...函数的其余部分...
Return type

bool

优云智算