评价此页

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

布尔值