crop function
Crop images.
Args:
- images: 4-D variable of NC4HW4 format.
- size: A variable. It takes the shape of
sizeas output cropped variable's shape while omits the values/format ofsize. - axis: A int indicating the dimention to crop. Must be >=2. All dimensions up to but excluding
axisare preserved, while the dimensions including and trailingaxisare cropped. - offset: A vector of int indicating the offsets. length(
offset) must be >=1 and <=2. If length(offset) is 1, then all dimensions are offset by this amount.Otherwise, the number of offsets must equal the number of cropped axes in each dimension accordingly.
Returns:
- The cropped 4-D variable of NC4HW4 format.
Implementation
VARP crop(VARP images, VARP size, int axis, List<int> offset) {
final (offsetPtr, offsetSize) = offset.toNativeArrayI32();
final rval = VARP.fromPointer(C.mnn_expr_Crop(images.ptr, size.ptr, axis, offsetPtr.cast(), offsetSize));
calloc.free(offsetPtr);
return rval;
}