IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo struct

ConvIm2colParams

struct ConvIm2colParams

Runtime conv geometry for the online im2col A-operand loader.

SM100/Apple M5 (compute_capability == 5). The fused conv path (AppleM5MatMul.run_conv) never materialises the [M, K] im2col matrix; instead each A MMA-fragment is gathered directly from the NHWC input by the address math below. This struct carries the per-launch conv parameters the gather needs, and is DevicePassable (all-Int32 POD, device_type = Self) so it can cross enqueue_function directly.

The (M, K) -> NHWC map mirrors nn/conv/gpu/im2col_matmul_2d.mojo bit-for-bit so the fused result matches the materialised path:

m -> (batch, h_out, w_out): batch = m // HW_out; spatial = m % HW_out; h_out = spatial // W_out; w_out = spatial % W_out k -> (r, s, c): r = k // (SC); sc = k % (SC); s = sc // C; c = sc % C h_in = h_outstride_h - pad_h + r; w_in = w_outstride_w - pad_w + s OOB (h_in/w_in outside [0,H)/[0,W)) -> 0 in_idx = batch*(HWC) + h_in*(WC) + w_inC + c

Dilation is assumed 1 (enforced at the conv dispatch gate); the map matches the materialiser, which also hardcodes dilation 1.

Fields

  • H (Int32):
  • W (Int32):
  • C (Int32):
  • R (Int32):
  • S (Int32):
  • H_out (Int32):
  • W_out (Int32):
  • pad_h (Int32):
  • pad_w (Int32):
  • stride_h (Int32):
  • stride_w (Int32):

Implemented traits

AnyType, Copyable, Deinitable, DevicePassable, ImplicitlyCopyable, Movable

comptime members

device_type

comptime device_type = ConvIm2colParams

Methods

__init__

def __init__(out self)

Zero-init all fields, for the dense matmul path that ignores conv.

get_type_name

static def get_type_name() -> String

Returns:

String