Class TensorType

java.lang.Object
com.linkedin.feathr.common.tensor.TensorType
All Implemented Interfaces:
Serializable

public final class TensorType extends Object implements Serializable
Type definition for a TypedTensor, defines the value type, dimension types and dimension names.
See Also:
  • Field Details

  • Constructor Details

    • TensorType

      public TensorType(ValueType valueType, List<DimensionType> dimensionTypes)
      Create a SPARSE tensor type with default local names for dimensions.
      Parameters:
      valueType - the type of the value contained in the tensor.
      dimensionTypes - a sequence of types for all dimensions of the tensor (can be empty). Dimension names will default to names taken from dimensionTypes.
    • TensorType

      public TensorType(ValueType valueType, List<DimensionType> dimensionTypes, List<String> dimensionNames)
      Create a SPARSE tensor type.
      Parameters:
      valueType - the type of the value contained in the tensor.
      dimensionTypes - a sequence of types for all dimensions of the tensor (can be empty).
      dimensionNames - are local to the TensorType, allowing to differentiate between multiple instances of the same dimension type, for example, x used for both viewer and viewee. If null, defaults to names taken from dimensionTypes.
    • TensorType

      public TensorType(TensorCategory tensorCategory, ValueType valueType, List<DimensionType> dimensionTypes, List<String> dimensionNames)
      Parameters:
      tensorCategory - the category of the tensor type, such as dense, sparse, etc. NOTE: at the moment this is stored as is, and no additional validation is guaranteed (such as choosing the right tensor builder based on the tensor category).
      valueType - the type of the value contained in the tensor.
      dimensionTypes - a sequence of types for all dimensions of the tensor (can be empty).
      dimensionNames - are local to the TensorType, allowing to differentiate between multiple instances of the same dimension type, for example, x used for both viewer and viewee. If null, defaults to names taken from dimensionTypes.
    • TensorType

      public TensorType(TensorCategory tensorCategory, ValueType valueType, List<DimensionType> dimensionTypes)
      Parameters:
      tensorCategory - the category of the tensor type, such as dense, sparse, etc. NOTE: at the moment this is stored as is, and no additional validation is guaranteed (such as choosing the right tensor builder based on the tensor category).
      valueType - the type of the value contained in the tensor.
      dimensionTypes - a sequence of types for all dimensions of the tensor (can be empty).
  • Method Details

    • getTensorCategory

      public TensorCategory getTensorCategory()
      Returns:
      the category of this tensor. NOTE: only use in context of the FDS until adopted elsewhere. This defaults to SPARSE if not specified in constructor.
    • getValueType

      public ValueType getValueType()
    • getDimensionTypes

      public List<DimensionType> getDimensionTypes()
    • getDimensionNames

      public List<String> getDimensionNames()
    • getColumnTypes

      public Representable[] getColumnTypes()
      WARNING: this returns primitive representations, not DimensionType/ValueType.
      Returns:
      Dimension types followed by a value type.
    • setDimensions

      public void setDimensions(WriteableTuple target, Object[] dimensions)
    • getShape

      public int[] getShape()
    • getDenseSize

      public int getDenseSize()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object