Record Class TensorInfo

java.lang.Object
java.lang.Record
smile.onnx.TensorInfo
Record Components:
elementType - the element data type of the tensor.
shape - the shape of the tensor. Each element is the size of that dimension, or -1 for a dynamic dimension.
symbolicDimensions - optional symbolic names for each dimension (may be null or contain null entries for unnamed dimensions).

public record TensorInfo(ElementType elementType, long[] shape, String[] symbolicDimensions) extends Record
Describes the type and shape of a tensor.

A dimension value of -1 indicates a dynamic (symbolic) dimension whose size is not known until runtime.

  • Constructor Details

    • TensorInfo

      public TensorInfo(ElementType elementType, long[] shape)
      Constructor without symbolic dimension names.
      Parameters:
      elementType - the element data type.
      shape - the shape of the tensor.
    • TensorInfo

      public TensorInfo(ElementType elementType, long[] shape, String[] symbolicDimensions)
      Creates an instance of a TensorInfo record class.
      Parameters:
      elementType - the value for the elementType record component
      shape - the value for the shape record component
      symbolicDimensions - the value for the symbolicDimensions record component
  • Method Details

    • rank

      public int rank()
      Returns the number of dimensions (rank) of this tensor.
      Returns:
      the rank.
    • elementCount

      public long elementCount()
      Returns the total number of elements in the tensor, or -1 if any dimension is dynamic.
      Returns:
      the total element count, or -1.
    • isDynamic

      public boolean isDynamic()
      Returns true if the tensor has any dynamic dimensions.
      Returns:
      true if any dimension is -1.
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • elementType

      public ElementType elementType()
      Returns the value of the elementType record component.
      Returns:
      the value of the elementType record component
    • shape

      public long[] shape()
      Returns the value of the shape record component.
      Returns:
      the value of the shape record component
    • symbolicDimensions

      public String[] symbolicDimensions()
      Returns the value of the symbolicDimensions record component.
      Returns:
      the value of the symbolicDimensions record component