torch.result_type
- torch.result_type(tensor1, tensor2) → dtype 函数 `torch.result_type(tensor1, tensor2)` 返回两个张量的数据类型。
-
返回执行算术运算后提供的输入张量所得到的
torch.dtype
类型。有关类型提升逻辑的详细信息,请参阅类型提升文档。示例:
>>> torch.result_type(torch.tensor([1, 2], dtype=torch.int), 1.0) torch.float32 >>> torch.result_type(torch.tensor([1, 2], dtype=torch.uint8), torch.tensor(1)) torch.uint8