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 long |
convertFromFlatIndexToPermutedFlatIndex(long fromFlatIndex,
long[] shape,
long[] stride,
long[] permutedShape,
long[] permutedStride,
int[] rearrange) |
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 long |
getBroadcastedFlatIndex(long fromFlatIndex,
long[] fromStride,
long[] toShape,
long[] toStride) |
static long[] |
getBroadcastResultShape(long[] left,
long[] right) |
static long[] |
getConcatResultShape(int dimension,
Tensor... toConcat) |
static long |
getFlatIndex(long[] shape,
long[] stride,
long... index) |
static long |
getLength(long[] shape) |
static int |
getLengthAsInt(long[] shape) |
static int[] |
getPermutationForDimensionToDimensionZero(int dimension,
long[] shape) |
static long[] |
getPermutedIndices(long[] indices,
int... rearrange) |
int |
getRank() |
static long[] |
getReductionResultShape(long[] inputShape,
int[] sumOverDimensions) |
static long[] |
getReshapeAllowingWildcard(long[] oldShape,
long oldShapeLength,
long[] newShape) |
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() |
static boolean |
incrementIndexByShape(long[] shape,
long[] index,
int[] dimensionOrder) |
static int[] |
invertedPermute(int[] rearrange) |
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 int[] |
setToAbsoluteDimensions(int rank,
int[] dimensions)
It's possible to express negative dimensions, which are relative to the rank of a
tensor.
|
static long[] |
shapeDesiredToRankByAppendingOnes(long[] lowRankTensorShape,
int desiredRank) |
static long[] |
shapeToDesiredRankByPrependingOnes(long[] lowRankTensorShape,
int desiredRank) |
static int[] |
slideDimension(int from,
int to,
int rank) |
public long[] getShape()
public boolean isScalar()
public boolean isLengthOne()
public int getRank()
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic 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 int[] slideDimension(int from,
int to,
int rank)
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 long[] getBroadcastResultShape(long[] left,
long[] right)
public static int[] setToAbsoluteDimensions(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 rankpublic static long[] getReductionResultShape(long[] inputShape,
int[] sumOverDimensions)
public static long[] getPermutedIndices(long[] indices,
int... rearrange)
public static int[] invertedPermute(int[] rearrange)
public static long convertFromFlatIndexToPermutedFlatIndex(long fromFlatIndex,
long[] shape,
long[] stride,
long[] permutedShape,
long[] permutedStride,
int[] rearrange)
public static long[] getReshapeAllowingWildcard(long[] oldShape,
long oldShapeLength,
long[] newShape)
oldShape - The original shape to reshape from. This should have a shape length that
matches oldShapeLengtholdShapeLength - The length of the old shape. e.g shape = [2, 2] then the length is 4newShape - A shape that must be the same length as oldShape unless a single -1 dimension length
is specified. If -1 is used then a dimension length will be calculated in order to ensure
the new shape length is equal to the old shape length.public static long[] getConcatResultShape(int dimension,
Tensor... toConcat)
public static int[] getPermutationForDimensionToDimensionZero(int dimension,
long[] shape)
public static long getBroadcastedFlatIndex(long fromFlatIndex,
long[] fromStride,
long[] toShape,
long[] toStride)
public static boolean incrementIndexByShape(long[] shape,
long[] index,
int[] dimensionOrder)