Package com.yahoo.tensor
Class TensorType
java.lang.Object
com.yahoo.tensor.TensorType
A tensor type with its dimensions. This is immutable.
A dimension can be indexed (bound or unbound) or mapped.
- Author:
- geirst, bratseth
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
static class
A tensor dimension.static class
static class
static class
static enum
The permissible cell value types. -
Field Summary
Modifier and TypeFieldDescriptionstatic final TensorType
The empty tensor type - which is the same as a double -
Constructor Summary
ConstructorDescriptionTensorType
(TensorType.Value valueType, Collection<TensorType.Dimension> dimensions) -
Method Summary
Modifier and TypeMethodDescriptionstatic TensorType.Value
combinedValueType
(TensorType... types) Returns the dimension with this name, or empty if not presentReturns an immutable set of the names of the dimensions of thisReturns an immutable list of the dimensions of thisReturns the dimensionwise generalization of this and the given type, or empty if no generalization exists.boolean
static TensorType
Returns a tensor type instance from a tensor type spec:tensor(dimension1, dimension2, ...)
where each dimension is eitherdimension-name[]
- an unbound indexed dimensiondimension-name[int]
- an bound indexed dimensiondimension-name{}
- a mapped dimension Example:tensor(x[10],y[20])
(a matrix)int
hashCode()
boolean
boolean
boolean
The type representing the indexed subset of dimensions of this.indexOfDimension
(String dimension) Returns the 0-base index of this dimension, or empty if it is not presentint
indexOfDimensionAsInt
(String dimension) Returns the 0-base index of this dimension, or empty if it is not presentboolean
isAssignableTo
(TensorType generalization) Returns whether this type can be assigned to the given type, i.e if the given type is a generalization of this type.boolean
isConvertibleTo
(TensorType generalization) Returns whether this type can be converted to the given type.boolean
isRenamableTo
(TensorType other) Returns whether this type can simply be renamed to the given type.The type representing the mapped subset of dimensions of this.boolean
mathematicallyEquals
(TensorType other) Returns whether the given type has the same dimension names as thisint
rank()
Returns the number of dimensions of this: dimensions().size()sizeOfDimension
(String dimension) toString()
Returns the numeric type of the cell values of this
-
Field Details
-
empty
The empty tensor type - which is the same as a double
-
-
Constructor Details
-
TensorType
-
-
Method Details
-
hasIndexedDimensions
public boolean hasIndexedDimensions() -
hasMappedDimensions
public boolean hasMappedDimensions() -
hasOnlyIndexedBoundDimensions
public boolean hasOnlyIndexedBoundDimensions() -
combinedValueType
-
fromSpec
Returns a tensor type instance from a tensor type spec:tensor(dimension1, dimension2, ...)
where each dimension is eitherdimension-name[]
- an unbound indexed dimensiondimension-name[int]
- an bound indexed dimensiondimension-name{}
- a mapped dimension
tensor(x[10],y[20])
(a matrix) -
valueType
Returns the numeric type of the cell values of this -
mappedSubtype
The type representing the mapped subset of dimensions of this. -
indexedSubtype
The type representing the indexed subset of dimensions of this. -
rank
public int rank()Returns the number of dimensions of this: dimensions().size() -
dimensions
Returns an immutable list of the dimensions of this -
dimensionNames
Returns an immutable set of the names of the dimensions of this -
dimension
Returns the dimension with this name, or empty if not present -
indexOfDimension
Returns the 0-base index of this dimension, or empty if it is not present -
indexOfDimensionAsInt
Returns the 0-base index of this dimension, or empty if it is not present -
sizeOfDimension
-
isAssignableTo
Returns whether this type can be assigned to the given type, i.e if the given type is a generalization of this type. -
isConvertibleTo
Returns whether this type can be converted to the given type. This is true if this type isAssignableTo the given type or if it is not assignable only because it has a shorter dimension length than the given type in some shared dimension(s), as it can then be converted to the given type by zero padding. -
isRenamableTo
Returns whether this type can simply be renamed to the given type. This is the same as being assignable, but disregarding dimension names. -
toString
-
equals
-
mathematicallyEquals
Returns whether the given type has the same dimension names as this -
dimensionwiseGeneralizationWith
Returns the dimensionwise generalization of this and the given type, or empty if no generalization exists. A dimensionwise generalization exists if the two tensors share the same dimensions, and each dimension is compatible. For example, the dimensionwise generalization of tensor(x[],y[5]) and tensor(x[5],y[]) is tensor(x[],y[]) -
hashCode
public int hashCode()
-