Reduction 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(...).
Sums, means and extrema¶
tileops.ops.reduction.reduce.SumFwdOp
¶
Sum reduction along dim=-1.
__init__
¶
Construct a reduce op.
Parameters:
-
dim(Union[int, List[int], Tuple[int, ...], None], default:None) –Reduction dimension (default
None, i.e. full reduction). Acceptsint,list[int],tuple[int, ...], orNone. -
keepdim(bool, default:False) –Whether to retain reduced dims as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default
False).
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.
tileops.ops.reduction.reduce.MeanFwdOp
¶
Mean reduction along dim=-1.
__init__
¶
Construct a reduce op.
Parameters:
-
dim(Union[int, List[int], Tuple[int, ...], None], default:None) –Reduction dimension (default
None, i.e. full reduction). Acceptsint,list[int],tuple[int, ...], orNone. -
keepdim(bool, default:False) –Whether to retain reduced dims as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default
False).
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.
tileops.ops.reduction.reduce.ProdFwdOp
¶
Product reduction.
Unlike the other simple reduce ops, ProdFwdOp defaults to
dim=-1 (manifest declares default: -1 for prod).
__init__
¶
Construct ProdFwdOp.
Parameters:
-
dim(int, default:-1) –Reduction dimension (default
-1). -
keepdim(bool, default:False) –Whether to retain reduced dims as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default
False).
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.
tileops.ops.reduction.reduce.AmaxFwdOp
¶
Amax (element-wise maximum) reduction along dim=-1.
__init__
¶
Construct a reduce op.
Parameters:
-
dim(Union[int, List[int], Tuple[int, ...], None], default:None) –Reduction dimension (default
None, i.e. full reduction). Acceptsint,list[int],tuple[int, ...], orNone. -
keepdim(bool, default:False) –Whether to retain reduced dims as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default
False).
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.
tileops.ops.reduction.reduce.AminFwdOp
¶
Amin (element-wise minimum) reduction along dim=-1.
__init__
¶
Construct a reduce op.
Parameters:
-
dim(Union[int, List[int], Tuple[int, ...], None], default:None) –Reduction dimension (default
None, i.e. full reduction). Acceptsint,list[int],tuple[int, ...], orNone. -
keepdim(bool, default:False) –Whether to retain reduced dims as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default
False).
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.
Variance and deviation¶
tileops.ops.reduction.reduce.VarFwdOp
¶
Variance reduction with Bessel's correction.
__init__
¶
Construct a Welford-based reduce op.
Parameters:
-
dim(Union[int, List[int], Tuple[int, ...], None], default:None) –Reduction dimension (default
None, i.e. full reduction). Acceptsint,list[int],tuple[int, ...], orNone. -
correction(int, default:1) –Bessel's correction (default 1).
-
keepdim(bool, default:False) –Whether to retain reduced dims as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default
False).
Parameters:
-
dim(Union[int, List[int], Tuple[int, ...], None], default:None) –Reduction dimension (default
None, i.e. full reduction). Acceptsint,list[int], ortuple[int, ...]for multi-dim reduction. -
correction(int, default:1) –Bessel's correction (default 1).
-
keepdim(bool, default:False) –Whether to retain the reduced dimension as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default False).
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.
tileops.ops.reduction.reduce.VarMeanFwdOp
¶
Variance and mean reduction.
__init__
¶
Construct a Welford-based reduce op.
Parameters:
-
dim(Union[int, List[int], Tuple[int, ...], None], default:None) –Reduction dimension (default
None, i.e. full reduction). Acceptsint,list[int],tuple[int, ...], orNone. -
correction(int, default:1) –Bessel's correction (default 1).
-
keepdim(bool, default:False) –Whether to retain reduced dims as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default
False).
Parameters:
-
dim(Union[int, List[int], Tuple[int, ...], None], default:None) –Reduction dimension (default
None, i.e. full reduction). Acceptsint,list[int], ortuple[int, ...]for multi-dim reduction. -
correction(int, default:1) –Bessel's correction (default 1).
-
keepdim(bool, default:False) –Whether to retain the reduced dimension as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default False).
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.
tileops.ops.reduction.reduce.StdFwdOp
¶
Standard deviation reduction with Bessel's correction.
__init__
¶
Construct a Welford-based reduce op.
Parameters:
-
dim(Union[int, List[int], Tuple[int, ...], None], default:None) –Reduction dimension (default
None, i.e. full reduction). Acceptsint,list[int],tuple[int, ...], orNone. -
correction(int, default:1) –Bessel's correction (default 1).
-
keepdim(bool, default:False) –Whether to retain reduced dims as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default
False).
Parameters:
-
dim(Union[int, List[int], Tuple[int, ...], None], default:None) –Reduction dimension (default
None, i.e. full reduction). Acceptsint,list[int], ortuple[int, ...]for multi-dim reduction. -
correction(int, default:1) –Bessel's correction (default 1).
-
keepdim(bool, default:False) –Whether to retain the reduced dimension as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default False).
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.
Arg reductions¶
tileops.ops.reduction.argreduce.ArgmaxFwdOp
¶
Argmax reduction along an arbitrary dim, returning int64 indices.
Construction: ArgmaxFwdOp(dim=None, keepdim=False).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
dim(Optional[int], default:None) –Reduction dimension.
None(the default) matchestorch.argmax(x)semantics: the input is treated as a contiguous flattened 1D buffer and the returned index is into that flattened tensor. -
keepdim(bool, default:False) –Whether to retain the reduced dimension as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional custom kernel map.
-
tune(bool, default:False) –Whether to autotune the kernel.
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.
tileops.ops.reduction.argreduce.ArgminFwdOp
¶
Argmin reduction along an arbitrary dim, returning int64 indices.
Construction: ArgminFwdOp(dim=None, keepdim=False).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
dim(Optional[int], default:None) –Reduction dimension.
None(the default) matchestorch.argmin(x)semantics: the input is treated as a contiguous flattened 1D buffer and the returned index is into that flattened tensor. -
keepdim(bool, default:False) –Whether to retain the reduced dimension as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional custom kernel map.
-
tune(bool, default:False) –Whether to autotune the kernel.
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.
Softmax¶
tileops.ops.reduction.softmax.SoftmaxFwdOp
¶
Softmax operator: y = softmax(x, dim).
Output has the same shape and dtype as input. The reduction-dim extent
N and dtype are inferred from x during forward().
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
dim(Optional[int], default:None) –Reduction dimension (default
None, matching PyTorch'storch.nn.functional.softmax). WhenNone, the axis is resolved at forward time using PyTorch's implicit-axis rule (0forndim in {0, 1, 3}else1) and the same deprecationUserWarningis emitted. -
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 override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default False).
forward
¶
Run the softmax-family op.
One call to the operator this op registers: this is as far as dynamo traces.
tileops.ops.reduction.softmax.LogSoftmaxFwdOp
¶
Log-softmax operator: y = log_softmax(x, dim).
Output has the same shape and dtype as input. The reduction-dim extent
N and dtype are inferred from x during forward().
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
dim(Optional[int], default:None) –Reduction dimension (default
None, matching PyTorch'storch.nn.functional.log_softmax). WhenNone, the axis is resolved at forward time using PyTorch's implicit-axis rule (0forndim in {0, 1, 3}else1) and the same deprecationUserWarningis emitted. -
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 override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default False).
forward
¶
Run the softmax-family op.
One call to the operator this op registers: this is as far as dynamo traces.
tileops.ops.reduction.softmax.LogSumExpFwdOp
¶
LogSumExp operator: y = logsumexp(x, dim, keepdim).
Output shape is input shape without the reduction dimension (or with size-1 if keepdim=True).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
dim(Union[int, List[int]], default:-1) –Reduction dimension (default -1).
-
keepdim(bool, default:False) –Retain reduced dimension (default False).
-
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 override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default False).
forward
¶
Run the softmax-family op.
One call to the operator this op registers: this is as far as dynamo traces.
Vector norms¶
tileops.ops.reduction.vector_norm.L1NormFwdOp
¶
L1 norm reduction along a configurable dim.
Construction: L1NormFwdOp(dim=None, keepdim=False).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
dim(Union[int, List[int], None], default:None) –Reduction dimension (default
None-> full reduction, matchingtorch.linalg.vector_norm). Acceptsint,list[int], orNone. -
keepdim(bool, default:False) –Whether to retain the reduced dimension as size 1.
-
ord(Union[int, float], default:1) –Norm order. Must equal 1 for
L1NormFwdOp(manifest fixesord == 1); accepted as a kwarg to mirrortorch.linalg.vector_norm. -
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 custom kernel map.
-
tune(bool, default:False) –Whether to autotune the kernel.
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.
tileops.ops.reduction.vector_norm.L2NormFwdOp
¶
L2 norm reduction along a configurable dim.
Construction: L2NormFwdOp(dim=None, keepdim=False).
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
dim(Union[int, List[int], None], default:None) –Reduction dimension (default
None-> full reduction, matchingtorch.linalg.vector_norm). Acceptsint,list[int], orNone. -
keepdim(bool, default:False) –Whether to retain the reduced dimension as size 1.
-
ord(Union[int, float], default:2) –Norm order. Must equal 2 for
L2NormFwdOp(manifest fixesord == 2); accepted as a kwarg to mirrortorch.linalg.vector_norm. -
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 custom kernel map.
-
tune(bool, default:False) –Whether to autotune the kernel.
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.
tileops.ops.reduction.vector_norm.InfNormFwdOp
¶
Infinity norm reduction along a configurable dim.
Construction: InfNormFwdOp(dim=None, keepdim=False).
NaN handling: rows containing any NaN produce NaN output, matching torch.linalg.vector_norm(ord=inf) semantics. The kernel drops NaN values and patches those rows itself, so the compensation stays with the implementation that needs it.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
dim(Union[int, List[int], None], default:None) –Reduction dimension (default
None-> full reduction, matchingtorch.linalg.vector_norm). Acceptsint,list[int], orNone. -
keepdim(bool, default:False) –Whether to retain the reduced dimension as size 1.
-
ord(Union[int, float], default:inf) –Norm order. Must equal
float('inf')forInfNormFwdOp(manifest fixesord == float('inf')); accepted as a kwarg to mirrortorch.linalg.vector_norm. -
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 custom kernel map.
-
tune(bool, default:False) –Whether to autotune the kernel.
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.
Cumulative¶
tileops.ops.reduction.cumulative.CumulativeOp
¶
Abstract base for cumulative scan operators with a user-selectable axis.
Subclasses must override _op_kind (class attribute) — the kernel's
op-kind dispatch string ("sum" or "prod").
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
dim(int, default:-1) –Reduction axis (default -1). Negative values are normalized at forward time (
dim % x.ndim). -
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 override dict.
-
tune(bool, default:False) –If True, autotune tile configs.
forward
¶
Run the scan.
One call to the operator this op registers: this is as far as dynamo traces.
tileops.ops.reduction.cumulative.CumsumFwdOp
¶
Cumulative sum operator: y = cumsum(x, dim).
Output has the same shape and dtype as x. Alignment padding is
handled inside the kernel via masked loads.
Shapes with M < 128 and N > 8192 take a three-pass parallel scan for
SM utilization; every other shape takes the sequential scan.
Parameters:
-
dim(int, default:-1) –Reduction axis (default -1). Negative values are normalized at forward time.
-
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 override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default False).
Example
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
dim(int, default:-1) –Reduction axis (default -1). Negative values are normalized at forward time (
dim % x.ndim). -
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 override dict.
-
tune(bool, default:False) –If True, autotune tile configs.
forward
¶
Run the scan.
One call to the operator this op registers: this is as far as dynamo traces.
tileops.ops.reduction.cumulative.CumprodFwdOp
¶
Cumulative product operator: y = cumprod(x, dim).
Output has the same shape and dtype as x. Alignment padding is
handled inside the kernel via masked loads.
Parameters:
-
dim(int, default:-1) –Reduction axis (default -1). Negative values are normalized at forward time.
-
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 override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default False).
Example
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
dim(int, default:-1) –Reduction axis (default -1). Negative values are normalized at forward time (
dim % x.ndim). -
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 override dict.
-
tune(bool, default:False) –If True, autotune tile configs.
forward
¶
Run the scan.
One call to the operator this op registers: this is as far as dynamo traces.
Logical reductions¶
tileops.ops.reduction.logical_reduce.AllFwdOp
¶
All reduction along dim, returning bool.
Construction: AllFwdOp(dim=None, keepdim=False).
are derived from the input tensor at forward time, and kernels are
cached by (M, N) to avoid rebuilds.
Supports any numeric dtype including torch.bool, int32, int64, and complex types. A dtype TileLang cannot store as shared memory is converted inside the kernel, so this op hands over the tensor its manifest declares.
Empty-dim contract: dim=[] / dim=() is a no-op -- forward returns
x.bool() with the input shape, matching torch.all semantics.
__init__
¶
Construct AllFwdOp.
Parameters:
-
dim(Union[int, List[int], Tuple[int, ...], None], default:None) –Reduction dimension (default
None, i.e. full reduction). Acceptsint,list[int],tuple[int, ...], orNone. -
keepdim(bool, default:False) –Whether to retain reduced dims as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default
False).
Parameters:
-
dim(Union[int, List[int], Tuple[int, ...], None], default:None) –Reduction dimension (default
None, i.e. full reduction). Acceptsint,list[int], ortuple[int, ...]for multi-dim reduction. -
keepdim(bool, default:False) –Whether to retain the reduced dimension as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional custom kernel map.
-
tune(bool, default:False) –Whether to autotune the kernel.
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.
tileops.ops.reduction.logical_reduce.AnyFwdOp
¶
Any reduction along dim, returning bool.
Construction: AnyFwdOp(dim=None, keepdim=False).
are derived from the input tensor at forward time, and kernels are
cached by (M, N) to avoid rebuilds.
Supports any numeric dtype including torch.bool, int32, int64, and complex types. A dtype TileLang cannot store as shared memory is converted inside the kernel, so this op hands over the tensor its manifest declares.
Empty-dim contract: dim=[] / dim=() is a no-op -- forward returns
x.bool() with the input shape, matching torch.any semantics.
__init__
¶
Construct AnyFwdOp.
Parameters:
-
dim(Union[int, List[int], Tuple[int, ...], None], default:None) –Reduction dimension (default
None, i.e. full reduction). Acceptsint,list[int],tuple[int, ...], orNone. -
keepdim(bool, default:False) –Whether to retain reduced dims as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional override for kernel dispatch.
-
tune(bool, default:False) –Whether to autotune (default
False).
Parameters:
-
dim(Union[int, List[int], Tuple[int, ...], None], default:None) –Reduction dimension (default
None, i.e. full reduction). Acceptsint,list[int], ortuple[int, ...]for multi-dim reduction. -
keepdim(bool, default:False) –Whether to retain the reduced dimension as size 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. -
kernel_map(Optional[Dict[str, Kernel]], default:None) –Optional custom kernel map.
-
tune(bool, default:False) –Whether to autotune the kernel.
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.
tileops.ops.reduction.logical_reduce.CountNonzeroFwdOp
¶
Count nonzero reduction along dim, returning int64.
Construction: CountNonzeroFwdOp(dim=None).
Note: No keepdim parameter -- the reduction dimension is always
removed, matching torch.count_nonzero semantics.
Supports any numeric dtype including torch.bool, int32, int64, and complex types. A dtype TileLang cannot store as shared memory is converted inside the kernel, so this op hands over the tensor its manifest declares.
__init__
¶
Build the op. Shapes and dtype are taken from the first call.
Parameters:
-
dim(Union[int, List[int], Tuple[int, ...], None], default:None) –Reduction dimension (default
None, i.e. full reduction). Acceptsint,list[int], ortuple[int, ...]for multi-dim reduction. -
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 custom kernel map.
-
tune(bool, default:False) –Whether to autotune the kernel.
forward
¶
Run the reduce op on x along the configured dim.
One call to the operator this op registers: this is as far as dynamo traces.