评价此页

result_type#

torch.result_type(tensor1, tensor2) dtype#

返回执行算术运算后将生成的结果 torch.dtype。有关类型提升逻辑的更多信息,请参阅类型提升 文档

参数
  • tensor1 (TensorNumber) – 一个输入张量或数字

  • tensor2 (TensorNumber) – 一个输入张量或数字

示例

>>> 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