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 inputs, tensors
or numbers. Both are documented under each op — __init__ and forward, where
forward is what runs when you call op(...).
Arithmetic¶
tileops.elementwise.AddFwdOp
¶
Element-wise addition with broadcast: y = input + alpha * other, as torch.add.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
alpha(int | float, default:1) –Multiplier on
other(default 1). -
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.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.SubFwdOp
¶
Element-wise subtraction with broadcast: y = input - alpha * other, as torch.sub.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
alpha(int | float, default:1) –Multiplier on
other(default 1). -
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.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.MulFwdOp
¶
Element-wise multiplication with broadcast: y = input * other.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.DivFwdOp
¶
Element-wise division with broadcast: y = input / other, as torch.div.
rounding_mode is None (true division), "trunc" or "floor".
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
rounding_mode(str | None, default:None) –None,"trunc"or"floor". -
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.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.FloorDivideFwdOp
¶
Element-wise floor division with broadcast: y = a // b, as torch.floor_divide.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.RemainderFwdOp
¶
Element-wise remainder with broadcast: y = a % b.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.PowFwdOp
¶
Element-wise power with broadcast: y = input ** exponent, as torch.pow.
Accuracy differs from torch.pow: the power is computed as
exp2(exponent * log2|input|), whose error scales with
|exponent * log2(input)| rather than staying flat. Measured against a
float64 reference, in units of a float32 ulp:
input |
exponent |
here | torch.pow |
|---|---|---|---|
| 0.9 to 1.1 | -1 to 1 | 1.2 | 0.5 |
| 0.5 to 2 | -2 to 2 | 1.8 | 0.6 |
| 0.25 to 4 | -3 to 3 | 3.4 | 0.6 |
| 0.01 to 100 | -3 to 3 | 10.6 | 0.6 |
| 1e-6 to 1e6 | -2 to 2 | 22.5 | 0.6 |
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and exponent.
Parameters:
-
input(Tensor) –Base.
-
exponent(Tensor) –Exponent, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandexponent.
tileops.elementwise.MaximumFwdOp
¶
Element-wise maximum with broadcast: y = max(a, b).
A NaN operand gives a NaN result, canonical rather than the operand's own
payload and sign bit; torch.maximum returns the operand's bit pattern.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.MinimumFwdOp
¶
Element-wise minimum with broadcast: y = min(a, b).
A NaN operand gives a NaN result, canonical rather than the operand's own
payload and sign bit; torch.minimum returns the operand's bit pattern.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.LerpFwdOp
¶
Linear interpolation out = input + weight * (end - input) (torch.lerp).
weight is a Number or a Tensor that broadcasts with input and end; one
instance serves both. A Number weight is baked into its kernel.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input, end and weight.
Parameters:
-
input(Tensor) –Start point.
-
end(Tensor) –End point, broadcastable with
input. -
weight(float | Tensor) –Interpolation weight: a Number, or a Tensor broadcastable with
inputandend.
Returns:
-
Tensor–A new tensor of the broadcast shape of the inputs.
Unary math¶
tileops.elementwise.ExpFwdOp
¶
Element-wise exp(x).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.Expm1FwdOp
¶
Element-wise exp(x) - 1.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.LogFwdOp
¶
Element-wise log(x).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.Log1pFwdOp
¶
Element-wise log(1 + x).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.SqrtFwdOp
¶
Element-wise sqrt(x).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.RsqrtFwdOp
¶
Element-wise 1/sqrt(x).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.ReciprocalFwdOp
¶
Element-wise 1/x.
An integral input gives a float32 output, as torch.reciprocal promotes it; a
floating input keeps its dtype. A float16 or bfloat16 result equals
torch.reciprocal's bit for bit at every input.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.AbsFwdOp
¶
Element-wise |x|.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.NegFwdOp
¶
Element-wise -x.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.SignFwdOp
¶
Element-wise sign(x): -1, 0, or +1.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.SinFwdOp
¶
Element-wise sin(x).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.CosFwdOp
¶
Element-wise cos(x).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.ErfFwdOp
¶
Element-wise erf(x).
On float16 and bfloat16 the error function is evaluated as a polynomial that
saturates to exactly +/-1; its worst case over the real line is 1.7e-5, an
order below half a float16 ulp at 1.0. float32 keeps erff.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.FloorFwdOp
¶
Element-wise floor(x).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.CeilFwdOp
¶
Element-wise ceil(x).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.RoundFwdOp
¶
Element-wise round(x) half to even, to decimals decimal places, as torch.round.
__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 — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.TruncFwdOp
¶
Element-wise trunc(x).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
Activations¶
tileops.elementwise.ReLUFwdOp
¶
ReLU activation: y = max(x, 0); in place when inplace.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
inplace(bool, default:False) –When True, write the result into
inputand returninput. -
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.
forward
¶
Run the activation on input, into input itself when inplace is set.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–inputwheninplaceis set, else a new tensor of its shape and dtype.
tileops.elementwise.LeakyReLUFwdOp
¶
Leaky ReLU: y = x if x > 0 else negative_slope * x; in place when inplace.
__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, write the result into
inputand returninput. -
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.
forward
¶
Run the activation on input, into input itself when inplace is set.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–inputwheninplaceis set, else a new tensor of its shape and dtype.
tileops.elementwise.ELUFwdOp
¶
ELU: y = x if x > 0 else alpha * (exp(x) - 1); in place when inplace.
__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, write the result into
inputand returninput. -
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.
forward
¶
Run the activation on input, into input itself when inplace is set.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–inputwheninplaceis set, else a new tensor of its shape and dtype.
tileops.elementwise.SELUFwdOp
¶
Element-wise SELU activation; in place when inplace.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
inplace(bool, default:False) –When True, write the result into
inputand returninput. -
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.
forward
¶
Run the activation on input, into input itself when inplace is set.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–inputwheninplaceis set, else a new tensor of its shape and dtype.
tileops.elementwise.GELUFwdOp
¶
Element-wise GELU honoring the manifest approximate contract.
On float16 and bfloat16 the error function is evaluated as a polynomial that
saturates to exactly +/-1; its worst case over the real line is 1.7e-5, an
order below half a float16 ulp at 1.0. float32 keeps erff.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
approximate(str, default:'none') –'none'(default) evaluates the erf form;'tanh'the 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 — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.SiLUFwdOp
¶
Element-wise SiLU (Swish): y = x * sigmoid(x); in place when inplace.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
inplace(bool, default:False) –When True, write the result into
inputand returninput. -
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.
forward
¶
Run the activation on input, into input itself when inplace is set.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–inputwheninplaceis set, else a new tensor of its shape and dtype.
tileops.elementwise.MishFwdOp
¶
Element-wise Mish: y = x * tanh(softplus(x)); in place when inplace.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
inplace(bool, default:False) –When True, write the result into
inputand returninput. -
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.
forward
¶
Run the activation on input, into input itself when inplace is set.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–inputwheninplaceis set, else a new tensor of its shape and dtype.
tileops.elementwise.SigmoidFwdOp
¶
Element-wise sigmoid(x).
A float16 or bfloat16 result equals torch.sigmoid's bit for bit at every input.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.TanhFwdOp
¶
Element-wise tanh(x).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.HardsigmoidFwdOp
¶
Element-wise HardSigmoid: y = clamp(x + 3, 0, 6) / 6; in place when inplace.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
inplace(bool, default:False) –When True, write the result into
inputand returninput. -
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.
forward
¶
Run the activation on input, into input itself when inplace is set.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–inputwheninplaceis set, else a new tensor of its shape and dtype.
tileops.elementwise.HardswishFwdOp
¶
Element-wise HardSwish: y = x * clamp(x + 3, 0, 6) / 6; in place when inplace.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
inplace(bool, default:False) –When True, write the result into
inputand returninput. -
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.
forward
¶
Run the activation on input, into input itself when inplace is set.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–inputwheninplaceis set, else a new tensor of its shape and dtype.
tileops.elementwise.HardtanhFwdOp
¶
Hardtanh: y = clamp(x, min_val, max_val); in place when inplace.
__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, write the result into
inputand returninput. -
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.
forward
¶
Run the activation on input, into input itself when inplace is set.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–inputwheninplaceis set, else a new tensor of its shape and dtype.
tileops.elementwise.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).
-
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.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.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 dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and weight.
Parameters:
-
input(Tensor) –Input tensor; its channel dimension is dim 1, or dim 0 when 1-D.
-
weight(Tensor) –Negative slopes, same dtype as
input: one element, or one per channel wheninputhas two or more dims.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.DropoutFwdOp
¶
Dropout, following torch.nn.functional.dropout; in place when inplace.
- Training mode: output = x * mask / (1 - p), mask ~ Bernoulli(1 - p)
- Eval mode (training=False): output = x (identity)
- p=0: identity
- p=1: all zeros
Without seed, each call draws a fresh mask from torch's default CUDA generator of
the input's device, as torch's own dropout does: it reads the generator's seed and
Philox offset and advances the offset past the draws it uses. torch.manual_seed
therefore makes the sequence of masks reproducible. Reading the offset is not allowed
while a CUDA graph is captured, so a captured call needs seed.
With seed, every call uses Philox stream seed at offset 0 and draws the same
mask for the same input shape, without touching torch's generator.
Each element is dropped by a Philox4x32-10 draw of its own, independently of every other
element, with probability p rounded up to a multiple of 2**-32. The mask is
TileOPs' own: it does not reproduce torch's for the same generator state.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
p(float, default:0.5) –Drop probability in [0, 1].
-
training(bool, default:True) –If False, dropout is disabled (identity pass-through).
-
inplace(bool, default:False) –When True, write the result into
inputand returninput. -
seed(int | None, default:None) –Nonedraws a fresh mask on each call from torch's default CUDA generator; a non-negative integer fixes the mask, the same on every 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.
forward
¶
Drop each element of input with probability p and scale the rest.
Parameters:
-
input(Tensor) –The tensor to drop elements of.
Returns:
-
Tensor–A tensor of
input's shape and dtype;inputitself wheninplace.
Gated activations¶
tileops.elementwise.SiLUAndMulFwdOp
¶
SiLU-and-Mul: y = silu(gate) * value.
A positive swiglu_limit first clamps gate to at most it and value to within
plus or minus it, and a per-row scale multiplies each row before the one rounding to
the input dtype, as DeepSeek-V4-Flash's experts apply their routing weights.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
swiglu_limit(float, default:0.0) –A positive bound the gate and value are clamped to; a non-positive one clamps nothing.
-
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.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –\([M \times 2N]\): the gate in the first
Ncolumns, the value in the rest. -
scale(Tensor | None, default:None) –\([M]\)
float32per-row multipliers, orNone.
Returns:
-
Tensor–A new tensor \([M \times N]\) in the dtype of
input.
tileops.elementwise.GELUAndMulFwdOp
¶
GELU-and-Mul: y = gelu(gate) * value, GELU in the form approximate names.
On float16 and bfloat16 the exact form evaluates the error function as a polynomial
that saturates to exactly +/-1; its worst case over the real line is 1.7e-5, an
order below half a float16 ulp at 1.0. float32 keeps erff. On float16 and bfloat16
the tanh form evaluates in float32 and rounds once, at the product; down the negative
tail it keeps the zeros of torch's float32 form, and its NaN against an infinite value.
float32 keeps tanhf.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
approximate(str, default:'none') –'none'(default) evaluates the erf form of GELU;'tanh'the 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 — a target name,
BUILTINfor the in-tree kernels, orNoneto decide from the input device.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –\([M \times 2N]\): the gate in the first
Ncolumns, the value in the rest.
Returns:
-
Tensor–A new tensor \([M \times N]\) in the dtype of
input.
Comparison¶
tileops.elementwise.EqFwdOp
¶
Element-wise equality with broadcast: y = (a == b).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.NeFwdOp
¶
Element-wise not-equal with broadcast: y = (a != b).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.GtFwdOp
¶
Element-wise greater-than with broadcast: y = (a > b).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.GeFwdOp
¶
Element-wise greater-equal with broadcast: y = (a >= b).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.LtFwdOp
¶
Element-wise less-than with broadcast: y = (a < b).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.LeFwdOp
¶
Element-wise less-equal with broadcast: y = (a <= b).
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.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 dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.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 dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.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 dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
Logical and bitwise¶
tileops.elementwise.LogicalAndFwdOp
¶
Element-wise logical AND with broadcast using non-zero truthiness.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.LogicalOrFwdOp
¶
Element-wise logical OR with broadcast using non-zero truthiness.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.LogicalNotFwdOp
¶
Element-wise logical NOT with bool output.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
tileops.elementwise.BitwiseAndFwdOp
¶
Element-wise bitwise AND with broadcast: y = a & b.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.BitwiseOrFwdOp
¶
Element-wise bitwise OR with broadcast: y = a | b.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.BitwiseXorFwdOp
¶
Element-wise bitwise XOR with broadcast: y = a ^ b.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and other.
Parameters:
-
input(Tensor) –First operand.
-
other(Tensor) –Second operand, broadcastable with
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandother.
tileops.elementwise.BitwiseNotFwdOp
¶
Element-wise bitwise NOT (~x) for bool/integer inputs.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
Selection and clamping¶
tileops.elementwise.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 dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on condition, input and other.
Parameters:
-
condition(Tensor) –torch.boolselector;Truepicksinput,Falsepicksother. -
input(Tensor) –Values where
conditionholds. -
other(Tensor) –Values elsewhere, same dtype as
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of the three inputs.
tileops.elementwise.ClampFwdOp
¶
Clamp with Number or Tensor bounds (torch.clamp(input, min, max)).
Each bound is a Number, a Tensor broadcasting with input, or None; at least one is
given, and a Number bound is never paired with a Tensor bound, as in torch.clamp's two
overloads. A single bound is torch.clamp_min / torch.clamp_max.
Which form and which bounds a call passes is read off the call, so one instance serves every form, one specialization each. A Number bound's value reaches the kernel's cache key, since the kernel is built for it.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input and whichever bounds the call passes.
Parameters:
-
input(Tensor) –Tensor to clamp.
-
min(float | Tensor | None, default:None) –Lower bound: a Number, a Tensor broadcastable with
input, orNonefor no lower bound. -
max(float | Tensor | None, default:None) –Upper bound, the same way. At least one bound is given, and both given bounds are Numbers or both Tensors.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputand the Tensor bounds.
tileops.elementwise.MaskedFillFwdOp
¶
MaskedFill (torch.Tensor.masked_fill(mask, value)) with a scalar or 0-dim Tensor value.
Output shape is the bidirectional broadcast of input and mask. A Number value
follows PyTorch's coercion to the element type: bool reduces non-zero to True;
integer dtypes range-check the real value against torch.iinfo and truncate floats
toward zero (1.5 -> 1); torch.uint8 additionally wraps Python ints in
[-255, 0) via two's complement. A Tensor value is read by the kernel at forward time.
Every dtype of the manifest union dispatches to a real kernel; a bool operand is served
by whatever storage the selected kernel requires.
Which form a call passes is read off the call, so one instance serves both. A Number value reaches the kernel's cache key, since the kernel is built for it.
__init__
¶
Build the op; shapes and dtypes arrive with each call. A subclass with manifest parameters assigns them first and then calls this.
It selects and builds no kernel and reads no device property: an op constructs wherever it is imported, and a device it cannot run on is refused at 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.
Raises:
-
ValueError–A manifest parameter is outside its signature, or an implementation breaks its kernel interface's contract.
-
TypeError–An implementation breaks its kernel interface's contract.
forward
¶
Run the op on input, mask and value.
Parameters:
-
input(Tensor) –Tensor to fill.
-
mask(Tensor) –torch.boolmask, broadcastable withinput;Truemarks the elements to fill. -
value(bool | int | float | Tensor) –Fill value: a Number, a bool, or a 0-dim tensor in the dtype of
input.
Returns:
-
Tensor–A new tensor of the broadcast shape of
inputandmask.
tileops.elementwise.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(float | None, 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). An explicit value outside that element type's finite range is stored as Inf, as torch does. -
neginf(float | None, 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.
forward
¶
Run the op on input.
Parameters:
-
input(Tensor) –Input tensor of any shape.
Returns:
-
Tensor–A new tensor of the shape and dtype of
input.
Positional encodings¶
tileops.elementwise.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: the extents and dtype are its parameters.
Parameters:
-
seq_len(int) –Sequence length.
-
num_heads(int) –Number of attention heads.
-
out_dtype(dtype, default:float32) –Dtype of the generated tensor.
-
device(device | str | None, default:None) –Where the tensor is produced, and so the device a target is detected from.
Noneproduces it on the current CUDA device, or wherever a named target decides. -
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide fromdevice.
forward
¶
Generate the tensor, in out_dtype whatever storage the kernel computes in.
Returns:
-
Tensor–A new tensor in
out_dtype, -
Tensor–\([\text{num\_heads} \times \text{seq\_len} \times \text{seq\_len}]\).
tileops.elementwise.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: the extents and dtype are its parameters.
Parameters:
-
seq_len(int) –Sequence length.
-
d_model(int) –Model dimension.
-
out_dtype(dtype, default:float32) –Dtype of the generated tensor.
-
device(device | str | None, default:None) –Where the tensor is produced, and so the device a target is detected from.
Noneproduces it on the current CUDA device, or wherever a named target decides. -
target(Target, default:None) –Which set of kernels serves this op — a target name,
BUILTINfor the in-tree kernels, orNoneto decide fromdevice.
forward
¶
Generate the tensor, in out_dtype whatever storage the kernel computes in.
Returns:
-
Tensor–A new tensor \([\text{seq\_len} \times \text{d\_model}]\) in
out_dtype.