Skip to main content

function

slice

slice(input: Symbol, slices: List[SymbolicSlice], static_shape: Optional[List[Dim]] = #kgen.none) -> Symbol

Slices a symbolic tensor along each dimension.

Args:

  • input (Symbol): The symbolic tensor to slice.
  • slices (List[SymbolicSlice]): Per-dimension slice specifiers. If smaller than the input rank, trivial slices (ie. ones which select the whole range) will be added to the end for the remaining dimensions.
  • static_shape (Optional[List[Dim]]): An optional shape to use to hint the output type.

Returns:

A new symbolic tensor representing the result of slicing the input along each dimension using each slice in slices respectively. The output will have the same rank as the input, but fewer values depending on the slices. If static_shape is present it will be used as the output tensor's shape, otherwise each dimension will be dynamic size.

slice(input: Symbol, s: Slice) -> Symbol

Slices a symbolic tensor along its first dimension.

Args:

  • input (Symbol): The symbolic tensor to slice.
  • s (Slice): A slice applied to the first dimension of the input.

Returns:

A new symbolic tensor representing the result of slicing the input along its major dimension according to s. The output will have the same rank as the input, but fewer values depending on the slice.

slice[keep_dims: Bool = false](input: Symbol, idx: Symbol, axis: Int = 0) -> Symbol

Slices out a n-1-d plane from the input symbolic tensor.

Args:

  • input (Symbol): The symbolic tensor to slice.
  • idx (Symbol): The index to select along the given axis.
  • axis (Int): The axis to select using the index.

Returns:

A new symbolic tensor representing the result of selecting every value having the specified index in the specified axis. The result will have rank n-1 where n is the rank of the input tensor, with the axis dimension removed.