Skip to main content

Module reduction

Module reduction 

Source
Expand description

Reduction kernels — each CTA handles one output element (one “row” of the flattened [outer, inner] view). The caller is responsible for reshaping the input to [n_outer, n_inner] before invoking these kernels.

Grid: [n_outer, 1, 1] Block: [BLOCK_INNER, 1, 1]

Structs§

CumProdForward
Forward: y = cumprod(x, axis=0) over a 1-D block
CumSumForward
Forward: y = cumsum(x, axis=0) over a 1-D block Each CTA handles one complete row (n_inner elements).
GlobalAvgPoolForward
Forward: y[row] = mean(x[row, :]) (same as ReduceMean)
GlobalMaxPoolForward
Forward: y[row] = max(x[row, :]) (same as ReduceMax)
ReduceL1Forward
Forward: y[row] = sum(|x[row, :]|)
ReduceL2Forward
Forward: y[row] = sqrt(sum(x[row, :]^2))
ReduceLogSumExpForward
Forward: y[row] = log(sum(exp(x[row, :]))) — numerically stable via max subtraction
ReduceLogSumForward
Forward: y[row] = log(sum(x[row, :])) (numerically unsafe; use ReduceLogSumExp for stable)
ReduceMaxForward
Forward: y[row] = max(x[row, :])
ReduceMeanForward
Forward: y[row] = mean(x[row, :])
ReduceMinForward
Forward: y[row] = min(x[row, :])
ReduceProdForward
Forward: y[row] = prod(x[row, :]) Note: implemented as exp(sum(log(x))) — only valid for positive x. For general use this is a placeholder.
ReduceSumForward
Forward: y[row] = sum(x[row, :])
ReduceSumSquareForward
Forward: y[row] = sum(x[row, :]^2)

Functions§

cum_prod_forward
Forward: y = cumprod(x, axis=0) over a 1-D block
cum_sum_forward
Forward: y = cumsum(x, axis=0) over a 1-D block Each CTA handles one complete row (n_inner elements).
global_avg_pool_forward
Forward: y[row] = mean(x[row, :]) (same as ReduceMean)
global_max_pool_forward
Forward: y[row] = max(x[row, :]) (same as ReduceMax)
reduce_l1_forward
Forward: y[row] = sum(|x[row, :]|)
reduce_l2_forward
Forward: y[row] = sqrt(sum(x[row, :]^2))
reduce_log_sum_exp_forward
Forward: y[row] = log(sum(exp(x[row, :]))) — numerically stable via max subtraction
reduce_log_sum_forward
Forward: y[row] = log(sum(x[row, :])) (numerically unsafe; use ReduceLogSumExp for stable)
reduce_max_forward
Forward: y[row] = max(x[row, :])
reduce_mean_forward
Forward: y[row] = mean(x[row, :])
reduce_min_forward
Forward: y[row] = min(x[row, :])
reduce_prod_forward
Forward: y[row] = prod(x[row, :]) Note: implemented as exp(sum(log(x))) — only valid for positive x. For general use this is a placeholder.
reduce_sum_forward
Forward: y[row] = sum(x[row, :])
reduce_sum_square_forward
Forward: y[row] = sum(x[row, :]^2)