@ Override public INDArray unsafeDuplication ( ) { WorkspaceUtils . assertValidArray ( this , "Cannot duplicate array" ) ; if ( isView ( ) ) return this . dup ( this . ordering ( ) ) ; DataBuffer rb = Nd4j . getMemoryManager ( ) . getCurrentWorkspace ( ) == null ? Nd4j . getDataBufferFactory ( ) . createSame ( this . data , false ) : Nd4j . getDataBufferFactory ( ) . createSame ( this . data , false , Nd4j . getMemoryManager ( ) . getCurrentWorkspace ( ) ) ; INDArray ret = Nd4j . createArrayFromShapeBuffer ( rb , this . shapeInfoDataBuffer ( ) ) ; val perfD = PerformanceTracker . getInstance ( ) . helperStartTransaction ( ) ; Pointer . memcpy ( ret . data ( ) . addressPointer ( ) , this . data ( ) . addressPointer ( ) , this . data ( ) . length ( ) * this . data ( ) . getElementSize ( ) ) ; PerformanceTracker . getInstance ( ) . helperRegisterTransaction ( 0 , perfD , this . data ( ) . length ( ) * this . data ( ) . getElementSize ( ) , MemcpyDirection . HOST_TO_HOST ) ; return ret ; }
This method does direct array copy . Impossible to use on views or mixed orders .