vortex_torch.indexer.elementwise_binary¶
Classes
|
Affine combination of two tensors. |
|
Binary elementwise dispatcher for rank-3 logical tensors |
|
Elementwise maximum between two tensors. |
|
Elementwise minimum between two tensors. |
|
Elementwise product of two tensors. |
- class vortex_torch.indexer.elementwise_binary.Elementwise_Binary(alpha=1.0, beta=1.0)[source]¶
Bases:
vOpBinary elementwise dispatcher for rank-3 logical tensors
[S, C, D].This operator dispatches to a binary elementwise implementation based on the pair of input formats
(x._format, y._format). The logical output shape:keeps the
Saxis from the runtime context (ctx.max_num_pages), andfollows broadcasting over the
(C, D)axes.
Scalar parameters
alphaandbetacan be used by certain binary operations (e.g. anaxpby-style op).- _impl_map¶
Dispatch table keyed by
(x_format, y_format). Each entry maps to(callable_impl, resolved_output_format).
- op_type¶
The operator type used by the implementation.
- Type:
Optional[ElementwiseBinaryOpType]
- output_buffer¶
Preallocated output tensor buffer that stores the binary result.
- Type:
Optional[torch.Tensor]
- profile(x, y, ctx)[source]¶
Validate inputs, select implementation, allocate the output buffer, and return a
vTensorview with the resolved output format.The dispatcher:
checks that
xandyare rank-3 tensors of shape[S, C, D]enforces broadcastability on the
CandDdimensionsselects an implementation using
(x._format, y._format)allocates an output buffer with shape
[S_ctx, C_out, D_out]where\[C_{\text{out}} = \max(C_x, C_y), \quad D_{\text{out}} = \max(D_x, D_y),\]and
S_ctx = ctx.max_num_pages.
- Parameters:
- Returns:
A
vTensorview wrapping the allocated output buffer, using the resolved output format from the dispatch table.- Return type:
- Raises:
AssertionError – If types are not
vTensor, if ranks are not 3, ifC/Dare not broadcastable, if formats are unsupported, or if devices ofxandydo not match.
- execute(x, y, ctx)[source]¶
Execute the selected binary elementwise implementation into the internal output buffer and return it.
Expected implementation signature:
impl(x, y, output, op_type, alpha, beta, ctx)
- Parameters:
x (torch.Tensor) – Left-hand input tensor on the same device as
yand the output buffer.y (torch.Tensor) – Right-hand input tensor on the same device as
xand the output buffer.ctx (Context) – Execution context passed through to the underlying implementation.
- Returns:
The output tensor stored in
self.output_buffer.- Return type:
torch.Tensor
- Raises:
AssertionError – If
profile()has not been called (no implementation or buffer), or if there is a device mismatch between inputs and output.
- class vortex_torch.indexer.elementwise_binary.Maximum(alpha=1.0, beta=1.0)[source]¶
Bases:
Elementwise_BinaryElementwise maximum between two tensors.
This operator computes the pointwise maximum:
\[\operatorname{out}(x, y) = \max(x, y)\]Broadcasting over the
(C, D)axes is supported as described inElementwise_Binary.
- class vortex_torch.indexer.elementwise_binary.Minimum(alpha=1.0, beta=1.0)[source]¶
Bases:
Elementwise_BinaryElementwise minimum between two tensors.
This operator computes the pointwise minimum:
\[\operatorname{out}(x, y) = \min(x, y)\]Broadcasting over the
(C, D)axes is supported as described inElementwise_Binary.
- class vortex_torch.indexer.elementwise_binary.Add(alpha=1.0, beta=1.0)[source]¶
Bases:
Elementwise_BinaryAffine combination of two tensors.
This operator computes a weighted sum of the two inputs:
\[\operatorname{out}(x, y) = \alpha x + \beta y\]With the defaults \(\alpha = 1\) and \(\beta = 1\), this reduces to standard elementwise addition:
\[\operatorname{out}(x, y) = x + y\]Broadcasting over the
(C, D)axes is supported as described inElementwise_Binary.
- class vortex_torch.indexer.elementwise_binary.Multiply(alpha=1.0, beta=1.0)[source]¶
Bases:
Elementwise_BinaryElementwise product of two tensors.
This operator computes the pointwise product:
\[\operatorname{out}(x, y) = x \cdot y\]Broadcasting over the
(C, D)axes is supported as described inElementwise_Binary.- Parameters:
alpha (float, optional) – Scalar parameter forwarded to the binary kernel. It is not used by the pure multiplication operation itself. Default is
1.0.beta (float, optional) – Scalar parameter forwarded to the binary kernel. It is not used by the pure multiplication operation itself. Default is
1.0.