Java Code Examples for org.bytedeco.javacpp.Pointer#memcpy()
The following examples show how to use
org.bytedeco.javacpp.Pointer#memcpy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NoOp.java From nd4j with Apache License 2.0 | 6 votes |
@Override protected CompressedDataBuffer compressPointer(DataBuffer.TypeEx srcType, Pointer srcPointer, int length, int elementSize) { CompressionDescriptor descriptor = new CompressionDescriptor(); descriptor.setCompressionType(getCompressionType()); descriptor.setOriginalLength(length * elementSize); descriptor.setCompressionAlgorithm(getDescriptor()); descriptor.setOriginalElementSize(elementSize); descriptor.setCompressedLength(length * elementSize); descriptor.setNumberOfElements(length); BytePointer ptr = new BytePointer(length * elementSize); val perfD = PerformanceTracker.getInstance().helperStartTransaction(); // this Pointer.memcpy is used intentionally. This method operates on host memory ALWAYS Pointer.memcpy(ptr, srcPointer, length * elementSize); PerformanceTracker.getInstance().helperRegisterTransaction(0, perfD, length * elementSize, MemcpyDirection.HOST_TO_HOST); CompressedDataBuffer buffer = new CompressedDataBuffer(ptr, descriptor); return buffer; }
Example 2
Source File: NoOp.java From deeplearning4j with Apache License 2.0 | 6 votes |
@Override protected CompressedDataBuffer compressPointer(DataTypeEx srcType, Pointer srcPointer, int length, int elementSize) { CompressionDescriptor descriptor = new CompressionDescriptor(); descriptor.setCompressionType(getCompressionType()); descriptor.setOriginalLength(length * elementSize); descriptor.setCompressionAlgorithm(getDescriptor()); descriptor.setOriginalElementSize(elementSize); descriptor.setCompressedLength(length * elementSize); descriptor.setNumberOfElements(length); BytePointer ptr = new BytePointer(length * elementSize); val perfD = PerformanceTracker.getInstance().helperStartTransaction(); // this Pointer.memcpy is used intentionally. This method operates on host memory ALWAYS Pointer.memcpy(ptr, srcPointer, length * elementSize); PerformanceTracker.getInstance().helperRegisterTransaction(0, perfD, length * elementSize, MemcpyDirection.HOST_TO_HOST); CompressedDataBuffer buffer = new CompressedDataBuffer(ptr, descriptor); return buffer; }
Example 3
Source File: BasicMemoryManager.java From nd4j with Apache License 2.0 | 5 votes |
@Override public void memcpy(DataBuffer dstBuffer, DataBuffer srcBuffer) { val perfD = PerformanceTracker.getInstance().helperStartTransaction(); Pointer.memcpy(dstBuffer.addressPointer(), srcBuffer.addressPointer(), srcBuffer.length() * srcBuffer.getElementSize()); PerformanceTracker.getInstance().helperRegisterTransaction(0, perfD, srcBuffer.length() * srcBuffer.getElementSize(), MemcpyDirection.HOST_TO_HOST); }
Example 4
Source File: BasicMemoryManager.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Override public void memcpy(DataBuffer dstBuffer, DataBuffer srcBuffer) { val perfD = PerformanceTracker.getInstance().helperStartTransaction(); Pointer.memcpy(dstBuffer.addressPointer(), srcBuffer.addressPointer(), srcBuffer.length() * srcBuffer.getElementSize()); PerformanceTracker.getInstance().helperRegisterTransaction(0, perfD, srcBuffer.length() * srcBuffer.getElementSize(), MemcpyDirection.HOST_TO_HOST); }
Example 5
Source File: NDArray.java From nd4j with Apache License 2.0 | 4 votes |
/** * This method does direct array copy. Impossible to use on views or mixed orders. * * PLEASE NOTE: YOU SHOULD NEVER USE THIS METHOD, UNLESS YOU 100% CLEAR ABOUT IT * * @return */ @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; }
Example 6
Source File: NDArray.java From deeplearning4j with Apache License 2.0 | 4 votes |
@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; }
Example 7
Source File: CompressedDataBuffer.java From nd4j with Apache License 2.0 | 3 votes |
@Override public DataBuffer dup() { Pointer nPtr = new BytePointer(compressionDescriptor.getCompressedLength()); val perfD = PerformanceTracker.getInstance().helperStartTransaction(); Pointer.memcpy(nPtr, pointer, compressionDescriptor.getCompressedLength()); PerformanceTracker.getInstance().helperRegisterTransaction(0, perfD, compressionDescriptor.getCompressedLength(), MemcpyDirection.HOST_TO_HOST); CompressionDescriptor nDesc = compressionDescriptor.clone(); CompressedDataBuffer nBuf = new CompressedDataBuffer(nPtr, nDesc); return nBuf; }
Example 8
Source File: CompressedDataBuffer.java From deeplearning4j with Apache License 2.0 | 3 votes |
@Override public DataBuffer dup() { Pointer nPtr = new BytePointer(compressionDescriptor.getCompressedLength()); val perfD = PerformanceTracker.getInstance().helperStartTransaction(); Pointer.memcpy(nPtr, pointer, compressionDescriptor.getCompressedLength()); PerformanceTracker.getInstance().helperRegisterTransaction(0, perfD, compressionDescriptor.getCompressedLength(), MemcpyDirection.HOST_TO_HOST); CompressionDescriptor nDesc = compressionDescriptor.clone(); CompressedDataBuffer nBuf = new CompressedDataBuffer(nPtr, nDesc); return nBuf; }