Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Onnxruntime MapInfo: Difference between revisions

From Leeroopedia
Auto-imported from implementations/Microsoft_Onnxruntime_MapInfo.md
 
Sync from local file
 
Line 96: Line 96:


== Related Pages ==
== Related Pages ==
* [[Microsoft_Onnxruntime_OnnxMap|OnnxMap.java]] - The map value container described by MapInfo
* [[Implementation:Microsoft_Onnxruntime_OnnxMap|OnnxMap.java]] - The map value container described by MapInfo
* [[Microsoft_Onnxruntime_NodeInfo|NodeInfo.java]] - Node information that wraps MapInfo
* [[Implementation:Microsoft_Onnxruntime_NodeInfo|NodeInfo.java]] - Node information that wraps MapInfo
* [[Microsoft_Onnxruntime_OnnxJavaType|OnnxJavaType.java]] - Type enum used for key and value types
* [[Implementation:Microsoft_Onnxruntime_OnnxJavaType|OnnxJavaType.java]] - Type enum used for key and value types


[[Category:Implementations]]
[[Category:Implementations]]


[[Category:Implementations]]
[[Category:Implementations]]

Latest revision as of 10:46, 27 September 2026


Knowledge Sources Description
Source File java/src/main/java/ai/onnxruntime/MapInfo.java
Repository Microsoft/onnxruntime

Domains

  • Machine Learning Runtime
  • Type Metadata

Overview

MapInfo describes an OnnxMap object or map-typed output node. It implements the ValueInfo interface and stores the number of entries, the key type, and the value type. It is constructed from JNI using native ONNX tensor type integers, or from Java-side OnnxJavaType values.

Description

The class has three public final fields:

  • size: The number of entries in the map (-1 when unknown, e.g., for model output type info).
  • keyType: The OnnxJavaType of the keys (typically STRING or INT64).
  • valueType: The OnnxJavaType of the values (typically STRING, INT64, FLOAT, or DOUBLE).

Three constructors exist: one taking OnnxJavaType key/value types (size unknown), one adding size, and one using native integer type identifiers (called from JNI).

Code Reference

Source Location

// File: java/src/main/java/ai/onnxruntime/MapInfo.java
// Package: ai.onnxruntime

Signature

public class MapInfo implements ValueInfo {
    public final int size;
    public final OnnxJavaType keyType;
    public final OnnxJavaType valueType;

    MapInfo(OnnxJavaType keyType, OnnxJavaType valueType);
    MapInfo(int size, OnnxJavaType keyType, OnnxJavaType valueType);
    MapInfo(int size, int keyTypeInt, int valueTypeInt);  // called from JNI
}

Import

import ai.onnxruntime.MapInfo;

I/O Contract

Inputs

Name Type Description
size int Number of entries (-1 if unknown)
keyType OnnxJavaType or int The key type (STRING or INT64)
valueType OnnxJavaType or int The value type (STRING, INT64, FLOAT, or DOUBLE)

Outputs

Name Type Description
size int Number of map entries
keyType OnnxJavaType The Java key type
valueType OnnxJavaType The Java value type

Usage Examples

import ai.onnxruntime.*;
import java.util.*;

OrtEnvironment env = OrtEnvironment.getEnvironment();
try (OrtSession session = env.createSession("/path/to/model.onnx")) {
    // Inspect map output info
    Map<String, NodeInfo> outputInfo = session.getOutputInfo();
    for (Map.Entry<String, NodeInfo> entry : outputInfo.entrySet()) {
        ValueInfo info = entry.getValue().getInfo();
        if (info instanceof MapInfo) {
            MapInfo mapInfo = (MapInfo) info;
            System.out.println("Output '" + entry.getKey() + "' is a map:");
            System.out.println("  Key type: " + mapInfo.keyType);
            System.out.println("  Value type: " + mapInfo.valueType);
        }
    }
}

Related Pages