• 文档 >
  • torch >
  • torch.result_type
快捷键

torch.result_type

torch.result_type(tensor1, tensor2) → dtype

返回对提供的输入张量执行算术运算后得到的 torch.dtype 。有关类型提升逻辑的更多信息,请参阅类型提升文档。

参数:
  • tensor1(张量或数字)- 输入张量或数字

  • tensor2(张量或数字)- 输入张量或数字

示例:

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

© 版权所有 PyTorch 贡献者。

使用 Sphinx 构建,并使用 Read the Docs 提供的主题。

文档

PyTorch 的全面开发者文档

查看文档

教程

深入了解初学者和高级开发者的教程

查看教程

资源

查找开发资源并获得您的疑问解答

查看资源