onnxruntime/csharp/src/Microsoft.ML.OnnxRuntime
Dmitri Smirnov a5dec8eedf
[C# ] Improve string marshalling and reduce GC pressure (#15545)
### Description

  Reduce a number of auxillary objects created to reduce GC pressure.
Eliminate GCHandle type of memory pinning in most of the places.
Improve string marshalling by allocating unmanaged memory that does not
require pinning. Change native methods from `IntPtr` to `byte[]`
(marshalling pinning is more efficient).

Allocate input/output UTF-8 names in unmanaged heap for the lifetime of
InferenceSession. So we do not keep converting them and pinning on every
Run.

Introduce a new native API that allows to allocate and convert/copy
strings directly into a native tensor.

The PR delivers around 50% latency improvements and less GC pauses.

Inspired by: https://github.com/microsoft/onnxruntime/pull/15520

### Motivation and Context
Client experience GC pressure and performance degradation when dealing
with string tensors.


Co-Authored-By: @tannergooding
2023-04-20 15:12:51 -07:00
..
targets Add yml file for Snpe EP build (#13494) 2022-10-28 19:47:50 -07:00
Tensors [C# ] Improve string marshalling and reduce GC pressure (#15545) 2023-04-20 15:12:51 -07:00
Training [C# ] Improve string marshalling and reduce GC pressure (#15545) 2023-04-20 15:12:51 -07:00
AssemblyInfo.shared.cs Add .net6 support to the C# nuget package. (#11908) 2022-06-22 08:08:24 +10:00
DisposableNamedOnnxValue.shared.cs Implement Optional Metadata support and C# test support (#15314) 2023-04-11 09:41:59 -07:00
Exceptions.shared.cs
FixedBufferOnnxValue.shared.cs
InferenceSession.shared.cs [C# ] Improve string marshalling and reduce GC pressure (#15545) 2023-04-20 15:12:51 -07:00
ManagedProjections.shared.cs Implement Optional Metadata support and C# test support (#15314) 2023-04-11 09:41:59 -07:00
Microsoft.ML.OnnxRuntime.csproj [C# ] Improve string marshalling and reduce GC pressure (#15545) 2023-04-20 15:12:51 -07:00
Microsoft.ML.OnnxRuntime.sln
NamedOnnxValue.shared.cs Implement Optional Metadata support and C# test support (#15314) 2023-04-11 09:41:59 -07:00
NativeApiStatus.shared.cs
NativeMethods.shared.cs [C# ] Improve string marshalling and reduce GC pressure (#15545) 2023-04-20 15:12:51 -07:00
NativeOnnxValueHelper.shared.cs [C# ] Improve string marshalling and reduce GC pressure (#15545) 2023-04-20 15:12:51 -07:00
OrtAllocator.shared.cs [C# ] Improve string marshalling and reduce GC pressure (#15545) 2023-04-20 15:12:51 -07:00
OrtEnv.shared.cs [C#] Allow passing various options when creating singleton Environment object. (#14723) 2023-04-18 21:49:55 -07:00
OrtIoBinding.shared.cs [C# ] Improve string marshalling and reduce GC pressure (#15545) 2023-04-20 15:12:51 -07:00
OrtLoggingLevel.shared.cs [C#] Allow passing various options when creating singleton Environment object. (#14723) 2023-04-18 21:49:55 -07:00
OrtThreadingOptions.shared.cs [C#] Allow passing various options when creating singleton Environment object. (#14723) 2023-04-18 21:49:55 -07:00
OrtValue.shared.cs [C# ] Improve string marshalling and reduce GC pressure (#15545) 2023-04-20 15:12:51 -07:00
OrtValueTensor.shared.cs [C# ] Improve string marshalling and reduce GC pressure (#15545) 2023-04-20 15:12:51 -07:00
PrepackedWeightsContainer.shared.cs
ProviderOptions.shared.cs [C# ] Improve string marshalling and reduce GC pressure (#15545) 2023-04-20 15:12:51 -07:00
RunOptions.shared.cs [C# ] Improve string marshalling and reduce GC pressure (#15545) 2023-04-20 15:12:51 -07:00
SessionOptions.shared.cs [C# ] Improve string marshalling and reduce GC pressure (#15545) 2023-04-20 15:12:51 -07:00
SessionOptionsContainer.shared.cs