template<Operator Operation, Expression Operand, Expression Cooperand>
class tannic::operation::Binary< Operation, Operand, Cooperand >
Expression template for a binary tensor operation.
Represents a lazily evaluated binary operation between two expressions. The Binary
class performs type promotion, shape broadcasting, and stride generation upon construction to prepare for efficient evaluation.
- Template Parameters
-
Operation | A stateless functor implementing void forward(Tensor const&, Tensor const&, Tensor&) . |
Operand | Left-hand-side expression satisfying the Expression concept. |
Cooperand | Right-hand-side expression satisfying the Expression concept. |
template<Operator Operation, Expression Operand, Expression Cooperand>
Returns the promoted data type of the result.
The data type is computed using a type promotion rule (based on the type
enum), choosing the higher-precision or broader type between the two operands.
- Returns
- Promoted type of the two operands.
template<Operator Operation, Expression Operand, Expression Cooperand>
Returns the shape of the result.
The shape is computed via broadcasting rules, similar to NumPy or PyTorch. Dimensions are aligned from the right, and incompatible sizes throw.
- Returns
- Broadcasted shape between the two operands.