microsoft / microsoft/onnxruntime
Bug in CreateTensorValueFromSystemNumericsTensorObject
- Dominant language
- C++
- Stars
- 21.9k
- Forks
- 4.2k
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 184
Description
The api CreateTensorValueFromSystemNumericsTensorObject throws the following error:
```
Unhandled exception. System.MissingMethodException: Method not found: 'Void System.Numerics.Tensors.Tensor`1.CopyTo(System.Numerics.Tensors.TensorSpan`1)'.
at Microsoft.ML.OnnxRuntime.OrtValue.CreateTensorValueFromSystemNumericsTensorObject[T](Tensor`1 tensor)
at Microsoft.ML.OnnxRuntime.OrtValue.CreateTensorValueFromSystemNumericsTensorObject[T](Tensor`1 tensor)
at Program.$(String[] args) in D:\Code\NET\ML\fai\Example\FailingTensor.cs:line 15
```
When running:
```C#
#:package System.Numerics.Tensors@10.0.0-preview.6.*
#:package Microsoft.ML.OnnxRuntime.Gpu@1.22.1
#:property NoWarn=$(NoWarn);SYSLIB5001
using System.Numerics.Tensors;
using Microsoft.ML.OnnxRuntime;
Span length = [1000, 1];
Span strides = [1, 0];
Tensor tensor = Tensor.Create(length, strides);
OrtValue.CreateTensorValueFromSystemNumericsTensorObject(tensor);
```
Also, looking at the implementation of CreateTensorValueFromSystemNumericsTensorObject, there is a bug/performance issue with `IsContiguousAndDense` -
If I have a tensor of shape [1000, 1] then the strides will be [1, 0] and contiguous and dense.
But then both checks fail, and it returns false even though it should return true.
Contributor guide
Assessment
This issue has not been assessed yet.