Module tornado.api

Record Class Shape

java.lang.Object
java.lang.Record
uk.ac.manchester.tornado.api.types.tensors.Shape

public record Shape(long[] dimensions) extends Record
  • Constructor Summary

    Constructors
    Constructor
    Description
    Shape(long... dimensions)
    Creates an instance of a Shape record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    long[]
    Returns the value of the dimensions record component.
    boolean
    Indicates whether some other object is "equal to" this one.
    long[]
    Returns of the dimensions of the shape.
    int
    Returns the rank of the shape, which is the number of dimensions.
    int
    Calculates and returns the size of the shape, which is the product of all its dimensions.
    int
    Returns a hash code value for this object.
    Generates a string representation of the shape compatible with ONNX's shape format.
    Returns a string representation of this record class.
    Generates a string representation of the shape compatible with TensorFlow's shape format.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Shape

      public Shape(long... dimensions)
      Creates an instance of a Shape record class.
      Parameters:
      dimensions - the value for the dimensions record component
  • Method Details

    • getRank

      public int getRank()
      Returns the rank of the shape, which is the number of dimensions.
      Returns:
      the number of dimensions of the shape
    • getDimensions

      public long[] getDimensions()
      Returns of the dimensions of the shape.
      Returns:
      an array of long values representing the dimensions of the shape
    • getSize

      public int getSize()
      Calculates and returns the size of the shape, which is the product of all its dimensions.
      Returns:
      the total size of the shape as an int
    • equals

      public 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.
    • hashCode

      public 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
    • 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
    • toTensorFlowShapeString

      public String toTensorFlowShapeString()
      Generates a string representation of the shape compatible with TensorFlow's shape format.
      Returns:
      a string representing the shape in TensorFlow's format
    • toONNXShapeString

      public String toONNXShapeString()
      Generates a string representation of the shape compatible with ONNX's shape format.
      Returns:
      a string representing the shape in ONNX's format
    • dimensions

      public long[] dimensions()
      Returns the value of the dimensions record component.
      Returns:
      the value of the dimensions record component