Package com.yahoo.tensor
Class TensorType.Builder
- java.lang.Object
-
- com.yahoo.tensor.TensorType.Builder
-
- Enclosing class:
- TensorType
public static class TensorType.Builder extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Builder()
Creates an empty builder with cells of type doubleBuilder(boolean allowDifferentSizes, TensorType... types)
Builder(TensorType.Value valueType)
Builder(TensorType.Value valueType, java.lang.Iterable<TensorType.Dimension> dimensions)
Creates a builder from the given value type and dimensionsBuilder(TensorType... types)
Creates a builder containing a combination of the dimensions of the given types If the same dimension is indexed with different size restrictions the smallest size will be used.Builder(java.lang.Iterable<TensorType.Dimension> dimensions)
Creates a builder from the given dimensions, having double as the value type
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TensorType
build()
TensorType.Builder
dimension(TensorType.Dimension dimension)
Adds the given dimensionTensorType.Builder
dimension(java.lang.String name, TensorType.Dimension.Type type)
java.util.Optional<TensorType.Dimension>
getDimension(java.lang.String dimension)
Returns the given dimension, or empty if none is presentTensorType.Builder
indexed(java.lang.String name)
Adds an unbound indexed dimension to thisTensorType.Builder
indexed(java.lang.String name, long size)
Adds a bound indexed dimension to thisTensorType.Builder
mapped(java.lang.String name)
Adds a mapped dimension to thisint
rank()
Returns the current number of dimensions in thisTensorType.Builder
set(TensorType.Dimension dimension)
Adds or replaces a dimension in this
-
-
-
Constructor Detail
-
Builder
public Builder()
Creates an empty builder with cells of type double
-
Builder
public Builder(TensorType.Value valueType)
-
Builder
public Builder(TensorType... types)
Creates a builder containing a combination of the dimensions of the given types If the same dimension is indexed with different size restrictions the smallest size will be used. If it is size restricted in one argument but not the other it will not be size restricted. If it is indexed in one and mapped in the other it will become mapped. The value type will be the largest of the value types of the input types
-
Builder
public Builder(boolean allowDifferentSizes, TensorType... types)
-
Builder
public Builder(java.lang.Iterable<TensorType.Dimension> dimensions)
Creates a builder from the given dimensions, having double as the value type
-
Builder
public Builder(TensorType.Value valueType, java.lang.Iterable<TensorType.Dimension> dimensions)
Creates a builder from the given value type and dimensions
-
-
Method Detail
-
rank
public int rank()
Returns the current number of dimensions in this
-
set
public TensorType.Builder set(TensorType.Dimension dimension)
Adds or replaces a dimension in this
-
indexed
public TensorType.Builder indexed(java.lang.String name, long size)
Adds a bound indexed dimension to this- Throws:
java.lang.IllegalArgumentException
- if the dimension is already present
-
indexed
public TensorType.Builder indexed(java.lang.String name)
Adds an unbound indexed dimension to this- Throws:
java.lang.IllegalArgumentException
- if the dimension is already present
-
mapped
public TensorType.Builder mapped(java.lang.String name)
Adds a mapped dimension to this- Throws:
java.lang.IllegalArgumentException
- if the dimension is already present
-
dimension
public TensorType.Builder dimension(TensorType.Dimension dimension)
Adds the given dimension
-
getDimension
public java.util.Optional<TensorType.Dimension> getDimension(java.lang.String dimension)
Returns the given dimension, or empty if none is present
-
dimension
public TensorType.Builder dimension(java.lang.String name, TensorType.Dimension.Type type)
-
build
public TensorType build()
-
-