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

From Leeroopedia


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

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment