mxnet.ndarray.NDArray.copyto¶
-
NDArray.copyto(other)[source]¶ Copies the value of this array to another array.
If
otheris aNDArrayobject, thenother.shapeandself.shapeshould be the same. This function copies the value fromselftoother.If
otheris a context, a newNDArraywill be first created on the target context, and the value ofselfis copied.- Parameters
other (NDArray or Context) – The destination array or context.
- Returns
The copied array. If
otheris anNDArray, then the return value andotherwill point to the sameNDArray.- Return type
Examples
>>> x = mx.nd.ones((2,3)) >>> y = mx.nd.zeros((2,3), mx.gpu(0)) >>> z = x.copyto(y) >>> z is y True >>> y.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> y.copyto(mx.gpu(0)) <NDArray 2x3 @gpu(0)>