torch.BinaryBroadcastResult
export type BinaryBroadcastResult<
S1 extends Shape,
S2 extends Shape,
_D extends string,
_Dev extends string,
TensorType,
> =
BroadcastShape<S1, S2> extends { __isShapeError: true }
? ShapeErrorMessage<BroadcastShape<S1, S2>>
: TensorType;S1extends ShapeS2extends Shape_Dextends string_Devextends stringTensorTypeResult type for binary broadcast operations (add, sub, mul, div). When broadcast shapes are compatible, returns a Tensor with the broadcast shape. When shapes are incompatible, returns an error message string that triggers compile-time errors.
Examples
// Compatible shapes - returns Tensor
type Valid = BinaryBroadcastResult<readonly [2, 3], readonly [1, 3], 'float32', 'webgpu'>;
// = Tensor<readonly [2, 3], 'float32', 'webgpu'>
// Incompatible shapes - returns error message
type Invalid = BinaryBroadcastResult<readonly [2, 3], readonly [2, 5], 'float32', 'webgpu'>;
// = "SHAPE_ERROR: broadcast_error_incompatible_dimensions<3, 5>"