onnxruntime
35dcab50 - [C#] Implement missing APIs (#26101)

Commit
133 days ago
[C#] Implement missing APIs (#26101) This pull request adds new APIs and updates existing ones to improve memory and device information handling in the ONNX Runtime C# bindings. The most significant changes introduce methods for fetching memory info and device info for session inputs/outputs, and add support for shared allocators and synchronization streams. There are also several updates and renamings for LoraAdapter delegates and related APIs. ### Memory and Device Info APIs * Added `GetMemoryInfosForInputs`, `GetMemoryInfosForOutputs`, and `GetEpDeviceForInputs` methods to `InferenceSession.shared.cs` to fetch memory info and device info for session inputs/outputs. These methods utilize new native delegates for retrieving memory and device information. * Introduced native delegates in `NativeMethods.shared.cs` for `OrtSessionGetMemoryInfoForInputs`, `OrtSessionGetMemoryInfoForOutputs`, and `OrtSessionGetEpDeviceForInputs`, and wired them up in the static constructor. [[1]](diffhunk://#diff-f9f2aaafc076365917de8ab96628da427d9dd0fd6a214fb9c266733f90d6fc73R530-R532) [[2]](diffhunk://#diff-f9f2aaafc076365917de8ab96628da427d9dd0fd6a214fb9c266733f90d6fc73R1312-R1335) ### Shared Allocator and Synchronization Stream Support * Added delegates and static fields for creating, getting, and releasing shared allocators, as well as for creating and managing synchronization streams (`OrtCreateSharedAllocator`, `OrtGetSharedAllocator`, `OrtReleaseSharedAllocator`, `OrtCreateSyncStreamForEpDevice`, `OrtSyncStream_GetHandle`, `OrtReleaseSyncStream`). * Added delegate for copying tensors (`OrtCopyTensors`). ### LoraAdapter API Updates * Renamed LoraAdapter-related delegates to use the `Ort` prefix (`OrtCreateLoraAdapter`, `OrtCreateLoraAdapterFromArray`, `OrtReleaseLoraAdapter`) and updated their usage throughout the codebase. [[1]](diffhunk://#diff-f9f2aaafc076365917de8ab96628da427d9dd0fd6a214fb9c266733f90d6fc73L699-R710) [[2]](diffhunk://#diff-f9f2aaafc076365917de8ab96628da427d9dd0fd6a214fb9c266733f90d6fc73L1561-R1672) [[3]](diffhunk://#diff-f9f2aaafc076365917de8ab96628da427d9dd0fd6a214fb9c266733f90d6fc73L1578-R1695) ### MemoryInfo Enhancements * Added new delegates for creating memory info with more parameters (`OrtCreateMemoryInfoV2`), and for querying device memory type and vendor ID (`OrtMemoryInfoGetDeviceMemType`, `OrtMemoryInfoGetVendorId`). [[1]](diffhunk://#diff-f9f2aaafc076365917de8ab96628da427d9dd0fd6a214fb9c266733f90d6fc73R594-R596) [[2]](diffhunk://#diff-f9f2aaafc076365917de8ab96628da427d9dd0fd6a214fb9c266733f90d6fc73R1804-R1817) [[3]](diffhunk://#diff-f9f2aaafc076365917de8ab96628da427d9dd0fd6a214fb9c266733f90d6fc73R1866-R1877) ### Minor API Documentation Update * Clarified the lifetime of allocators in the documentation, noting they can be explicitly unregistered.### Description <!-- Describe your changes. --> ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. -->
Author
Parents
Loading