Skip to main content
Log in

Mojo function

stack

stack(values: List[Symbol, 0], axis: Int = 0) -> Symbol

Stacks a list of tensors along a new axis.

Args:

  • values (List[Symbol, 0]): A list of symbolic tensor values. Each tensor must have the same dtype and rank, and must have the same dimension size for each dimension.
  • axis (Int): The axis to concatenate along. If negative, indexes relative to the end of the tensor shape plus 1. For instance, stack(vs, -1) will create and stack along a new axis as the last dimension, aad stack(vs, -2) will create and stack along a new dimension which is inserted immediately before the last dimension.

Returns:

A new symbolic tensor representing the result of the stack. It will have rank n+1 where n is the rank of each input tensor. Its size on each dimension other than axis will be the same as each input tensors', with the new axis inserted. Along the new dimension it will have size len(values).

Was this page helpful?