split function

List<VARP> split(
  1. VARP value,
  2. List<int> sizeSplits, {
  3. int axis = 0,
})

Splits a variable value into a list of sub variables.

Args:

  • value: The variable to split.
  • size_splits: A vector, a 1-D integer containing the sizes of each output variable along axis.
  • axis: A int, the dimension along which to split. Must be in the range [-rank(value), rank(value)). Defaults to 0

Returns:

  • A list of variables.

Implementation

List<VARP> split(VARP value, List<int> sizeSplits, {int axis = 0}) {
  final (sizeSplitsPtr, sizeSplitsSize) = sizeSplits.toNativeArrayI32();
  final p = C.mnn_expr_Split(value.ptr, sizeSplitsPtr.cast(), sizeSplitsSize, axis);
  final size = C.mnn_expr_VecVARP_size(p);
  calloc.free(sizeSplitsPtr);
  final rval = List.generate(size, (index) => VARP.fromPointer(C.mnn_expr_VecVARP_at(p, index)));
  // only free the struct, keep internal ref.ptr since they are attached
  // and will be managed by VARP object
  C.mnn_expr_VecVARP_free(p);
  return rval;
}