torch.result_type
function result_type(tensor1: TensorClass | number, tensor2: TensorClass | number): DTypeReturns the dtype that would result from an arithmetic operation between the input tensors or scalars.
Parameters
tensor1TensorClass | number- First tensor or scalar
tensor2TensorClass | number- Second tensor or scalar
Returns
DType– The result dtype after type promotionExamples
const x = torch.tensor([1.0], { dtype: 'float32' });
const y = torch.tensor([1], { dtype: 'int32' });
torch.result_type(x, y) // 'float32'