IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/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. /max/get-started.md).

Mojo function

selective_scan_fwd_shape

def selective_scan_fwd_shape[dtype: DType](u: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=u.static_spec], delta: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=delta.static_spec], A: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=A.static_spec], B: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=B.static_spec], C: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=C.static_spec], D: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=D.static_spec], z: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=z.static_spec], delta_bias: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=delta_bias.static_spec]) -> IndexList[Int(3)]

Returns the output shape for the selective_scan_fwd op.

The output of a selective scan forward pass has the same shape as the input sequence u: (batch, dim, seqlen).

Parameters:

  • ​dtype (DType): Element type of the input tensors (inferred).

Args:

  • ​u (ManagedTensorSlice[IOSpec[_, _].Input, static_spec=u.static_spec]): Input sequence tensor with shape (batch, dim, seqlen).
  • ​delta (ManagedTensorSlice[IOSpec[_, _].Input, static_spec=delta.static_spec]): Time-step tensor with shape (batch, dim, seqlen).
  • ​A (ManagedTensorSlice[IOSpec[_, _].Input, static_spec=A.static_spec]): State transition matrix with shape (dim, dstate).
  • ​B (ManagedTensorSlice[IOSpec[_, _].Input, static_spec=B.static_spec]): Input projection with shape (batch, n_groups, dstate, seqlen).
  • ​C (ManagedTensorSlice[IOSpec[_, _].Input, static_spec=C.static_spec]): Output projection with shape (batch, n_groups, dstate, seqlen).
  • ​D (ManagedTensorSlice[IOSpec[_, _].Input, static_spec=D.static_spec]): Skip connection with shape (dim,).
  • ​z (ManagedTensorSlice[IOSpec[_, _].Input, static_spec=z.static_spec]): Gating tensor with shape (batch, dim, seqlen).
  • ​delta_bias (ManagedTensorSlice[IOSpec[_, _].Input, static_spec=delta_bias.static_spec]): Delta bias with shape (dim,).

Returns:

IndexList[Int(3)]: The shape of the output tensor (batch, dim, seqlen).