Java Code Examples for org.nd4j.linalg.api.shape.Shape#createShapeInformation()
The following examples show how to use
org.nd4j.linalg.api.shape.Shape#createShapeInformation() .
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: ShapeBufferTests.java From deeplearning4j with Apache License 2.0 | 6 votes |
@Test public void testShape() { long[] shape = {2, 4}; long[] stride = {1, 2}; val shapeInfoBuffer = Shape.createShapeInformation(shape, stride, 1, 'c', DataType.DOUBLE, false); val buff = shapeInfoBuffer.asNioLong(); val shapeView = Shape.shapeOf(buff); assertTrue(Shape.contentEquals(shape, shapeView)); val strideView = Shape.stride(buff); assertTrue(Shape.contentEquals(stride, strideView)); assertEquals('c', Shape.order(buff)); assertEquals(1, Shape.elementWiseStride(buff)); assertFalse(Shape.isVector(buff)); assertTrue(Shape.contentEquals(shape, Shape.shapeOf(buff))); assertTrue(Shape.contentEquals(stride, Shape.stride(buff))); }
Example 2
Source File: BaseShapeInfoProvider.java From nd4j with Apache License 2.0 | 5 votes |
@Override public Pair<DataBuffer, long[]> createShapeInformation(int[] shape, int[] stride, long offset, int elementWiseStride, char order) { DataBuffer buffer = Shape.createShapeInformation(ArrayUtil.toLongArray(shape), ArrayUtil.toLongArray(stride), offset, (long) elementWiseStride, order); buffer.setConstant(true); return Pair.create(buffer, buffer.asLong()); }
Example 3
Source File: ShapeBufferTests.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Test public void testRank() { long[] shape = {2, 4}; long[] stride = {1, 2}; val shapeInfoBuffer = Shape.createShapeInformation(shape, stride, 1, 'c', DataType.DOUBLE, false); val buff = shapeInfoBuffer.asNioLong(); assertEquals(2, Shape.rank(buff)); }
Example 4
Source File: BaseShapeInfoProvider.java From nd4j with Apache License 2.0 | 4 votes |
@Override public Pair<DataBuffer, long[]> createShapeInformation(long[] shape, long[] stride, long offset, long elementWiseStride, char order) { DataBuffer buffer = Shape.createShapeInformation(shape, stride, offset, elementWiseStride, order); buffer.setConstant(true); return Pair.create(buffer, buffer.asLong()); }
Example 5
Source File: BaseShapeInfoProvider.java From deeplearning4j with Apache License 2.0 | 4 votes |
@Override public Pair<DataBuffer, long[]> createShapeInformation(long[] shape, long[] stride, long elementWiseStride, char order, DataType dataType, boolean empty) { DataBuffer buffer = Shape.createShapeInformation(shape, stride, elementWiseStride, order, dataType, empty); buffer.setConstant(true); return Pair.create(buffer, buffer.asLong()); }
Example 6
Source File: BaseShapeInfoProvider.java From deeplearning4j with Apache License 2.0 | 4 votes |
@Override public Pair<DataBuffer, long[]> createShapeInformation(long[] shape, long[] stride, long elementWiseStride, char order, long extras) { DataBuffer buffer = Shape.createShapeInformation(shape, stride, elementWiseStride, order, extras); buffer.setConstant(true); return Pair.create(buffer, buffer.asLong()); }
Example 7
Source File: BaseComplexNDArray.java From nd4j with Apache License 2.0 | 2 votes |
/** * Construct an ndarray of the specified shape * with an empty data array * * @param shape the shape of the ndarray * @param stride the stride of the ndarray * @param offset the desired offset * @param ordering the ordering for the ndarray */ public BaseComplexNDArray(int[] shape, int[] stride, long offset, char ordering) { this(new float[ArrayUtil.prod(shape) * 2], shape, stride, offset); this.shapeInformation = Shape.createShapeInformation(shape, stride, offset, stride[stride.length - 1], ordering); }