microsoft / microsoft/onnxruntime
[Training] [C# API] There is no way to get input dimensions from onnx model
- Dominant language
- C++
- Stars
- 21.9k
- Forks
- 4.2k
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 184
Description
### Describe the issue
`InferenceSession` class provides an API to get input dimensions:
```
using (InferenceSession inferenceSession = new InferenceSession(TRAINED_MODEL_PATH))
{
int[] inputDims = inferenceSession.InputMetadata[inferenceSession.InputNames[0]].Dimensions;
}
```
`TrainingSession` class provides no such API, nor have I found any other way to load the model using C# ONNX API and read the input dimensions.
### To reproduce
Should be clear from issue description, not really much to reproduce, it's just a missing functionality.
### Urgency
We are trying to implement on device training scenario and currently we have to send model input dimensions together with onnx model, which seems redundant because that info is already written inside ONNX model, but ONNX C# SDK has no API to extract that info.
### ONNX Runtime Installation
Released Package
### ONNX Runtime Version or Commit ID
1.16.3
### PyTorch Version
2.01
### Execution Provider
Default CPU
### Execution Provider Library Version
_No response_
Contributor guide
Research direction
Start by examining the C# TrainingSession API and compare it with the InferenceSession.InputMetadata and InputNames APIs shown in the issue. Determine how input dimensions are represented for a training model, then add a way to expose them and verify that dimensions can be read without separately supplying them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100