Implementation:Microsoft Onnxruntime InferenceSession Get Inputs
Appearance
Metadata
| Field | Value |
|---|---|
| Implementation Name | InferenceSession_Get_Inputs |
| Repository | Microsoft_Onnxruntime |
| Source Repository | https://github.com/microsoft/onnxruntime |
| Type | API Doc |
| Language | Python |
| Domain | ML_Inference, Model_Optimization |
| Last Updated | 2026-02-10 |
| Workflow | Python_Inference_Pipeline |
| Pair | 3 of 6 |
Overview
API documentation for the session.get_inputs() and session.get_outputs() methods, which return metadata about the model's input and output tensor specifications.
API Signature
session.get_inputs() -> list[NodeArg]
session.get_outputs() -> list[NodeArg]
Import
No additional import is needed beyond the InferenceSession. The NodeArg type is imported at onnxruntime/__init__.py:L32 from onnxruntime.capi._pybind_state.
Code Reference
| Reference | Location |
|---|---|
| Usage example | docs/python/examples/plot_load_and_predict.py:L30-45 |
I/O Contract
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
self |
InferenceSession |
Yes | A fully initialized InferenceSession with a loaded model. |
Outputs
| Output | Type | Description |
|---|---|---|
| return value | list[NodeArg] |
A list of NodeArg objects describing the model's input or output tensors. |
NodeArg Properties
| Property | Type | Description |
|---|---|---|
.name |
str |
The symbolic name of the tensor (used as key in the input feed dictionary). |
.shape |
list |
The tensor shape. None elements indicate dynamic dimensions.
|
.type |
str |
The ONNX tensor type string, e.g. "tensor(float)".
|
Usage Example
# Inspect input metadata
input_name = sess.get_inputs()[0].name
input_shape = sess.get_inputs()[0].shape
input_type = sess.get_inputs()[0].type
# Inspect output metadata
output_name = sess.get_outputs()[0].name
output_shape = sess.get_outputs()[0].shape
output_type = sess.get_outputs()[0].type
From the source example at docs/python/examples/plot_load_and_predict.py:L30-45:
input_name = sess.get_inputs()[0].name
print("input name", input_name)
input_shape = sess.get_inputs()[0].shape
print("input shape", input_shape)
input_type = sess.get_inputs()[0].type
print("input type", input_type)
output_name = sess.get_outputs()[0].name
print("output name", output_name)
output_shape = sess.get_outputs()[0].shape
print("output shape", output_shape)
output_type = sess.get_outputs()[0].type
print("output type", output_type)
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment