public class Shape extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
areShapesBroadcastable(int[] x,
int[] y) |
static void |
assertBroadcastable(INDArray x,
INDArray y) |
static void |
assertBroadcastable(int[] x,
int[] y) |
static void |
assertShapeLessThan(int[] shape,
int[] lessThan)
Assert the both shapes are the same length
and shape[i] < lessThan[i]
|
static int[] |
broadcastOutputShape(int[] left,
int[] right)
Get the broadcast output shape
based on the 2 input shapes
Result output shape based on:
https://docs.scipy.org/doc/numpy-1.10.1/user/basics.broadcasting.html
|
static String |
bufferToString(IntBuffer buffer)
Prints the
IntBuffer |
static boolean |
contentEquals(int[] arr,
DataBuffer other)
Compare the contents of a buffer and
an array for equals
|
static boolean |
contentEquals(int[] arr,
IntBuffer other)
Compare the contents of a buffer and
an array for equals
|
static boolean |
cOrFortranOrder(int[] shape,
int[] stride,
int elementStride)
Infer order from
|
static DataBuffer |
createShapeInformation(int[] shape,
int[] stride,
long offset,
int elementWiseStride,
char order)
Creates the shape information buffer
given the shape,stride
|
static DataBuffer |
createSparseInformation(int[] flags,
long[] sparseOffsets,
int[] hiddenDimensions,
int underlyingRank) |
static int |
elementWiseStride(DataBuffer buffer)
Get the element wise stride for the
shape info buffer
|
static int |
elementWiseStride(int[] shape,
int[] stride,
boolean isFOrder) |
static int |
elementWiseStride(IntBuffer buffer)
Get the element wise stride for the
shape info buffer
|
static int[] |
ensureAtMinRowVector(int... shape)
If a shape array is ony 1 in length
it returns a row vector
|
static int[] |
flags(DataBuffer buffer) |
static int[] |
getBroadcastDimensions(int[] left,
int[] right)
Compute the broadcast rules according to:
https://docs.scipy.org/doc/numpy-1.10.1/user/basics.broadcasting.html
Note that the array can be null if the arrays are already equal
in shape.
|
static double |
getDouble(INDArray arr,
int... indices)
Get a double based on the array and given indices
|
static int[] |
getMatrixMultiplyShape(int[] left,
int[] right)
Get the output shape of a matrix multiply
|
static int[] |
getMaxShape(INDArray... inputs)
Return the shape of the largest length array
based on the input
|
static long |
getOffset(DataBuffer shapeInformation,
int... indices)
Get the offset of the specified indices from the shape info buffer
|
static long |
getOffset(DataBuffer shapeInformation,
int row,
int col)
Get the offset of the specified [row,col] for the 2d array
|
static long |
getOffset(DataBuffer shapeInformation,
int dim0,
int dim1,
int dim2)
Get the offset of the specified [dim0,dim1,dim2] for the 3d array
|
static long |
getOffset(DataBuffer shapeInformation,
int dim0,
int dim1,
int dim2,
int dim3)
Get the offset of the specified [dim0,dim1,dim2,dim3] for the 4d array
|
static long |
getOffset(int[] shapeInformation,
int... indices) |
static long |
getOffset(IntBuffer shapeInformation,
int... indices)
Get the offset of the specified indices from the shape info buffer
|
static long |
getOffset(IntBuffer shapeInformation,
int row,
int col)
Get the offset of the specified [row,col] for the 2d array
|
static long |
getOffset(IntBuffer shapeInformation,
int dim0,
int dim1,
int dim2)
Get the offset of the specified [dim0,dim1,dim2] for the 3d array
|
static long |
getOffset(IntBuffer shapeInformation,
int dim0,
int dim1,
int dim2,
int dim3)
Get the offset of the specified [dim0,dim1,dim2,dim3] for the 4d array
|
static long |
getOffset(long baseOffset,
int[] shape,
int[] stride,
int... indices)
Get an offset for retrieval
from a data buffer
based on the given
shape stride and given indices
|
static long |
getOffsetUnsafe(DataBuffer shapeInformation,
int row,
int col)
Identical to
getOffset(DataBuffer, int, int) but without input validation on array rank |
static long |
getOffsetUnsafe(DataBuffer shapeInformation,
int dim0,
int dim1,
int dim2)
Identical to
getOffset(DataBuffer, int, int, int) but without input validation on array rank |
static long |
getOffsetUnsafe(DataBuffer shapeInformation,
int dim0,
int dim1,
int dim2,
int dim3) |
static long |
getOffsetUnsafe(int[] shapeInformation,
int row,
int col) |
static long |
getOffsetUnsafe(int[] shapeInformation,
int dim0,
int dim1,
int dim2) |
static long |
getOffsetUnsafe(int[] shapeInformation,
int dim0,
int dim1,
int dim2,
int dim3) |
static char |
getOrder(INDArray arr)
Infer the order for the ndarray based on the
array's strides
|
static char |
getOrder(int[] shape,
int[] stride,
int elementStride)
Infer order from
|
static int[] |
getReducedShape(int[] wholeShape,
int[] dimensions)
Get the shape of the reduced array
|
static int[] |
getReducedShape(int[] wholeShape,
int[] dimensions,
boolean keepDims,
boolean newFormat)
Get the shape of the reduced array
|
static long |
getTADLength(int[] shape,
int... dimensions) |
static boolean |
hasDefaultStridesForShape(INDArray input) |
static int[] |
hiddenDimension(DataBuffer buffer) |
static int[] |
ind2sub(INDArray arr,
long index)
Convert a linear index to
the equivalent nd index based on the shape of the specified ndarray.
|
static int[] |
ind2sub(int[] shape,
long index)
Convert a linear index to
the equivalent nd index.
|
static int[] |
ind2sub(int[] shape,
long index,
long numIndices)
Convert a linear index to
the equivalent nd index
|
static int[] |
ind2subC(INDArray arr,
long index)
Convert a linear index to
the equivalent nd index based on the shape of the specified ndarray.
|
static int[] |
ind2subC(int[] shape,
long index)
Convert a linear index to
the equivalent nd index.
|
static int[] |
ind2subC(int[] shape,
long index,
long numIndices)
Convert a linear index to
the equivalent nd index
|
static boolean |
isColumnVectorShape(int[] shape)
Returns true if the given shape is length 2 and
the size at element 1 is 1
|
static boolean |
isColumnVectorShape(long[] shape)
Returns true if the given shape length is 2
and the size at element 1 is 1
|
static boolean |
isContiguousInBuffer(INDArray in)
Are the elements in the buffer contiguous for this NDArray?
|
static boolean |
isMatrix(DataBuffer shapeInfo)
Returns whether the passed in shape is a matrix
|
static boolean |
isMatrix(int[] shape)
Returns whether the passed in shape is a matrix
|
static boolean |
isMatrix(IntBuffer shapeInfo)
Returns whether the passed in shape is a matrix
|
static boolean |
isPlaceholderShape(int[] shape)
Returns true if any shape has a -1
or a null or empty array is passed in
|
static boolean |
isRowVectorShape(DataBuffer shapeInfo)
Returns true if the given shape is of length 1
or provided the shape length is 2:
element 0 is 1
|
static boolean |
isRowVectorShape(int[] shape)
Returns true if the given shape is of length 1
or provided the shape length is 2:
element 0 is 1
|
static boolean |
isRowVectorShape(IntBuffer shapeInfo)
Returns true if the given shape is of length 1
or provided the shape length is 2:
element 0 is 1
|
static boolean |
isVector(DataBuffer shapeInfo)
Returns whether the given shape is a vector
|
static boolean |
isVector(int[] shape)
Returns whether the given shape is a vector
|
static boolean |
isVector(IntBuffer shapeInfo)
Returns whether the given shape is a vector
|
static boolean |
isWholeArray(int[] shape,
int... dimension)
Returns true if the dimension is null
or the dimension length is 1 and the first entry
is
Integer.MAX_VALUE |
static boolean |
isWholeArray(int rank,
int... dimension)
Returns true if the dimension is null
or the dimension length is 1 and the first entry
is
Integer.MAX_VALUE |
static void |
iterate(INDArray arr,
CoordinateFunction coordinateFunction)
Iterate over 2
coordinate spaces given 2 arrays
|
static void |
iterate(INDArray arr,
INDArray arr2,
CoordinateFunction coordinateFunction)
Iterate over 2
coordinate spaces given 2 arrays
|
static void |
iterate(int dimension,
int n,
int[] size,
int[] res,
CoordinateFunction func)
Iterate over a pair of coordinates
|
static void |
iterate(int dimension,
int n,
int[] size,
int[] res,
int dimension2,
int n2,
int[] size2,
int[] res2,
CoordinateFunction func)
Iterate over a pair of coordinates
|
static int |
length(DataBuffer buffer)
Gets the rank given the shape info buffer
|
static int |
length(IntBuffer buffer)
Gets the rank given the shape info buffer
|
static INDArray |
newShapeNoCopy(INDArray arr,
int[] newShape,
boolean isFOrder)
A port of numpy's reshaping algorithm that leverages
no copy where possible and returns
null if the reshape
couldn't happen without copying
|
static int[] |
newStrides(int[] strides,
int newLength,
INDArrayIndex[] indexes) |
static int[] |
normalizeAxis(int rank,
int... axis) |
static int |
offset(DataBuffer buffer)
Deprecated.
|
static int |
offset(int[] buffer)
Deprecated.
|
static int |
offset(IntBuffer buffer)
Get the offset for the buffer
|
static long |
offsetFor(INDArray arr,
int[] indexes)
Compute the offset for the given array
given the indices
|
static char |
order(DataBuffer buffer)
Returns the order given the shape information
|
static char |
order(int[] buffer) |
static char |
order(IntBuffer buffer)
Returns the order given the shape information
|
static int |
rank(DataBuffer buffer)
Gets the rank given the shape info buffer
|
static int |
rank(int[] buffer) |
static int |
rank(IntBuffer buffer)
Gets the rank given the shape info buffer
|
static int |
rankFromShape(int[] shape)
Return the rank for the given shape
|
static int[] |
resolveNegativeShapeIfNeccessary(int[] newShape,
int[] shape) |
static boolean |
scalarEquals(int[] shape1,
int[] shape2)
Returns true if the given shapes are both scalars (0 dimension or shape[0] == 1)
|
static void |
setElementWiseStride(DataBuffer buffer,
int elementWiseStride)
Get the element wise stride for the
shape info buffer
|
static void |
setElementWiseStride(IntBuffer buffer,
int elementWiseStride)
Get the element wise stride for the
shape info buffer
|
static void |
setOrder(IntBuffer buffer,
char order)
Deprecated.
|
static int[] |
shape(DataBuffer buffer)
Get array shape from the buffer, as an int[]
|
static int[] |
shape(int[] buffer)
Get array shape from an int[]
|
static int[] |
shape(IntBuffer buffer)
Get array shape from the buffer, as an int[]
|
static boolean |
shapeEquals(int[] shape1,
int[] shape2)
Returns whether 2 shapes are equals by checking for dimension semantics
as well as array equality
|
static int |
shapeInfoLength(int rank)
Return the shape info length
given the rank
|
static boolean |
shapeIsScalar(int[] shape)
Returns true if this shape is scalar
|
static DataBuffer |
shapeOf(DataBuffer buffer)
Get the shape from
the given int buffer
|
static int[] |
shapeOf(int[] buffer) |
static IntBuffer |
shapeOf(IntBuffer buffer)
Get the shape from
the given int buffer
|
static String |
shapeToString(INDArray arr)
Prints the shape
for this shape information
|
static String |
shapeToString(IntBuffer buffer)
Prints the shape
for this shape information
|
static int |
size(DataBuffer buffer,
int dimension)
Get the size of the specified dimension.
|
static int |
size(int[] buffer,
int dimension) |
static int |
size(IntBuffer buffer,
int dimension)
Get the size of the specified dimension.
|
static int[] |
sizeForAxes(int[] axes,
int[] shape)
Output an int array for a particular dimension
|
static int |
sizeUnsafe(DataBuffer buffer,
int dimension)
Get the size of the specified dimension.
|
static int |
sizeUnsafe(int[] buffer,
int dimension) |
static int[] |
sparseOffsets(DataBuffer buffer) |
static int[] |
squeeze(int[] shape)
Gets rid of any singleton dimensions of the given array
|
static DataBuffer |
stride(DataBuffer buffer)
Get the shape from
the given int buffer
|
static int |
stride(DataBuffer buffer,
int dimension)
Get the stride of the specified dimension
|
static int[] |
stride(int[] buffer) |
static int |
stride(int[] buffer,
int dimension) |
static IntBuffer |
stride(IntBuffer buffer)
Get the stride for the given
shape information buffer
|
static int |
stride(IntBuffer buffer,
int dimension)
Get the stride of the specified dimension
|
static int[] |
strideArr(DataBuffer buffer)
Get array shape from the buffer, as an int[]
|
static boolean |
strideDescendingCAscendingF(INDArray array)
Check if strides are in order suitable for non-strided mmul etc.
|
static int[] |
stridesOf(int[] buffer) |
static int |
strideUnsafe(DataBuffer buffer,
int dimension,
int rank)
Get the stride of the specified dimension, without any input validation
|
static int |
strideUnsafe(int[] buffer,
int dimension,
int rank) |
static long |
sub2Ind(int[] shape,
int[] indices)
Convert the given index (such as 1,1)
to a linear index
|
static IntBuffer |
toBuffer(int... arr)
Convert an array to a byte buffer
|
static INDArrayIndex[] |
toIndexes(int[] indices)
Convert the given int indexes
to nd array indexes
|
static INDArray |
toMmulCompatible(INDArray input)
This method is used in DL4J LSTM implementation
|
static INDArray |
toOffsetZero(INDArray arr)
Create a copy of the matrix
where the new offset is zero
|
static INDArray |
toOffsetZeroCopy(INDArray arr)
Create a copy of the ndarray where the new offset is zero
|
static INDArray |
toOffsetZeroCopy(INDArray arr,
char order)
Create a copy of the ndarray where the new offset is zero, and has specified order
|
static INDArray |
toOffsetZeroCopyAnyOrder(INDArray arr)
Create a copy of the ndarray where the new offset is zero.
|
static String |
toString(DataBuffer buffer)
To String for an int buffer
|
static String |
toString(IntBuffer buffer)
To String for an int buffer
|
static int |
underlyingRank(DataBuffer buffer) |
static int[] |
uniquify(int[] array) |
static boolean |
wholeArrayDimension(int... arr)
Returns true if the given array
is meant for the whole dimension
|
public static int[] getMaxShape(INDArray... inputs)
inputs
- the inputs to get the max shape forpublic static boolean shapeIsScalar(int[] shape)
shape
- the shape that is scalarpublic static boolean isPlaceholderShape(int[] shape)
shape
- the input shape to validatepublic static int[] getBroadcastDimensions(int[] left, int[] right)
left
- the left arrayright
- the right array (the array to be broadcastedpublic static int[] broadcastOutputShape(int[] left, int[] right)
left
- the left shaperight
- the right secondpublic static int[] resolveNegativeShapeIfNeccessary(int[] newShape, int[] shape)
newShape
- the new shape possibly
containing a negative numbershape
- the shape to calculate frompublic static boolean isWholeArray(int[] shape, int... dimension)
Integer.MAX_VALUE
shape
- the shape of the input arraydimension
- the dimensions specifiedInteger.MAX_VALUE
public static boolean isWholeArray(int rank, int... dimension)
Integer.MAX_VALUE
rank
- the rank of the input arraydimension
- the dimensions specifiedInteger.MAX_VALUE
public static int[] getReducedShape(int[] wholeShape, int[] dimensions)
wholeShape
- the shape of the array
with the reduce op being performeddimensions
- the dimensions the reduce op is being performed onpublic static int[] getReducedShape(int[] wholeShape, int[] dimensions, boolean keepDims, boolean newFormat)
wholeShape
- the shape of the array
with the reduce op being performeddimensions
- the dimensions the reduce op is being performed onkeepDims
- if set to true, corresponding dimensions will be set to 1public static int[] getMatrixMultiplyShape(int[] left, int[] right)
left
- the first matrix shape to multiplyright
- the second matrix shape to multiplypublic static INDArray toOffsetZero(INDArray arr)
arr
- the array to copy to offset 0public static INDArray toOffsetZeroCopy(INDArray arr)
arr
- the array to copy to offset 0public static INDArray toOffsetZeroCopy(INDArray arr, char order)
arr
- the array to copy to offset 0order
- the order of the returned arraypublic static INDArray toOffsetZeroCopyAnyOrder(INDArray arr)
arr
- NDArray to duplicatepublic static double getDouble(INDArray arr, int... indices)
arr
- the array to retrieve the double fromindices
- the indices to iterate overpublic static void iterate(INDArray arr, CoordinateFunction coordinateFunction)
arr
- the first arraycoordinateFunction
- the coordinate function to usepublic static void iterate(INDArray arr, INDArray arr2, CoordinateFunction coordinateFunction)
arr
- the first arrayarr2
- the second arraycoordinateFunction
- the coordinate function to usepublic static void iterate(int dimension, int n, int[] size, int[] res, int dimension2, int n2, int[] size2, int[] res2, CoordinateFunction func)
dimension
- n
- size
- res
- dimension2
- n2
- size2
- res2
- func
- public static void iterate(int dimension, int n, int[] size, int[] res, CoordinateFunction func)
dimension
- n
- size
- public static long getOffset(long baseOffset, int[] shape, int[] stride, int... indices)
baseOffset
- the offset to start fromshape
- the shape of the arraystride
- the stride of the arrayindices
- the indices to iterate overpublic static long getOffset(IntBuffer shapeInformation, int... indices)
shapeInformation
- Shape information to get the offset forindices
- Indices array to get the offset for (must be same length as array rank)public static long getOffset(DataBuffer shapeInformation, int... indices)
shapeInformation
- Shape information to get the offset forindices
- Indices array to get the offset for (must be same length as array rank)public static long getOffset(int[] shapeInformation, int... indices)
public static long getOffset(DataBuffer shapeInformation, int row, int col)
shapeInformation
- Shape informationrow
- Row index to get the offset forcol
- Column index to get the offset forpublic static long getOffsetUnsafe(DataBuffer shapeInformation, int row, int col)
getOffset(DataBuffer, int, int)
but without input validation on array rankpublic static long getOffsetUnsafe(int[] shapeInformation, int row, int col)
public static long getOffset(IntBuffer shapeInformation, int row, int col)
shapeInformation
- Shape informationrow
- Row index to get the offset forcol
- Column index to get the offset forpublic static long getOffset(IntBuffer shapeInformation, int dim0, int dim1, int dim2)
shapeInformation
- Shape informationdim0
- Row index to get the offset fordim1
- Column index to get the offset fordim2
- dimension 2 index to get the offset forpublic static long getOffset(DataBuffer shapeInformation, int dim0, int dim1, int dim2)
shapeInformation
- Shape informationdim0
- Row index to get the offset fordim1
- Column index to get the offset fordim2
- dimension 2 index to get the offset forpublic static long getOffsetUnsafe(DataBuffer shapeInformation, int dim0, int dim1, int dim2)
getOffset(DataBuffer, int, int, int)
but without input validation on array rankpublic static long getOffsetUnsafe(int[] shapeInformation, int dim0, int dim1, int dim2)
public static long getOffset(IntBuffer shapeInformation, int dim0, int dim1, int dim2, int dim3)
shapeInformation
- Shape informationdim0
- Row index to get the offset fordim1
- Column index to get the offset fordim2
- dimension 2 index to get the offset fordim3
- dimension 3 index to get the offset forpublic static long getOffset(DataBuffer shapeInformation, int dim0, int dim1, int dim2, int dim3)
shapeInformation
- Shape informationdim0
- Row index to get the offset fordim1
- Column index to get the offset fordim2
- dimension 2 index to get the offset fordim3
- dimension 3 index to get the offset forpublic static long getOffsetUnsafe(DataBuffer shapeInformation, int dim0, int dim1, int dim2, int dim3)
public static long getOffsetUnsafe(int[] shapeInformation, int dim0, int dim1, int dim2, int dim3)
public static int[] sizeForAxes(int[] axes, int[] shape)
axes
- the axesshape
- the current shapepublic static boolean isVector(IntBuffer shapeInfo)
shapeInfo
- the shapeinfo to testpublic static boolean isVector(DataBuffer shapeInfo)
shapeInfo
- the shapeinfo to testpublic static boolean isVector(int[] shape)
shape
- the shape to testpublic static boolean isMatrix(IntBuffer shapeInfo)
shapeInfo
- whether the passed in shape is a matrixpublic static boolean isMatrix(DataBuffer shapeInfo)
shapeInfo
- whether the passed in shape is a matrixpublic static boolean isMatrix(int[] shape)
shape
- whether the passed in shape is a matrixpublic static int[] squeeze(int[] shape)
shape
- the shape to squeezepublic static boolean shapeEquals(int[] shape1, int[] shape2)
shape1
- the first shape for comparisonshape2
- the second shape for comparisonpublic static boolean scalarEquals(int[] shape1, int[] shape2)
shape1
- the first shape for comparisonshape2
- the second shape for comparisonpublic static boolean isRowVectorShape(DataBuffer shapeInfo)
shapeInfo
- the shape info to checkpublic static boolean isRowVectorShape(IntBuffer shapeInfo)
shapeInfo
- the shape info to checkpublic static boolean isRowVectorShape(int[] shape)
shape
- the shape to checkpublic static boolean isColumnVectorShape(int[] shape)
shape
- the shape to checkpublic static boolean isColumnVectorShape(long[] shape)
shape
- public static int[] ensureAtMinRowVector(int... shape)
shape
- the shape of the arraypublic static long getTADLength(int[] shape, int... dimensions)
public static int elementWiseStride(int[] shape, int[] stride, boolean isFOrder)
shape
- stride
- isFOrder
- public static INDArray newShapeNoCopy(INDArray arr, int[] newShape, boolean isFOrder)
arr
- the array to reshapenewShape
- the new shapeisFOrder
- whether the array will be fortran ordered or notpublic static boolean cOrFortranOrder(int[] shape, int[] stride, int elementStride)
shape
- the shape to infer bystride
- the stride to infer byelementStride
- the element stride to start atpublic static char getOrder(int[] shape, int[] stride, int elementStride)
shape
- the shape to infer bystride
- the stride to infer byelementStride
- the element stride to start atpublic static char getOrder(INDArray arr)
arr
- the array to get the
ordering forpublic static long sub2Ind(int[] shape, int[] indices)
shape
- the shape of the indexes to convertindices
- the index to convertpublic static int[] ind2sub(int[] shape, long index, long numIndices)
shape
- the shape of the dimensionsindex
- the index to mapnumIndices
- the number of total indices (typically prod of shape(public static int[] ind2sub(int[] shape, long index)
shape
- the shape of the dimensionsindex
- the index to mappublic static int[] ind2sub(INDArray arr, long index)
arr
- the array to compute the indexes
based onindex
- the index to mappublic static int[] ind2subC(int[] shape, long index, long numIndices)
shape
- the shape of the dimensionsindex
- the index to mapnumIndices
- the number of total indices (typically prod of shape(public static int[] ind2subC(int[] shape, long index)
shape
- the shape of the dimensionsindex
- the index to mappublic static int[] ind2subC(INDArray arr, long index)
arr
- the array to compute the indexes
based onindex
- the index to mappublic static long offsetFor(INDArray arr, int[] indexes)
arr
- the array to compute the offset forindexes
- the indexes along each dimension to create the offset forpublic static void assertShapeLessThan(int[] shape, int[] lessThan)
shape
- the shape to checklessThan
- the shape to assert againstpublic static INDArrayIndex[] toIndexes(int[] indices)
indices
- the indices to convertpublic static int[] newStrides(int[] strides, int newLength, INDArrayIndex[] indexes)
public static boolean strideDescendingCAscendingF(INDArray array)
public static int length(IntBuffer buffer)
buffer
- the buffer to get the rank forpublic static int length(DataBuffer buffer)
buffer
- the buffer to get the rank forpublic static int rank(DataBuffer buffer)
buffer
- the buffer to get the rank forpublic static int rank(IntBuffer buffer)
buffer
- the buffer to get the rank forpublic static int rank(int[] buffer)
public static int size(IntBuffer buffer, int dimension)
buffer
- The buffer to get thedimension
- The dimension to get.public static int size(DataBuffer buffer, int dimension)
buffer
- The buffer to get the shape fromdimension
- The dimension to get.public static int size(int[] buffer, int dimension)
public static int sizeUnsafe(DataBuffer buffer, int dimension)
buffer
- The buffer to get the shape fromdimension
- The dimension to get.public static int sizeUnsafe(int[] buffer, int dimension)
public static int[] shape(IntBuffer buffer)
buffer
- Buffer to get the shape frompublic static int[] shape(DataBuffer buffer)
buffer
- Buffer to get the shape frompublic static int[] shape(int[] buffer)
buffer
- Buffer to get the shape frompublic static int stride(IntBuffer buffer, int dimension)
buffer
- The buffer to get the stride fromdimension
- The dimension to get.public static int stride(DataBuffer buffer, int dimension)
buffer
- The buffer to get the stride fromdimension
- The dimension to get.public static int stride(int[] buffer, int dimension)
public static int[] strideArr(DataBuffer buffer)
buffer
- Buffer to get the shape frompublic static int strideUnsafe(DataBuffer buffer, int dimension, int rank)
buffer
- The buffer to get the stride fromdimension
- The dimension to get.rank
- Rank of the arraypublic static int strideUnsafe(int[] buffer, int dimension, int rank)
public static int shapeInfoLength(int rank)
rank
- the rank to get the length forpublic static IntBuffer stride(IntBuffer buffer)
buffer
- public static DataBuffer stride(DataBuffer buffer)
buffer
- the buffer to get the shape information forpublic static int[] stride(int[] buffer)
public static DataBuffer shapeOf(DataBuffer buffer)
buffer
- the buffer to get the shape information forpublic static IntBuffer shapeOf(IntBuffer buffer)
buffer
- the buffer to get the shape information forpublic static int[] shapeOf(int[] buffer)
public static int[] stridesOf(int[] buffer)
public static int[] flags(DataBuffer buffer)
public static int[] sparseOffsets(DataBuffer buffer)
public static int[] hiddenDimension(DataBuffer buffer)
public static int underlyingRank(DataBuffer buffer)
public static String shapeToString(INDArray arr)
arr
- the shape information to printpublic static String shapeToString(IntBuffer buffer)
buffer
- the shape information to print@Deprecated public static int offset(DataBuffer buffer)
buffer
- the shape info buffer to get the offset for@Deprecated public static int offset(int[] buffer)
buffer
- public static int offset(IntBuffer buffer)
buffer
- the shape info buffer to get the offset forpublic static int elementWiseStride(DataBuffer buffer)
buffer
- the buffer to get the element
wise stride frompublic static int elementWiseStride(IntBuffer buffer)
buffer
- the buffer to get the element
wise stride frompublic static void setElementWiseStride(IntBuffer buffer, int elementWiseStride)
buffer
- the buffer to get the element
wise stride frompublic static void setElementWiseStride(DataBuffer buffer, int elementWiseStride)
buffer
- the buffer to get the element
wise stride frompublic static String bufferToString(IntBuffer buffer)
IntBuffer
buffer
- the buffer to printpublic static char order(IntBuffer buffer)
buffer
- the bufferpublic static char order(DataBuffer buffer)
buffer
- the bufferpublic static char order(int[] buffer)
@Deprecated public static void setOrder(IntBuffer buffer, char order)
buffer
- the bufferpublic static DataBuffer createShapeInformation(int[] shape, int[] stride, long offset, int elementWiseStride, char order)
shape
- the shape for the bufferstride
- the stride for the bufferoffset
- the offset for the bufferelementWiseStride
- the element wise stride for the bufferorder
- the order for the bufferpublic static DataBuffer createSparseInformation(int[] flags, long[] sparseOffsets, int[] hiddenDimensions, int underlyingRank)
public static IntBuffer toBuffer(int... arr)
arr
- the arraypublic static String toString(IntBuffer buffer)
buffer
- public static String toString(DataBuffer buffer)
buffer
- public static boolean wholeArrayDimension(int... arr)
arr
- the array to testpublic static int[] uniquify(int[] array)
public static int[] normalizeAxis(int rank, int... axis)
public static boolean contentEquals(int[] arr, DataBuffer other)
arr
- the arrayother
- the bufferpublic static boolean contentEquals(int[] arr, IntBuffer other)
arr
- the arrayother
- the bufferpublic static boolean isContiguousInBuffer(INDArray in)
public static INDArray toMmulCompatible(INDArray input)
input
- public static int rankFromShape(int[] shape)
shape
- Shape to get the rank forND4JIllegalStateException
- If shape array is nullpublic static void assertBroadcastable(@NonNull INDArray x, @NonNull INDArray y)
public static void assertBroadcastable(@NonNull int[] x, @NonNull int[] y)
public static boolean areShapesBroadcastable(@NonNull int[] x, @NonNull int[] y)
public static boolean hasDefaultStridesForShape(INDArray input)
Copyright © 2018. All rights reserved.