torch.promote_types¶
- torch.promote_types(type1, type2) → dtype
返回具有最小大小和标量类型的
torch.dtype
,该类型不小于 type1 或 type2。有关类型提升逻辑的更多信息,请参阅类型提升文档。- 参数:
类型 1(
torch.dtype
) –类型 2(
torch.dtype
) –
示例:
>>> torch.promote_types(torch.int32, torch.float32) torch.float32 >>> torch.promote_types(torch.uint8, torch.long) torch.long