Class OnnxMap

java.lang.Object
ai.onnxruntime.OnnxMap
All Implemented Interfaces:
OnnxValue, AutoCloseable

public class OnnxMap extends Object implements OnnxValue
A container for a map returned by OrtSession.run(Map).

Supported types are those mentioned in onnxruntime_c_api.h, keys: String and Long, values: String, Long, Float, Double.

  • Method Details

    • size

      public int size()
      The number of entries in the map.
      Returns:
      The number of entries.
    • getType

      public OnnxValue.OnnxValueType getType()
      Description copied from interface: OnnxValue
      Gets the type of this OnnxValue.
      Specified by:
      getType in interface OnnxValue
      Returns:
      The value type.
    • getValue

      public Map<? extends Object,? extends Object> getValue() throws OrtException
      Returns a weakly typed Map containing all the elements.
      Specified by:
      getValue in interface OnnxValue
      Returns:
      A map.
      Throws:
      OrtException - If the onnx runtime failed to read the entries.
    • getInfo

      public MapInfo getInfo()
      Description copied from interface: OnnxValue
      Gets the type info object associated with this OnnxValue.
      Specified by:
      getInfo in interface OnnxValue
      Returns:
      The type information.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isClosed

      public boolean isClosed()
      Description copied from interface: OnnxValue
      Checks if this value is closed (i.e., the native object has been released).
      Specified by:
      isClosed in interface OnnxValue
      Returns:
      True if the value is closed and the native object has been released.
    • close

      public void close()
      Closes this map, releasing the native memory backing it and it's elements.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface OnnxValue
    • checkClosed

      protected void checkClosed()
      Checks if the OnnxValue is closed, if so throws IllegalStateException.