Class Tensor

java.lang.Object
smile.onnx.genai.Tensor
All Implemented Interfaces:
AutoCloseable

public final class Tensor extends Object implements AutoCloseable
Thin GenAI tensor wrapper for Generator.setModelInput(String, Tensor) / multimodal inputs.

Element-type ordinals match OgaElementType / ONNX tensor element types.

  • Method Details

    • of

      public static Tensor of(ByteBuffer data, long[] shape, Tensor.ElementType elementType)
      Creates a tensor from a direct native-order ByteBuffer.
      Parameters:
      data - direct buffer with native byte order; kept reachable.
      shape - tensor shape.
      elementType - element type.
      Returns:
      tensor owned by the caller.
    • type

      public Tensor.ElementType type()
      Returns the element type.
      Returns:
      element type.
    • shape

      public long[] shape()
      Returns a copy of the shape.
      Returns:
      shape.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable