emptyLike<T extends SizedNativeType> function
empty_like(prototype, dtype=None, order='K', subok=True, shape=None) Return a new var with the same shape and type as a given var.
Parameters
prototype : var_like The shape and data-type of prototype define these same attributes of the returned array. dtype : data-type, optional Overrides the data type of the result. order : {'C', 'F', 'A', or 'K'}, optional Compatible with numpy. subok : bool, optional. Compatible with numpy. shape : int or sequence of ints, optional. Overrides the shape of the result.
Returns
out : var Var of uninitialized (arbitrary) data with the same shape and type as prototype.
Example:
a = (
1,2,3,4,5,6) np.empty_like(a)
Implementation
VARP emptyLike<T extends ffi.SizedNativeType>(
VARP prototype, {
String order = "K",
bool subOk = true,
List<int>? shape,
}) {
MnnAssert(T != ffi.SizedNativeType, "You must specify the generic type T. e.g., mnn.float32");
_orderAssert(order);
final (dstDtype, dstShape) = _arrayLikeType(
prototype,
dtype: HalideType.of<T>(),
order: order,
shape: shape,
);
return F.input<T>(dstShape, dataFormat: prototype.dataFormat ?? DimensionFormat.NCHW);
}