Elementwise Operators¶
Every op on this page is used the same way: construct it once, then call it. The
constructor takes what the kernel is compiled with; the call takes the tensors.
Both are documented under each op — __init__ and forward, where forward is
what runs when you call op(...).
Arithmetic¶
tileops.ops.elementwise.arithmetic.AddFwdOp
¶
Element-wise addition with broadcast: y = input + alpha * other.
Conforms to torch.add(input, other, *, alpha=1). alpha is baked
into the kernel, so non-default alpha runs through the same fast
kernel as the default.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Backend target to serve this op, or
Noneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel override dict.
-
tune(bool, default:False) –Whether to autotune, applied when a kernel is first built.
tileops.ops.elementwise.arithmetic.SubFwdOp
¶
Element-wise subtraction with broadcast: y = input - alpha * other.
Conforms to torch.sub(input, other, *, alpha=1). alpha is baked
into the kernel, so non-default alpha runs through the same fast
kernel as the default.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Backend target to serve this op, or
Noneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel override dict.
-
tune(bool, default:False) –Whether to autotune, applied when a kernel is first built.
tileops.ops.elementwise.arithmetic.MulFwdOp
¶
Element-wise multiplication with broadcast: y = input * other.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.arithmetic.DivFwdOp
¶
Element-wise division with broadcast: y = input / other.
Conforms to torch.div(input, other, *, rounding_mode=None).
rounding_mode accepts None (true division), "trunc"
(truncation toward zero), or "floor" (floor division); each
value selects a dedicated kernel specialization. It is fixed for the
instance, which is why it is not part of the memory key.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
rounding_mode(Optional[str], default:None) –Manifest
params.rounding_mode,str | None, defaultNone. -
target(Target, default:None) –Backend target to serve this op, or
Noneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel override dict.
-
tune(bool, default:False) –Whether to autotune, applied when a kernel is first built.
tileops.ops.elementwise.arithmetic.FloorDivideFwdOp
¶
Element-wise floor division with broadcast: y = floor(a / b).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.arithmetic.RemainderFwdOp
¶
Element-wise remainder with broadcast: y = a % b.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.arithmetic.PowFwdOp
¶
Element-wise power with broadcast: y = input ** exponent.
Conforms to torch.pow(input, exponent): the second operand carries
the manifest-declared name exponent rather than the generic
other so the L1 signature check matches the manifest.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.arithmetic.MaximumFwdOp
¶
Element-wise maximum with broadcast: y = max(a, b).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.arithmetic.MinimumFwdOp
¶
Element-wise minimum with broadcast: y = min(a, b).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.arithmetic.LerpFwdOp
¶
Element-wise lerp with broadcast: y = a + weight * (b - a).
Unlike torch.lerp(a, b, weight) where weight is a runtime parameter,
here weight is a construction-time constant baked into the compiled
kernel. This enables compile-time folding but means a new Op instance is
needed for each distinct weight value.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
weight(float, default:0.5) –Scalar interpolation weight, fixed at construction (manifest
params.weight, default 0.5). -
target(Target, default:None) –Which set of kernels serves this op.
-
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.arithmetic.LerpTensorFwdOp
¶
Tensor-weight lerp: out = input + weight * (end - input).
Conforms to the Tensor-weight overload of torch.lerp —
torch.lerp(input, end, weight: Tensor) where weight is a Tensor that
broadcasts together with input and end to the output shape. The scalar-weight
overload is handled separately by LerpFwdOp.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op.
-
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
forward
¶
Run the op on the inputs the manifest declares.
Parameters:
-
input(Tensor) –Input tensor, dtype
float16 | bfloat16 | float32. -
end(Tensor) –Input tensor, dtype
same_as(input). -
weight(Tensor) –Input tensor, dtype
same_as(input).
Returns:
-
Tensor–output, as the manifest declares. Shape rules:output.shape == broadcast_shapes(input.shape, end.shape, weight.shape).
Unary math¶
tileops.ops.elementwise.math_unary.ExpFwdOp
¶
Element-wise exp(x).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.Expm1FwdOp
¶
Element-wise exp(x) - 1.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.LogFwdOp
¶
Element-wise log(x).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.Log1pFwdOp
¶
Element-wise log(1 + x).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.SqrtFwdOp
¶
Element-wise sqrt(x).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.RsqrtFwdOp
¶
Element-wise 1/sqrt(x).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.ReciprocalFwdOp
¶
Element-wise 1/x.
Mirrors torch.reciprocal int-input promotion: the manifest declares the
output as promote_int_to_float(input), and ReciprocalFwdKernel.specialize
names float32 as the compute type for an integral input. The semantic dtype
keys the specialization and drives roofline accounting — integer input bytes,
float32 output bytes — while the kernel is built for the type it computes in.
Floating inputs follow the standard same-dtype path.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.AbsFwdOp
¶
Element-wise |x|.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.NegFwdOp
¶
Element-wise -x.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.SignFwdOp
¶
Element-wise sign(x): -1, 0, or +1.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.SinFwdOp
¶
Element-wise sin(x).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.CosFwdOp
¶
Element-wise cos(x).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.ErfFwdOp
¶
Element-wise erf(x).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.FloorFwdOp
¶
Element-wise floor(x).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.CeilFwdOp
¶
Element-wise ceil(x).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.RoundFwdOp
¶
Element-wise round(x) to decimals decimal places.
The shipped kernel performs banker's round-to-nearest-integer, matching
torch.round for decimals=0. decimals is a manifest param, so it is
fixed for the instance and handed to whichever kernel serves the op; in-tree, a
non-zero value selects _RoundDecimalsCall.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
decimals(int, default:0) –Number of decimal places to round to (manifest
params.decimals, default 0). -
target(Target, default:None) –Which set of kernels serves this op.
-
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.math_unary.TruncFwdOp
¶
Element-wise trunc(x).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
Activations¶
tileops.ops.elementwise.activations.ReluFwdOp
¶
ReLU activation: y = max(x, 0).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Backend target to serve this op, or
Noneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel override dict.
-
tune(bool, default:False) –Whether to autotune, applied when a kernel is first built.
tileops.ops.elementwise.activations.LeakyReluFwdOp
¶
Leaky ReLU: y = x if x > 0 else negative_slope * x.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
negative_slope(float, default:0.01) –Slope for negative inputs (default 0.01).
-
inplace(bool, default:False) –When True, copy the result back into
inputand returninput(preserving tensor identity). The kernel still computes into a fresh buffer; only the user-visible tensor is mutated, mirroringtorch.nn.functional.leaky_relu. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune the kernel.
tileops.ops.elementwise.activations.EluFwdOp
¶
ELU: y = x if x > 0 else alpha * (exp(x) - 1).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
alpha(float, default:1.0) –Scale for the negative part (default 1.0).
-
inplace(bool, default:False) –When True, copy the result back into
inputand returninput(preserving tensor identity). -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune the kernel.
tileops.ops.elementwise.activations.SeluFwdOp
¶
Element-wise SELU activation.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Backend target to serve this op, or
Noneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel override dict.
-
tune(bool, default:False) –Whether to autotune, applied when a kernel is first built.
tileops.ops.elementwise.activations.GeluFwdOp
¶
Element-wise GELU honoring the manifest approximate contract.
Parameters:
-
approximate(str, default:'none') –Approximation mode.
'none'(default) routes to the erf-basedGeluFwdKernel.'tanh'routes toGeluTanhFwdKernel(the fused tanh approximation0.5 * x * (1 + tanh(sqrt(2/pi) * (x + 0.044715 * x^3)))). -
target(Target, default:None) –Which set of kernels serves this op.
-
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune the kernel.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Backend target to serve this op, or
Noneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel override dict.
-
tune(bool, default:False) –Whether to autotune, applied when a kernel is first built.
tileops.ops.elementwise.activations.SiluFwdOp
¶
Element-wise SiLU (Swish): y = x * sigmoid(x).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Backend target to serve this op, or
Noneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel override dict.
-
tune(bool, default:False) –Whether to autotune, applied when a kernel is first built.
tileops.ops.elementwise.activations.MishFwdOp
¶
Element-wise Mish: y = x * tanh(softplus(x)).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Backend target to serve this op, or
Noneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel override dict.
-
tune(bool, default:False) –Whether to autotune, applied when a kernel is first built.
tileops.ops.elementwise.activations.SigmoidFwdOp
¶
Element-wise sigmoid(x).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.activations.TanhFwdOp
¶
Element-wise tanh(x).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.activations.HardsigmoidFwdOp
¶
Element-wise HardSigmoid: y = clamp(x + 3, 0, 6) / 6.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Backend target to serve this op, or
Noneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel override dict.
-
tune(bool, default:False) –Whether to autotune, applied when a kernel is first built.
tileops.ops.elementwise.activations.HardswishFwdOp
¶
Element-wise HardSwish: y = x * clamp(x + 3, 0, 6) / 6.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Backend target to serve this op, or
Noneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel override dict.
-
tune(bool, default:False) –Whether to autotune, applied when a kernel is first built.
tileops.ops.elementwise.activations.HardtanhFwdOp
¶
Hardtanh: y = clamp(x, min_val, max_val).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
min_val(float, default:-1.0) –Lower bound (default -1.0).
-
max_val(float, default:1.0) –Upper bound (default 1.0).
-
inplace(bool, default:False) –When True, copy the result back into
inputand returninput(preserving tensor identity). -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune the kernel.
tileops.ops.elementwise.activations.SoftplusFwdOp
¶
Softplus: y = log(1 + exp(xbeta))/beta if xbeta <= threshold else x.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
beta(float, default:1.0) –Scaling factor (default 1.0).
-
threshold(float, default:20.0) –Linear regime threshold (default 20.0).
-
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune the kernel.
tileops.ops.elementwise.prelu.PreluFwdOp
¶
PReLU: y = x if x > 0 else weight[channel] * x.
Channel dimension follows PyTorch convention: dimension 1 for inputs with ndim >= 2, dimension 0 for 1-D inputs. Both the shape and the channel count arrive with the tensors.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional dispatch override mapping kernel keys to
Kernelsubclasses. Falls back todefault_kernel_map. -
tune(bool, default:False) –Whether to autotune.
forward
¶
Run the op on the inputs the manifest declares.
Parameters:
-
input(Tensor) –Input tensor, dtype
float16 | bfloat16 | float32. -
weight(Tensor) –Input tensor, dtype
same_as(input).
Returns:
-
Tensor–output, as the manifest declares. Shape rules:output.shape == input.shape.
Gated activations¶
tileops.ops.elementwise.activations.SiluAndMulFwdOp
¶
SiLU-and-Mul: y = silu(gate) * value.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.activations.GeluAndMulFwdOp
¶
GELU-and-Mul: y = gelu(gate) * value (exact GELU).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.activations.GeluTanhAndMulFwdOp
¶
GELU-Tanh-and-Mul: y = gelu_tanh(gate) * value (tanh approximation).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
Comparison¶
tileops.ops.elementwise.comparison.EqFwdOp
¶
Element-wise equality with broadcast: y = (a == b).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.comparison.NeFwdOp
¶
Element-wise not-equal with broadcast: y = (a != b).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.comparison.GtFwdOp
¶
Element-wise greater-than with broadcast: y = (a > b).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.comparison.GeFwdOp
¶
Element-wise greater-equal with broadcast: y = (a >= b).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.comparison.LtFwdOp
¶
Element-wise less-than with broadcast: y = (a < b).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.comparison.LeFwdOp
¶
Element-wise less-equal with broadcast: y = (a <= b).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.comparison.IsnanFwdOp
¶
Element-wise isnan with bool output.
Always False on integer / bool input (no NaN representation in those dtypes).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.comparison.IsinfFwdOp
¶
Element-wise isinf with bool output.
Always False on integer / bool input (no Inf representation in those dtypes).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.comparison.IsfiniteFwdOp
¶
Element-wise isfinite with bool output.
Always True on integer / bool input (every value in those dtypes is finite).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
Logical and bitwise¶
tileops.ops.elementwise.logical.LogicalAndFwdOp
¶
Element-wise logical AND with broadcast using non-zero truthiness.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.logical.LogicalOrFwdOp
¶
Element-wise logical OR with broadcast using non-zero truthiness.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.logical.LogicalNotFwdOp
¶
Element-wise logical NOT with bool output.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.bitwise.BitwiseAndFwdOp
¶
Element-wise bitwise AND with broadcast: y = a & b.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.bitwise.BitwiseOrFwdOp
¶
Element-wise bitwise OR with broadcast: y = a | b.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.bitwise.BitwiseXorFwdOp
¶
Element-wise bitwise XOR with broadcast: y = a ^ b.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
tileops.ops.elementwise.bitwise.BitwiseNotFwdOp
¶
Element-wise bitwise NOT (~x) for bool/integer inputs.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
Selection and clamping¶
tileops.ops.elementwise.where.WhereFwdOp
¶
Where: out = condition ? input : other (with full PyTorch broadcasting).
Conforms to torch.where(condition, input, other): condition is a
bool tensor and input / other may broadcast with each other and
with condition to produce the output. The three operand shapes arrive with
the tensors; broadcasting them is the kernel's business.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional dispatch override mapping kernel keys to
Kernelsubclasses. Falls back todefault_kernel_map. -
tune(bool, default:False) –Whether to autotune.
forward
¶
Run the op on the inputs the manifest declares.
Parameters:
-
condition(Tensor) –Input tensor, dtype
bool. -
input(Tensor) –Input tensor, dtype
float16 | bfloat16 | float32. -
other(Tensor) –Input tensor, dtype
same_as(input).
Returns:
-
Tensor–output, as the manifest declares. Shape rules:output.shape == broadcast_shapes(condition.shape, input.shape, other.shape).
tileops.ops.elementwise.clamp.ClampFwdOp
¶
Clamp with Tensor lower and/or upper bounds (broadcasting).
Conforms to torch.clamp(input, min, max) where min and max
are each either a Tensor or None. At least one of the two bounds
must be a Tensor. All Tensor operands broadcast together. A single bound
is torch.clamp_min / torch.clamp_max.
Which bounds this call carries is read off the call, not settled at
construction: the manifest declares both as optional: true, so presence is a
fact of the call, and it reaches the kernel's cache key because it changes what
gets built. One instance therefore serves clamp, clamp_min and
clamp_max, one specialization each.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
forward
¶
Run the op on the inputs the manifest declares.
Parameters:
-
input(Tensor) –Input tensor, dtype
float16 | bfloat16 | float32. -
min(Optional[Tensor], default:None) –Input tensor, dtype
same_as(input). Optional. -
max(Optional[Tensor], default:None) –Input tensor, dtype
same_as(input). Optional.
Returns:
-
Tensor–output, as the manifest declares. Shape rules:min is None or max is None or output.shape == broadcast_shapes(input.shape, min.shape, max.shape);min is None or max is not None or output.shape == broadcast_shapes(input.shape, min.shape);max is None or min is not None or output.shape == broadcast_shapes(input.shape, max.shape).
tileops.ops.elementwise.clamp.ClampScalarFwdOp
¶
Scalar-bound clamp (torch.clamp(input, min: Number|None, max: Number|None)).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
min(Optional[float], default:None) –Lower bound (Number or None).
-
max(Optional[float], default:None) –Upper bound (Number or None).
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune.
forward
¶
Run the op on the inputs the manifest declares.
Parameters:
-
input(Tensor) –Input tensor, dtype
float16 | bfloat16 | float32.
Returns:
-
Tensor–output, as the manifest declares. Shape rules:output.shape == input.shape.
tileops.ops.elementwise.masked_fill.MaskedFillFwdOp
¶
MaskedFill with 0-dim Tensor value (torch.Tensor.masked_fill(mask, value: Tensor)).
Output shape is the bidirectional broadcast of input and mask;
value must be a 0-dim Tensor. The kernel reads value at forward time,
which is consistent with the 0-dim semantics.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional dispatch override mapping kernel keys to
Kernelsubclasses. Falls back todefault_kernel_map.
forward
¶
Run the op on the inputs the manifest declares.
Parameters:
-
input(Tensor) –Input tensor, dtype
bool | uint8 | int8 | int16 | int32 | int64 | float16 | bfloat16 | float32. -
mask(Tensor) –Input tensor, dtype
bool. -
value(Tensor) –Input tensor, dtype
same_as(input).
Returns:
-
Tensor–output, as the manifest declares. Shape rules:output.shape == broadcast_shapes(input.shape, mask.shape).
tileops.ops.elementwise.masked_fill.MaskedFillScalarFwdOp
¶
MaskedFill with Number (scalar) value.
Conforms to torch.Tensor.masked_fill(mask, value: Number). Output
shape follows the bidirectional broadcast of input and mask.
The manifest declares the PyTorch dtype union (bool | uint8 |
int8 | int16 | int32 | int64 | float16 | bfloat16 | float32); every
union member dispatches to a real kernel. A bool operand is served by
whatever storage the selected kernel requires; the op passes and receives
semantic bool either way.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
value(bool | int | float, default:0) –Scalar fill value (bool / int / float). Range-validated against the element type of the call with PyTorch
Tensor.masked_fillcoercion: bool reduces non-zero toTrue; integer dtypes range-check the real value againsttorch.iinfoand truncate floats toward zero (1.5 -> 1);torch.uint8additionally wraps Python ints in[-255, 0)via two's complement. -
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional dispatch override mapping kernel keys to
Kernelsubclasses. Falls back todefault_kernel_map.
forward
¶
Run the op on the inputs the manifest declares.
Parameters:
-
input(Tensor) –Input tensor, dtype
bool | uint8 | int8 | int16 | int32 | int64 | float16 | bfloat16 | float32. -
mask(Tensor) –Input tensor, dtype
bool.
Returns:
-
Tensor–output, as the manifest declares. Shape rules:output.shape == broadcast_shapes(input.shape, mask.shape).
tileops.ops.elementwise.nan_to_num.NanToNumFwdOp
¶
NanToNum: replace NaN, +Inf, -Inf with specified values.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
nan(float, default:0.0) –Replacement for NaN (default 0.0).
-
posinf(Optional[float], default:None) –Replacement for +Inf. Manifest default
Noneresolves to the largest finite value representable in the element type of the call (matchestorch.nan_to_num). Explicit values must also be representable in that dtype end-to-end; values that fit only in the kernel's intermediate dtype (e.g. fp16 for fp8_e5m2) are rejected so the post-cast cannot resurface them as Inf. -
neginf(Optional[float], default:None) –Replacement for -Inf. Manifest default
Noneresolves to the smallest (most negative) finite value representable in the element type of the call. -
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional kernel dispatch override.
-
tune(bool, default:False) –Whether to autotune the kernel.
forward
¶
Run the op on the inputs the manifest declares.
Parameters:
-
input(Tensor) –Input tensor, dtype
float16 | bfloat16 | float32.
Returns:
-
Tensor–output, as the manifest declares. Shape rules:output.shape == input.shape.
Positional encodings¶
tileops.ops.elementwise.alibi.AlibiFwdOp
¶
ALiBi position encoding: bias[h, i, j] = -slope_h * |i - j|.
Generates the full (num_heads, seq_len, seq_len) bias tensor.
Note
Eager-only. Unlike the other elementwise ops in this package,
AlibiFwdOp is not registered as a torch.library.custom_op,
so torch.compile graph capture is not supported. The op has
zero tensor inputs and constructs its output entirely from
__init__ parameters; no compile-time wrapping is needed.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
seq_len(int) –Sequence length.
-
num_heads(int) –Number of attention heads.
-
dtype(dtype) –Torch dtype.
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNone. Nothing is probed: with no tensor input there is no device to detect, so the in-tree kernels serve unless a target is named. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional dispatch override mapping kernel keys to
Kernelsubclasses. Falls back todefault_kernel_map.
forward
¶
Run the op on the inputs the manifest declares.
Returns:
-
Tensor–output, as the manifest declares.
tileops.ops.elementwise.sinusoidal.SinusoidalFwdOp
¶
Sinusoidal positional encoding from "Attention Is All You Need".
Generates the full (seq_len, d_model) encoding tensor.
Note
Eager-only. Unlike the other elementwise ops in this package,
SinusoidalFwdOp is not registered as a torch.library.custom_op,
so torch.compile graph capture is not supported. The op has
zero tensor inputs and constructs its output entirely from
__init__ parameters; no compile-time wrapping is needed.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
seq_len(int) –Sequence length.
-
d_model(int) –Model dimension.
-
dtype(dtype) –Torch dtype.
-
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNone. Nothing is probed: with no tensor input there is no device to detect, so the in-tree kernels serve unless a target is named. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional dispatch override mapping kernel keys to
Kernelsubclasses. Falls back todefault_kernel_map.
forward
¶
Run the op on the inputs the manifest declares.
Returns:
-
Tensor–output, as the manifest declares.