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 NodeInfo

From Leeroopedia


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

Domains

  • Machine Learning Runtime
  • Model Graph Metadata

Overview

NodeInfo holds the information for a single input or output node from an ONNX model. It wraps a name and a ValueInfo object (which can be a TensorInfo, MapInfo, or SequenceInfo). Instances are constructed from native code and returned by OrtSession.getInputInfo() and OrtSession.getOutputInfo().

Description

The class has two fields:

  • name: The name of the input or output node.
  • info: A ValueInfo instance describing the type and shape. Note that MapInfo and SequenceInfo instances returned from model inspection may have insufficient detail since full type information is only available with example data.

Code Reference

Source Location

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

Signature

public class NodeInfo {
    public NodeInfo(String name, ValueInfo info);
    public String getName();
    public ValueInfo getInfo();
}

Import

import ai.onnxruntime.NodeInfo;

I/O Contract

Inputs

Name Type Description
name String The node name
info ValueInfo Type and shape information (TensorInfo, MapInfo, or SequenceInfo)

Outputs

Name Type Description
getName() String The node name
getInfo() ValueInfo The value info (downcast to TensorInfo, MapInfo, or SequenceInfo)

Usage Examples

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

OrtEnvironment env = OrtEnvironment.getEnvironment();
try (OrtSession session = env.createSession("/path/to/model.onnx")) {
    Map<String, NodeInfo> inputInfo = session.getInputInfo();
    for (Map.Entry<String, NodeInfo> entry : inputInfo.entrySet()) {
        NodeInfo node = entry.getValue();
        System.out.println("Input: " + node.getName());
        ValueInfo vInfo = node.getInfo();
        if (vInfo instanceof TensorInfo) {
            TensorInfo tInfo = (TensorInfo) vInfo;
            System.out.println("  Shape: " + java.util.Arrays.toString(tInfo.getShape()));
            System.out.println("  Type: " + tInfo.type);
        }
    }
}

Related Pages

Page Connections

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