Package com.yahoo.tensor
Class MixedTensor
java.lang.Object
com.yahoo.tensor.MixedTensor
- All Implemented Interfaces:
Tensor
A mixed tensor type. This is class is currently suitable for serialization
and deserialization, not yet for computation.
A mixed tensor has a combination of mapped and indexed dimensions. By
reordering the mapped dimensions before the indexed dimensions, one can
think of mixed tensors as the mapped dimensions mapping to a
dense tensor. This dense tensor is called a dense subspace.
- Author:
- lesters
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder for mixed tensors with bound indexed dimensions.static class
Base class for building mixed tensors.static class
Temporarily stores all cells to find bounds of indexed dimensions, then creates a tensor using BoundBuilder.Nested classes/interfaces inherited from interface com.yahoo.tensor.Tensor
Tensor.Cell
-
Method Summary
Modifier and TypeMethodDescriptionReturns an iterator over the cells of this tensor.cells()
Returns an immutable map of the cells of this in no particular order.static TensorType
createPartialType
(TensorType.Value valueType, List<TensorType.Dimension> dimensions) long
Returns the size of dense subspacesboolean
Returns whether this tensor and the given tensor is mathematically equal: That they have the same dimension *names* and the same content.double
get
(TensorAddress address) Returns the value at the given addressboolean
has
(TensorAddress address) Returns true if this cell existsint
hashCode()
Returns a hash computed deterministically from the content of this tensorremove
(Set<TensorAddress> addresses) Returns a new tensor where existing cells in this tensor have been removed according to the given set of addresses.long
size()
Returns the size of the tensor measured in number of cellsReturns an abbreviated string representation of this tensor suitable for human-readable messagestoString()
Returns this tensor on the tensor literal form with type included.type()
Returns the tensor typeReturns an iterator over the values of this tensor.withType
(TensorType other) Returns this tensor with the given type if types are compatibleMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.yahoo.tensor.Tensor
add, approxEqual, argmax, argmin, asDouble, atan2, avg, avg, avg, bit, cellCast, concat, concat, count, count, count, divide, equal, expand, fmod, hamming, isEmpty, join, l1Normalize, l2Normalize, larger, largerOrEqual, largest, ldexp, map, matmul, max, max, max, max, median, median, median, merge, min, min, min, min, modify, multiply, notEqual, pow, prod, prod, prod, reduce, reduce, rename, rename, smaller, smallerOrEqual, smallest, softmax, subtract, sum, sum, sum, xwPlusB
-
Method Details
-
type
Returns the tensor type -
size
public long size()Returns the size of the tensor measured in number of cells -
get
Returns the value at the given address -
has
Description copied from interface:Tensor
Returns true if this cell exists -
cellIterator
Returns an iterator over the cells of this tensor. Cells are returned in order of increasing indexes in the indexed dimensions, increasing indexes of later dimensions in the dimension type before earlier. No guarantee is given for the order of sparse dimensions.- Specified by:
cellIterator
in interfaceTensor
-
valueIterator
Returns an iterator over the values of this tensor. The iteration order is the same as for cellIterator.- Specified by:
valueIterator
in interfaceTensor
-
cells
Description copied from interface:Tensor
Returns an immutable map of the cells of this in no particular order. This may be expensive for some implementations - avoid when possible -
withType
Description copied from interface:Tensor
Returns this tensor with the given type if types are compatible -
remove
Description copied from interface:Tensor
Returns a new tensor where existing cells in this tensor have been removed according to the given set of addresses. Only valid for sparse or mixed tensors. For mixed tensors, addresses are assumed to only contain the sparse dimensions, as the entire dense subspace is removed. -
hashCode
public int hashCode()Description copied from interface:Tensor
Returns a hash computed deterministically from the content of this tensor -
toString
Description copied from interface:Tensor
Returns this tensor on the tensor literal form with type included. -
toShortString
Description copied from interface:Tensor
Returns an abbreviated string representation of this tensor suitable for human-readable messages- Specified by:
toShortString
in interfaceTensor
-
equals
Description copied from interface:Tensor
Returns whether this tensor and the given tensor is mathematically equal: That they have the same dimension *names* and the same content. -
denseSubspaceSize
public long denseSubspaceSize()Returns the size of dense subspaces -
createPartialType
public static TensorType createPartialType(TensorType.Value valueType, List<TensorType.Dimension> dimensions)
-