Java Code Examples for org.nd4j.linalg.api.shape.Shape#toOffsetZeroCopyAnyOrder()
The following examples show how to use
org.nd4j.linalg.api.shape.Shape#toOffsetZeroCopyAnyOrder() .
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: NDArrayTestsFortran.java From nd4j with Apache License 2.0 | 5 votes |
@Test public void testToOffsetZeroCopy() { List<Pair<INDArray, String>> testInputs = NDArrayCreationUtil.getAllTestMatricesWithShape(4, 5, 123); for (Pair<INDArray, String> pair : testInputs) { String msg = pair.getSecond(); INDArray in = pair.getFirst(); INDArray dup = Shape.toOffsetZeroCopy(in); INDArray dupc = Shape.toOffsetZeroCopy(in, 'c'); INDArray dupf = Shape.toOffsetZeroCopy(in, 'f'); INDArray dupany = Shape.toOffsetZeroCopyAnyOrder(in); assertEquals(msg, in, dup); assertEquals(msg, in, dupc); assertEquals(msg, in, dupf); assertEquals(msg, dupc.ordering(), 'c'); assertEquals(msg, dupf.ordering(), 'f'); assertEquals(msg, in, dupany); assertEquals(dup.offset(), 0); assertEquals(dupc.offset(), 0); assertEquals(dupf.offset(), 0); assertEquals(dupany.offset(), 0); assertEquals(dup.length(), dup.data().length()); assertEquals(dupc.length(), dupc.data().length()); assertEquals(dupf.length(), dupf.data().length()); assertEquals(dupany.length(), dupany.data().length()); } }
Example 2
Source File: NDArrayTestsFortran.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Test public void testToOffsetZeroCopy() { List<Pair<INDArray, String>> testInputs = NDArrayCreationUtil.getAllTestMatricesWithShape(4, 5, 123, DataType.DOUBLE); int cnt = 0; for (Pair<INDArray, String> pair : testInputs) { String msg = pair.getSecond(); INDArray in = pair.getFirst(); INDArray dup = Shape.toOffsetZeroCopy(in); INDArray dupc = Shape.toOffsetZeroCopy(in, 'c'); INDArray dupf = Shape.toOffsetZeroCopy(in, 'f'); INDArray dupany = Shape.toOffsetZeroCopyAnyOrder(in); assertEquals(msg + ": " + cnt, in, dup); assertEquals(msg, in, dupc); assertEquals(msg, in, dupf); assertEquals(msg, dupc.ordering(), 'c'); assertEquals(msg, dupf.ordering(), 'f'); assertEquals(msg, in, dupany); assertEquals(dup.offset(), 0); assertEquals(dupc.offset(), 0); assertEquals(dupf.offset(), 0); assertEquals(dupany.offset(), 0); assertEquals(dup.length(), dup.data().length()); assertEquals(dupc.length(), dupc.data().length()); assertEquals(dupf.length(), dupf.data().length()); assertEquals(dupany.length(), dupany.data().length()); cnt++; } }