microsoft / microsoft/onnxruntime

[Feature Request] Implement IEquatable<T> on OrtTensorTypeAndShapeInfo

Open
#21,751 0 comments 0 reactions 0 assignees View on GitHub
feature request
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 11h
Merged PRs (30d)
184

Description

### Describe the feature request

it would be useful in some scenarios that `OrtTensorTypeAndShapeInfo` implements `IEquatable` and associated `GetHashCode` to compare instances

```c#
struct OrtTensorTypeAndShapeInfo : IEquatable
{
...
}
```

### Describe scenario use case

I've found myself in a situation in which I have, I am using a Dictionary where the lambda is a specific funcion that knows how to operate on a tensor of that specific type and shape.

Unfortunately, because the OrtTensorTypeAndShapeInfo has a Shape array, the default equality is comparing the instances of the arrays and not the contents of the shape arrays.

implementing IEquality would fix that.

Contributor guide

Open the contributing guide

Research direction

Locate OrtTensorTypeAndShapeInfo in the C# bindings and inspect how its Shape array is represented and how related tests are organized. Implement equality and hashing so instances with equivalent tensor shapes compare consistently, then verify that they work correctly as Dictionary keys.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, machine-learning
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.