快捷方式

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

文件

訪問 PyTorch 的全面開發者文件

檢視文件

教程

獲取針對初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源