public class TensorShape
extends java.lang.Object
Constructor and Description |
---|
TensorShape(long[] shape) |
Modifier and Type | Method and Description |
---|---|
static long[] |
calculateShapeForLengthOneBroadcast(long[] shape1,
long[] shape2) |
static long[] |
concat(long[] shape1,
long[] shape2) |
static int[] |
dimensionRange(int fromDimension,
int toDimension) |
boolean |
equals(java.lang.Object o) |
static int |
getAbsoluteDimension(int dimension,
int rank)
Finds the absolute dimension for a shape
|
static int[] |
getAbsoluteDimensions(int rank,
int[] dimensions)
It's possible to express negative dimensions, which are relative to the rank of a
tensor.
|
static long |
getFlatIndex(long[] shape,
long[] stride,
long... index) |
static long |
getLength(long[] shape) |
static int |
getLengthAsInt(long[] shape) |
int |
getRank() |
static long[] |
getRowFirstStride(long[] shape) |
long[] |
getShape() |
static long[] |
getShapeIndices(long[] shape,
long[] stride,
long flatIndex)
This method can be interpreted as the opposite to getFlatIndex.
|
int |
hashCode() |
boolean |
isLengthOne() |
static boolean |
isLengthOne(long[] shape) |
boolean |
isScalar() |
static boolean |
isScalar(long[] shape) |
static long[] |
removeDimension(int dimension,
long[] shape)
Removes a dimension from a shape.
|
static long[] |
selectDimensions(int from,
int to,
long[] shape) |
static long[] |
shapeDesiredToRankByAppendingOnes(long[] lowRankTensorShape,
int desiredRank) |
static long[] |
shapeToDesiredRankByPrependingOnes(long[] lowRankTensorShape,
int desiredRank) |
public long[] getShape()
public boolean isScalar()
public boolean isLengthOne()
public int getRank()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public static long getLength(long[] shape)
shape
- for finding length ofpublic static int getLengthAsInt(long[] shape)
public static long[] getRowFirstStride(long[] shape)
shape
- shape to find stride forpublic static long getFlatIndex(long[] shape, long[] stride, long... index)
shape
- shape to find the index forstride
- stride to find the index forindex
- the index in each dimensionpublic static long[] getShapeIndices(long[] shape, long[] stride, long flatIndex)
shape
- the shape to find the index ofstride
- the stride to find the index offlatIndex
- the index to fpublic static boolean isScalar(long[] shape)
public static boolean isLengthOne(long[] shape)
public static long[] concat(long[] shape1, long[] shape2)
public static int[] dimensionRange(int fromDimension, int toDimension)
fromDimension
- starting from and including this dimensiontoDimension
- up to but excluding this dimensionpublic static long[] selectDimensions(int from, int to, long[] shape)
public static long[] shapeDesiredToRankByAppendingOnes(long[] lowRankTensorShape, int desiredRank)
public static long[] shapeToDesiredRankByPrependingOnes(long[] lowRankTensorShape, int desiredRank)
public static long[] calculateShapeForLengthOneBroadcast(long[] shape1, long[] shape2)
public static int[] getAbsoluteDimensions(int rank, int[] dimensions)
rank
- the rank that the dimension array is related todimensions
- positive dimensions are absolute and negative are relative to the rankpublic static long[] removeDimension(int dimension, long[] shape)
dimension
- the dimension to removeshape
- the shape to remove the dimension fromjava.lang.IllegalArgumentException
- if the dimension does not existpublic static int getAbsoluteDimension(int dimension, int rank)
dimension
- the negative or positive dimension to find the absolute ofrank
- the rank