moments function

List<VARP> moments(
  1. VARP x,
  2. List<int> axis,
  3. VARP shift,
  4. bool keepDims,
)

Calculates the mean and variance of x.

Args:

  • x: A variable. must be 4-D with NC4HW4 format.
  • axes: Array of ints. Axes along which to compute mean and variance. Ignored for this implementation: must be {2, 3}
  • shift: Not used in the current implementation.
  • keepdims: produce moments with the same dimensionality as the input. Ignored for this implementation: must be true.

Returns:

  • Two variable objects: mean and variance.

Implementation

List<VARP> moments(VARP x, List<int> axis, VARP shift, bool keepDims) {
  final (axisPtr, axisSize) = axis.toNativeArrayI32();
  final vec = VecVARP.fromPointer(C.mnn_expr_Moments(x.ptr, axisPtr.cast(), axisSize, shift.ptr, keepDims));
  calloc.free(axisPtr);
  final rval = vec.toList();
  vec.dispose();
  return rval;
}