torch.result_type¶
- torch.result_type(tensor1, tensor2) dtype ¶
傳回對提供的輸入張量執行算術運算後產生的
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