vortex_torch.indexer.elementwise

Classes

Abs([alpha, beta])

Absolute value of an affine transform.

Add_Mul([alpha, beta])

Affine elementwise transform.

Elementwise([alpha, beta])

Unary elementwise dispatcher for rank-3 logical tensors [S, C, D].

Relu([alpha, beta])

ReLU-style elementwise operator.

Sigmoid([alpha, beta])

Sigmoid elementwise operator with affine argument.

Silu([alpha, beta])

SiLU-style elementwise operator with affine pre-transform.

class vortex_torch.indexer.elementwise.Elementwise(alpha=1.0, beta=1.0)[source]

Bases: vOp

Unary elementwise dispatcher for rank-3 logical tensors [S, C, D].

This operator dispatches implementation only based on the input format (x._format). The output tensor has the same logical shape as the input. Optional scalar parameters alpha and beta may be used by certain elementwise operations.

Parameters:
_impl_map

Implementation dispatch table keyed by input format. Each entry maps to (callable_impl, resolved_output_format).

Type:

Dict[FORMAT, Tuple[Callable, FORMAT]]

alpha

Scalar parameter used by some ops. Default is 1.0.

Type:

float

beta

Scalar parameter used by some ops. Default is 1.0.

Type:

float

impl

The resolved implementation selected during profile().

Type:

Optional[Callable]

op_type

The operator type used by the implementation.

Type:

Optional[ElementwiseOpType]

output_format

The output tensor format as determined in profile().

Type:

Optional[FORMAT]

output_buffer

Preallocated output tensor buffer.

Type:

Optional[torch.Tensor]

profile(x, ctx)[source]

Validate input, select the implementation based on x._format, allocate the output buffer, and return a vTensor view.

Parameters:
  • x (vTensor) – Input tensor. Must be rank-3 with shape [S, C, D].

  • ctx (Context) – Execution context providing runtime S (ctx.max_num_pages) and memory tracking.

Returns:

A vTensor view wrapping the allocated output buffer, using the resolved output format.

Return type:

vTensor

Raises:

AssertionError – If input tensor type, rank, or format is invalid.

execute(x, ctx)[source]

Execute the selected implementation into the internal output buffer.

Expected implementation signature:

impl(x, output, op_type, alpha, beta, ctx)
Parameters:
  • x (torch.Tensor) – Input tensor on the same device as the output buffer.

  • ctx (Context) – Execution context.

Returns:

The output tensor stored in self.output_buffer.

Return type:

torch.Tensor

Raises:

AssertionError – If profile was not called, or device mismatch occurs.

class vortex_torch.indexer.elementwise.Relu(alpha=0.0, beta=0.0)[source]

Bases: Elementwise

ReLU-style elementwise operator.

This operator applies a thresholded linear function:

\[\begin{split}\operatorname{out}(x) = \begin{cases} x, & x \ge \alpha \\ \beta, & x < \alpha \end{cases}\end{split}\]
Parameters:
  • alpha (float, optional) – Threshold value for activation. Default is 0.0.

  • beta (float, optional) – Value used when \(x < \alpha\). Default is 0.0.

class vortex_torch.indexer.elementwise.Silu(alpha=0.0, beta=0.0)[source]

Bases: Elementwise

SiLU-style elementwise operator with affine pre-transform.

This operator applies:

\[\operatorname{SiLU}_{\alpha,\beta}(x) = \frac{x}{1 + \exp(\beta x + \alpha)}\]

When \(\alpha = 0\) and \(\beta = -1\), this reduces to the common SiLU/Swish-like form \(x \, \sigma(x)\) (up to the chosen parameterization in the kernel).

Parameters:
  • alpha (float, optional) – Bias term inside the exponent, used in \(\beta x + \alpha\). Default is 0.0.

  • beta (float, optional) – Scale term inside the exponent, used in \(\beta x + \alpha\). Default is 0.0.

class vortex_torch.indexer.elementwise.Sigmoid(alpha=0.0, beta=0.0)[source]

Bases: Elementwise

Sigmoid elementwise operator with affine argument.

This operator applies:

\[\sigma_{\alpha,\beta}(x) = \frac{1}{1 + \exp(\beta x + \alpha)}\]

When \(\alpha = 0\) and \(\beta = -1\), this is the standard logistic sigmoid \(\sigma(x) = 1 / (1 + e^{-x})\).

Parameters:
  • alpha (float, optional) – Bias term inside the exponent, used in \(\beta x + \alpha\). Default is 0.0.

  • beta (float, optional) – Scale term inside the exponent, used in \(\beta x + \alpha\). Default is 0.0.

class vortex_torch.indexer.elementwise.Add_Mul(alpha=0.0, beta=1.0)[source]

Bases: Elementwise

Affine elementwise transform.

This operator applies a simple affine mapping:

\[\operatorname{out}(x) = \beta x + \alpha\]

With the defaults \(\alpha = 0\) and \(\beta = 1\), this is the identity transform \(\operatorname{out}(x) = x\).

Parameters:
  • alpha (float, optional) – Additive bias term \(\alpha\). Default is 0.0.

  • beta (float, optional) – Multiplicative scale term \(\beta\). Default is 1.0.

class vortex_torch.indexer.elementwise.Abs(alpha=0.0, beta=1.0)[source]

Bases: Elementwise

Absolute value of an affine transform.

This operator applies:

\[\operatorname{out}(x) = \lvert \beta x + \alpha \rvert\]

With the defaults \(\alpha = 0\) and \(\beta = 1\), this reduces to the standard absolute value \(\lvert x \rvert\).

Parameters:
  • alpha (float, optional) – Additive bias term inside the absolute value, used in \(\beta x + \alpha\). Default is 0.0.

  • beta (float, optional) – Multiplicative scale term inside the absolute value, used in \(\beta x + \alpha\). Default is 1.0.