gravix-rtc-react-native 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +134 -0
- package/LICENSE +20 -0
- package/LICENSES/Apache-2.0.txt +175 -0
- package/NOTICE +68 -0
- package/README.md +313 -2
- package/android/build.gradle +137 -0
- package/android/consumer-rules.pro +29 -0
- package/android/src/main/AndroidManifest.xml +9 -0
- package/android/src/main/cpp/CMakeLists.txt +48 -0
- package/android/src/main/cpp/gx_dfn_engine.c +332 -0
- package/android/src/main/cpp/gx_fx_jni.cpp +34 -0
- package/android/src/main/cpp/gx_ns_jni.c +162 -0
- package/android/src/main/cpp/third_party/onnxruntime/LICENSE +21 -0
- package/android/src/main/cpp/third_party/onnxruntime/include/onnxruntime_c_api.h +9227 -0
- package/android/src/main/cpp/third_party/onnxruntime/include/onnxruntime_ep_c_api.h +3315 -0
- package/android/src/main/cpp/third_party/onnxruntime/include/onnxruntime_error_code.h +98 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixAudioHooks.kt +144 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixAudioModule.kt +105 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixNativeAudio.kt +310 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixRtc.kt +134 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixRtcModule.kt +176 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixRtcPackage.kt +39 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioDeviceKind.java +44 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioManagerUtils.kt +120 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioSwitchManager.java +270 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioType.kt +50 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicCaptureRouter.kt +375 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicDecoder.kt +339 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicInterruptionWatcher.kt +82 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicMicRelease.kt +117 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicMixKernel.kt +191 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicMixerEngine.kt +617 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/AudioRoutePolicy.kt +137 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GravixCaptureProcessing.kt +67 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxCaptureDump.kt +143 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxCaptureSwitcher.kt +196 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNoiseProcessor.kt +795 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNsLogic.kt +180 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNsNative.kt +83 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNsStudio.kt +372 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxRecordStartGuard.kt +76 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxRecorderSeam.kt +434 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxSingerSource.kt +37 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxVoiceFx.kt +160 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/OtherAppAudioPolicy.kt +143 -0
- package/android/src/main/java/org/webrtc/audio/WebRtcAudioTrackHelper.kt +43 -0
- package/docs/ANDROID_NATIVE_HOOKS.md +102 -0
- package/docs/FEATURE_MATRIX.md +192 -0
- package/docs/IOS_NATIVE_HOOKS.md +190 -0
- package/gravix-rtc-react-native.podspec +49 -0
- package/ios/GravixRtc.h +7 -0
- package/ios/GravixRtc.mm +273 -0
- package/ios/GravixRtcSetup.h +29 -0
- package/ios/GravixRtcSetup.m +52 -0
- package/ios/audio/GravixRtcIosAudio.m +157 -0
- package/ios/audio/GxAudioDevice.h +62 -0
- package/ios/audio/GxAudioDevice.m +857 -0
- package/ios/audio/GxAudioSetup.h +34 -0
- package/ios/audio/GxAudioSetup.m +70 -0
- package/ios/audio/GxCompat.swift +53 -0
- package/ios/audio/GxIosAudio.swift +99 -0
- package/ios/audio/GxMusicController.swift +150 -0
- package/ios/audio/GxMusicPost.swift +362 -0
- package/ios/audio/GxNoiseProcessor.swift +718 -0
- package/ios/audio/GxNsDfn3CoreML.swift +195 -0
- package/ios/audio/GxNsStudioEngine.swift +237 -0
- package/ios/audio/GxNsStudioPack.swift +212 -0
- package/ios/audio/GxVoiceFx.swift +161 -0
- package/ios/audio/gx_adm_state.h +153 -0
- package/ios/gxcore/apple/gx_music_post.c +312 -0
- package/ios/gxcore/apple/gx_pcm.c +30 -0
- package/ios/gxcore/apple/gxns_build.h +19 -0
- package/ios/gxcore/apple/gxns_ios.c +17 -0
- package/ios/gxcore/apple/include/gx_fx.h +3 -0
- package/ios/gxcore/apple/include/gx_music_post.h +88 -0
- package/ios/gxcore/apple/include/gx_ns.h +3 -0
- package/ios/gxcore/apple/include/gx_pcm.h +33 -0
- package/ios/gxcore/apple/include/gxns_ios.h +18 -0
- package/ios/gxcore/apple/include/module.modulemap +10 -0
- package/ios/gxcore/apple/shim/rnnoise.h +2 -0
- package/ios/gxcore/apple/shim/speex_resampler.h +2 -0
- package/ios/gxcore/apple/units/gx_fx_forward.cpp +3 -0
- package/ios/gxcore/apple/units/gx_ns.c +7 -0
- package/ios/gxcore/apple/units/gx_ns_timer.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_celt_lpc.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_denoise.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_kiss_fft.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_pitch.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_rnn.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_rnn_data.c +7 -0
- package/ios/gxcore/apple/units/speexdsp_resample.c +7 -0
- package/ios/resources/ns/DFN3-NOTICE.txt +10 -0
- package/ios/resources/ns/DeepFilterNet-LICENSE-APACHE +201 -0
- package/ios/resources/ns/DeepFilterNet-LICENSE-MIT +19 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/analytics/coremldata.bin +0 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/coremldata.bin +0 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/metadata.json +338 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/model.mil +927 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/weights/weight.bin +0 -0
- package/lib/module/android/bindings.js +49 -0
- package/lib/module/android/bindings.js.map +1 -0
- package/lib/module/android/index.js +13 -0
- package/lib/module/android/index.js.map +1 -0
- package/lib/module/android/micMute.js +341 -0
- package/lib/module/android/micMute.js.map +1 -0
- package/lib/module/android/nativeAudio.js +47 -0
- package/lib/module/android/nativeAudio.js.map +1 -0
- package/lib/module/android/noiseSuppression.js +170 -0
- package/lib/module/android/noiseSuppression.js.map +1 -0
- package/lib/module/android/roomMusic.js +142 -0
- package/lib/module/android/roomMusic.js.map +1 -0
- package/lib/module/android/singerMode.js +31 -0
- package/lib/module/android/singerMode.js.map +1 -0
- package/lib/module/android/voiceEffects.js +65 -0
- package/lib/module/android/voiceEffects.js.map +1 -0
- package/lib/module/audio/AudioManager.js +79 -0
- package/lib/module/audio/AudioManager.js.map +1 -0
- package/lib/module/audio/AudioSession.js +90 -0
- package/lib/module/audio/AudioSession.js.map +1 -0
- package/lib/module/audio/remoteVolume.js +54 -0
- package/lib/module/audio/remoteVolume.js.map +1 -0
- package/lib/module/components/VideoView.js +109 -0
- package/lib/module/components/VideoView.js.map +1 -0
- package/lib/module/features/audioScenario.js +53 -0
- package/lib/module/features/audioScenario.js.map +1 -0
- package/lib/module/features/beauty.js +828 -0
- package/lib/module/features/beauty.js.map +1 -0
- package/lib/module/features/micRelease.js +89 -0
- package/lib/module/features/micRelease.js.map +1 -0
- package/lib/module/features/noiseSuppression.js +213 -0
- package/lib/module/features/noiseSuppression.js.map +1 -0
- package/lib/module/features/roomMusic.js +90 -0
- package/lib/module/features/roomMusic.js.map +1 -0
- package/lib/module/features/roomMusicAndroid.js +294 -0
- package/lib/module/features/roomMusicAndroid.js.map +1 -0
- package/lib/module/features/roomMusicIos.js +250 -0
- package/lib/module/features/roomMusicIos.js.map +1 -0
- package/lib/module/features/roomMusicTypes.js +53 -0
- package/lib/module/features/roomMusicTypes.js.map +1 -0
- package/lib/module/features/screenShare.js +22 -0
- package/lib/module/features/screenShare.js.map +1 -0
- package/lib/module/features/singerMode.js +73 -0
- package/lib/module/features/singerMode.js.map +1 -0
- package/lib/module/features/voiceEffects.js +148 -0
- package/lib/module/features/voiceEffects.js.map +1 -0
- package/lib/module/hooks/context.js +34 -0
- package/lib/module/hooks/context.js.map +1 -0
- package/lib/module/hooks/hooks.js +145 -0
- package/lib/module/hooks/hooks.js.map +1 -0
- package/lib/module/hooks/types.js +4 -0
- package/lib/module/hooks/types.js.map +1 -0
- package/lib/module/hooks/useRoomEvents.js +30 -0
- package/lib/module/hooks/useRoomEvents.js.map +1 -0
- package/lib/module/index.js +43 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/ios/autoAttach.js +14 -0
- package/lib/module/ios/autoAttach.js.map +1 -0
- package/lib/module/ios/iosAudio.js +149 -0
- package/lib/module/ios/iosAudio.js.map +1 -0
- package/lib/module/join/appStateLifecycle.js +54 -0
- package/lib/module/join/appStateLifecycle.js.map +1 -0
- package/lib/module/micPolicy.js +249 -0
- package/lib/module/micPolicy.js.map +1 -0
- package/lib/module/native/NativeGravixAudio.js +18 -0
- package/lib/module/native/NativeGravixAudio.js.map +1 -0
- package/lib/module/native/NativeGravixRtc.js +13 -0
- package/lib/module/native/NativeGravixRtc.js.map +1 -0
- package/lib/module/native/module.js +23 -0
- package/lib/module/native/module.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/polyfills/DOMException.js +22 -0
- package/lib/module/polyfills/DOMException.js.map +1 -0
- package/lib/module/polyfills/early.js +18 -0
- package/lib/module/polyfills/early.js.map +1 -0
- package/lib/module/polyfills/event.js +71 -0
- package/lib/module/polyfills/event.js.map +1 -0
- package/lib/module/polyfills/sha256.js +92 -0
- package/lib/module/polyfills/sha256.js.map +1 -0
- package/lib/module/polyfills/subtleHmac.js +91 -0
- package/lib/module/polyfills/subtleHmac.js.map +1 -0
- package/lib/module/polyfills/textCoding.js +164 -0
- package/lib/module/polyfills/textCoding.js.map +1 -0
- package/lib/module/registerGlobals.js +135 -0
- package/lib/module/registerGlobals.js.map +1 -0
- package/lib/module/unsupported.js +90 -0
- package/lib/module/unsupported.js.map +1 -0
- package/lib/module/version.js +7 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/android/bindings.d.ts +14 -0
- package/lib/typescript/src/android/bindings.d.ts.map +1 -0
- package/lib/typescript/src/android/index.d.ts +9 -0
- package/lib/typescript/src/android/index.d.ts.map +1 -0
- package/lib/typescript/src/android/micMute.d.ts +124 -0
- package/lib/typescript/src/android/micMute.d.ts.map +1 -0
- package/lib/typescript/src/android/nativeAudio.d.ts +40 -0
- package/lib/typescript/src/android/nativeAudio.d.ts.map +1 -0
- package/lib/typescript/src/android/noiseSuppression.d.ts +48 -0
- package/lib/typescript/src/android/noiseSuppression.d.ts.map +1 -0
- package/lib/typescript/src/android/roomMusic.d.ts +80 -0
- package/lib/typescript/src/android/roomMusic.d.ts.map +1 -0
- package/lib/typescript/src/android/singerMode.d.ts +27 -0
- package/lib/typescript/src/android/singerMode.d.ts.map +1 -0
- package/lib/typescript/src/android/voiceEffects.d.ts +30 -0
- package/lib/typescript/src/android/voiceEffects.d.ts.map +1 -0
- package/lib/typescript/src/audio/AudioManager.d.ts +32 -0
- package/lib/typescript/src/audio/AudioManager.d.ts.map +1 -0
- package/lib/typescript/src/audio/AudioSession.d.ts +70 -0
- package/lib/typescript/src/audio/AudioSession.d.ts.map +1 -0
- package/lib/typescript/src/audio/remoteVolume.d.ts +8 -0
- package/lib/typescript/src/audio/remoteVolume.d.ts.map +1 -0
- package/lib/typescript/src/components/VideoView.d.ts +44 -0
- package/lib/typescript/src/components/VideoView.d.ts.map +1 -0
- package/lib/typescript/src/features/audioScenario.d.ts +24 -0
- package/lib/typescript/src/features/audioScenario.d.ts.map +1 -0
- package/lib/typescript/src/features/beauty.d.ts +377 -0
- package/lib/typescript/src/features/beauty.d.ts.map +1 -0
- package/lib/typescript/src/features/micRelease.d.ts +28 -0
- package/lib/typescript/src/features/micRelease.d.ts.map +1 -0
- package/lib/typescript/src/features/noiseSuppression.d.ts +64 -0
- package/lib/typescript/src/features/noiseSuppression.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusic.d.ts +41 -0
- package/lib/typescript/src/features/roomMusic.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusicAndroid.d.ts +60 -0
- package/lib/typescript/src/features/roomMusicAndroid.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusicIos.d.ts +56 -0
- package/lib/typescript/src/features/roomMusicIos.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusicTypes.d.ts +76 -0
- package/lib/typescript/src/features/roomMusicTypes.d.ts.map +1 -0
- package/lib/typescript/src/features/screenShare.d.ts +12 -0
- package/lib/typescript/src/features/screenShare.d.ts.map +1 -0
- package/lib/typescript/src/features/singerMode.d.ts +20 -0
- package/lib/typescript/src/features/singerMode.d.ts.map +1 -0
- package/lib/typescript/src/features/voiceEffects.d.ts +46 -0
- package/lib/typescript/src/features/voiceEffects.d.ts.map +1 -0
- package/lib/typescript/src/hooks/context.d.ts +12 -0
- package/lib/typescript/src/hooks/context.d.ts.map +1 -0
- package/lib/typescript/src/hooks/hooks.d.ts +54 -0
- package/lib/typescript/src/hooks/hooks.d.ts.map +1 -0
- package/lib/typescript/src/hooks/types.d.ts +8 -0
- package/lib/typescript/src/hooks/types.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useRoomEvents.d.ts +13 -0
- package/lib/typescript/src/hooks/useRoomEvents.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +37 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/ios/autoAttach.d.ts +2 -0
- package/lib/typescript/src/ios/autoAttach.d.ts.map +1 -0
- package/lib/typescript/src/ios/iosAudio.d.ts +96 -0
- package/lib/typescript/src/ios/iosAudio.d.ts.map +1 -0
- package/lib/typescript/src/join/appStateLifecycle.d.ts +14 -0
- package/lib/typescript/src/join/appStateLifecycle.d.ts.map +1 -0
- package/lib/typescript/src/micPolicy.d.ts +104 -0
- package/lib/typescript/src/micPolicy.d.ts.map +1 -0
- package/lib/typescript/src/native/NativeGravixAudio.d.ts +21 -0
- package/lib/typescript/src/native/NativeGravixAudio.d.ts.map +1 -0
- package/lib/typescript/src/native/NativeGravixRtc.d.ts +31 -0
- package/lib/typescript/src/native/NativeGravixRtc.d.ts.map +1 -0
- package/lib/typescript/src/native/module.d.ts +7 -0
- package/lib/typescript/src/native/module.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/DOMException.d.ts +3 -0
- package/lib/typescript/src/polyfills/DOMException.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/early.d.ts +2 -0
- package/lib/typescript/src/polyfills/early.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/event.d.ts +2 -0
- package/lib/typescript/src/polyfills/event.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/sha256.d.ts +3 -0
- package/lib/typescript/src/polyfills/sha256.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/subtleHmac.d.ts +37 -0
- package/lib/typescript/src/polyfills/subtleHmac.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/textCoding.d.ts +36 -0
- package/lib/typescript/src/polyfills/textCoding.d.ts.map +1 -0
- package/lib/typescript/src/registerGlobals.d.ts +42 -0
- package/lib/typescript/src/registerGlobals.d.ts.map +1 -0
- package/lib/typescript/src/unsupported.d.ts +42 -0
- package/lib/typescript/src/unsupported.d.ts.map +1 -0
- package/lib/typescript/src/version.d.ts +3 -0
- package/lib/typescript/src/version.d.ts.map +1 -0
- package/metro/index.js +39 -0
- package/metro/noise-stub.js +10 -0
- package/native/gxfx/include/gx_fx.h +82 -0
- package/native/gxfx/src/gx_fx.cpp +527 -0
- package/native/gxfx/third_party/README.md +4 -0
- package/native/gxfx/third_party/signalsmith-linear/LICENSE.txt +21 -0
- package/native/gxfx/third_party/signalsmith-linear/approx.h +191 -0
- package/native/gxfx/third_party/signalsmith-linear/fft.h +1386 -0
- package/native/gxfx/third_party/signalsmith-linear/linear.h +1129 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/approx-cmsisdsp.h +40 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/basic-fill-warnings.h +61 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-accelerate.h +340 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-cmsisdsp.h +307 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-ipp.h +532 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-linear.h +213 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-pffft-double.h +221 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-pffft.h +221 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-accelerate.h +593 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-cmsisdsp.h +713 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-xsimd-dispatch.cpp +6 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-xsimd.h +818 -0
- package/native/gxfx/third_party/signalsmith-linear/stft.h +700 -0
- package/native/gxfx/third_party/signalsmith-stretch-LICENSE.txt +21 -0
- package/native/gxfx/third_party/signalsmith-stretch.h +1060 -0
- package/native/gxns/CMakeLists.txt +67 -0
- package/native/gxns/include/gx_ns.h +285 -0
- package/native/gxns/src/gx_ns.c +1518 -0
- package/native/gxns/src/gx_ns_timer.c +84 -0
- package/native/gxns/src/gx_ns_timer.h +29 -0
- package/native/gxns/third_party/VENDOR.md +43 -0
- package/native/gxns/third_party/rnnoise/AUTHORS +1 -0
- package/native/gxns/third_party/rnnoise/COPYING +31 -0
- package/native/gxns/third_party/rnnoise/include/rnnoise.h +117 -0
- package/native/gxns/third_party/rnnoise/src/_kiss_fft_guts.h +182 -0
- package/native/gxns/third_party/rnnoise/src/arch.h +261 -0
- package/native/gxns/third_party/rnnoise/src/celt_lpc.c +172 -0
- package/native/gxns/third_party/rnnoise/src/celt_lpc.h +45 -0
- package/native/gxns/third_party/rnnoise/src/common.h +48 -0
- package/native/gxns/third_party/rnnoise/src/denoise.c +664 -0
- package/native/gxns/third_party/rnnoise/src/kiss_fft.c +601 -0
- package/native/gxns/third_party/rnnoise/src/kiss_fft.h +203 -0
- package/native/gxns/third_party/rnnoise/src/opus_types.h +159 -0
- package/native/gxns/third_party/rnnoise/src/pitch.c +523 -0
- package/native/gxns/third_party/rnnoise/src/pitch.h +149 -0
- package/native/gxns/third_party/rnnoise/src/rnn.c +178 -0
- package/native/gxns/third_party/rnnoise/src/rnn.h +65 -0
- package/native/gxns/third_party/rnnoise/src/rnn_data.c +11051 -0
- package/native/gxns/third_party/rnnoise/src/rnn_data.h +34 -0
- package/native/gxns/third_party/rnnoise/src/tansig_table.h +45 -0
- package/native/gxns/third_party/speexdsp/AUTHORS +18 -0
- package/native/gxns/third_party/speexdsp/COPYING +35 -0
- package/native/gxns/third_party/speexdsp/arch.h +232 -0
- package/native/gxns/third_party/speexdsp/resample.c +1239 -0
- package/native/gxns/third_party/speexdsp/resample_neon.h +339 -0
- package/native/gxns/third_party/speexdsp/resample_sse.h +128 -0
- package/native/gxns/third_party/speexdsp/speex_resampler.h +343 -0
- package/package.json +186 -4
- package/src/android/bindings.ts +61 -0
- package/src/android/index.ts +10 -0
- package/src/android/micMute.ts +422 -0
- package/src/android/nativeAudio.ts +94 -0
- package/src/android/noiseSuppression.ts +209 -0
- package/src/android/roomMusic.ts +193 -0
- package/src/android/singerMode.ts +53 -0
- package/src/android/voiceEffects.ts +126 -0
- package/src/audio/AudioManager.ts +111 -0
- package/src/audio/AudioSession.ts +190 -0
- package/src/audio/remoteVolume.ts +58 -0
- package/src/components/VideoView.tsx +152 -0
- package/src/features/audioScenario.ts +58 -0
- package/src/features/beauty.ts +1057 -0
- package/src/features/micRelease.ts +108 -0
- package/src/features/noiseSuppression.ts +251 -0
- package/src/features/roomMusic.ts +106 -0
- package/src/features/roomMusicAndroid.ts +310 -0
- package/src/features/roomMusicIos.ts +300 -0
- package/src/features/roomMusicTypes.ts +97 -0
- package/src/features/screenShare.ts +19 -0
- package/src/features/singerMode.ts +70 -0
- package/src/features/voiceEffects.ts +245 -0
- package/src/hooks/context.tsx +38 -0
- package/src/hooks/hooks.ts +247 -0
- package/src/hooks/types.ts +10 -0
- package/src/hooks/useRoomEvents.ts +35 -0
- package/src/index.tsx +134 -0
- package/src/ios/autoAttach.ts +11 -0
- package/src/ios/iosAudio.ts +202 -0
- package/src/join/appStateLifecycle.ts +55 -0
- package/src/micPolicy.ts +312 -0
- package/src/native/NativeGravixAudio.ts +30 -0
- package/src/native/NativeGravixRtc.ts +38 -0
- package/src/native/module.ts +22 -0
- package/src/polyfills/DOMException.ts +20 -0
- package/src/polyfills/early.ts +16 -0
- package/src/polyfills/event.ts +88 -0
- package/src/polyfills/sha256.ts +112 -0
- package/src/polyfills/subtleHmac.ts +124 -0
- package/src/polyfills/textCoding.ts +197 -0
- package/src/registerGlobals.ts +201 -0
- package/src/unsupported.ts +139 -0
- package/src/version.ts +4 -0
|
@@ -0,0 +1,3315 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
// Do not include this file directly. Please include "onnxruntime_c_api.h" instead.
|
|
5
|
+
|
|
6
|
+
#if defined(__DOXYGEN__)
|
|
7
|
+
// When running a Doxygen build, include onnxruntime_c_api.h. Doxygen expects header files to be self-contained.
|
|
8
|
+
#include "onnxruntime_c_api.h"
|
|
9
|
+
#else
|
|
10
|
+
// In normal usage, do not include onnxruntime_c_api.h. This file is explicitly included in onnxruntime_c_api.h.
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
#ifdef __cplusplus
|
|
14
|
+
extern "C" {
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
/** \addtogroup Global
|
|
18
|
+
* @{
|
|
19
|
+
*/
|
|
20
|
+
ORT_RUNTIME_CLASS(Ep);
|
|
21
|
+
ORT_RUNTIME_CLASS(EpFactory);
|
|
22
|
+
ORT_RUNTIME_CLASS(EpGraphSupportInfo);
|
|
23
|
+
ORT_RUNTIME_CLASS(MemoryDevice); // opaque class to wrap onnxruntime::OrtDevice
|
|
24
|
+
ORT_RUNTIME_CLASS(NodeComputeContext);
|
|
25
|
+
|
|
26
|
+
ORT_RUNTIME_CLASS(DataTransferImpl);
|
|
27
|
+
ORT_RUNTIME_CLASS(SyncNotificationImpl);
|
|
28
|
+
ORT_RUNTIME_CLASS(SyncStreamImpl);
|
|
29
|
+
|
|
30
|
+
ORT_RUNTIME_CLASS(ExternalResourceImporterImpl);
|
|
31
|
+
|
|
32
|
+
ORT_RUNTIME_CLASS(OpSchema);
|
|
33
|
+
ORT_RUNTIME_CLASS(OpSchemaTypeConstraint);
|
|
34
|
+
ORT_RUNTIME_CLASS(ProfilingEventsContainer);
|
|
35
|
+
ORT_RUNTIME_CLASS(ProfilingEvent); // Based on the Trace Event Format's "complete event"
|
|
36
|
+
/// @}
|
|
37
|
+
|
|
38
|
+
/** \brief Base struct for imported external memory handles.
|
|
39
|
+
*
|
|
40
|
+
* EPs derive from this struct to add EP-specific fields (e.g., CUdeviceptr for CUDA).
|
|
41
|
+
* EP is responsible for creating and releasing instances of the derived type.
|
|
42
|
+
*
|
|
43
|
+
* Example derived type for CUDA EP:
|
|
44
|
+
* \code
|
|
45
|
+
* struct MyCudaExternalMemoryHandle : OrtExternalMemoryHandle {
|
|
46
|
+
* CUexternalMemory ext_memory;
|
|
47
|
+
* CUdeviceptr mapped_ptr;
|
|
48
|
+
* bool is_dedicated;
|
|
49
|
+
* };
|
|
50
|
+
* \endcode
|
|
51
|
+
*
|
|
52
|
+
* \since Version 1.24.
|
|
53
|
+
*/
|
|
54
|
+
struct OrtExternalMemoryHandle {
|
|
55
|
+
uint32_t version; ///< Must be ORT_API_VERSION
|
|
56
|
+
const OrtEpDevice* ep_device; ///< EP device that created this handle
|
|
57
|
+
OrtExternalMemoryDescriptor descriptor; ///< External memory descriptor
|
|
58
|
+
|
|
59
|
+
/** \brief Release callback for this handle. EP sets this to its release function.
|
|
60
|
+
*
|
|
61
|
+
* ORT calls this when ReleaseExternalMemoryHandle is invoked. The EP's callback
|
|
62
|
+
* should cast the handle to its derived type and delete it.
|
|
63
|
+
*/
|
|
64
|
+
void(ORT_API_CALL* Release)(_In_ OrtExternalMemoryHandle* handle);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/** \brief Base struct for imported external semaphore handles.
|
|
68
|
+
*
|
|
69
|
+
* EPs derive from this struct to add EP-specific fields (e.g., CUexternalSemaphore for CUDA).
|
|
70
|
+
* EP is responsible for creating and releasing instances of the derived type.
|
|
71
|
+
*
|
|
72
|
+
* Example derived type for CUDA EP:
|
|
73
|
+
* \code
|
|
74
|
+
* struct MyCudaExternalSemaphoreHandle : OrtExternalSemaphoreHandle {
|
|
75
|
+
* CUexternalSemaphore ext_semaphore;
|
|
76
|
+
* };
|
|
77
|
+
* \endcode
|
|
78
|
+
*
|
|
79
|
+
* \since Version 1.24.
|
|
80
|
+
*/
|
|
81
|
+
struct OrtExternalSemaphoreHandle {
|
|
82
|
+
uint32_t version; ///< Must be ORT_API_VERSION
|
|
83
|
+
const OrtEpDevice* ep_device; ///< EP device that created this handle
|
|
84
|
+
OrtExternalSemaphoreDescriptor descriptor; ///< External semaphore descriptor
|
|
85
|
+
|
|
86
|
+
/** \brief Release callback for this handle. EP sets this to its release function.
|
|
87
|
+
*
|
|
88
|
+
* ORT calls this when ReleaseExternalSemaphoreHandle is invoked. The EP's callback
|
|
89
|
+
* should cast the handle to its derived type and delete it.
|
|
90
|
+
*/
|
|
91
|
+
void(ORT_API_CALL* Release)(_In_ OrtExternalSemaphoreHandle* handle);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// Opaque types for kernel-based EPs
|
|
95
|
+
ORT_RUNTIME_CLASS(KernelRegistry);
|
|
96
|
+
ORT_RUNTIME_CLASS(KernelDefBuilder);
|
|
97
|
+
ORT_RUNTIME_CLASS(KernelDef);
|
|
98
|
+
ORT_RUNTIME_CLASS(DataType); // combination of ONNXType (e.g., Tensor, Map, Sequence) and ONNXTensorElementDataType
|
|
99
|
+
ORT_RUNTIME_CLASS(SharedPrePackedWeightCache);
|
|
100
|
+
|
|
101
|
+
/** \brief Struct that an EP implements for IDataTransfer to copy between devices it uses and CPU.
|
|
102
|
+
*
|
|
103
|
+
* \since Version 1.23.
|
|
104
|
+
*/
|
|
105
|
+
struct OrtDataTransferImpl {
|
|
106
|
+
uint32_t ort_version_supported; ///< Must be initialized to ORT_API_VERSION
|
|
107
|
+
|
|
108
|
+
/** \brief Release the OrtDataTransferImpl instance.
|
|
109
|
+
*
|
|
110
|
+
* This is called by ORT when the OrtDataTransferImpl instance is no longer needed.
|
|
111
|
+
* The implementation should release any resources held by the instance.
|
|
112
|
+
*
|
|
113
|
+
* \param[in] this_ptr Pointer to the OrtDataTransferImpl instance.
|
|
114
|
+
*
|
|
115
|
+
* \since Version 1.23.
|
|
116
|
+
*/
|
|
117
|
+
ORT_API_T(void, Release, _In_ OrtDataTransferImpl* this_ptr);
|
|
118
|
+
|
|
119
|
+
/** \brief Check if the implementation can copy between the source and destination memory devices.
|
|
120
|
+
*
|
|
121
|
+
* \param[in] this_ptr Pointer to the OrtDataTransferImpl instance.
|
|
122
|
+
* \param[in] src_memory_device Source OrtMemoryDevice to copy from.
|
|
123
|
+
* \param[in] dst_memory_device Destination OrtMemoryDevice to copy to.
|
|
124
|
+
* \return True if the implementation can copy between the devices.
|
|
125
|
+
*
|
|
126
|
+
* \since Version 1.23.
|
|
127
|
+
*/
|
|
128
|
+
ORT_API_T(bool, CanCopy, _In_ const OrtDataTransferImpl* this_ptr,
|
|
129
|
+
_In_ const OrtMemoryDevice* src_memory_device, _In_ const OrtMemoryDevice* dst_memory_device);
|
|
130
|
+
|
|
131
|
+
/** \brief Copy tensors from src_tensors to dst_tensors using the provided streams.
|
|
132
|
+
*
|
|
133
|
+
* The implementation can use the provided streams to perform asynchronous copies if supported.
|
|
134
|
+
* If a stream is not available, the copy is performed synchronously.
|
|
135
|
+
*
|
|
136
|
+
* \param[in] this_ptr Pointer to the OrtDataTransferImpl instance.
|
|
137
|
+
* \param[in] src_tensors Array of source OrtValue pointers to copy from.
|
|
138
|
+
* \param[in] dst_tensors Array of destination OrtValue pointers to copy to.
|
|
139
|
+
* \param[in] streams Array of OrtSyncStream pointers for the copy operations, if the execution provider is stream
|
|
140
|
+
* aware. nullptr if it is not.
|
|
141
|
+
* \param[in] num_tensors Number of tensors to copy.
|
|
142
|
+
*
|
|
143
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
144
|
+
*
|
|
145
|
+
* \since Version 1.23.
|
|
146
|
+
*/
|
|
147
|
+
ORT_API2_STATUS(CopyTensors, _In_ OrtDataTransferImpl* this_ptr,
|
|
148
|
+
_In_reads_(num_tensors) const OrtValue** src_tensors,
|
|
149
|
+
_In_reads_(num_tensors) OrtValue** dst_tensors,
|
|
150
|
+
_In_reads_(num_tensors) OrtSyncStream** streams,
|
|
151
|
+
_In_ size_t num_tensors);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/** \brief Struct that an EP implements for Stream Notifications.
|
|
155
|
+
*
|
|
156
|
+
* \since Version 1.23.
|
|
157
|
+
*/
|
|
158
|
+
struct OrtSyncNotificationImpl {
|
|
159
|
+
uint32_t ort_version_supported; ///< Must be initialized to ORT_API_VERSION
|
|
160
|
+
|
|
161
|
+
/** \brief Release the OrtSyncNotificationImpl instance.
|
|
162
|
+
*
|
|
163
|
+
* This is called by ORT when the OrtSyncNotificationImpl instance is no longer needed.
|
|
164
|
+
* The implementation should release any resources held by the instance.
|
|
165
|
+
*
|
|
166
|
+
* \param[in] this_ptr Pointer to the OrtSyncNotificationImpl instance.
|
|
167
|
+
*
|
|
168
|
+
* \since Version 1.23.
|
|
169
|
+
*/
|
|
170
|
+
ORT_API_T(void, Release, _In_ OrtSyncNotificationImpl* this_ptr);
|
|
171
|
+
|
|
172
|
+
/** \brief Called by ORT to activate the notification.
|
|
173
|
+
*
|
|
174
|
+
* \param[in] this_ptr Pointer to the OrtSyncNotificationImpl instance.
|
|
175
|
+
*
|
|
176
|
+
* \since Version 1.23.
|
|
177
|
+
*/
|
|
178
|
+
ORT_API2_STATUS(Activate, _In_ OrtSyncNotificationImpl* this_ptr);
|
|
179
|
+
|
|
180
|
+
/** \brief Wait for a device to device operation to complete.
|
|
181
|
+
*
|
|
182
|
+
* \param[in] this_ptr Pointer to the OrtSyncNotificationImpl instance.
|
|
183
|
+
* \param[in] consumer_stream The OrtSyncStream instance that will wait on this notification to be activated.
|
|
184
|
+
*
|
|
185
|
+
* \since Version 1.23.
|
|
186
|
+
*/
|
|
187
|
+
ORT_API2_STATUS(WaitOnDevice, _In_ OrtSyncNotificationImpl* this_ptr, _In_ OrtSyncStream* consumer_stream);
|
|
188
|
+
|
|
189
|
+
/** \brief Wait for a device to host operation to complete.
|
|
190
|
+
*
|
|
191
|
+
* \param[in] this_ptr Pointer to the OrtSyncNotificationImpl instance.
|
|
192
|
+
*
|
|
193
|
+
* \since Version 1.23.
|
|
194
|
+
*/
|
|
195
|
+
ORT_API2_STATUS(WaitOnHost, _In_ OrtSyncNotificationImpl* this_ptr);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/** \brief Struct that an EP implements if it wishes to implement Stream support.
|
|
199
|
+
*
|
|
200
|
+
* This struct provides the overrides for onnxruntime::Stream's virtual methods.
|
|
201
|
+
*
|
|
202
|
+
* \since Version 1.23.
|
|
203
|
+
*/
|
|
204
|
+
struct OrtSyncStreamImpl {
|
|
205
|
+
uint32_t ort_version_supported; ///< Must be initialized to ORT_API_VERSION
|
|
206
|
+
|
|
207
|
+
/** \brief Release the OrtSyncStreamImpl instance.
|
|
208
|
+
*
|
|
209
|
+
* This is called by ORT when the OrtSyncStreamImpl instance is no longer needed.
|
|
210
|
+
* The implementation should release any resources held by the instance.
|
|
211
|
+
*
|
|
212
|
+
* \param[in] this_ptr Pointer to the OrtSyncStreamImpl instance.
|
|
213
|
+
*
|
|
214
|
+
* \since Version 1.23.
|
|
215
|
+
*/
|
|
216
|
+
ORT_API_T(void, Release, _In_ OrtSyncStreamImpl* this_ptr);
|
|
217
|
+
|
|
218
|
+
/** \brief Get the handle of the stream.
|
|
219
|
+
*
|
|
220
|
+
* This returns the native handle for the stream. e.g. cudaStream_t for CUDA streams.
|
|
221
|
+
*
|
|
222
|
+
* \param[in] this_ptr Pointer to the OrtSyncStreamImpl instance.
|
|
223
|
+
* \return The handle of the stream.
|
|
224
|
+
*
|
|
225
|
+
* \since Version 1.23.
|
|
226
|
+
*/
|
|
227
|
+
ORT_API_T(void*, GetHandle, _In_ OrtSyncStreamImpl* this_ptr);
|
|
228
|
+
|
|
229
|
+
/** \brief Create an OrtSyncNotificationImpl for the OrtSyncStreamImpl instance.
|
|
230
|
+
*
|
|
231
|
+
* \param[in] this_ptr Pointer to the OrtSyncStreamImpl instance
|
|
232
|
+
* \param[out] notification The new OrtSyncNotificationImpl instance.
|
|
233
|
+
*
|
|
234
|
+
* \since Version 1.23.
|
|
235
|
+
*/
|
|
236
|
+
ORT_API2_STATUS(CreateNotification, _In_ OrtSyncStreamImpl* this_ptr,
|
|
237
|
+
_Outptr_ OrtSyncNotificationImpl** notification);
|
|
238
|
+
|
|
239
|
+
/** \brief Flush the stream.
|
|
240
|
+
*
|
|
241
|
+
* This is called by ORT to flush the stream, ensuring that all operations submitted to the stream are completed.
|
|
242
|
+
*
|
|
243
|
+
* \param[in] this_ptr Pointer to the OrtSyncStreamImpl instance.
|
|
244
|
+
*
|
|
245
|
+
* \since Version 1.23.
|
|
246
|
+
*/
|
|
247
|
+
ORT_API2_STATUS(Flush, _In_ OrtSyncStreamImpl* this_ptr);
|
|
248
|
+
|
|
249
|
+
/** \brief Notify the stream that a session run has ended.
|
|
250
|
+
*
|
|
251
|
+
* This is called by ORT to notify the stream that a session run has ended, allowing the stream to perform any
|
|
252
|
+
* necessary cleanup or finalization.
|
|
253
|
+
*
|
|
254
|
+
* \param[in] this_ptr Pointer to the OrtSyncStreamImpl instance.
|
|
255
|
+
*
|
|
256
|
+
* \since Version 1.23.
|
|
257
|
+
*/
|
|
258
|
+
ORT_API2_STATUS(OnSessionRunEnd, _In_ OrtSyncStreamImpl* this_ptr);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
/** \brief Struct that an EP implements for external resource import (memory + semaphore import).
|
|
262
|
+
*
|
|
263
|
+
* This capability object provides methods for importing external GPU memory and semaphores
|
|
264
|
+
* for zero-copy import. EPs that support D3D12, CUDA, HIP, or Vulkan external resource APIs
|
|
265
|
+
* can implement this interface.
|
|
266
|
+
*
|
|
267
|
+
* \since Version 1.24.
|
|
268
|
+
*/
|
|
269
|
+
struct OrtExternalResourceImporterImpl {
|
|
270
|
+
uint32_t ort_version_supported; ///< Must be initialized to ORT_API_VERSION
|
|
271
|
+
|
|
272
|
+
// Memory operations (stream-independent)
|
|
273
|
+
|
|
274
|
+
/** \brief Check if the implementation can import external memory of the given handle type.
|
|
275
|
+
*
|
|
276
|
+
* \param[in] this_ptr Pointer to the OrtExternalResourceImporterImpl instance.
|
|
277
|
+
* \param[in] handle_type The type of external memory handle to check.
|
|
278
|
+
* \return True if the handle type is supported.
|
|
279
|
+
*
|
|
280
|
+
* \since Version 1.24.
|
|
281
|
+
*/
|
|
282
|
+
ORT_API_T(bool, CanImportMemory,
|
|
283
|
+
_In_ const OrtExternalResourceImporterImpl* this_ptr,
|
|
284
|
+
_In_ OrtExternalMemoryHandleType handle_type);
|
|
285
|
+
|
|
286
|
+
/** \brief Import external memory.
|
|
287
|
+
*
|
|
288
|
+
* The EP creates a derived type of OrtExternalMemoryHandle and returns a pointer to the base.
|
|
289
|
+
* EP is responsible for the lifetime of the handle (release via ReleaseMemory).
|
|
290
|
+
*
|
|
291
|
+
* \param[in] this_ptr Pointer to the OrtExternalResourceImporterImpl instance.
|
|
292
|
+
* \param[in] desc Descriptor containing the external memory handle and properties.
|
|
293
|
+
* \param[out] out_handle Output parameter set to the created OrtExternalMemoryHandle (EP's derived type).
|
|
294
|
+
*
|
|
295
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
296
|
+
*
|
|
297
|
+
* \since Version 1.24.
|
|
298
|
+
*/
|
|
299
|
+
ORT_API2_STATUS(ImportMemory,
|
|
300
|
+
_In_ OrtExternalResourceImporterImpl* this_ptr,
|
|
301
|
+
_In_ const OrtExternalMemoryDescriptor* desc,
|
|
302
|
+
_Outptr_ OrtExternalMemoryHandle** out_handle);
|
|
303
|
+
|
|
304
|
+
/** \brief Release an imported external memory handle.
|
|
305
|
+
*
|
|
306
|
+
* The EP deletes its derived type instance.
|
|
307
|
+
*
|
|
308
|
+
* \param[in] this_ptr Pointer to the OrtExternalResourceImporterImpl instance.
|
|
309
|
+
* \param[in] handle The OrtExternalMemoryHandle to release (EP casts to its derived type).
|
|
310
|
+
*
|
|
311
|
+
* \since Version 1.24.
|
|
312
|
+
*/
|
|
313
|
+
ORT_API_T(void, ReleaseMemory,
|
|
314
|
+
_In_ OrtExternalResourceImporterImpl* this_ptr,
|
|
315
|
+
_In_ OrtExternalMemoryHandle* handle);
|
|
316
|
+
|
|
317
|
+
/** \brief Create a tensor backed by imported external memory.
|
|
318
|
+
*
|
|
319
|
+
* The created tensor is a view over the imported memory and does not copy data.
|
|
320
|
+
*
|
|
321
|
+
* \param[in] this_ptr Pointer to the OrtExternalResourceImporterImpl instance.
|
|
322
|
+
* \param[in] mem_handle The imported external memory handle (EP casts to its derived type).
|
|
323
|
+
* \param[in] tensor_desc Descriptor specifying tensor element type, shape, and optional offset.
|
|
324
|
+
* \param[out] out_tensor Output parameter set to the created OrtValue containing the tensor.
|
|
325
|
+
*
|
|
326
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
327
|
+
*
|
|
328
|
+
* \since Version 1.24.
|
|
329
|
+
*/
|
|
330
|
+
ORT_API2_STATUS(CreateTensorFromMemory,
|
|
331
|
+
_In_ OrtExternalResourceImporterImpl* this_ptr,
|
|
332
|
+
_In_ const OrtExternalMemoryHandle* mem_handle,
|
|
333
|
+
_In_ const OrtExternalTensorDescriptor* tensor_desc,
|
|
334
|
+
_Outptr_ OrtValue** out_tensor);
|
|
335
|
+
|
|
336
|
+
// Semaphore operations (require stream)
|
|
337
|
+
|
|
338
|
+
/** \brief Check if the implementation can import external semaphores of the given type.
|
|
339
|
+
*
|
|
340
|
+
* \param[in] this_ptr Pointer to the OrtExternalResourceImporterImpl instance.
|
|
341
|
+
* \param[in] type The type of external semaphore to check.
|
|
342
|
+
* \return True if the semaphore type is supported.
|
|
343
|
+
*
|
|
344
|
+
* \since Version 1.24.
|
|
345
|
+
*/
|
|
346
|
+
ORT_API_T(bool, CanImportSemaphore,
|
|
347
|
+
_In_ const OrtExternalResourceImporterImpl* this_ptr,
|
|
348
|
+
_In_ OrtExternalSemaphoreType type);
|
|
349
|
+
|
|
350
|
+
/** \brief Import an external semaphore.
|
|
351
|
+
*
|
|
352
|
+
* The EP creates a derived type of OrtExternalSemaphoreHandle and returns a pointer to the base.
|
|
353
|
+
* EP is responsible for the lifetime of the handle (release via ReleaseSemaphore).
|
|
354
|
+
*
|
|
355
|
+
* \param[in] this_ptr Pointer to the OrtExternalResourceImporterImpl instance.
|
|
356
|
+
* \param[in] desc Descriptor containing the external semaphore handle and type.
|
|
357
|
+
* \param[out] out_handle Output parameter set to the created OrtExternalSemaphoreHandle (EP's derived type).
|
|
358
|
+
*
|
|
359
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
360
|
+
*
|
|
361
|
+
* \since Version 1.24.
|
|
362
|
+
*/
|
|
363
|
+
ORT_API2_STATUS(ImportSemaphore,
|
|
364
|
+
_In_ OrtExternalResourceImporterImpl* this_ptr,
|
|
365
|
+
_In_ const OrtExternalSemaphoreDescriptor* desc,
|
|
366
|
+
_Outptr_ OrtExternalSemaphoreHandle** out_handle);
|
|
367
|
+
|
|
368
|
+
/** \brief Release an imported external semaphore handle.
|
|
369
|
+
*
|
|
370
|
+
* The EP deletes its derived type instance.
|
|
371
|
+
*
|
|
372
|
+
* \param[in] this_ptr Pointer to the OrtExternalResourceImporterImpl instance.
|
|
373
|
+
* \param[in] handle The OrtExternalSemaphoreHandle to release (EP casts to its derived type).
|
|
374
|
+
*
|
|
375
|
+
* \since Version 1.24.
|
|
376
|
+
*/
|
|
377
|
+
ORT_API_T(void, ReleaseSemaphore,
|
|
378
|
+
_In_ OrtExternalResourceImporterImpl* this_ptr,
|
|
379
|
+
_In_ OrtExternalSemaphoreHandle* handle);
|
|
380
|
+
|
|
381
|
+
/** \brief Wait on an external semaphore on the EP's stream.
|
|
382
|
+
*
|
|
383
|
+
* Inserts a wait operation into the EP's stream that blocks until the semaphore
|
|
384
|
+
* reaches the specified value.
|
|
385
|
+
*
|
|
386
|
+
* \param[in] this_ptr Pointer to the OrtExternalResourceImporterImpl instance.
|
|
387
|
+
* \param[in] handle The imported external semaphore (EP casts to its derived type).
|
|
388
|
+
* \param[in] stream The OrtSyncStream to wait on.
|
|
389
|
+
* \param[in] value The fence/semaphore value to wait for.
|
|
390
|
+
*
|
|
391
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
392
|
+
*
|
|
393
|
+
* \since Version 1.24.
|
|
394
|
+
*/
|
|
395
|
+
ORT_API2_STATUS(WaitSemaphore,
|
|
396
|
+
_In_ OrtExternalResourceImporterImpl* this_ptr,
|
|
397
|
+
_In_ OrtExternalSemaphoreHandle* handle,
|
|
398
|
+
_In_ OrtSyncStream* stream,
|
|
399
|
+
_In_ uint64_t value);
|
|
400
|
+
|
|
401
|
+
/** \brief Signal an external semaphore from the EP's stream.
|
|
402
|
+
*
|
|
403
|
+
* Inserts a signal operation into the EP's stream that sets the semaphore
|
|
404
|
+
* to the specified value when reached.
|
|
405
|
+
*
|
|
406
|
+
* \param[in] this_ptr Pointer to the OrtExternalResourceImporterImpl instance.
|
|
407
|
+
* \param[in] handle The imported external semaphore (EP casts to its derived type).
|
|
408
|
+
* \param[in] stream The OrtSyncStream to signal from.
|
|
409
|
+
* \param[in] value The fence/semaphore value to signal.
|
|
410
|
+
*
|
|
411
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
412
|
+
*
|
|
413
|
+
* \since Version 1.24.
|
|
414
|
+
*/
|
|
415
|
+
ORT_API2_STATUS(SignalSemaphore,
|
|
416
|
+
_In_ OrtExternalResourceImporterImpl* this_ptr,
|
|
417
|
+
_In_ OrtExternalSemaphoreHandle* handle,
|
|
418
|
+
_In_ OrtSyncStream* stream,
|
|
419
|
+
_In_ uint64_t value);
|
|
420
|
+
|
|
421
|
+
// Release the capability object itself
|
|
422
|
+
|
|
423
|
+
/** \brief Release the OrtExternalResourceImporterImpl instance.
|
|
424
|
+
*
|
|
425
|
+
* This is called by ORT when the OrtExternalResourceImporterImpl instance is no longer needed.
|
|
426
|
+
* The implementation should release any resources held by the instance.
|
|
427
|
+
*
|
|
428
|
+
* \param[in] this_ptr Pointer to the OrtExternalResourceImporterImpl instance.
|
|
429
|
+
*
|
|
430
|
+
* \since Version 1.24.
|
|
431
|
+
*/
|
|
432
|
+
ORT_API_T(void, Release, _In_ OrtExternalResourceImporterImpl* this_ptr);
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
/** \brief The event category for profiling events reported by an execution provider.
|
|
436
|
+
*
|
|
437
|
+
* \since Version 1.25.
|
|
438
|
+
*/
|
|
439
|
+
typedef enum OrtProfilingEventCategory {
|
|
440
|
+
OrtProfilingEventCategory_SESSION = 0, ///< Session-level event
|
|
441
|
+
OrtProfilingEventCategory_NODE = 1, ///< Node-level event
|
|
442
|
+
OrtProfilingEventCategory_KERNEL = 2, ///< Kernel-level event
|
|
443
|
+
OrtProfilingEventCategory_API = 3, ///< API-level event
|
|
444
|
+
} OrtProfilingEventCategory;
|
|
445
|
+
|
|
446
|
+
struct OrtEpProfilerImpl;
|
|
447
|
+
typedef struct OrtEpProfilerImpl OrtEpProfilerImpl;
|
|
448
|
+
|
|
449
|
+
/** \brief Struct that an EP implements for profiling support.
|
|
450
|
+
*
|
|
451
|
+
* An execution provider optionally implements this struct to participate in ONNX Runtime's profiling system.
|
|
452
|
+
* The EP creates and returns an instance of this struct via OrtEp::CreateProfiler.
|
|
453
|
+
*
|
|
454
|
+
* ORT calls the function pointers at appropriate times during a profiling session:
|
|
455
|
+
* - StartProfiling once when profiling begins.
|
|
456
|
+
* - [Optional] StartEvent / StopEvent around each ORT event (operator executions, session events, etc.).
|
|
457
|
+
* - EndProfiling once when profiling ends to collect EP events.
|
|
458
|
+
* - Release when ORT no longer needs the profiler.
|
|
459
|
+
*
|
|
460
|
+
* Profiling scenarios:
|
|
461
|
+
* - ORT session profiling: Captures session initialization and one or more runs with a single ORT session.
|
|
462
|
+
* - Enabled via OrtApi::EnableProfiling(session_options).
|
|
463
|
+
* - There is one ORT session, one OrtEp, and one OrtEpProfilerImpl
|
|
464
|
+
* - Concurrency notes: An application may use a single ORT session (and the single OrtEpProfilerImpl) to run
|
|
465
|
+
* multiple inferences concurrently. The OrtEpProfilerImpl::StartEvent and OrtEpProfilerImpl::StopEvent
|
|
466
|
+
* functions will be called with ORT events from multiple concurrent runs. The OrtEpProfilerImpl::EndProfiling
|
|
467
|
+
* function is expected to return all EP events from all runs with correct correlations with the original ORT
|
|
468
|
+
* events.
|
|
469
|
+
* - ORT run profiling: Captures events for a given run. An application can either enable session profiling or run
|
|
470
|
+
* profiling, but not both at the same time.
|
|
471
|
+
* - Enabled via OrtApi::RunOptionsEnableProfiling(run_options).
|
|
472
|
+
* - There is one ORT session, one OrtEp, and multiple OrtEpProfilerImpl instances (one per profiled run).
|
|
473
|
+
* - Concurrency notes: each OrtEpProfilerImpl only receives calls for its specific run.
|
|
474
|
+
* OrtEpProfilerImpl::EndProfiling must only return EP events for its specific run.
|
|
475
|
+
*
|
|
476
|
+
* \since Version 1.25.
|
|
477
|
+
*/
|
|
478
|
+
struct OrtEpProfilerImpl {
|
|
479
|
+
uint32_t ort_version_supported; ///< Must be initialized to ORT_API_VERSION.
|
|
480
|
+
|
|
481
|
+
/** \brief Release the OrtEpProfilerImpl instance.
|
|
482
|
+
*
|
|
483
|
+
* Called by ORT when the profiler is no longer needed.
|
|
484
|
+
* The implementation should release any resources held by the instance.
|
|
485
|
+
*
|
|
486
|
+
* \param[in] this_ptr Pointer to the OrtEpProfilerImpl instance.
|
|
487
|
+
*
|
|
488
|
+
* \note Implementation of this function is required.
|
|
489
|
+
*
|
|
490
|
+
* \since Version 1.25.
|
|
491
|
+
*/
|
|
492
|
+
ORT_API_T(void, Release, _In_ OrtEpProfilerImpl* this_ptr);
|
|
493
|
+
|
|
494
|
+
/** \brief Called when profiling starts.
|
|
495
|
+
*
|
|
496
|
+
* Allows the EP profiler to initialize profiling utilities and record the profiling start time.
|
|
497
|
+
*
|
|
498
|
+
* An EP profiler should record its own clock's current time when this function is called. This allows the EP to
|
|
499
|
+
* later compute ORT-relative event timestamps by combining `ep_profiling_start_offset_ns` with the EP's own
|
|
500
|
+
* elapsed time since this call. The formula is:
|
|
501
|
+
*
|
|
502
|
+
* event_timestamp_us = (ep_profiling_start_offset_ns + (ep_event_time_ns - ep_profiling_start_time_ns)) / 1000
|
|
503
|
+
*
|
|
504
|
+
* where `ep_event_time_ns` and `ep_profiling_start_time_ns` are measured using the EP's own clock.
|
|
505
|
+
*
|
|
506
|
+
* \param[in] this_ptr Pointer to the OrtEpProfilerImpl instance.
|
|
507
|
+
* \param[in] ep_profiling_start_offset_ns The elapsed time in nanoseconds (using ORT's profiling clock) between
|
|
508
|
+
* ORT's profiling start and this call to StartProfiling.
|
|
509
|
+
*
|
|
510
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
511
|
+
*
|
|
512
|
+
* \note An error OrtStatus returned from this function is logged by ORT (does not end execution).
|
|
513
|
+
* \note Implementation of this function is required.
|
|
514
|
+
*
|
|
515
|
+
* \since Version 1.25.
|
|
516
|
+
*/
|
|
517
|
+
ORT_API2_STATUS(StartProfiling, _In_ OrtEpProfilerImpl* this_ptr, _In_ int64_t ep_profiling_start_offset_ns);
|
|
518
|
+
|
|
519
|
+
/** \brief Called when an ORT event (e.g., session initialization, node kernel execution, etc.) begins.
|
|
520
|
+
*
|
|
521
|
+
* ORT pairs every StartEvent call with a corresponding call to StopEvent with the same ORT event correlation ID.
|
|
522
|
+
* EP profiler implementations may use the calls to StartEvent and StopEvent to maintain a stack of ORT event
|
|
523
|
+
* correlation IDs that can be correlated with EP events (e.g., GPU kernel events). For example:
|
|
524
|
+
*
|
|
525
|
+
* OrtEpProfilerImpl::StartEvent(x) -> EP ort event stack: [x] <- top of stack
|
|
526
|
+
* [EP events are tagged with 'x']
|
|
527
|
+
* OrtEpProfilerImpl::StartEvent(y) -> EP ort event stack: [x, y] <- top of stack
|
|
528
|
+
* [EP events are tagged with 'y']
|
|
529
|
+
* OrtEpProfilerImpl::StopEvent(y) -> EP ort event stack: [x] <- top of stack
|
|
530
|
+
* OrtEpProfilerImpl::StartEvent(z) -> EP ort event stack: [x, z] <- top of stack
|
|
531
|
+
* [EP events are tagged with 'z']
|
|
532
|
+
* OrtEpProfilerImpl::StopEvent(z) -> EP ort event stack: [x] <- top of stack
|
|
533
|
+
* OrtEpProfilerImpl::StopEvent(x) -> EP ort event stack: [ ] <- top of stack
|
|
534
|
+
*
|
|
535
|
+
* Tagging EP events with the ORT event correlation ID enables the EP to annotate its own events
|
|
536
|
+
* with metadata from the parent ORT event (e.g., operator name).
|
|
537
|
+
*
|
|
538
|
+
* \note **Threading:** For a given ORT event, StartEvent, the kernel's Compute() entry point, and StopEvent
|
|
539
|
+
* are all invoked on the same CPU thread (Compute() may asynchronously launch device work).
|
|
540
|
+
* Different ORT events may run on different threads (e.g., inter-op parallelism), so correlation
|
|
541
|
+
* stacks (e.g., for CUPTI) should use thread-local storage.
|
|
542
|
+
*
|
|
543
|
+
* \note The ORT event correlation ID is an absolute, epoch-based timestamp in microseconds. It is computed
|
|
544
|
+
* from the ORT event's start time using std::chrono::high_resolution_clock (platform-defined epoch).
|
|
545
|
+
* Because it is absolute rather than relative to profiling start, it is practically unique across
|
|
546
|
+
* concurrent profiling sessions within the same process (collisions require sub-microsecond event
|
|
547
|
+
* concurrency) and can be used directly as a correlation ID for EP profiling utilities
|
|
548
|
+
* (e.g., CUPTI or ROCTracer).
|
|
549
|
+
*
|
|
550
|
+
* \param[in] this_ptr Pointer to the OrtEpProfilerImpl instance.
|
|
551
|
+
* \param[in] ort_event_correlation_id Absolute, epoch-based correlation ID for the ORT event that is starting.
|
|
552
|
+
* The same value is passed to the corresponding StopEvent call.
|
|
553
|
+
*
|
|
554
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
555
|
+
*
|
|
556
|
+
* \note An error OrtStatus returned from this function is logged by ORT (does not end execution).
|
|
557
|
+
* \note Implementation of this function is optional. If set to NULL, it is not called.
|
|
558
|
+
*
|
|
559
|
+
* \since Version 1.25.
|
|
560
|
+
*/
|
|
561
|
+
ORT_API2_STATUS(StartEvent, _In_ OrtEpProfilerImpl* this_ptr, _In_ uint64_t ort_event_correlation_id);
|
|
562
|
+
|
|
563
|
+
/** \brief Called when a profiled ORT event (e.g., session initialization, node kernel execution, etc.) ends.
|
|
564
|
+
*
|
|
565
|
+
* ORT pairs every StartEvent call with a corresponding call to StopEvent with the same ORT event correlation ID.
|
|
566
|
+
* EP profiler implementations may use the calls to StartEvent and StopEvent to maintain a stack of ORT event
|
|
567
|
+
* correlation IDs that can be correlated with EP events (e.g., GPU kernel events). For example:
|
|
568
|
+
*
|
|
569
|
+
* OrtEpProfilerImpl::StartEvent(x) -> EP ort event stack: [x] <- top of stack
|
|
570
|
+
* [EP events are tagged with 'x']
|
|
571
|
+
* OrtEpProfilerImpl::StartEvent(y) -> EP ort event stack: [x, y] <- top of stack
|
|
572
|
+
* [EP events are tagged with 'y']
|
|
573
|
+
* OrtEpProfilerImpl::StopEvent(y) -> EP ort event stack: [x] <- top of stack
|
|
574
|
+
* OrtEpProfilerImpl::StartEvent(z) -> EP ort event stack: [x, z] <- top of stack
|
|
575
|
+
* [EP events are tagged with 'z']
|
|
576
|
+
* OrtEpProfilerImpl::StopEvent(z) -> EP ort event stack: [x] <- top of stack
|
|
577
|
+
* OrtEpProfilerImpl::StopEvent(x) -> EP ort event stack: [ ] <- top of stack
|
|
578
|
+
*
|
|
579
|
+
* Tagging EP events with the ORT event correlation ID enables the EP to annotate its own events
|
|
580
|
+
* with metadata from the parent ORT event (e.g., operator name).
|
|
581
|
+
*
|
|
582
|
+
* \note **Threading:** For a given ORT event, StartEvent, the kernel's Compute() entry point, and StopEvent
|
|
583
|
+
* are all invoked on the same CPU thread (Compute() may asynchronously launch device work).
|
|
584
|
+
* Different ORT events may run on different threads (e.g., inter-op parallelism), so correlation
|
|
585
|
+
* stacks (e.g., for CUPTI) should use thread-local storage.
|
|
586
|
+
*
|
|
587
|
+
* \note The ORT event correlation ID is an absolute, epoch-based timestamp in microseconds. It is computed
|
|
588
|
+
* from the ORT event's start time using std::chrono::high_resolution_clock (platform-defined epoch).
|
|
589
|
+
* Because it is absolute rather than relative to profiling start, it is practically unique across
|
|
590
|
+
* concurrent profiling sessions within the same process (collisions require sub-microsecond event
|
|
591
|
+
* concurrency) and can be used directly as a correlation ID for EP profiling utilities
|
|
592
|
+
* (e.g., CUPTI or ROCTracer).
|
|
593
|
+
*
|
|
594
|
+
* \param[in] this_ptr Pointer to the OrtEpProfilerImpl instance.
|
|
595
|
+
* \param[in] ort_event_correlation_id Absolute, epoch-based correlation ID for the ORT event that is ending.
|
|
596
|
+
* The same value was passed to the corresponding StartEvent call.
|
|
597
|
+
* \param[in] ort_event Opaque pointer to the ORT profiling event. Valid only during this call.
|
|
598
|
+
* Use OrtEpApi accessor functions to read event fields.
|
|
599
|
+
*
|
|
600
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
601
|
+
*
|
|
602
|
+
* \note An error OrtStatus returned from this function is logged by ORT (does not end execution).
|
|
603
|
+
* \note Implementation of this function is optional. If set to NULL, it is not called.
|
|
604
|
+
*
|
|
605
|
+
* \since Version 1.25.
|
|
606
|
+
*/
|
|
607
|
+
ORT_API2_STATUS(StopEvent, _In_ OrtEpProfilerImpl* this_ptr, _In_ uint64_t ort_event_correlation_id,
|
|
608
|
+
_In_ const OrtProfilingEvent* ort_event);
|
|
609
|
+
|
|
610
|
+
/** \brief Called when profiling ends to collect the EP's new profiling events since the call to StartProfiling.
|
|
611
|
+
*
|
|
612
|
+
* An EP profiler converts its events to OrtProfilingEvent instances and adds them into the provided
|
|
613
|
+
* OrtProfilingEventsContainer container. Call OrtEpApi::CreateProfilingEvent to create a new
|
|
614
|
+
* OrtProfilingEvent instance. Then call OrtEpApi::ProfilingEventsContainer_AddEvents to add one or more
|
|
615
|
+
* events to the container.
|
|
616
|
+
*
|
|
617
|
+
* After this function returns, ORT appends the EP's events to the profiling timeline.
|
|
618
|
+
*
|
|
619
|
+
* \param[in] this_ptr The OrtEpProfilerImpl instance.
|
|
620
|
+
* \param[in] events_container Event container to which the EP profiler adds its new events.
|
|
621
|
+
*
|
|
622
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
623
|
+
*
|
|
624
|
+
* \note An error OrtStatus returned from this function is logged by ORT (does not end execution).
|
|
625
|
+
* \note Implementation of this function is required.
|
|
626
|
+
*
|
|
627
|
+
* \since Version 1.25.
|
|
628
|
+
*/
|
|
629
|
+
ORT_API2_STATUS(EndProfiling, _In_ OrtEpProfilerImpl* this_ptr,
|
|
630
|
+
_In_ OrtProfilingEventsContainer* events_container);
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
struct OrtNodeFusionOptions;
|
|
634
|
+
typedef struct OrtNodeFusionOptions OrtNodeFusionOptions;
|
|
635
|
+
|
|
636
|
+
struct OrtNodeComputeInfo;
|
|
637
|
+
typedef struct OrtNodeComputeInfo OrtNodeComputeInfo;
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* \brief The OrtNodeFusionOptions struct specifies options for fusing nodes supported by an execution provider.
|
|
641
|
+
*
|
|
642
|
+
* Refer to OrtEpApi::EpGraphSupportInfo_AddNodesToFuse.
|
|
643
|
+
*
|
|
644
|
+
* \since Version 1.23.
|
|
645
|
+
*/
|
|
646
|
+
struct OrtNodeFusionOptions {
|
|
647
|
+
/** \brief The ONNX Runtime version the OrtNodeFusionOptions was compiled with.
|
|
648
|
+
*
|
|
649
|
+
* Implementation should set to ORT_API_VERSION.
|
|
650
|
+
* ORT will use this to ensure it does not use members that were not available when the EP library was compiled.
|
|
651
|
+
*
|
|
652
|
+
* \since Version 1.23.
|
|
653
|
+
*/
|
|
654
|
+
uint32_t ort_version_supported;
|
|
655
|
+
|
|
656
|
+
/** \brief If set to true, specify that the execution provider does not require ONNX Runtime to provide constant
|
|
657
|
+
* initializers as inputs to the fused node during model inference. This is used when the execution
|
|
658
|
+
* provider saves a copy of constant initializers, and allows ONNX Runtime to release constant initializers that
|
|
659
|
+
* are not used by any execution provider.
|
|
660
|
+
*
|
|
661
|
+
* If not specified, defaults to false. That is, ONNX Runtime provides constant initializers as inputs to
|
|
662
|
+
* the fused node by default.
|
|
663
|
+
*
|
|
664
|
+
* \since Version 1.23.
|
|
665
|
+
*/
|
|
666
|
+
bool drop_constant_initializers;
|
|
667
|
+
|
|
668
|
+
// const OrtNode* fused_node_schema;
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* \brief The OrtNodeComputeInfo struct provides functions that an OrtEp implements to specify the compute
|
|
673
|
+
* function for a compiled OrtGraph instance.
|
|
674
|
+
* \since Version 1.23.
|
|
675
|
+
*/
|
|
676
|
+
struct OrtNodeComputeInfo {
|
|
677
|
+
/** \brief The ONNX Runtime version the OrtNodeComputeInfo was compiled with.
|
|
678
|
+
*
|
|
679
|
+
* Implementation should set to ORT_API_VERSION.
|
|
680
|
+
* ORT will use this to ensure it does not call functions that were not available when the EP library was compiled.
|
|
681
|
+
*
|
|
682
|
+
* \since Version 1.23.
|
|
683
|
+
*/
|
|
684
|
+
uint32_t ort_version_supported;
|
|
685
|
+
|
|
686
|
+
/** \brief Creates an opaque compute state object that is then passed to the Compute() function during inference.
|
|
687
|
+
* \param[in] this_ptr The OrtNodeComputeInfo instance.
|
|
688
|
+
* \param[in] compute_context OrtNodeComputeContext instance that contains compiled/fused node's name and host
|
|
689
|
+
* memory allocation functions. Can optionally be used to build the compute state.
|
|
690
|
+
* \param[out] compute_state Output parameter that is assigned the opaque computation state. ONNX Runtime calls
|
|
691
|
+
* ReleaseState() (after calling Compute()) to allow the implementer to release the
|
|
692
|
+
* compute state.
|
|
693
|
+
*
|
|
694
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
695
|
+
*
|
|
696
|
+
* \since Version 1.23.
|
|
697
|
+
*/
|
|
698
|
+
OrtStatus*(ORT_API_CALL* CreateState)(_In_ OrtNodeComputeInfo* this_ptr,
|
|
699
|
+
_In_ OrtNodeComputeContext* compute_context,
|
|
700
|
+
_Outptr_ void** compute_state);
|
|
701
|
+
|
|
702
|
+
/** \brief Computation function called to execute the fused node compiled by an OrtEp instance.
|
|
703
|
+
* \param[in] this_ptr The OrtNodeComputeInfo instance.
|
|
704
|
+
* \param[in] compute_state The opaque computation state returned by CreateState().
|
|
705
|
+
* \param[in] kernel_context The OrtKernelContext instance used to access inputs/outputs.
|
|
706
|
+
*
|
|
707
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
708
|
+
*
|
|
709
|
+
* \since Version 1.23.
|
|
710
|
+
*/
|
|
711
|
+
OrtStatus*(ORT_API_CALL* Compute)(_In_ OrtNodeComputeInfo* this_ptr, _In_ void* compute_state,
|
|
712
|
+
_In_ OrtKernelContext* kernel_context);
|
|
713
|
+
|
|
714
|
+
/** \brief Releases the compute state returned by CreateState().
|
|
715
|
+
* \param[in] this_ptr The OrtNodeComputeInfo instance.
|
|
716
|
+
* \param[inout] compute_state The opaque compute state returned by CreateState().
|
|
717
|
+
*
|
|
718
|
+
* \since Version 1.23.
|
|
719
|
+
*/
|
|
720
|
+
void(ORT_API_CALL* ReleaseState)(_In_ OrtNodeComputeInfo* this_ptr, _Frees_ptr_opt_ void* compute_state);
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
struct OrtKernelImpl;
|
|
724
|
+
typedef struct OrtKernelImpl OrtKernelImpl;
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* \brief Contains functions that an OrtEp implements to specify the computation for an operator kernel.
|
|
728
|
+
* \since Version 1.24.
|
|
729
|
+
*/
|
|
730
|
+
struct OrtKernelImpl {
|
|
731
|
+
uint32_t ort_version_supported; ///< Must be initialized to ORT_API_VERSION
|
|
732
|
+
uint32_t flags; ///< EP must initialize to 0. Used internally by ORT.
|
|
733
|
+
|
|
734
|
+
/** \brief Computation function called to execute the kernel on an EP.
|
|
735
|
+
*
|
|
736
|
+
* \note Implementation of this function is required.
|
|
737
|
+
*
|
|
738
|
+
* \param[in] this_ptr The OrtKernelImpl instance.
|
|
739
|
+
* \param[in] context The OrtKernelContext instance that provides access to the inputs and outputs.
|
|
740
|
+
*
|
|
741
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
742
|
+
*
|
|
743
|
+
* \since Version 1.24.
|
|
744
|
+
*/
|
|
745
|
+
ORT_API2_STATUS(Compute, _In_ OrtKernelImpl* this_ptr, _In_ OrtKernelContext* context);
|
|
746
|
+
|
|
747
|
+
/** \brief Called by ORT to release the OrtKernelImpl instance and its resources.
|
|
748
|
+
*
|
|
749
|
+
* \note Implementation of this function is required.
|
|
750
|
+
*
|
|
751
|
+
* \param[in] this_ptr The OrtKernelImpl instance.
|
|
752
|
+
*
|
|
753
|
+
* \since Version 1.24.
|
|
754
|
+
*/
|
|
755
|
+
ORT_API_T(void, Release, _In_ OrtKernelImpl* this_ptr);
|
|
756
|
+
|
|
757
|
+
/** \brief Optional function to pre-pack a constant tensor (i.e., a weight) to the kernel's preferred data layout.
|
|
758
|
+
*
|
|
759
|
+
* For example, a Conv kernel can define this function to pack input W to the channel-last data layout
|
|
760
|
+
* before inference.
|
|
761
|
+
*
|
|
762
|
+
* Pre-packing can operate in three different modes: no pre-packing mode, sharing mode, and non-sharing mode.
|
|
763
|
+
* 1) No pre-packing mode: The kernel can forgo any weight pre-packing for the given `input_index` by setting
|
|
764
|
+
* `is_packed` to false and returning a successful OrtStatus. In this mode, the kernel's
|
|
765
|
+
* OrtKernelImpl::SetSharedPrePackedWeight() function is not called for that specific
|
|
766
|
+
* `input_index`.
|
|
767
|
+
* 2) Sharing mode: Sharing is allowed if the `prepacked_weight_cache` argument is not NULL and the EP stores
|
|
768
|
+
* weight data in CPU-accessible memory. In this case, the kernel can optionally choose
|
|
769
|
+
* to share the packed weight with other kernels that use the same weight
|
|
770
|
+
* (compared by content hash). To do so, the kernel must allocate the packed weight with the
|
|
771
|
+
* provided `allocator`, then it stores the packed weight data into `prepacked_weight_cache`
|
|
772
|
+
* via SharedPrePackedWeightCache_StoreWeightData(), sets `is_packed` to true, and returns a
|
|
773
|
+
* successful OrtStatus. ORT will subsequently call OrtKernelImpl::SetSharedPrePackedWeight()
|
|
774
|
+
* to provide this kernel with the actual shared weight data, whose memory location could
|
|
775
|
+
* differ (i.e., if shared data was allocated by a previously processed kernel).
|
|
776
|
+
* 3) Non-sharing mode: In non-sharing mode, the `prepacked_weight_cache` argument is ignored. In this mode,
|
|
777
|
+
* the implementation allocates the packed data with the provided `allocator`, sets
|
|
778
|
+
* `is_packed` to true, and returns a successful OrtStatus. The kernel is ultimately
|
|
779
|
+
* responsible for releasing the packed data for the weight with `allocator`.
|
|
780
|
+
* ORT may release the original (unpacked) weight, which must not be accessed in
|
|
781
|
+
* OrtKernelImpl::Compute(). Note that in this mode, the kernel's
|
|
782
|
+
* OrtKernelImpl::SetSharedPrePackedWeight() function is not called by ORT for that specific
|
|
783
|
+
* `input_index`.
|
|
784
|
+
*
|
|
785
|
+
* \note This function is based on the internal OpKernel::PrePack() virtual function used within ORT.
|
|
786
|
+
*
|
|
787
|
+
* \param[in] this_ptr The OrtKernelImpl instance.
|
|
788
|
+
* \param[in] tensor The OrtValue instance representing the constant tensor (weight). Do not cache in the kernel.
|
|
789
|
+
* \param[in] input_index The input index of the tensor in this kernel.
|
|
790
|
+
* \param[in] allocator Allocator for allocating the pre-packed data. Its use is required in sharing mode and
|
|
791
|
+
* recommended, but not required, in the non-sharing mode. This will be an allocator set by
|
|
792
|
+
* the application for the session/environment (e.g., via CreateAndRegisterAllocator[V2]
|
|
793
|
+
* or RegisterAllocator), or an allocator on the OrtEpDevice (read-only or default) otherwise.
|
|
794
|
+
* The allocator remains valid throughout the lifetime of the OrtKernelImpl instance.
|
|
795
|
+
* \param[in] prepacked_weight_cache May be NULL. If not NULL, the kernel may choose to share a packed weight by
|
|
796
|
+
* first storing it in the OrtSharedPrePackedWeightCache instance and then
|
|
797
|
+
* receiving the actual shared weight data in the call to
|
|
798
|
+
* OrtKernelImpl::SetSharedPrePackedWeight(). See the above description for
|
|
799
|
+
* "sharing mode".
|
|
800
|
+
* \param[out] is_packed Output parameter that the implementation sets to true if the kernel packed the tensor data.
|
|
801
|
+
*
|
|
802
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
803
|
+
*
|
|
804
|
+
* \note Implementation of this function is optional. If not implemented (set to NULL), ORT assumes the kernel
|
|
805
|
+
* does not pre-pack weight data (i.e., `is_packed` defaults to false).
|
|
806
|
+
*
|
|
807
|
+
* \since Version 1.24.
|
|
808
|
+
*/
|
|
809
|
+
ORT_API2_STATUS(PrePackWeight, _In_ OrtKernelImpl* this_ptr, _In_ const OrtValue* tensor,
|
|
810
|
+
_In_ int input_index, _Inout_ OrtAllocator* allocator,
|
|
811
|
+
_In_opt_ OrtSharedPrePackedWeightCache* prepacked_weight_cache, _Out_ bool* is_packed);
|
|
812
|
+
|
|
813
|
+
/** \brief Optional function that receives data for a shared pre-packed weight from ORT.
|
|
814
|
+
*
|
|
815
|
+
* ORT calls this function after calling OrtKernelImpl::PrePackWeight for a specific `input_index` if:
|
|
816
|
+
* - OrtKernelImpl::PrePackWeight set the output parameter `is_packed` to true.
|
|
817
|
+
* - OrtKernelImpl::PrePackWeight stored weight data to share into the provided OrtSharedPrePackedWeightCache
|
|
818
|
+
* parameter (`prepacked_weight_cache`) via the API SharedPrePackedWeightCache_StoreWeightData.
|
|
819
|
+
*
|
|
820
|
+
* Refer to the description of the "sharing-mode" in the documentation for OrtKernelImpl::PrePackWeight().
|
|
821
|
+
*
|
|
822
|
+
* \note ORT will not call this function for an `input_index` that a previous call to
|
|
823
|
+
* OrtKernelImpl::PrePackWeight() did not elect to pre-pack and share.
|
|
824
|
+
*
|
|
825
|
+
* \note This function is based on the internal OpKernel::UseSharedPrePackedBuffers() virtual function used
|
|
826
|
+
* within ORT.
|
|
827
|
+
*
|
|
828
|
+
* \param[in] this_ptr The OrtKernelImpl instance.
|
|
829
|
+
* \param[in] buffer_data_ptrs An array of buffer data pointers that collectively hold the pre-packed data for a
|
|
830
|
+
* single shared weight. The buffers are provided in the same order and with the same
|
|
831
|
+
* contents (in a potentially different memory location) as the buffers
|
|
832
|
+
* passed into SharedPrePackedWeightCache_StoreWeightData() within the
|
|
833
|
+
* OrtKernelImpl::PrePackWeight() call for the same `input_index`.
|
|
834
|
+
* \param[in] buffer_data_sizes An array of buffer byte sizes, one per element in `buffer_data_ptrs`.
|
|
835
|
+
* \param[in] num_buffers The number of buffers used to store the data for the shared pre-packed weight.
|
|
836
|
+
* Specifies the number of elements in the `buffer_data_ptrs` and `buffer_data_sizes` arrays.
|
|
837
|
+
* \param[in] input_index The input index of the tensor in this kernel. This index identifies the identity of
|
|
838
|
+
* the weight.
|
|
839
|
+
*
|
|
840
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
841
|
+
*
|
|
842
|
+
* \note Implementation of this function is generally optional. It is only required if OrtKernelImpl::PrePack()
|
|
843
|
+
* elects to share pre-packed weights.
|
|
844
|
+
*
|
|
845
|
+
* \since Version 1.24.
|
|
846
|
+
*/
|
|
847
|
+
ORT_API2_STATUS(SetSharedPrePackedWeight, _In_ OrtKernelImpl* this_ptr,
|
|
848
|
+
_In_reads_(num_buffers) const void* const* buffer_data_ptrs,
|
|
849
|
+
_In_reads_(num_buffers) const size_t* buffer_data_sizes,
|
|
850
|
+
_In_ size_t num_buffers, _In_ int input_index);
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
/** \brief Type definition for a function that creates an OrtKernelImpl instance for an operator kernel.
|
|
854
|
+
*
|
|
855
|
+
* \param[in] kernel_create_func_state Opaque state initially provided by the EP that registered the kernel.
|
|
856
|
+
* Refer to OrtEpApi::KernelRegistry_AddKernel(). May be null.
|
|
857
|
+
* \param[in] info The OrtKernelInfo instance that provides access to the kernel's input and output characteristics.
|
|
858
|
+
* \param[out] kernel_out Output parameter set to the new OrtKernelImpl instance. On success, ownership of this
|
|
859
|
+
* OrtKernelImpl instance transfers to ORT, which will call OrtKernelImpl::Release() to
|
|
860
|
+
* release the instance when it is no longer used.
|
|
861
|
+
*
|
|
862
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
863
|
+
*
|
|
864
|
+
* \since Version 1.24.
|
|
865
|
+
*/
|
|
866
|
+
typedef OrtStatus*(ORT_API_CALL* OrtKernelCreateFunc)(_In_ void* kernel_create_func_state,
|
|
867
|
+
_In_ const OrtKernelInfo* info,
|
|
868
|
+
_Outptr_result_maybenull_ OrtKernelImpl** kernel_out);
|
|
869
|
+
|
|
870
|
+
struct OrtLoopKernelHelper;
|
|
871
|
+
typedef struct OrtLoopKernelHelper OrtLoopKernelHelper;
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* \brief Contains helper functions for a Loop OrtKernelImpl created via OrtEpApi::CreateLoopKernel.
|
|
875
|
+
* \since Version 1.24.
|
|
876
|
+
*/
|
|
877
|
+
struct OrtLoopKernelHelper {
|
|
878
|
+
uint32_t ort_version_supported; ///< Must be initialized to ORT_API_VERSION
|
|
879
|
+
|
|
880
|
+
/** \brief Called by ORT to release the OrtLoopKernelHelper instance and its resources.
|
|
881
|
+
*
|
|
882
|
+
* \param[in] this_ptr The OrtLoopKernelHelper instance.
|
|
883
|
+
*
|
|
884
|
+
* \since Version 1.24.
|
|
885
|
+
*/
|
|
886
|
+
ORT_API_T(void, Release, _In_ OrtLoopKernelHelper* this_ptr);
|
|
887
|
+
|
|
888
|
+
/** \brief Helper function that concatenates OrtValue instances from each loop iteration into a single
|
|
889
|
+
* pre-allocated output buffer.
|
|
890
|
+
*
|
|
891
|
+
* \note Implementing this function is required for all Loop opset versions.
|
|
892
|
+
*
|
|
893
|
+
* \param[in] this_ptr The OrtLoopKernelHelper instance.
|
|
894
|
+
* \param[in] stream_handle Optional native stream handle that enables asynchronous operations. May be NULL.
|
|
895
|
+
* \param[in] per_iteration_outputs Array of OrtValue instances from each iteration. All OrtValue elements have the
|
|
896
|
+
* same shape.
|
|
897
|
+
* \param[in] num_per_iteration_outputs The number of OrtValue* elements in the `per_iteration_outputs` array.
|
|
898
|
+
* \param[out] output The pre-allocated output buffer. Memory is allocated on the device for the EP running the
|
|
899
|
+
* Loop node.
|
|
900
|
+
* \param[in] output_size_in_bytes The size in bytes of the `output` buffer. It is guaranteed to be large enough
|
|
901
|
+
* to hold the concatenated data of each element in `per_iteration_outputs`.
|
|
902
|
+
*
|
|
903
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
904
|
+
*
|
|
905
|
+
* \since Version 1.24.
|
|
906
|
+
*/
|
|
907
|
+
ORT_API2_STATUS(ConcatOutput, _In_ OrtLoopKernelHelper* this_ptr, _In_opt_ void* stream_handle,
|
|
908
|
+
_In_reads_(num_per_iteration_outputs) const OrtValue* const* per_iteration_outputs,
|
|
909
|
+
_In_ size_t num_per_iteration_outputs, _Out_writes_bytes_all_(output_size_in_bytes) void* output,
|
|
910
|
+
_In_ size_t output_size_in_bytes);
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
struct OrtScanKernelHelper;
|
|
914
|
+
typedef struct OrtScanKernelHelper OrtScanKernelHelper;
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* \brief Contains helper functions for a Scan OrtKernelImpl created via OrtEpApi::CreateScanKernel.
|
|
918
|
+
* \since Version 1.24.
|
|
919
|
+
*/
|
|
920
|
+
struct OrtScanKernelHelper {
|
|
921
|
+
uint32_t ort_version_supported; ///< Must be initialized to ORT_API_VERSION
|
|
922
|
+
|
|
923
|
+
/** \brief Called by ORT to release the OrtScanKernelHelper instance and its resources.
|
|
924
|
+
*
|
|
925
|
+
* \param[in] this_ptr The OrtScanKernelHelper instance.
|
|
926
|
+
*
|
|
927
|
+
* \since Version 1.24.
|
|
928
|
+
*/
|
|
929
|
+
ORT_API_T(void, Release, _In_ OrtScanKernelHelper* this_ptr);
|
|
930
|
+
|
|
931
|
+
/** \brief Helper function that transposes an OrtValue instance during execution of a Scan kernel.
|
|
932
|
+
*
|
|
933
|
+
* \note Called for Scan (opset >= 9) when the 'scan_input_axes' or 'scan_output_axes' attributes contain
|
|
934
|
+
* non-zero values. Implementing this function is required for Scan opset versions >= 9.
|
|
935
|
+
*
|
|
936
|
+
* \param[in] this_ptr The OrtScanKernelHelper instance.
|
|
937
|
+
* \param[in] permutation An array of integers that defines how the input tensor's axes should be permuted.
|
|
938
|
+
* \param[in] num_permutation_elems The number of integer elements in the `permutation` array.
|
|
939
|
+
* \param[in] input The input OrtValue tensor to transpose.
|
|
940
|
+
* \param[in] stream An optional OrtSyncStream instance to be used for asynchronous operations. May be NULL.
|
|
941
|
+
* \param[out] output The pre-allocated output OrtValue instance into which to store the results of the
|
|
942
|
+
* transpose operation. Must not be released as it is owned by ORT.
|
|
943
|
+
*
|
|
944
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
945
|
+
*
|
|
946
|
+
* \since Version 1.24.
|
|
947
|
+
*/
|
|
948
|
+
ORT_API2_STATUS(Transpose, _In_ OrtScanKernelHelper* this_ptr,
|
|
949
|
+
_In_reads_(num_permutation_elems) const size_t* permutation, _In_ size_t num_permutation_elems,
|
|
950
|
+
_In_ const OrtValue* input, _In_opt_ OrtSyncStream* stream, _Inout_ OrtValue* output);
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* \brief Discriminator for the resource count type stored in an OrtResourceCount.
|
|
955
|
+
*
|
|
956
|
+
* New resource accounting types can be added by appending new enum values.
|
|
957
|
+
* The OrtResourceCount union storage is large enough to hold all current and future types.
|
|
958
|
+
*
|
|
959
|
+
* \since Version 1.26.
|
|
960
|
+
*/
|
|
961
|
+
typedef enum OrtResourceCountKind {
|
|
962
|
+
OrtResourceCountKind_None = 0, ///< Unset / zero-cost sentinel.
|
|
963
|
+
OrtResourceCountKind_TotalBytes = 1, ///< Single uint64_t: byte count (cost or budget).
|
|
964
|
+
} OrtResourceCountKind;
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* \brief ABI-stable tagged union representing a resource cost or budget.
|
|
968
|
+
*
|
|
969
|
+
* This struct is a C-safe variant that can be passed by value across the plugin DLL boundary.
|
|
970
|
+
* The `kind` field selects which member of the `value` union is active. The
|
|
971
|
+
* `value.reserved_words` storage reserves space for future resource types without changing
|
|
972
|
+
* the struct layout.
|
|
973
|
+
*
|
|
974
|
+
* Adding new resource types requires only: (a) a new OrtResourceCountKind enum value,
|
|
975
|
+
* (b) a new union member. No new C API functions are needed.
|
|
976
|
+
*
|
|
977
|
+
* \since Version 1.26.
|
|
978
|
+
*/
|
|
979
|
+
typedef struct OrtResourceCount {
|
|
980
|
+
uint32_t kind; /**< OrtResourceCountKind discriminator. */
|
|
981
|
+
uint32_t reserved; /**< Must be zero. Ensures natural alignment for the value union. */
|
|
982
|
+
|
|
983
|
+
union {
|
|
984
|
+
uint64_t total_bytes; /**< Active when kind == OrtResourceCountKind_TotalBytes. */
|
|
985
|
+
uint64_t reserved_words[6]; /**< 48 bytes fixed storage for future resource types. */
|
|
986
|
+
} value;
|
|
987
|
+
|
|
988
|
+
#ifdef __cplusplus
|
|
989
|
+
/** Default-construct a None (unset) resource count. */
|
|
990
|
+
OrtResourceCount() noexcept : kind{OrtResourceCountKind_None}, reserved{0}, value{} {}
|
|
991
|
+
|
|
992
|
+
/** Construct a zero/unset resource count. */
|
|
993
|
+
static OrtResourceCount None() noexcept {
|
|
994
|
+
return OrtResourceCount{};
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
/** Construct a resource count representing total bytes. */
|
|
998
|
+
static OrtResourceCount FromTotalBytes(uint64_t bytes) noexcept {
|
|
999
|
+
OrtResourceCount rc{};
|
|
1000
|
+
rc.kind = OrtResourceCountKind_TotalBytes;
|
|
1001
|
+
rc.value.total_bytes = bytes;
|
|
1002
|
+
return rc;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
/** Read the total_bytes value (caller must check kind first). */
|
|
1006
|
+
uint64_t AsTotalBytes() const noexcept {
|
|
1007
|
+
return value.total_bytes;
|
|
1008
|
+
}
|
|
1009
|
+
#endif
|
|
1010
|
+
} OrtResourceCount;
|
|
1011
|
+
|
|
1012
|
+
#ifdef __cplusplus
|
|
1013
|
+
static_assert(sizeof(OrtResourceCount) == 56, "OrtResourceCount size must not change to maintain ABI stability");
|
|
1014
|
+
#endif
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* \brief The OrtEpApi struct provides functions that are relevant to the implementation of an execution provider.
|
|
1018
|
+
*
|
|
1019
|
+
* \since Version 1.22.
|
|
1020
|
+
*/
|
|
1021
|
+
struct OrtEpApi {
|
|
1022
|
+
/** \brief Create an OrtEpDevice for the EP and an OrtHardwareDevice.
|
|
1023
|
+
* \param[in] ep_factory Execution provider factory that is creating the instance.
|
|
1024
|
+
* \param[in] hardware_device Hardware device that the EP can utilize.
|
|
1025
|
+
* \param[in] ep_metadata Optional OrtKeyValuePairs instance for execution provider metadata that may be used
|
|
1026
|
+
* during execution provider selection and passed to CreateEp.
|
|
1027
|
+
* ep_device will copy this instance and the user should call ReleaseKeyValuePairs.
|
|
1028
|
+
* \param[in] ep_options Optional OrtKeyValuePairs instance for execution provider options that will be added
|
|
1029
|
+
* to the Session configuration options if the execution provider is selected.
|
|
1030
|
+
* ep_device will copy this instance and the user should call ReleaseKeyValuePairs.
|
|
1031
|
+
* \param ep_device OrtExecutionDevice that is created.
|
|
1032
|
+
*
|
|
1033
|
+
* \since Version 1.22.
|
|
1034
|
+
*/
|
|
1035
|
+
ORT_API2_STATUS(CreateEpDevice, _In_ OrtEpFactory* ep_factory,
|
|
1036
|
+
_In_ const OrtHardwareDevice* hardware_device,
|
|
1037
|
+
_In_opt_ const OrtKeyValuePairs* ep_metadata,
|
|
1038
|
+
_In_opt_ const OrtKeyValuePairs* ep_options,
|
|
1039
|
+
_Out_ OrtEpDevice** ep_device);
|
|
1040
|
+
|
|
1041
|
+
ORT_CLASS_RELEASE(EpDevice);
|
|
1042
|
+
|
|
1043
|
+
/** \brief Specify nodes that are supported by an OrtEp and should be fused into one node.
|
|
1044
|
+
*
|
|
1045
|
+
* Because the nodes will be fused into one "fused node", there must not exist an unsupported node in
|
|
1046
|
+
* a path between two of the provided nodes. Otherwise, the graph will become invalid.
|
|
1047
|
+
*
|
|
1048
|
+
* This function can be called multiple times. A subsequent call to this function will force the next set of
|
|
1049
|
+
* nodes to be fused into a different node.
|
|
1050
|
+
*
|
|
1051
|
+
* \param[in] graph_support_info OrtEpGraphSupportInfo instance to which to add the supported nodes.
|
|
1052
|
+
* \param[in] nodes Array of nodes supported by the EP that should be fused/compiled.
|
|
1053
|
+
* \param[in] num_nodes The number of supported nodes.
|
|
1054
|
+
* \param[in] node_fusion_options Optional node fusion options. Ignored if set to NULL.
|
|
1055
|
+
*
|
|
1056
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1057
|
+
*
|
|
1058
|
+
* \since Version 1.23.
|
|
1059
|
+
*/
|
|
1060
|
+
ORT_API2_STATUS(EpGraphSupportInfo_AddNodesToFuse, _In_ OrtEpGraphSupportInfo* graph_support_info,
|
|
1061
|
+
_In_reads_(num_nodes) const OrtNode* const* nodes, _In_ size_t num_nodes,
|
|
1062
|
+
_In_opt_ const OrtNodeFusionOptions* node_fusion_options);
|
|
1063
|
+
|
|
1064
|
+
/** \brief Specify a node that is supported by an OrtEp and should be run with a registered EP kernel.
|
|
1065
|
+
*
|
|
1066
|
+
* \param[in] graph_support_info OrtEpGraphSupportInfo instance to which to add the supported node.
|
|
1067
|
+
* \param[in] node The supported OrtNode instance.
|
|
1068
|
+
*
|
|
1069
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1070
|
+
*
|
|
1071
|
+
* \since Version 1.23.
|
|
1072
|
+
*/
|
|
1073
|
+
ORT_API2_STATUS(EpGraphSupportInfo_AddSingleNode, _In_ OrtEpGraphSupportInfo* graph_support_info,
|
|
1074
|
+
_In_ const OrtNode* node);
|
|
1075
|
+
|
|
1076
|
+
/** \brief Query a OrtNodeComputeContext for the name of the node that encapsulates the compiled/fused node.
|
|
1077
|
+
*
|
|
1078
|
+
* Used in OrtNodeComputeInfo::CreateComputeState().
|
|
1079
|
+
*
|
|
1080
|
+
* \param[in] context The OrtNodeComputeContext instance to query.
|
|
1081
|
+
* \return The node's name.
|
|
1082
|
+
*
|
|
1083
|
+
* \note Returned string is owned by ORT and valid only while OrtNodeComputeInfo::CreateComputeState() is called.
|
|
1084
|
+
*
|
|
1085
|
+
* \since Version 1.23.
|
|
1086
|
+
*/
|
|
1087
|
+
ORT_API_T(const char*, NodeComputeContext_NodeName, _In_ const OrtNodeComputeContext* context);
|
|
1088
|
+
|
|
1089
|
+
/** \brief Register an allocator with the OrtEpDevice.
|
|
1090
|
+
*
|
|
1091
|
+
* This allows an EP to provide OrtMemoryInfo for DEFAULT and HOST_ACCESSIBLE memory type as needed.
|
|
1092
|
+
* The registered values will be used in calls to OrtEpFactory::CreateAllocator to ensure the required allocator/s
|
|
1093
|
+
* are available for EP usage.
|
|
1094
|
+
*
|
|
1095
|
+
* Multiple calls for the same entry type will replace a previous entry.
|
|
1096
|
+
*
|
|
1097
|
+
* Available entries:
|
|
1098
|
+
* - OrtDeviceAllocator with type of OrtDeviceMemoryType_DEFAULT
|
|
1099
|
+
* - OrtDeviceAllocator with type of OrtDeviceMemoryType_HOST_ACCESSIBLE
|
|
1100
|
+
* - OrtReadOnlyAllocator with type of OrtDeviceMemoryType_DEFAULT
|
|
1101
|
+
* - if provided this allocator will only be used to copy initializers to the device the EP uses.
|
|
1102
|
+
* ORT will use the OrtDeviceAllocator if not provided.
|
|
1103
|
+
*
|
|
1104
|
+
* \param[in] ep_device The OrtEpDevice instance to register the OrtMemoryInfo with.
|
|
1105
|
+
* \param[in] allocator_memory_info The OrtMemoryInfo information for the allocator.
|
|
1106
|
+
*
|
|
1107
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1108
|
+
*
|
|
1109
|
+
* \since Version 1.23.
|
|
1110
|
+
*/
|
|
1111
|
+
ORT_API2_STATUS(EpDevice_AddAllocatorInfo, _In_ OrtEpDevice* ep_device,
|
|
1112
|
+
_In_ const OrtMemoryInfo* allocator_memory_info);
|
|
1113
|
+
|
|
1114
|
+
/** \brief Get the OrtMemoryDevice from an OrtMemoryInfo instance.
|
|
1115
|
+
*
|
|
1116
|
+
* This is required for OrtDataTransferImpl (which implements onnxruntime::IDataTransfer) where the OrtMemoryDevice
|
|
1117
|
+
* is used in the CanCopy and CopyTensors functions.
|
|
1118
|
+
*
|
|
1119
|
+
* \param[in] memory_info The OrtMemoryInfo instance to get the memory device from.
|
|
1120
|
+
* \return The OrtMemoryDevice associated with the OrtMemoryInfo instance.
|
|
1121
|
+
*
|
|
1122
|
+
* \since Version 1.23.
|
|
1123
|
+
*/
|
|
1124
|
+
ORT_API_T(const OrtMemoryDevice*, MemoryInfo_GetMemoryDevice, _In_ const OrtMemoryInfo* memory_info);
|
|
1125
|
+
|
|
1126
|
+
/** \brief Get the OrtMemoryDevice from an OrtValue instance if it contains a Tensor.
|
|
1127
|
+
*
|
|
1128
|
+
* \param[in] value The OrtValue instance to get the memory device from.
|
|
1129
|
+
* \return Memory device if OrtValue contains a Tensor, nullptr otherwise.
|
|
1130
|
+
*
|
|
1131
|
+
* \since Version 1.23.
|
|
1132
|
+
*/
|
|
1133
|
+
ORT_API_T(const OrtMemoryDevice*, Value_GetMemoryDevice, _In_ const OrtValue* value);
|
|
1134
|
+
|
|
1135
|
+
/** \brief Compare two OrtMemoryDevice instances for equality.
|
|
1136
|
+
*
|
|
1137
|
+
* This is used to check if two memory devices are the same.
|
|
1138
|
+
* Used to implement DataTransferImpl::CanCopy.
|
|
1139
|
+
*
|
|
1140
|
+
* \param[in] a The first OrtMemoryDevice instance to compare.
|
|
1141
|
+
* \param[in] b The second OrtMemoryDevice instance to compare.
|
|
1142
|
+
* \return True if the two OrtMemoryDevice instances are equal, false otherwise.
|
|
1143
|
+
*
|
|
1144
|
+
* \since Version 1.23.
|
|
1145
|
+
*/
|
|
1146
|
+
ORT_API_T(bool, MemoryDevice_AreEqual, _In_ const OrtMemoryDevice* a, _In_ const OrtMemoryDevice* b);
|
|
1147
|
+
|
|
1148
|
+
/** \brief Get the OrtMemoryInfoDeviceType value from an OrtMemoryDevice instance.
|
|
1149
|
+
*
|
|
1150
|
+
* \param[in] memory_device OrtMemoryDevice instance.
|
|
1151
|
+
* \return The OrtMemoryInfoDeviceType value.
|
|
1152
|
+
*
|
|
1153
|
+
* \since Version 1.23.
|
|
1154
|
+
*/
|
|
1155
|
+
ORT_API_T(OrtMemoryInfoDeviceType, MemoryDevice_GetDeviceType, _In_ const OrtMemoryDevice* memory_device);
|
|
1156
|
+
|
|
1157
|
+
/** \brief Get the OrtDeviceMemoryType value from an OrtMemoryDevice instance.
|
|
1158
|
+
*
|
|
1159
|
+
* \param[in] memory_device OrtMemoryDevice instance.
|
|
1160
|
+
* \return The OrtDeviceMemoryType value.
|
|
1161
|
+
*
|
|
1162
|
+
* \since Version 1.23.
|
|
1163
|
+
*/
|
|
1164
|
+
ORT_API_T(OrtDeviceMemoryType, MemoryDevice_GetMemoryType, _In_ const OrtMemoryDevice* memory_device);
|
|
1165
|
+
|
|
1166
|
+
/** \brief Get the vendor ID from an OrtMemoryDevice instance.
|
|
1167
|
+
*
|
|
1168
|
+
* The vendor ID is used to identify the vendor of the device, and is typically set to the PCI vendor ID.
|
|
1169
|
+
*
|
|
1170
|
+
* If the device is not vendor specific (e.g. CPU memory) the vendor ID is set to 0.
|
|
1171
|
+
*
|
|
1172
|
+
* \param[in] memory_device OrtMemoryDevice instance.
|
|
1173
|
+
* \return The vendor ID value.
|
|
1174
|
+
*
|
|
1175
|
+
* \since Version 1.23.
|
|
1176
|
+
*/
|
|
1177
|
+
ORT_API_T(uint32_t, MemoryDevice_GetVendorId, _In_ const OrtMemoryDevice* memory_device);
|
|
1178
|
+
|
|
1179
|
+
/** \brief Get the device ID from an OrtMemoryDevice instance.
|
|
1180
|
+
*
|
|
1181
|
+
* \param[in] memory_device OrtMemoryDevice instance.
|
|
1182
|
+
* \return The device ID.
|
|
1183
|
+
*
|
|
1184
|
+
* \since Version 1.23.
|
|
1185
|
+
*/
|
|
1186
|
+
ORT_API_T(uint32_t, MemoryDevice_GetDeviceId, _In_ const OrtMemoryDevice* memory_device);
|
|
1187
|
+
|
|
1188
|
+
/** \brief Get the OrtSyncStreamImpl associated with an OrtSyncStream instance.
|
|
1189
|
+
*
|
|
1190
|
+
* This allows an the plugin library to connect its OrtSyncStreamImpl instance with an OrtSyncStream if needed.
|
|
1191
|
+
*
|
|
1192
|
+
* \param[in] stream The OrtSyncStream instance to find an OrtSyncStreamImpl for.
|
|
1193
|
+
* \return The associated OrtSyncStreamImpl if found. nullptr otherwise.
|
|
1194
|
+
*
|
|
1195
|
+
* \since Version 1.23.
|
|
1196
|
+
*
|
|
1197
|
+
* \remarks There should always be an OrtSyncStreamImpl associated with an OrtSyncStream instance that the EP gets.
|
|
1198
|
+
*/
|
|
1199
|
+
ORT_API_T(const OrtSyncStreamImpl*, SyncStream_GetImpl, _In_ const OrtSyncStream* stream);
|
|
1200
|
+
|
|
1201
|
+
/** \brief Get the current sync ID for a stream.
|
|
1202
|
+
*
|
|
1203
|
+
* \param[in] stream The OrtSyncStream to get the sync ID for.
|
|
1204
|
+
* \return Current sync ID.
|
|
1205
|
+
*
|
|
1206
|
+
* \since Version 1.23.
|
|
1207
|
+
*/
|
|
1208
|
+
ORT_API_T(uint64_t, SyncStream_GetSyncId, _In_ const OrtSyncStream* stream);
|
|
1209
|
+
|
|
1210
|
+
/** \brief Get the sync ID for the last time the consumer_stream waited on the producer_stream.
|
|
1211
|
+
*
|
|
1212
|
+
* When two streams are synchronized, the sync id represents the event used in that synchronization.
|
|
1213
|
+
*
|
|
1214
|
+
* \param[in] producer_stream The OrtSyncStream that produced the data.
|
|
1215
|
+
* \param[in] consumer_stream The OrtSyncStream that waited on the producer_stream.
|
|
1216
|
+
* \return ID for last sync. 0 if no sync has occurred between the two streams.
|
|
1217
|
+
*
|
|
1218
|
+
* \since Version 1.23.
|
|
1219
|
+
*/
|
|
1220
|
+
ORT_API_T(uint64_t, GetSyncIdForLastWaitOnSyncStream,
|
|
1221
|
+
_In_ const OrtSyncStream* producer_stream, _In_ const OrtSyncStream* consumer_stream);
|
|
1222
|
+
|
|
1223
|
+
/** \brief Create an OrtHardwareDevice.
|
|
1224
|
+
*
|
|
1225
|
+
* \note Called within OrtEpFactory::GetSupportedDevices to create a new hardware device (e.g., virtual).
|
|
1226
|
+
*
|
|
1227
|
+
* \param[in] type The hardware device type.
|
|
1228
|
+
* \param[in] vendor_id The hardware device's vendor identifier.
|
|
1229
|
+
* \param[in] device_id The hardware device's identifier.
|
|
1230
|
+
* \param[in] vendor_name The hardware device's vendor name as a null-terminated string. Copied by ORT.
|
|
1231
|
+
* \param[in] metadata Optional OrtKeyValuePairs instance for hardware device metadata that may be queried by
|
|
1232
|
+
* applications via OrtApi::GetEpDevices().
|
|
1233
|
+
* Refer to onnxruntime_ep_device_ep_metadata_keys.h for common OrtHardwareDevice metadata keys.
|
|
1234
|
+
* \param[out] hardware_device Output parameter set to the new OrtHardwareDevice instance that is created.
|
|
1235
|
+
* Must be release with ReleaseHardwareDevice().
|
|
1236
|
+
*
|
|
1237
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1238
|
+
*
|
|
1239
|
+
* \since Version 1.24.
|
|
1240
|
+
*/
|
|
1241
|
+
ORT_API2_STATUS(CreateHardwareDevice, _In_ OrtHardwareDeviceType type,
|
|
1242
|
+
_In_ uint32_t vendor_id,
|
|
1243
|
+
_In_ uint32_t device_id,
|
|
1244
|
+
_In_ const char* vendor_name,
|
|
1245
|
+
_In_opt_ const OrtKeyValuePairs* metadata,
|
|
1246
|
+
_Out_ OrtHardwareDevice** hardware_device);
|
|
1247
|
+
|
|
1248
|
+
ORT_CLASS_RELEASE(HardwareDevice);
|
|
1249
|
+
|
|
1250
|
+
/** \brief Creates an empty kernel registry. A kernel registry contains kernel creation information for
|
|
1251
|
+
* every operator kernel supported by an EP.
|
|
1252
|
+
*
|
|
1253
|
+
* \remarks Refer to OrtEp::GetKernelRegistry, which returns an EP's kernel registry to ORT.
|
|
1254
|
+
*
|
|
1255
|
+
* \param[out] kernel_registry Output parameter set to the new OrtKernelRegistry instance.
|
|
1256
|
+
* Must be released with OrtEpApi::ReleaseKernelRegistry.
|
|
1257
|
+
*
|
|
1258
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1259
|
+
*
|
|
1260
|
+
* \since Version 1.24.
|
|
1261
|
+
*/
|
|
1262
|
+
ORT_API2_STATUS(CreateKernelRegistry, _Outptr_ OrtKernelRegistry** kernel_registry);
|
|
1263
|
+
|
|
1264
|
+
ORT_CLASS_RELEASE(KernelRegistry);
|
|
1265
|
+
|
|
1266
|
+
/** \brief Adds kernel creation information for a supported operator kernel to the given kernel registry.
|
|
1267
|
+
*
|
|
1268
|
+
* \remarks Refer to OrtEp::GetKernelRegistry, which returns an EP's kernel registry to ORT.
|
|
1269
|
+
*
|
|
1270
|
+
* \param[in] kernel_registry The OrtKernelRegistry instance.
|
|
1271
|
+
* \param[in] kernel_def The kernel definition, which includes operator type, version, EP name, type constraints, etc.
|
|
1272
|
+
* \param[in] kernel_create_func Function that creates an instance of the operator kernel as a OrtKernelImpl instance.
|
|
1273
|
+
* \param[in] kernel_create_func_state Custom state passed to the kernel creation function. Can be null.
|
|
1274
|
+
*
|
|
1275
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1276
|
+
*
|
|
1277
|
+
* \since Version 1.24.
|
|
1278
|
+
*/
|
|
1279
|
+
ORT_API2_STATUS(KernelRegistry_AddKernel, _In_ OrtKernelRegistry* kernel_registry,
|
|
1280
|
+
_In_ const OrtKernelDef* kernel_def, _In_ OrtKernelCreateFunc kernel_create_func,
|
|
1281
|
+
_In_ void* kernel_create_func_state);
|
|
1282
|
+
|
|
1283
|
+
/** \brief Creates a kernel definition builder used to create instances of OrtKernelDef.
|
|
1284
|
+
*
|
|
1285
|
+
* \param[out] kernel_def_builder_out Output parameter set to the new OrtKernelDefBuilder instance.
|
|
1286
|
+
* Must be released with OrtEpApi::ReleaseKernelDefBuilder().
|
|
1287
|
+
*
|
|
1288
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1289
|
+
*
|
|
1290
|
+
* \since Version 1.24.
|
|
1291
|
+
*/
|
|
1292
|
+
ORT_API2_STATUS(CreateKernelDefBuilder, _Outptr_ OrtKernelDefBuilder** kernel_def_builder_out);
|
|
1293
|
+
|
|
1294
|
+
ORT_CLASS_RELEASE(KernelDefBuilder);
|
|
1295
|
+
|
|
1296
|
+
/** \brief Sets the kernel's operator type.
|
|
1297
|
+
*
|
|
1298
|
+
* \param[in] kernel_def_builder The OrtKernelDefBuilder instance.
|
|
1299
|
+
* \param[in] op_type A null-terminated string representing the operator type.
|
|
1300
|
+
*
|
|
1301
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1302
|
+
*
|
|
1303
|
+
* \since Version 1.24.
|
|
1304
|
+
*/
|
|
1305
|
+
ORT_API2_STATUS(KernelDefBuilder_SetOperatorType, _In_ OrtKernelDefBuilder* kernel_def_builder,
|
|
1306
|
+
_In_ const char* op_type);
|
|
1307
|
+
|
|
1308
|
+
/** \brief Sets the kernel's domain.
|
|
1309
|
+
*
|
|
1310
|
+
* \param[in] kernel_def_builder The OrtKernelDefBuilder instance.
|
|
1311
|
+
* \param[in] domain A null-terminated string representing the operator's domain.
|
|
1312
|
+
*
|
|
1313
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1314
|
+
*
|
|
1315
|
+
* \since Version 1.24.
|
|
1316
|
+
*/
|
|
1317
|
+
ORT_API2_STATUS(KernelDefBuilder_SetDomain, _In_ OrtKernelDefBuilder* kernel_def_builder, _In_ const char* domain);
|
|
1318
|
+
|
|
1319
|
+
/** \brief Sets the kernel's opset version range that is supported.
|
|
1320
|
+
*
|
|
1321
|
+
* \param[in] kernel_def_builder The OrtKernelDefBuilder instance.
|
|
1322
|
+
* \param[in] since_version_start The starting opset version that is supported.
|
|
1323
|
+
* \param[in] since_version_end The ending opset version (inclusive) that is supported.
|
|
1324
|
+
* Can be set equal to the starting version to indicate that only one
|
|
1325
|
+
* version is supported.
|
|
1326
|
+
*
|
|
1327
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1328
|
+
*
|
|
1329
|
+
* \since Version 1.24.
|
|
1330
|
+
*/
|
|
1331
|
+
ORT_API2_STATUS(KernelDefBuilder_SetSinceVersion, _In_ OrtKernelDefBuilder* kernel_def_builder,
|
|
1332
|
+
_In_ int since_version_start, _In_ int since_version_end);
|
|
1333
|
+
|
|
1334
|
+
/** \brief Sets the name of the kernel's intended execution provider.
|
|
1335
|
+
*
|
|
1336
|
+
* \param[in] kernel_def_builder The OrtKernelDefBuilder instance.
|
|
1337
|
+
* \param[in] ep_name A null-terminated string representing the execution provider's name.
|
|
1338
|
+
*
|
|
1339
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1340
|
+
*
|
|
1341
|
+
* \since Version 1.24.
|
|
1342
|
+
*/
|
|
1343
|
+
ORT_API2_STATUS(KernelDefBuilder_SetExecutionProvider, _In_ OrtKernelDefBuilder* kernel_def_builder,
|
|
1344
|
+
_In_ const char* ep_name);
|
|
1345
|
+
|
|
1346
|
+
/** \brief Sets the memory type for a kernel input.
|
|
1347
|
+
*
|
|
1348
|
+
* \param[in] kernel_def_builder The OrtKernelDefBuilder instance.
|
|
1349
|
+
* \param[in] input_index The index of the input.
|
|
1350
|
+
* \param[in] mem_type The input's memory type.
|
|
1351
|
+
*
|
|
1352
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1353
|
+
*
|
|
1354
|
+
* \since Version 1.24.
|
|
1355
|
+
*/
|
|
1356
|
+
ORT_API2_STATUS(KernelDefBuilder_SetInputMemType, _In_ OrtKernelDefBuilder* kernel_def_builder,
|
|
1357
|
+
_In_ size_t input_index, _In_ OrtMemType mem_type);
|
|
1358
|
+
|
|
1359
|
+
/** \brief Sets the memory type for a kernel output.
|
|
1360
|
+
*
|
|
1361
|
+
* \param[in] kernel_def_builder The OrtKernelDefBuilder instance.
|
|
1362
|
+
* \param[in] output_index The index of the output.
|
|
1363
|
+
* \param[in] mem_type The output's memory type.
|
|
1364
|
+
*
|
|
1365
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1366
|
+
*
|
|
1367
|
+
* \since Version 1.24.
|
|
1368
|
+
*/
|
|
1369
|
+
ORT_API2_STATUS(KernelDefBuilder_SetOutputMemType, _In_ OrtKernelDefBuilder* kernel_def_builder,
|
|
1370
|
+
_In_ size_t output_index, _In_ OrtMemType mem_type);
|
|
1371
|
+
|
|
1372
|
+
/** \brief Adds type constraints for a kernel argument represented as a string (e.g., "T").
|
|
1373
|
+
*
|
|
1374
|
+
* \param[in] kernel_def_builder The OrtKernelDefBuilder instance.
|
|
1375
|
+
* \param[in] arg_name A null-terminated string representing the argument to constrain (e.g., "T").
|
|
1376
|
+
* \param[in] types Array of OrtDataType instances representing allowed types for the argument.
|
|
1377
|
+
* Must contain `num_types` elements.
|
|
1378
|
+
* \param[in] num_types The number of OrtDataType elements in the `types` array.
|
|
1379
|
+
*
|
|
1380
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1381
|
+
*
|
|
1382
|
+
* \since Version 1.24.
|
|
1383
|
+
*/
|
|
1384
|
+
ORT_API2_STATUS(KernelDefBuilder_AddTypeConstraint, _In_ OrtKernelDefBuilder* kernel_def_builder,
|
|
1385
|
+
_In_ const char* arg_name, _In_reads_(num_types) const OrtDataType* const* types,
|
|
1386
|
+
_In_ size_t num_types);
|
|
1387
|
+
|
|
1388
|
+
/** \brief Adds aliases for the given input and output pairs.
|
|
1389
|
+
*
|
|
1390
|
+
* \note Used for operators like Identity and Reshape to allow ORT to reuse the input buffer for the output
|
|
1391
|
+
* without modification.
|
|
1392
|
+
*
|
|
1393
|
+
* \param[in] kernel_def_builder The OrtKernelDefBuilder instance.
|
|
1394
|
+
* \param[in] input_indices Array of input indices. Array must contain `num_io_indices` elements.
|
|
1395
|
+
* \param[in] output_indices Array of output indices. Each output index is aliased with a corresponding
|
|
1396
|
+
* input index in `input_indices`. Array must contain `num_io_indices` elements.
|
|
1397
|
+
* \param[in] num_io_indices The number of input/output index pairs to alias.
|
|
1398
|
+
*
|
|
1399
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1400
|
+
*
|
|
1401
|
+
* \since Version 1.24.
|
|
1402
|
+
*/
|
|
1403
|
+
ORT_API2_STATUS(KernelDefBuilder_AddInputOutputAliases, _In_ OrtKernelDefBuilder* kernel_def_builder,
|
|
1404
|
+
_In_reads_(num_io_indices) int const* input_indices,
|
|
1405
|
+
_In_reads_(num_io_indices) int const* output_indices,
|
|
1406
|
+
_In_ size_t num_io_indices);
|
|
1407
|
+
|
|
1408
|
+
/** \brief Adds mutable aliases for the given input and output pairs.
|
|
1409
|
+
*
|
|
1410
|
+
* \note Allows ORT to reuse and *modify* an input buffer (in-place) for the output buffer.
|
|
1411
|
+
* This is also known as "MayInplace" within the ORT codebase.
|
|
1412
|
+
*
|
|
1413
|
+
* \param[in] kernel_def_builder The OrtKernelDefBuilder instance.
|
|
1414
|
+
* \param[in] input_indices Array of input indices. Array must contain `num_io_indices` elements.
|
|
1415
|
+
* \param[in] output_indices Array of output indices. Each output index is aliased with a corresponding
|
|
1416
|
+
* input index in `input_indices`. Array must contain `num_io_indices` elements.
|
|
1417
|
+
* \param[in] num_io_indices The number of input/output index pairs to alias.
|
|
1418
|
+
*
|
|
1419
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1420
|
+
*
|
|
1421
|
+
* \since Version 1.24.
|
|
1422
|
+
*/
|
|
1423
|
+
ORT_API2_STATUS(KernelDefBuilder_AddInputOutputMutableAliases, _In_ OrtKernelDefBuilder* kernel_def_builder,
|
|
1424
|
+
_In_reads_(num_io_indices) int const* input_indices,
|
|
1425
|
+
_In_reads_(num_io_indices) int const* output_indices,
|
|
1426
|
+
_In_ size_t num_io_indices);
|
|
1427
|
+
|
|
1428
|
+
/** \brief Creates a OrtKernelDef instance from the given kernel definition builder.
|
|
1429
|
+
*
|
|
1430
|
+
* \param[in] kernel_def_builder The OrtKernelDefBuilder instance.
|
|
1431
|
+
* \param[out] kernel_def_out The new OrtKernelDef instance.
|
|
1432
|
+
*
|
|
1433
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1434
|
+
*
|
|
1435
|
+
* \since Version 1.24.
|
|
1436
|
+
*/
|
|
1437
|
+
ORT_API2_STATUS(KernelDefBuilder_Build, _In_ OrtKernelDefBuilder* kernel_def_builder,
|
|
1438
|
+
_Outptr_ OrtKernelDef** kernel_def_out);
|
|
1439
|
+
|
|
1440
|
+
ORT_CLASS_RELEASE(KernelDef);
|
|
1441
|
+
|
|
1442
|
+
/** \brief Returns the operator type from the kernel definition.
|
|
1443
|
+
*
|
|
1444
|
+
* \param[in] kernel_def The OrtKernelDef instance.
|
|
1445
|
+
* \return A null-terminated string representing the operator type.
|
|
1446
|
+
*
|
|
1447
|
+
* \since Version 1.24.
|
|
1448
|
+
*/
|
|
1449
|
+
ORT_API_T(const char*, KernelDef_GetOperatorType, _In_ const OrtKernelDef* kernel_def);
|
|
1450
|
+
|
|
1451
|
+
/** \brief Returns the operator's domain from the kernel definition.
|
|
1452
|
+
*
|
|
1453
|
+
* \param[in] kernel_def The OrtKernelDef instance.
|
|
1454
|
+
* \return A null-terminated string representing the operator's domain.
|
|
1455
|
+
*
|
|
1456
|
+
* \since Version 1.24.
|
|
1457
|
+
*/
|
|
1458
|
+
ORT_API_T(const char*, KernelDef_GetDomain, _In_ const OrtKernelDef* kernel_def);
|
|
1459
|
+
|
|
1460
|
+
/** \brief Gets the kernel's opset version range that is supported.
|
|
1461
|
+
*
|
|
1462
|
+
* \param[in] kernel_def The OrtKernelDef instance.
|
|
1463
|
+
* \param[out] start_version Output parameter set to the starting opset version that is supported.
|
|
1464
|
+
* \param[out] end_version Output parameter set to the ending opset version (inclusive) that is supported.
|
|
1465
|
+
*
|
|
1466
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1467
|
+
*
|
|
1468
|
+
* \since Version 1.24.
|
|
1469
|
+
*/
|
|
1470
|
+
ORT_API2_STATUS(KernelDef_GetSinceVersion, _In_ const OrtKernelDef* kernel_def,
|
|
1471
|
+
_Out_ int* start_version, _Out_ int* end_version);
|
|
1472
|
+
|
|
1473
|
+
/** \brief Returns the name of the kernel's intended execution provider.
|
|
1474
|
+
*
|
|
1475
|
+
* \param[in] kernel_def The OrtKernelDef instance.
|
|
1476
|
+
* \return A null-terminated string representing the name of the execution provider.
|
|
1477
|
+
*
|
|
1478
|
+
* \since Version 1.24.
|
|
1479
|
+
*/
|
|
1480
|
+
ORT_API_T(const char*, KernelDef_GetExecutionProvider, _In_ const OrtKernelDef* kernel_def);
|
|
1481
|
+
|
|
1482
|
+
/** \brief Gets the memory type for a kernel input.
|
|
1483
|
+
*
|
|
1484
|
+
* \param[in] kernel_def The OrtKernelDef instance.
|
|
1485
|
+
* \param[in] input_index The index of the input.
|
|
1486
|
+
* \param[out] mem_type Output parameter set to the input's memory type.
|
|
1487
|
+
*
|
|
1488
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1489
|
+
*
|
|
1490
|
+
* \since Version 1.24.
|
|
1491
|
+
*/
|
|
1492
|
+
ORT_API2_STATUS(KernelDef_GetInputMemType, _In_ const OrtKernelDef* kernel_def,
|
|
1493
|
+
_In_ size_t input_index, _Out_ OrtMemType* mem_type);
|
|
1494
|
+
|
|
1495
|
+
/** \brief Gets the memory type for a kernel output.
|
|
1496
|
+
*
|
|
1497
|
+
* \param[in] kernel_def The OrtKernelDef instance.
|
|
1498
|
+
* \param[in] output_index The index of the output.
|
|
1499
|
+
* \param[out] mem_type Output parameter set to the output's memory type.
|
|
1500
|
+
*
|
|
1501
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1502
|
+
*
|
|
1503
|
+
* \since Version 1.24.
|
|
1504
|
+
*/
|
|
1505
|
+
ORT_API2_STATUS(KernelDef_GetOutputMemType, _In_ const OrtKernelDef* kernel_def,
|
|
1506
|
+
_In_ size_t output_index, _Out_ OrtMemType* mem_type);
|
|
1507
|
+
|
|
1508
|
+
/** \brief Gets the OrtDataType that represents the data type for a tensor of the given element type.
|
|
1509
|
+
*
|
|
1510
|
+
* \param[in] elem_type The tensor's element type.
|
|
1511
|
+
* \param[out] out Output parameter set to the OrtDataType. Owned by ORT and must not be released.
|
|
1512
|
+
*
|
|
1513
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1514
|
+
*
|
|
1515
|
+
* \since Version 1.24.
|
|
1516
|
+
*/
|
|
1517
|
+
ORT_API2_STATUS(GetTensorDataType, _In_ ONNXTensorElementDataType elem_type,
|
|
1518
|
+
_Outptr_ const OrtDataType** out);
|
|
1519
|
+
|
|
1520
|
+
/** \brief Gets the kernel definition for a given node, if any exists for the calling execution provider.
|
|
1521
|
+
*
|
|
1522
|
+
* Used within OrtEp::GetCapability() to get the registered kernel definition for the given node.
|
|
1523
|
+
* The kernel definition is set to NULL if there is no registered kernel definition for the node
|
|
1524
|
+
* and execution provider.
|
|
1525
|
+
*
|
|
1526
|
+
* \param[in] graph_support_info The OrtEpGraphSupportInfo instance to query.
|
|
1527
|
+
* \param[in] node The node for which to look up a kernel definition.
|
|
1528
|
+
* \param[out] out_kernel_def Output parameter set to the OrtKernelDef or NULL.
|
|
1529
|
+
* Owned by ORT and must not be released.
|
|
1530
|
+
*
|
|
1531
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1532
|
+
*
|
|
1533
|
+
* \since Version 1.24.
|
|
1534
|
+
*/
|
|
1535
|
+
ORT_API2_STATUS(EpGraphSupportInfo_LookUpKernel, _In_ OrtEpGraphSupportInfo* graph_support_info,
|
|
1536
|
+
_In_ const OrtNode* node, _Outptr_result_maybenull_ const OrtKernelDef** out_kernel_def);
|
|
1537
|
+
|
|
1538
|
+
/** \brief Sets one or more data buffers that collectively hold the pre-packed data for a single shared weight.
|
|
1539
|
+
*
|
|
1540
|
+
* \note Used within the implementation of OrtKernelImpl::PrePackWeight() when the kernel wants to share pre-packed
|
|
1541
|
+
* weight data with other kernels. The buffer data MUST be allocated with the OrtAllocator provided to
|
|
1542
|
+
* OrtKernelImpl::PrePack.
|
|
1543
|
+
*
|
|
1544
|
+
* \note Ownership of weight data transfers to the OrtSharedPrePackedWeightCache instance on success.
|
|
1545
|
+
* If this function returns an error status, the caller retains ownership of the weight data.
|
|
1546
|
+
*
|
|
1547
|
+
* \note Subsequent calls with the same OrtSharedPrePackedWeightCache instance release and replace the old data.
|
|
1548
|
+
*
|
|
1549
|
+
* \param[in] prepacked_weight_cache The OrtSharedPrePackedWeightCache instance.
|
|
1550
|
+
* \param[in] buffer_data_ptrs An array of buffer data pointers that collectively hold the pre-packed data for a
|
|
1551
|
+
* single shared weight. Note that sometimes a single weight may have multiple pre-packed
|
|
1552
|
+
* buffers and it is up to the kernel implementation to determine how to split the data
|
|
1553
|
+
* into multiple buffers (if desired).
|
|
1554
|
+
* \param[in] buffer_data_sizes An array of buffer byte sizes, one per element in `buffer_data_ptrs`.
|
|
1555
|
+
* \param[in] num_buffers The number of buffers used to store the data for the shared pre-packed weight.
|
|
1556
|
+
* Specifies the number of elements in the `buffer_data_ptrs` and `buffer_data_sizes` arrays.
|
|
1557
|
+
*
|
|
1558
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1559
|
+
*
|
|
1560
|
+
* \since Version 1.24.
|
|
1561
|
+
*/
|
|
1562
|
+
ORT_API2_STATUS(SharedPrePackedWeightCache_StoreWeightData,
|
|
1563
|
+
_In_ OrtSharedPrePackedWeightCache* prepacked_weight_cache,
|
|
1564
|
+
_In_reads_(num_buffers) void** buffer_data_ptrs, _In_reads_(num_buffers) size_t* buffer_data_sizes,
|
|
1565
|
+
_In_ size_t num_buffers);
|
|
1566
|
+
|
|
1567
|
+
/** \brief Get the OrtEp instance to which the node is assigned from the OrtKernelInfo.
|
|
1568
|
+
*
|
|
1569
|
+
* \note Used within OrtKernelImpl implementations to obtain a reference to the OrtEp.
|
|
1570
|
+
*
|
|
1571
|
+
* \param[in] info The ::OrtKernelInfo instance.
|
|
1572
|
+
* \param[out] ep Output parameter set to the OrtEp instance associated with the OrtKernelInfo.
|
|
1573
|
+
*
|
|
1574
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1575
|
+
* \since Version 1.24
|
|
1576
|
+
*/
|
|
1577
|
+
ORT_API2_STATUS(KernelInfo_GetEp, _In_ const OrtKernelInfo* info, _Outptr_ const OrtEp** ep);
|
|
1578
|
+
|
|
1579
|
+
/** \brief Set the details of an OrtDeviceEpIncompatibilityDetails instance.
|
|
1580
|
+
*
|
|
1581
|
+
* Used by execution provider factories to set incompatibility details in their
|
|
1582
|
+
* GetHardwareDeviceIncompatibilityDetails implementation. ORT creates and initializes the object
|
|
1583
|
+
* before passing it to the EP, so calling this function is optional. The EP uses this function
|
|
1584
|
+
* to set incompatibility information when the device is not compatible.
|
|
1585
|
+
*
|
|
1586
|
+
* \param[in,out] details The OrtDeviceEpIncompatibilityDetails instance to update.
|
|
1587
|
+
* \param[in] reasons_bitmask Bitmask of OrtDeviceEpIncompatibilityReason values. (0 = no incompatibility).
|
|
1588
|
+
* \param[in] error_code Optional EP-specific error code (0 = no error).
|
|
1589
|
+
* \param[in] notes Optional human-readable notes. Can be null.
|
|
1590
|
+
*
|
|
1591
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1592
|
+
*
|
|
1593
|
+
* \since Version 1.24.
|
|
1594
|
+
*/
|
|
1595
|
+
ORT_API2_STATUS(DeviceEpIncompatibilityDetails_SetDetails, _Inout_ OrtDeviceEpIncompatibilityDetails* details,
|
|
1596
|
+
_In_ uint32_t reasons_bitmask,
|
|
1597
|
+
_In_ int32_t error_code,
|
|
1598
|
+
_In_opt_z_ const char* notes);
|
|
1599
|
+
|
|
1600
|
+
/** \brief Creates an OrtKernelImpl instance for an If operator.
|
|
1601
|
+
*
|
|
1602
|
+
* Control flow operators require access to ORT session internals to orchestrate subgraph operations.
|
|
1603
|
+
* This function allows an EP to create a properly configured OrtKernelImpl with access to ORT internals that
|
|
1604
|
+
* the EP can add to its kernel registry.
|
|
1605
|
+
*
|
|
1606
|
+
* An EP is required to create an OrtKernelDef that keeps input[0] ('cond') on the CPU (i.e., OrtMemTypeCPUInput)
|
|
1607
|
+
* as this input is used by CPU logic. The output should remain on the device (i.e., OrtMemTypeDefault), which is
|
|
1608
|
+
* the default setting, to avoid copying to/from CPU.
|
|
1609
|
+
*
|
|
1610
|
+
* Example kernel definition (CXX API):
|
|
1611
|
+
* Ort::KernelDef kernel_def = Ort::KernelDefBuilder()
|
|
1612
|
+
* .SetDomain("").SetOperatorType("If").SetSinceVersion(21, 22)
|
|
1613
|
+
* .SetExecutionProvider("MyEp")
|
|
1614
|
+
* .SetInputMemType(0, OrtMemTypeCPUInput) // 'cond' on CPU
|
|
1615
|
+
* .SetOutputMemType(0, OrtMemTypeDefault) // output on EP device
|
|
1616
|
+
* .AddTypeConstraint("B", ...)
|
|
1617
|
+
* .AddTypeConstraint("V", ...).Build();
|
|
1618
|
+
*
|
|
1619
|
+
* \param[in] kernel_info The ::OrtKernelInfo instance for an If node. This function returns error ORT_FAIL
|
|
1620
|
+
* if the opset version specified by `kernel_info` is unsupported.
|
|
1621
|
+
* \param[out] kernel_out Output parameter set to the OrtKernelImpl instance for the If node.
|
|
1622
|
+
* Must be released via OrtEpApi::ReleaseKernelImpl, unless ownership is transferred
|
|
1623
|
+
* to ORT (see OrtKernelCreateFunc and OrtEpApi::KernelRegistry_AddKernel).
|
|
1624
|
+
*
|
|
1625
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1626
|
+
* \since Version 1.24
|
|
1627
|
+
*/
|
|
1628
|
+
ORT_API2_STATUS(CreateIfKernel, _In_ const OrtKernelInfo* kernel_info, _Outptr_ OrtKernelImpl** kernel_out);
|
|
1629
|
+
|
|
1630
|
+
/** \brief Creates an OrtKernelImpl instance for a Loop operator.
|
|
1631
|
+
*
|
|
1632
|
+
* Control flow operators require access to ORT session internals to orchestrate subgraph operations.
|
|
1633
|
+
* This function allows an EP to create a properly configured OrtKernelImpl with access to ORT internals that
|
|
1634
|
+
* the EP can add to its kernel registry.
|
|
1635
|
+
*
|
|
1636
|
+
* An EP is required to create an OrtKernelDef that keeps input[0] ('M') and input[1] ('cond') on the CPU
|
|
1637
|
+
* (i.e., OrtMemTypeCPUInput) as these inputs are used by CPU logic. Input[2] ('v_initial') and the output should
|
|
1638
|
+
* remain on the device (i.e., OrtMemTypeDefault), which is the default setting, to avoid copying to/from CPU.
|
|
1639
|
+
*
|
|
1640
|
+
* Example kernel definition (CXX API):
|
|
1641
|
+
* Ort::KernelDef kernel_def = Ort::KernelDefBuilder()
|
|
1642
|
+
* .SetDomain("").SetOperatorType("Loop").SetSinceVersion(21, 22)
|
|
1643
|
+
* .SetExecutionProvider("MyEp")
|
|
1644
|
+
* .SetInputMemType(0, OrtMemTypeCPUInput) // 'M' on CPU
|
|
1645
|
+
* .SetInputMemType(1, OrtMemTypeCPUInput) // 'cond' on CPU
|
|
1646
|
+
* .SetInputMemType(2, OrtMemTypeDefault) // 'v_initial' on EP device
|
|
1647
|
+
* .SetOutputMemType(0, OrtMemTypeDefault) // output on EP device
|
|
1648
|
+
* .AddTypeConstraint("I", ...)
|
|
1649
|
+
* .AddTypeConstraint("B", ...)
|
|
1650
|
+
* .AddTypeConstraint("V", ...).Build();
|
|
1651
|
+
*
|
|
1652
|
+
* \param[in] kernel_info The ::OrtKernelInfo instance for a Loop node. This function returns error ORT_FAIL
|
|
1653
|
+
* if the opset version specified by `kernel_info` is unsupported.
|
|
1654
|
+
* \param[in] helper A OrtLoopKernelHelper instance that contains helper functions that ORT calls during kernel
|
|
1655
|
+
* execution to operate on tensors allocated with the EP's device memory.
|
|
1656
|
+
* ORT will call OrtLoopKernelHelper::Release() to release the helper and its resources.
|
|
1657
|
+
* \param[out] kernel_out Output parameter set to the OrtKernelImpl instance for the Loop node.
|
|
1658
|
+
* Must be released via OrtEpApi::ReleaseKernelImpl, unless ownership is transferred
|
|
1659
|
+
* to ORT (see OrtKernelCreateFunc and OrtEpApi::KernelRegistry_AddKernel).
|
|
1660
|
+
*
|
|
1661
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1662
|
+
* \since Version 1.24
|
|
1663
|
+
*/
|
|
1664
|
+
ORT_API2_STATUS(CreateLoopKernel, _In_ const OrtKernelInfo* kernel_info, _In_ OrtLoopKernelHelper* helper,
|
|
1665
|
+
_Outptr_ OrtKernelImpl** kernel_out);
|
|
1666
|
+
|
|
1667
|
+
/** \brief Creates an OrtKernelImpl instance for a Scan operator. Does not support opset versions older than 9.
|
|
1668
|
+
*
|
|
1669
|
+
* Control flow operators require access to ORT session internals to orchestrate subgraph operations.
|
|
1670
|
+
* This function allows an EP to create a properly configured OrtKernelImpl with access to ORT internals that
|
|
1671
|
+
* the EP can add to its kernel registry.
|
|
1672
|
+
*
|
|
1673
|
+
* It is recommended that an EP create an OrtKernelDef that keeps the inputs and outputs on the EP's
|
|
1674
|
+
* device (i.e., OrtMemTypeDefault), which is the default setting, to avoid copying to/from CPU.
|
|
1675
|
+
*
|
|
1676
|
+
* Example kernel definition (CXX API):
|
|
1677
|
+
* Ort::KernelDef kernel_def = Ort::KernelDefBuilder()
|
|
1678
|
+
* .SetDomain("").SetOperatorType("Scan").SetSinceVersion(21, 22)
|
|
1679
|
+
* .SetExecutionProvider("MyEp")
|
|
1680
|
+
* .SetInputMemType(0, OrtMemTypeDefault) // input[0] on EP device
|
|
1681
|
+
* .SetOutputMemType(0, OrtMemTypeDefault) // output[0] on EP device
|
|
1682
|
+
* .AddTypeConstraint("V", ...).Build();
|
|
1683
|
+
*
|
|
1684
|
+
* \param[in] kernel_info The ::OrtKernelInfo instance for a Scan node. This function returns error ORT_FAIL
|
|
1685
|
+
* if the opset version specified by `kernel_info` is unsupported.
|
|
1686
|
+
* \param[in] helper A OrtScanKernelHelper instance that contains helper functions that ORT calls during kernel
|
|
1687
|
+
* execution to operate on tensors allocated with the EP's device memory.
|
|
1688
|
+
* ORT will call OrtScanKernelHelper::Release() to release the helper and its resources.
|
|
1689
|
+
* \param[out] kernel_out Output parameter set to the OrtKernelImpl instance for the Scan node.
|
|
1690
|
+
* Must be released via OrtEpApi::ReleaseKernelImpl, unless ownership is transferred
|
|
1691
|
+
* to ORT (see OrtKernelCreateFunc and OrtEpApi::KernelRegistry_AddKernel).
|
|
1692
|
+
*
|
|
1693
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1694
|
+
* \since Version 1.24
|
|
1695
|
+
*/
|
|
1696
|
+
ORT_API2_STATUS(CreateScanKernel, _In_ const OrtKernelInfo* kernel_info, _In_ OrtScanKernelHelper* helper,
|
|
1697
|
+
_Outptr_ OrtKernelImpl** kernel_out);
|
|
1698
|
+
|
|
1699
|
+
ORT_CLASS_RELEASE(KernelImpl);
|
|
1700
|
+
|
|
1701
|
+
/** \brief Gets a new OrtKeyValuePairs instance containing a copy of all configuration entries set on the environment.
|
|
1702
|
+
*
|
|
1703
|
+
* \note An application provides environment-level configuration options for execution provider libraries by
|
|
1704
|
+
* using keys with the prefix 'ep_factory.\\<ep_name\\>.'. Ex: the key 'ep_factory.my_ep.some_ep_key' represents
|
|
1705
|
+
* a key named 'some_ep_key' that is meant to be consumed by an execution provider named 'my_ep'. Refer to
|
|
1706
|
+
* the specific execution provider's documentation for valid keys and values.
|
|
1707
|
+
*
|
|
1708
|
+
* \note Refer to onnxruntime_env_config_keys.h for common configuration entry keys and their supported values.
|
|
1709
|
+
*
|
|
1710
|
+
* \param[out] config_entries Output parameter set to the OrtKeyValuePairs instance containing all configuration entries.
|
|
1711
|
+
* Must be released via OrtApi::ReleaseKeyValuePairs.
|
|
1712
|
+
*
|
|
1713
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1714
|
+
* \since Version 1.24
|
|
1715
|
+
*/
|
|
1716
|
+
ORT_API2_STATUS(GetEnvConfigEntries, _Outptr_ OrtKeyValuePairs** config_entries);
|
|
1717
|
+
|
|
1718
|
+
/** \brief Get an operator schema from the global schema registry.
|
|
1719
|
+
*
|
|
1720
|
+
* Looks up a schema by name, maximum inclusive version, and domain.
|
|
1721
|
+
* The returned pointer is owned by the caller and must be released via ReleaseOpSchema.
|
|
1722
|
+
* If the schema is not found, *out_schema is set to nullptr (no allocation occurs).
|
|
1723
|
+
*
|
|
1724
|
+
* Available schemas include standard ONNX operators (domain "" or "ai.onnx"), ONNX ML operators
|
|
1725
|
+
* (domain "ai.onnx.ml"), and ORT contrib operators (domain "com.microsoft").
|
|
1726
|
+
*
|
|
1727
|
+
* \param[in] name A null-terminated string for the operator name.
|
|
1728
|
+
* \param[in] max_inclusive_version The maximum inclusive opset version.
|
|
1729
|
+
* \param[in] domain A null-terminated string for the operator domain.
|
|
1730
|
+
* \param[out] out_schema Output parameter set to the schema pointer, or nullptr if not found.
|
|
1731
|
+
* Must be released via OrtEpApi::ReleaseOpSchema.
|
|
1732
|
+
*
|
|
1733
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1734
|
+
*
|
|
1735
|
+
* \since Version 1.25.
|
|
1736
|
+
*/
|
|
1737
|
+
ORT_API2_STATUS(GetOpSchema, _In_ const char* name, _In_ int max_inclusive_version,
|
|
1738
|
+
_In_ const char* domain, _Outptr_result_maybenull_ OrtOpSchema** out_schema);
|
|
1739
|
+
|
|
1740
|
+
ORT_CLASS_RELEASE(OpSchema);
|
|
1741
|
+
|
|
1742
|
+
/** \brief Get the first ONNX opset version that introduced this operator schema.
|
|
1743
|
+
*
|
|
1744
|
+
* If an operator has had no changes that break backwards compatibility, the `since_version` is
|
|
1745
|
+
* just the first opset version that introduced the operator. However, if the operator has had breaking changes,
|
|
1746
|
+
* then `since_version` corresponds to the opset version that introduced the breaking change.
|
|
1747
|
+
*
|
|
1748
|
+
* For example, suppose operator "Foo" was added in version 3 and had a breaking change in version 6.
|
|
1749
|
+
* Then, there will be an operator schema entry for "Foo" with a since_version of 3 and another updated
|
|
1750
|
+
* operator schema entry for "Foo" with a since_version of 6.
|
|
1751
|
+
*
|
|
1752
|
+
* \param[in] schema The OrtOpSchema instance.
|
|
1753
|
+
* \param[out] out Output parameter set to the ONNX opset version.
|
|
1754
|
+
*
|
|
1755
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1756
|
+
*
|
|
1757
|
+
* \since Version 1.25.
|
|
1758
|
+
*/
|
|
1759
|
+
ORT_API2_STATUS(OpSchema_GetSinceVersion, _In_ const OrtOpSchema* schema, _Out_ int* out);
|
|
1760
|
+
|
|
1761
|
+
/** \brief Get the number of inputs defined by the operator schema.
|
|
1762
|
+
*
|
|
1763
|
+
* \param[in] schema The OrtOpSchema instance.
|
|
1764
|
+
* \param[out] out Output parameter set to the number of inputs.
|
|
1765
|
+
*
|
|
1766
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1767
|
+
*
|
|
1768
|
+
* \since Version 1.25.
|
|
1769
|
+
*/
|
|
1770
|
+
ORT_API2_STATUS(OpSchema_GetNumInputs, _In_ const OrtOpSchema* schema, _Out_ size_t* out);
|
|
1771
|
+
|
|
1772
|
+
/** \brief Get the name of the i-th input formal parameter from an operator schema.
|
|
1773
|
+
*
|
|
1774
|
+
* \param[in] schema The OrtOpSchema instance.
|
|
1775
|
+
* \param[in] index Zero-based index of the input parameter.
|
|
1776
|
+
* \param[out] out Output parameter set to the name of the input parameter (null-terminated UTF8 string).
|
|
1777
|
+
* Valid as long as the OrtOpSchema exists.
|
|
1778
|
+
*
|
|
1779
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1780
|
+
*
|
|
1781
|
+
* \since Version 1.25.
|
|
1782
|
+
*/
|
|
1783
|
+
ORT_API2_STATUS(OpSchema_GetInputName, _In_ const OrtOpSchema* schema, _In_ size_t index,
|
|
1784
|
+
_Outptr_ const char** out);
|
|
1785
|
+
|
|
1786
|
+
/** \brief Get the type constraint for the i-th input formal parameter from an operator schema.
|
|
1787
|
+
*
|
|
1788
|
+
* Returns a non-owning pointer to the OrtOpSchemaTypeConstraint associated with the given input.
|
|
1789
|
+
* The returned pointer is valid as long as the parent OrtOpSchema is alive.
|
|
1790
|
+
* If the input has no type constraint, *out is set to nullptr.
|
|
1791
|
+
*
|
|
1792
|
+
* Multiple inputs sharing the same type constraint (e.g., both using "T") return the same pointer.
|
|
1793
|
+
*
|
|
1794
|
+
* \param[in] schema The OrtOpSchema instance.
|
|
1795
|
+
* \param[in] index Zero-based index of the input parameter.
|
|
1796
|
+
* \param[out] out Output parameter set to the type constraint, or NULL if the input has no type constraint.
|
|
1797
|
+
* Valid as long as the OrtOpSchema exists.
|
|
1798
|
+
*
|
|
1799
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1800
|
+
*
|
|
1801
|
+
* \since Version 1.25.
|
|
1802
|
+
*/
|
|
1803
|
+
ORT_API2_STATUS(OpSchema_GetInputTypeConstraint, _In_ const OrtOpSchema* schema, _In_ size_t index,
|
|
1804
|
+
_Outptr_result_maybenull_ const OrtOpSchemaTypeConstraint** out);
|
|
1805
|
+
|
|
1806
|
+
/** \brief Get the number of outputs defined by the operator schema.
|
|
1807
|
+
*
|
|
1808
|
+
* \param[in] schema The OrtOpSchema instance.
|
|
1809
|
+
* \param[out] out Output parameter set to the number of outputs.
|
|
1810
|
+
*
|
|
1811
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1812
|
+
*
|
|
1813
|
+
* \since Version 1.25.
|
|
1814
|
+
*/
|
|
1815
|
+
ORT_API2_STATUS(OpSchema_GetNumOutputs, _In_ const OrtOpSchema* schema, _Out_ size_t* out);
|
|
1816
|
+
|
|
1817
|
+
/** \brief Get the name of the i-th output formal parameter from an operator schema.
|
|
1818
|
+
*
|
|
1819
|
+
* \param[in] schema The OrtOpSchema instance.
|
|
1820
|
+
* \param[in] index Zero-based index of the output parameter.
|
|
1821
|
+
* \param[out] out Output parameter set to the name of the output parameter (null-terminated UTF8 string).
|
|
1822
|
+
* Valid as long as the OrtOpSchema exists.
|
|
1823
|
+
*
|
|
1824
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1825
|
+
*
|
|
1826
|
+
* \since Version 1.25.
|
|
1827
|
+
*/
|
|
1828
|
+
ORT_API2_STATUS(OpSchema_GetOutputName, _In_ const OrtOpSchema* schema, _In_ size_t index,
|
|
1829
|
+
_Outptr_ const char** out);
|
|
1830
|
+
|
|
1831
|
+
/** \brief Get the type constraint for the i-th output formal parameter from an operator schema.
|
|
1832
|
+
*
|
|
1833
|
+
* Returns a non-owning pointer to the OrtOpSchemaTypeConstraint associated with the given output.
|
|
1834
|
+
* The returned pointer is valid as long as the parent OrtOpSchema is alive.
|
|
1835
|
+
* If the output has no type constraint, *out is set to nullptr.
|
|
1836
|
+
*
|
|
1837
|
+
* Multiple outputs sharing the same type constraint return the same pointer.
|
|
1838
|
+
* Pointer equality can be used to check if two outputs share a type constraint.
|
|
1839
|
+
*
|
|
1840
|
+
* \param[in] schema The OrtOpSchema instance.
|
|
1841
|
+
* \param[in] index Zero-based index of the output parameter.
|
|
1842
|
+
* \param[out] out Output parameter set to the type constraint, or NULL if the output has no type constraint.
|
|
1843
|
+
* Valid as long as the OrtOpSchema exists.
|
|
1844
|
+
*
|
|
1845
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1846
|
+
*
|
|
1847
|
+
* \since Version 1.25.
|
|
1848
|
+
*/
|
|
1849
|
+
ORT_API2_STATUS(OpSchema_GetOutputTypeConstraint, _In_ const OrtOpSchema* schema, _In_ size_t index,
|
|
1850
|
+
_Outptr_result_maybenull_ const OrtOpSchemaTypeConstraint** out);
|
|
1851
|
+
|
|
1852
|
+
/** \brief Get the number of unique type constraints in the operator schema.
|
|
1853
|
+
*
|
|
1854
|
+
* \param[in] schema The OrtOpSchema instance.
|
|
1855
|
+
* \param[out] out Output set to the number of type constraints.
|
|
1856
|
+
*
|
|
1857
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1858
|
+
*
|
|
1859
|
+
* \since Version 1.25.
|
|
1860
|
+
*/
|
|
1861
|
+
ORT_API2_STATUS(OpSchema_GetTypeConstraintCount, _In_ const OrtOpSchema* schema, _Out_ size_t* out);
|
|
1862
|
+
|
|
1863
|
+
/** \brief Get the i-th type constraint from the operator schema.
|
|
1864
|
+
*
|
|
1865
|
+
* Returns a non-owning pointer to the OrtOpSchemaTypeConstraint at the given index.
|
|
1866
|
+
* The returned pointer is valid as long as the parent OrtOpSchema is alive.
|
|
1867
|
+
*
|
|
1868
|
+
* Constraints are returned in the order they are declared in the ONNX operator schema
|
|
1869
|
+
* definition. The order is stable but has no semantic significance.
|
|
1870
|
+
*
|
|
1871
|
+
* Use this API to iterate all type constraints (e.g., to register allowed types for
|
|
1872
|
+
* each constraint). Use OpSchema_GetInputTypeConstraint / OpSchema_GetOutputTypeConstraint
|
|
1873
|
+
* to look up the constraint for a specific input or output.
|
|
1874
|
+
*
|
|
1875
|
+
* \param[in] schema The OrtOpSchema instance.
|
|
1876
|
+
* \param[in] index Zero-based index of the type constraint.
|
|
1877
|
+
* \param[out] out Output parameter set to the type constraint.
|
|
1878
|
+
* Valid as long as the OrtOpSchema exists.
|
|
1879
|
+
*
|
|
1880
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1881
|
+
*
|
|
1882
|
+
* \since Version 1.25.
|
|
1883
|
+
*/
|
|
1884
|
+
ORT_API2_STATUS(OpSchema_GetTypeConstraint, _In_ const OrtOpSchema* schema, _In_ size_t index,
|
|
1885
|
+
_Outptr_ const OrtOpSchemaTypeConstraint** out);
|
|
1886
|
+
|
|
1887
|
+
/** \brief Get the type parameter name of a type constraint (e.g., "T", "T1").
|
|
1888
|
+
*
|
|
1889
|
+
* \param[in] type_constraint The OrtOpSchemaTypeConstraint instance.
|
|
1890
|
+
* \param[out] out Output parameter set to the type parameter name.
|
|
1891
|
+
* Valid as long as the parent OrtOpSchema exists.
|
|
1892
|
+
*
|
|
1893
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1894
|
+
*
|
|
1895
|
+
* \since Version 1.25.
|
|
1896
|
+
*/
|
|
1897
|
+
ORT_API2_STATUS(OpSchemaTypeConstraint_GetTypeParamName, _In_ const OrtOpSchemaTypeConstraint* type_constraint,
|
|
1898
|
+
_Outptr_ const char** out);
|
|
1899
|
+
|
|
1900
|
+
/** \brief Get the allowed type strings for a type constraint.
|
|
1901
|
+
*
|
|
1902
|
+
* Returns an array of null-terminated strings representing the allowed data types
|
|
1903
|
+
* (e.g., "tensor(float)", "tensor(double)"). The array and its contents are valid
|
|
1904
|
+
* as long as the parent OrtOpSchema exists.
|
|
1905
|
+
*
|
|
1906
|
+
* \param[in] type_constraint The OrtOpSchemaTypeConstraint instance.
|
|
1907
|
+
* \param[out] out_types Output parameter set to the output array of type strings.
|
|
1908
|
+
* Valid as long as the parent OrtOpSchema exists.
|
|
1909
|
+
* \param[out] num_types Output parameter set to the number of elements in the output array.
|
|
1910
|
+
*
|
|
1911
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1912
|
+
*
|
|
1913
|
+
* \since Version 1.25.
|
|
1914
|
+
*/
|
|
1915
|
+
ORT_API2_STATUS(OpSchemaTypeConstraint_GetAllowedTypes, _In_ const OrtOpSchemaTypeConstraint* type_constraint,
|
|
1916
|
+
_Outptr_ const char* const** out_types, _Out_ size_t* num_types);
|
|
1917
|
+
|
|
1918
|
+
/** \brief Get the input indices that use a type constraint.
|
|
1919
|
+
*
|
|
1920
|
+
* Returns an array of zero-based input indices whose formal parameter type string
|
|
1921
|
+
* matches this type constraint. The array is valid as long as the parent OrtOpSchema exists.
|
|
1922
|
+
*
|
|
1923
|
+
* \param[in] type_constraint The OrtOpSchemaTypeConstraint instance.
|
|
1924
|
+
* \param[out] out_indices Output parameter set to the output array of input indices.
|
|
1925
|
+
* \param[out] count Output parameter set to the number of elements in the output array.
|
|
1926
|
+
*
|
|
1927
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1928
|
+
*
|
|
1929
|
+
* \since Version 1.25.
|
|
1930
|
+
*/
|
|
1931
|
+
ORT_API2_STATUS(OpSchemaTypeConstraint_GetInputIndices, _In_ const OrtOpSchemaTypeConstraint* type_constraint,
|
|
1932
|
+
_Outptr_ const size_t** out_indices, _Out_ size_t* count);
|
|
1933
|
+
|
|
1934
|
+
/** \brief Get the output indices that use a type constraint.
|
|
1935
|
+
*
|
|
1936
|
+
* Returns an array of zero-based output indices whose formal parameter type string
|
|
1937
|
+
* matches this type constraint. The array is valid as long as the parent OrtOpSchema exists.
|
|
1938
|
+
*
|
|
1939
|
+
* \param[in] type_constraint The OrtOpSchemaTypeConstraint instance.
|
|
1940
|
+
* \param[out] out_indices Output parameter set to the output array of output indices.
|
|
1941
|
+
* \param[out] count Output parameter set to the number of elements in the output array.
|
|
1942
|
+
*
|
|
1943
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1944
|
+
*
|
|
1945
|
+
* \since Version 1.25.
|
|
1946
|
+
*/
|
|
1947
|
+
ORT_API2_STATUS(OpSchemaTypeConstraint_GetOutputIndices, _In_ const OrtOpSchemaTypeConstraint* type_constraint,
|
|
1948
|
+
_Outptr_ const size_t** out_indices, _Out_ size_t* count);
|
|
1949
|
+
|
|
1950
|
+
/** \brief Create a profiling event.
|
|
1951
|
+
*
|
|
1952
|
+
* An EP profiler calls this to create an event to pass to OrtEpApi::ProfilingEventsContainer_AddEvents.
|
|
1953
|
+
* The returned event must be released via OrtEpApi::ReleaseProfilingEvent after it has been added.
|
|
1954
|
+
*
|
|
1955
|
+
* \param[in] category The event category (e.g., session, node, kernel, or API).
|
|
1956
|
+
* \param[in] process_id Process ID. Set to -1 if does not apply.
|
|
1957
|
+
* \param[in] thread_id Thread ID. Set to -1 if does not apply.
|
|
1958
|
+
* \param[in] event_name Null-terminated string representing the event name. ORT copies this string.
|
|
1959
|
+
* \param[in] timestamp_us Starting timestamp in microseconds relative to the profiling start time.
|
|
1960
|
+
* An OrtEpProfilerImpl should record its own clock's profiling start time and
|
|
1961
|
+
* use the `ep_profiling_start_offset_ns` value passed to OrtEpProfilerImpl::StartProfiling
|
|
1962
|
+
* to compute this value as:
|
|
1963
|
+
* timestamp_us = (ep_profiling_start_offset_ns +
|
|
1964
|
+
* (ep_event_time_ns - ep_profiling_start_time_ns)) / 1000
|
|
1965
|
+
* \param[in] duration_us Duration in microseconds.
|
|
1966
|
+
* \param[in] arg_keys Array of null-terminated argument key strings. Can be NULL if num_args is 0.
|
|
1967
|
+
* ORT copies these strings.
|
|
1968
|
+
* \param[in] arg_values Array of null-terminated argument value strings. Can be NULL if num_args is 0.
|
|
1969
|
+
* ORT copies these strings.
|
|
1970
|
+
* \param[in] num_args Number of key-value argument pairs.
|
|
1971
|
+
* \param[out] out Output parameter set to the created profiling event.
|
|
1972
|
+
*
|
|
1973
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
1974
|
+
*
|
|
1975
|
+
* \since Version 1.25.
|
|
1976
|
+
*/
|
|
1977
|
+
ORT_API2_STATUS(CreateProfilingEvent,
|
|
1978
|
+
_In_ OrtProfilingEventCategory category,
|
|
1979
|
+
_In_ int32_t process_id,
|
|
1980
|
+
_In_ int32_t thread_id,
|
|
1981
|
+
_In_ const char* event_name,
|
|
1982
|
+
_In_ int64_t timestamp_us,
|
|
1983
|
+
_In_ int64_t duration_us,
|
|
1984
|
+
_In_reads_(num_args) const char* const* arg_keys,
|
|
1985
|
+
_In_reads_(num_args) const char* const* arg_values,
|
|
1986
|
+
_In_ size_t num_args,
|
|
1987
|
+
_Outptr_ OrtProfilingEvent** out);
|
|
1988
|
+
|
|
1989
|
+
/** \brief Release an opaque profiling event created via CreateProfilingEvent.
|
|
1990
|
+
*
|
|
1991
|
+
* \since Version 1.25.
|
|
1992
|
+
*/
|
|
1993
|
+
ORT_CLASS_RELEASE(ProfilingEvent);
|
|
1994
|
+
|
|
1995
|
+
/** \brief Get the event category of a profiling event.
|
|
1996
|
+
*
|
|
1997
|
+
* \param[in] event The OrtProfilingEvent instance.
|
|
1998
|
+
* \param[out] out Output parameter set to the event category.
|
|
1999
|
+
*
|
|
2000
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2001
|
+
*
|
|
2002
|
+
* \since Version 1.25.
|
|
2003
|
+
*/
|
|
2004
|
+
ORT_API2_STATUS(ProfilingEvent_GetCategory, _In_ const OrtProfilingEvent* event,
|
|
2005
|
+
_Out_ OrtProfilingEventCategory* out);
|
|
2006
|
+
|
|
2007
|
+
/** \brief Get the event name of a profiling event.
|
|
2008
|
+
*
|
|
2009
|
+
* \param[in] event The OrtProfilingEvent instance.
|
|
2010
|
+
* \param[out] out Output parameter set to the event name as a null-terminated UTF-8 string.
|
|
2011
|
+
* Do not free as it is owned by the OrtProfilingEvent instance.
|
|
2012
|
+
*
|
|
2013
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2014
|
+
*
|
|
2015
|
+
* \since Version 1.25.
|
|
2016
|
+
*/
|
|
2017
|
+
ORT_API2_STATUS(ProfilingEvent_GetName, _In_ const OrtProfilingEvent* event,
|
|
2018
|
+
_Outptr_ const char** out);
|
|
2019
|
+
|
|
2020
|
+
/** \brief Get the start timestamp of a profiling event in microseconds.
|
|
2021
|
+
*
|
|
2022
|
+
* \param[in] event The OrtProfilingEvent instance.
|
|
2023
|
+
* \param[out] out Output parameter set to the start timestamp of the profiling event in microseconds relative to
|
|
2024
|
+
* the profiling start time.
|
|
2025
|
+
*
|
|
2026
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2027
|
+
*
|
|
2028
|
+
* \since Version 1.25.
|
|
2029
|
+
*/
|
|
2030
|
+
ORT_API2_STATUS(ProfilingEvent_GetTimestampUs, _In_ const OrtProfilingEvent* event,
|
|
2031
|
+
_Out_ int64_t* out);
|
|
2032
|
+
|
|
2033
|
+
/** \brief Get the duration of a profiling event in microseconds.
|
|
2034
|
+
*
|
|
2035
|
+
* \param[in] event The OrtProfilingEvent instance.
|
|
2036
|
+
* \param[out] out Output parameter set to the event duration in microseconds.
|
|
2037
|
+
*
|
|
2038
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2039
|
+
*
|
|
2040
|
+
* \since Version 1.25.
|
|
2041
|
+
*/
|
|
2042
|
+
ORT_API2_STATUS(ProfilingEvent_GetDurationUs, _In_ const OrtProfilingEvent* event,
|
|
2043
|
+
_Out_ int64_t* out);
|
|
2044
|
+
|
|
2045
|
+
/** \brief Get the value of an event argument by its key.
|
|
2046
|
+
*
|
|
2047
|
+
* The value is set to NULL if the key is not found.
|
|
2048
|
+
*
|
|
2049
|
+
* \param[in] event The OrtProfilingEvent instance.
|
|
2050
|
+
* \param[in] key Null-terminated argument key to look up.
|
|
2051
|
+
* \param[out] out Output parameter set to the argument value string, or NULL if not found.
|
|
2052
|
+
* The value is a null-terminated UTF-8 string.
|
|
2053
|
+
* Do not free as the string is owned by the OrtProfilingEvent instance.
|
|
2054
|
+
*
|
|
2055
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2056
|
+
* \since Version 1.25.
|
|
2057
|
+
*/
|
|
2058
|
+
ORT_API2_STATUS(ProfilingEvent_GetArgValue, _In_ const OrtProfilingEvent* event, _In_ const char* key,
|
|
2059
|
+
_Outptr_result_maybenull_ const char** out);
|
|
2060
|
+
|
|
2061
|
+
/** \brief Add EP profiling events to an events container.
|
|
2062
|
+
*
|
|
2063
|
+
* An EP profiler calls this function to report new EP profiling events (e.g., GPU kernel timings) during
|
|
2064
|
+
* OrtEpProfilerImpl::EndProfiling(). ORT copies the EP event data during this call. The EP retains ownership of the
|
|
2065
|
+
* OrtProfilingEvent instances and must release them via ReleaseProfilingEvent after this call returns.
|
|
2066
|
+
* This function may be called multiple times within a single EndProfiling call to add EP events in batches.
|
|
2067
|
+
*
|
|
2068
|
+
* \param[in] events_container The OrtProfilingEventsContainer instance provided by ORT
|
|
2069
|
+
* to OrtEpProfilerImpl::EndProfiling().
|
|
2070
|
+
* \param[in] events Array of pointers to opaque OrtProfilingEvent instances.
|
|
2071
|
+
* \param[in] num_events Number of events in the `events` array. Must be greater than 0.
|
|
2072
|
+
*
|
|
2073
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2074
|
+
*
|
|
2075
|
+
* \since Version 1.25.
|
|
2076
|
+
*/
|
|
2077
|
+
ORT_API2_STATUS(ProfilingEventsContainer_AddEvents, _In_ OrtProfilingEventsContainer* events_container,
|
|
2078
|
+
_In_reads_(num_events) const OrtProfilingEvent* const* events,
|
|
2079
|
+
_In_ size_t num_events);
|
|
2080
|
+
|
|
2081
|
+
/** \brief Get the weightless source model byte buffer from session options.
|
|
2082
|
+
*
|
|
2083
|
+
* Returns the buffer and size set by SessionOptionsSetWeightlessSourceModelBuffer, or NULL/0 if not set.
|
|
2084
|
+
* The EP can use this during CreateEp or Compile to access the source model for weightless
|
|
2085
|
+
* EPContext model sessions.
|
|
2086
|
+
*
|
|
2087
|
+
* \note If the source model is provided as a file path, the EP should read the
|
|
2088
|
+
* "ep.context_source_model_path" (kOrtSessionOptionEpContextSourceModelPath) session config entry
|
|
2089
|
+
* via GetSessionConfigEntry instead.
|
|
2090
|
+
*
|
|
2091
|
+
* \note Recommended EP precedence for locating the source model:
|
|
2092
|
+
* buffer (this API) > file path ("ep.context_source_model_path") > "onnx_model_filename" EPContext
|
|
2093
|
+
* node attribute.
|
|
2094
|
+
*
|
|
2095
|
+
* \param[in] session_options The OrtSessionOptions instance.
|
|
2096
|
+
* \param[out] source_model_data Output parameter set to the source model buffer, or NULL if not set.
|
|
2097
|
+
* \param[out] source_model_data_length Output parameter set to the buffer size, or 0 if not set.
|
|
2098
|
+
*
|
|
2099
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2100
|
+
*
|
|
2101
|
+
* \since Version 1.29.
|
|
2102
|
+
*/
|
|
2103
|
+
ORT_API2_STATUS(SessionOptionsGetWeightlessSourceModelBuffer, _In_ const OrtSessionOptions* session_options,
|
|
2104
|
+
_Outptr_result_maybenull_ const void** source_model_data,
|
|
2105
|
+
_Out_ size_t* source_model_data_length);
|
|
2106
|
+
|
|
2107
|
+
/** \brief Copy the EPContext callback configuration from session options into an owned handle.
|
|
2108
|
+
*
|
|
2109
|
+
* An EP should call this during OrtEpFactory::CreateEp and retain the returned handle for as long as its Compile
|
|
2110
|
+
* implementation may need the callbacks. The handle owns copies of the function and state pointers, but it does
|
|
2111
|
+
* not own the application-provided state itself. On failure, `*config` is not modified.
|
|
2112
|
+
*
|
|
2113
|
+
* \param[in] session_options Session options supplied to OrtEpFactory::CreateEp.
|
|
2114
|
+
* \param[out] config Non-null handle that must be released with ReleaseEpContextConfig.
|
|
2115
|
+
*
|
|
2116
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2117
|
+
*
|
|
2118
|
+
* \since Version 1.31.
|
|
2119
|
+
*/
|
|
2120
|
+
ORT_API2_STATUS(SessionOptionsGetEpContextConfig, _In_ const OrtSessionOptions* session_options,
|
|
2121
|
+
_Outptr_ OrtEpContextConfig** config);
|
|
2122
|
+
|
|
2123
|
+
/** \brief Release an OrtEpContextConfig handle. May be called with NULL.
|
|
2124
|
+
*
|
|
2125
|
+
* \since Version 1.31.
|
|
2126
|
+
*/
|
|
2127
|
+
ORT_CLASS_RELEASE(EpContextConfig);
|
|
2128
|
+
|
|
2129
|
+
/** \brief Get the EPContext data read callback and application state.
|
|
2130
|
+
*
|
|
2131
|
+
* If no callback is configured, both outputs are set to NULL. On failure, both outputs are unchanged.
|
|
2132
|
+
* The returned state is application-owned and remains
|
|
2133
|
+
* subject to the lifetime and synchronization requirements documented by SessionOptionsSetEpContextDataReadFunc.
|
|
2134
|
+
*
|
|
2135
|
+
* \param[in] config EPContext configuration handle.
|
|
2136
|
+
* \param[out] read_func Configured callback, or NULL.
|
|
2137
|
+
* \param[out] state Configured application state, or NULL.
|
|
2138
|
+
*
|
|
2139
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2140
|
+
*
|
|
2141
|
+
* \since Version 1.31.
|
|
2142
|
+
*/
|
|
2143
|
+
ORT_API2_STATUS(EpContextConfigGetEpContextDataReadFunc, _In_ const OrtEpContextConfig* config,
|
|
2144
|
+
_Out_ OrtReadNamedBufferFunc* read_func, _Out_ void** state);
|
|
2145
|
+
|
|
2146
|
+
/** \brief Get the EPContext data write callback and application state.
|
|
2147
|
+
*
|
|
2148
|
+
* If no callback is configured, both outputs are set to NULL. The returned state is application-owned and remains
|
|
2149
|
+
* subject to the lifetime and synchronization requirements documented by
|
|
2150
|
+
* ModelCompilationOptions_SetEpContextDataWriteFunc.
|
|
2151
|
+
*
|
|
2152
|
+
* \param[in] config EPContext configuration handle.
|
|
2153
|
+
* \param[out] write_func Configured callback, or NULL.
|
|
2154
|
+
* \param[out] state Configured application state, or NULL.
|
|
2155
|
+
*
|
|
2156
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2157
|
+
*
|
|
2158
|
+
* \since Version 1.31.
|
|
2159
|
+
*/
|
|
2160
|
+
ORT_API2_STATUS(EpContextConfigGetEpContextDataWriteFunc, _In_ const OrtEpContextConfig* config,
|
|
2161
|
+
_Out_ OrtWriteNamedBufferFunc* write_func, _Out_ void** state);
|
|
2162
|
+
};
|
|
2163
|
+
|
|
2164
|
+
/**
|
|
2165
|
+
* \brief The data layout type.
|
|
2166
|
+
*
|
|
2167
|
+
* EPs may specify a preferred data layout type. ORT's default layout type is OrtEpDataLayout_NCHW, or
|
|
2168
|
+
* OrtEpDataLayout_Default.
|
|
2169
|
+
*
|
|
2170
|
+
* \since Version 1.23.
|
|
2171
|
+
*/
|
|
2172
|
+
typedef enum OrtEpDataLayout {
|
|
2173
|
+
OrtEpDataLayout_NCHW = 0,
|
|
2174
|
+
OrtEpDataLayout_NHWC,
|
|
2175
|
+
|
|
2176
|
+
OrtEpDataLayout_Default = OrtEpDataLayout_NCHW,
|
|
2177
|
+
} OrtEpDataLayout;
|
|
2178
|
+
|
|
2179
|
+
/**
|
|
2180
|
+
* \brief Node assignment policies for graph capture validation.
|
|
2181
|
+
*
|
|
2182
|
+
* When graph capture is enabled, ORT validates that nodes are assigned to EPs in a way that is
|
|
2183
|
+
* compatible with graph capture. An EP can specify which validation policy ORT should apply.
|
|
2184
|
+
*
|
|
2185
|
+
* \since Version 1.26.
|
|
2186
|
+
*/
|
|
2187
|
+
typedef enum OrtGraphCaptureNodeAssignmentPolicy {
|
|
2188
|
+
/** All nodes in the main graph must be assigned to this EP. No CPU fallback is allowed. */
|
|
2189
|
+
OrtGraphCaptureNodeAssignmentPolicy_ALL_NODES_ON_EP = 0,
|
|
2190
|
+
|
|
2191
|
+
/** Compute nodes must be on this EP. CPU nodes are allowed for shape computation as long as
|
|
2192
|
+
* no memory copy nodes exist. */
|
|
2193
|
+
OrtGraphCaptureNodeAssignmentPolicy_ALLOW_CPU_FOR_SHAPES = 1,
|
|
2194
|
+
} OrtGraphCaptureNodeAssignmentPolicy;
|
|
2195
|
+
|
|
2196
|
+
/**
|
|
2197
|
+
* \brief Describes the scope of an EP's weightless mode support.
|
|
2198
|
+
*
|
|
2199
|
+
* Returned by OrtEp::GetWeightlessSupport() to indicate which types of initializers
|
|
2200
|
+
* the EP can operate on without copying.
|
|
2201
|
+
*
|
|
2202
|
+
* \since Version 1.29.
|
|
2203
|
+
*/
|
|
2204
|
+
typedef enum OrtWeightlessSupport {
|
|
2205
|
+
/** EP does not support weightless mode. */
|
|
2206
|
+
OrtWeightlessSupport_NONE = 0,
|
|
2207
|
+
|
|
2208
|
+
/** EP supports weightless mode for external initializers only.
|
|
2209
|
+
* Internal initializers are still copied by the EP during compilation. */
|
|
2210
|
+
OrtWeightlessSupport_EXTERNAL_ONLY = 1,
|
|
2211
|
+
|
|
2212
|
+
/** EP supports weightless mode for all initializers (internal and external). */
|
|
2213
|
+
OrtWeightlessSupport_ALL = 2,
|
|
2214
|
+
} OrtWeightlessSupport;
|
|
2215
|
+
|
|
2216
|
+
/**
|
|
2217
|
+
* \brief The OrtEp struct provides functions to implement for an execution provider.
|
|
2218
|
+
* \since Version 1.22.
|
|
2219
|
+
*/
|
|
2220
|
+
struct OrtEp {
|
|
2221
|
+
/** \brief The ONNX Runtime API version the execution provider was compiled with.
|
|
2222
|
+
*
|
|
2223
|
+
* Implementation should set this to ORT_API_VERSION.
|
|
2224
|
+
* ORT uses this to avoid calling functions that were not available when the EP was compiled.
|
|
2225
|
+
*
|
|
2226
|
+
* \since Version 1.22.
|
|
2227
|
+
*/
|
|
2228
|
+
uint32_t ort_version_supported;
|
|
2229
|
+
|
|
2230
|
+
/** \brief Get the execution provider name.
|
|
2231
|
+
*
|
|
2232
|
+
* The returned string should be a null-terminated, UTF-8 encoded string. ORT will copy it.
|
|
2233
|
+
*
|
|
2234
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2235
|
+
* \return The execution provider name.
|
|
2236
|
+
*
|
|
2237
|
+
* \since Version 1.22.
|
|
2238
|
+
*/
|
|
2239
|
+
ORT_API_T(const char*, GetName, _In_ const OrtEp* this_ptr);
|
|
2240
|
+
|
|
2241
|
+
/** \brief Get information about the nodes supported by the OrtEp instance.
|
|
2242
|
+
*
|
|
2243
|
+
* IMPORTANT: This is not the final version of this API function. This is currently experimental but will
|
|
2244
|
+
* be stabilized by the ONNX Runtime 1.23 release.
|
|
2245
|
+
*
|
|
2246
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2247
|
+
* \param[in] graph The OrtGraph instance for which to populate node support. The OrtGraph could be a nested subgraph
|
|
2248
|
+
* contained by a node (e.g., an If or Loop node). ONNX Runtime calls this function separately
|
|
2249
|
+
* for each nested subgraph.
|
|
2250
|
+
* \param[inout] graph_support_info OrtEpGraphSupportInfo instance that the implementer must fill out in order to
|
|
2251
|
+
* specify the supported nodes.
|
|
2252
|
+
*
|
|
2253
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2254
|
+
*
|
|
2255
|
+
* \since Version 1.23.
|
|
2256
|
+
*/
|
|
2257
|
+
ORT_API2_STATUS(GetCapability, _In_ OrtEp* this_ptr, _In_ const OrtGraph* graph,
|
|
2258
|
+
_Inout_ OrtEpGraphSupportInfo* graph_support_info);
|
|
2259
|
+
|
|
2260
|
+
/** \brief Compile OrtGraph instances assigned to the OrtEp. Implementer must set a OrtNodeComputeInfo instance
|
|
2261
|
+
* for each OrtGraph in order to define its computation function.
|
|
2262
|
+
*
|
|
2263
|
+
* If the session is configured to generate a pre-compiled model, the execution provider must return EPContext nodes,
|
|
2264
|
+
* as OrtNode instances, that ONNX Runtime uses to create a pre-compiled model, known as an "EPContext model".
|
|
2265
|
+
* An EPContext model contains EPContext nodes. Each EPContext node encapsulates the pre-compiled binary data for a
|
|
2266
|
+
* OrtGraph compiled for a specific execution provider. For more details about the EPContext design, refer to:
|
|
2267
|
+
* \htmlonly
|
|
2268
|
+
* <a href="https://onnxruntime.ai/docs/execution-providers/EP-Context-Design.html">EPContext design document.</a>
|
|
2269
|
+
* \endhtmlonly
|
|
2270
|
+
*
|
|
2271
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2272
|
+
* \param[in] graphs Array of `count` OrtGraph instances to compile. Each graph contains only the nodes for
|
|
2273
|
+
* which the execution provider indicated support. Nested subgraphs contained by a
|
|
2274
|
+
* node, such as an If or Loop, have separate OrtGraph instances.
|
|
2275
|
+
* \param[in] fused_nodes Array of `count` fused nodes that will replace the compiled graphs.
|
|
2276
|
+
* Each fused node is an OrtNode initialized with the intended fused node name and
|
|
2277
|
+
* input/output information.
|
|
2278
|
+
* \param[in] count The number of OrtGraph instances to compile.
|
|
2279
|
+
* \param[out] node_compute_infos Array of `count` OrtNodeComputeInfo instances that define each OrtGraph instance's
|
|
2280
|
+
* computation function. The implementer allocates the OrtNodeComputeInfo instances.
|
|
2281
|
+
* ORT calls ReleaseNodeComputeInfos() to release multiple instances in a batch.
|
|
2282
|
+
* \param[out] ep_context_nodes Output array of `count` OrtNode instances, each representing an EPContext
|
|
2283
|
+
* node for a compiled OrtGraph. The execution provider must use
|
|
2284
|
+
* OrtModelEditorApi::CreateNode to create the OrtNode instances. ONNX Runtime takes
|
|
2285
|
+
* ownership of the OrtNode instances, so the execution provider must NOT call
|
|
2286
|
+
* OrtApi::ReleaseNode. Should be ignored if the session is not configured to generate an
|
|
2287
|
+
* EPContext model.
|
|
2288
|
+
*
|
|
2289
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2290
|
+
*
|
|
2291
|
+
* \note Do NOT cache the provided OrtGraph instances in any of the OrtNodeComputeInfo functions because the
|
|
2292
|
+
* graphs are only valid for the duration of the call to Compile. Any graph/node/input/output
|
|
2293
|
+
* names that are needed by the OrtNodeComputeInfo functions must be copied and stored by the OrtEp.
|
|
2294
|
+
*
|
|
2295
|
+
* \note As of version 1.24, implementation of this function is optional if the EP does not compile nodes and
|
|
2296
|
+
* uses a kernel registry instead.
|
|
2297
|
+
*
|
|
2298
|
+
* \since Version 1.23.
|
|
2299
|
+
*/
|
|
2300
|
+
ORT_API2_STATUS(Compile, _In_ OrtEp* this_ptr, _In_ const OrtGraph** graphs,
|
|
2301
|
+
_In_ const OrtNode** fused_nodes, _In_ size_t count,
|
|
2302
|
+
_Out_writes_all_(count) OrtNodeComputeInfo** node_compute_infos,
|
|
2303
|
+
_Out_writes_(count) OrtNode** ep_context_nodes);
|
|
2304
|
+
|
|
2305
|
+
/** \brief Release OrtNodeComputeInfo instances.
|
|
2306
|
+
*
|
|
2307
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2308
|
+
* \param[inout] node_compute_infos The OrtNodeComputeInfo instances to release.
|
|
2309
|
+
* \param[in] num_node_compute_infos The number of OrtNodeComputeInfo instances.
|
|
2310
|
+
*
|
|
2311
|
+
* \note As of version 1.24, implementation of this function is optional if the EP does not compile nodes and
|
|
2312
|
+
* uses a kernel registry instead.
|
|
2313
|
+
*
|
|
2314
|
+
* \since Version 1.23.
|
|
2315
|
+
*/
|
|
2316
|
+
ORT_API_T(void, ReleaseNodeComputeInfos, _In_ OrtEp* this_ptr,
|
|
2317
|
+
OrtNodeComputeInfo** node_compute_infos,
|
|
2318
|
+
_In_ size_t num_node_compute_infos);
|
|
2319
|
+
|
|
2320
|
+
/** \brief Get the EP's preferred data layout.
|
|
2321
|
+
*
|
|
2322
|
+
* \note Implementation of this function is optional.
|
|
2323
|
+
* If not implemented, ORT will assume that this EP prefers the data layout `OrtEpDataLayout::NCHW`.
|
|
2324
|
+
*
|
|
2325
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2326
|
+
* \param[out] preferred_data_layout The EP's preferred data layout.
|
|
2327
|
+
*
|
|
2328
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2329
|
+
*
|
|
2330
|
+
* \since Version 1.23.
|
|
2331
|
+
*/
|
|
2332
|
+
ORT_API2_STATUS(GetPreferredDataLayout, _In_ OrtEp* this_ptr, _Out_ OrtEpDataLayout* preferred_data_layout);
|
|
2333
|
+
|
|
2334
|
+
/** \brief Given an op with domain `domain` and type `op_type`, determine whether an associated node's data layout
|
|
2335
|
+
* should be converted to `target_data_layout`.
|
|
2336
|
+
* If the EP prefers a non-default data layout (see `GetPreferredDataLayout()`), this function will be called
|
|
2337
|
+
* during layout transformation with `target_data_layout` set to the EP's preferred data layout.
|
|
2338
|
+
*
|
|
2339
|
+
* \note Implementation of this function is optional.
|
|
2340
|
+
* If an EP prefers a non-default data layout, it may implement this to customize the specific op data layout
|
|
2341
|
+
* preferences at a finer granularity.
|
|
2342
|
+
*
|
|
2343
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2344
|
+
* \param[in] domain The op domain. An empty string means the ONNX domain.
|
|
2345
|
+
* \param[in] op_type The op type.
|
|
2346
|
+
* \param[in] target_data_layout The target data layout.
|
|
2347
|
+
* \param[out] should_convert Whether the associated node's data layout should be converted to `target_data_layout`.
|
|
2348
|
+
* If greater than 0, convert.
|
|
2349
|
+
* If 0, don't convert.
|
|
2350
|
+
* Otherwise, if less than 0, leave the decision to ORT.
|
|
2351
|
+
*
|
|
2352
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2353
|
+
*
|
|
2354
|
+
* \since Version 1.23.
|
|
2355
|
+
*/
|
|
2356
|
+
ORT_API2_STATUS(ShouldConvertDataLayoutForOp, _In_ OrtEp* this_ptr,
|
|
2357
|
+
_In_z_ const char* domain, _In_z_ const char* op_type,
|
|
2358
|
+
_In_ OrtEpDataLayout target_data_layout,
|
|
2359
|
+
_Outptr_ int* should_convert);
|
|
2360
|
+
|
|
2361
|
+
/** \brief Set dynamic options on this EP.
|
|
2362
|
+
*
|
|
2363
|
+
* Dynamic options can be set by the user at any time after session creation with `OrtApi::SetEpDynamicOptions()`.
|
|
2364
|
+
*
|
|
2365
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2366
|
+
* \param[in] option_keys The dynamic option keys.
|
|
2367
|
+
* \param[in] option_values The dynamic option values.
|
|
2368
|
+
* \param[in] num_options The number of dynamic options.
|
|
2369
|
+
*
|
|
2370
|
+
* \note Implementation of this function is optional.
|
|
2371
|
+
* An EP should only implement this if it needs to handle any dynamic options.
|
|
2372
|
+
*
|
|
2373
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2374
|
+
*
|
|
2375
|
+
* \since Version 1.23.
|
|
2376
|
+
*/
|
|
2377
|
+
ORT_API2_STATUS(SetDynamicOptions, _In_ OrtEp* this_ptr,
|
|
2378
|
+
_In_reads_(num_options) const char* const* option_keys,
|
|
2379
|
+
_In_reads_(num_options) const char* const* option_values,
|
|
2380
|
+
_In_ size_t num_options);
|
|
2381
|
+
|
|
2382
|
+
/** \brief Called by ORT to notify the EP of the start of a run.
|
|
2383
|
+
*
|
|
2384
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2385
|
+
* \param[in] run_options The run options for this run.
|
|
2386
|
+
*
|
|
2387
|
+
* \note Implementation of this function is optional.
|
|
2388
|
+
* When graph capture/replay is enabled and a graph has already been captured, ORT skips
|
|
2389
|
+
* normal execution and calls ReplayGraph() directly, so this callback is not invoked for replay runs.
|
|
2390
|
+
*
|
|
2391
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2392
|
+
*
|
|
2393
|
+
* \since Version 1.23.
|
|
2394
|
+
*/
|
|
2395
|
+
ORT_API2_STATUS(OnRunStart, _In_ OrtEp* this_ptr, _In_ const OrtRunOptions* run_options);
|
|
2396
|
+
|
|
2397
|
+
/** \brief Called by ORT to notify the EP of the end of a run.
|
|
2398
|
+
*
|
|
2399
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2400
|
+
* \param[in] run_options The run options for this run.
|
|
2401
|
+
* \param[in] sync_stream Whether any associated stream should be synchronized during this call.
|
|
2402
|
+
* Only applicable if there is such a stream.
|
|
2403
|
+
*
|
|
2404
|
+
* \note Implementation of this function is optional.
|
|
2405
|
+
* When graph capture/replay is enabled and a graph has already been captured, ORT skips
|
|
2406
|
+
* normal execution and calls ReplayGraph() directly, so this callback is not invoked for replay runs.
|
|
2407
|
+
*
|
|
2408
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2409
|
+
*
|
|
2410
|
+
* \since Version 1.23.
|
|
2411
|
+
*/
|
|
2412
|
+
ORT_API2_STATUS(OnRunEnd, _In_ OrtEp* this_ptr, _In_ const OrtRunOptions* run_options, _In_ bool sync_stream);
|
|
2413
|
+
|
|
2414
|
+
/** \brief Create an OrtAllocator for the given OrtMemoryInfo for an OrtSession.
|
|
2415
|
+
*
|
|
2416
|
+
* The OrtMemoryInfo instance will match one of the values set in the OrtEpDevice using EpDevice_AddAllocatorInfo.
|
|
2417
|
+
* Any allocator specific options should be read from the session options.
|
|
2418
|
+
*
|
|
2419
|
+
* Implementation of this function is optional. If nullptr, OrtEpFactory::CreateAllocator will be used if
|
|
2420
|
+
* implemented. If neither callback is implemented, the EP does not provide a preferred allocator for the memory
|
|
2421
|
+
* location. For default CPU memory, this allows ORT to use its default CPU allocator.
|
|
2422
|
+
*
|
|
2423
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2424
|
+
* \param[in] memory_info The OrtMemoryInfo to create the allocator for. May be nullptr.
|
|
2425
|
+
* \param[out] allocator The created OrtAllocator instance. Set to nullptr if the EP does not provide a preferred
|
|
2426
|
+
* allocator for the memory location.
|
|
2427
|
+
*
|
|
2428
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2429
|
+
*
|
|
2430
|
+
* \since Version 1.23.
|
|
2431
|
+
*/
|
|
2432
|
+
ORT_API2_STATUS(CreateAllocator, _In_ OrtEp* this_ptr,
|
|
2433
|
+
_In_ const OrtMemoryInfo* memory_info,
|
|
2434
|
+
_Outptr_result_maybenull_ OrtAllocator** allocator);
|
|
2435
|
+
|
|
2436
|
+
/** \brief Create a synchronization stream for the given memory device for an OrtSession.
|
|
2437
|
+
*
|
|
2438
|
+
* This is used to create a synchronization stream for the execution provider and is used to synchronize
|
|
2439
|
+
* operations on the device during model execution.
|
|
2440
|
+
* Any stream specific options should be read from the session options.
|
|
2441
|
+
*
|
|
2442
|
+
* If nullptr OrtEpFactory::CreateSyncStreamForDevice will be used.
|
|
2443
|
+
*
|
|
2444
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
2445
|
+
* \param[in] memory_device The OrtMemoryDevice to create the synchronization stream for.
|
|
2446
|
+
* \param[out] stream The created OrtSyncStreamImpl instance. nullptr if the execution provider is not stream aware.
|
|
2447
|
+
*
|
|
2448
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2449
|
+
*
|
|
2450
|
+
* \since Version 1.23.
|
|
2451
|
+
*/
|
|
2452
|
+
ORT_API2_STATUS(CreateSyncStreamForDevice, _In_ OrtEp* this_ptr,
|
|
2453
|
+
_In_ const OrtMemoryDevice* memory_device,
|
|
2454
|
+
_Outptr_ OrtSyncStreamImpl** stream);
|
|
2455
|
+
|
|
2456
|
+
/** \brief Get a string with details about the EP stack used to produce a compiled model.
|
|
2457
|
+
*
|
|
2458
|
+
* This function gets a compatibility information string that contains details about the execution provider
|
|
2459
|
+
* used to compile a given model. This string can later be used with ValidateCompiledModelCompatibilityInfo
|
|
2460
|
+
* to determine if a compiled model is compatible with the EP.
|
|
2461
|
+
*
|
|
2462
|
+
* The format and contents of the string are defined by the EP and are opaque to ORT and applications. The EP should
|
|
2463
|
+
* include enough information to determine whether the compiled model can run with a future EP configuration. This may
|
|
2464
|
+
* include the devices used to compile the model, but applications are not expected to parse or otherwise recover that
|
|
2465
|
+
* information from the string.
|
|
2466
|
+
*
|
|
2467
|
+
* The returned string should be a null-terminated, UTF-8 encoded string. ORT will copy it.
|
|
2468
|
+
*
|
|
2469
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2470
|
+
* \param[in] graph The OrtGraph instance for which to generate compatibility information.
|
|
2471
|
+
*
|
|
2472
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2473
|
+
*
|
|
2474
|
+
* \since Version 1.23.
|
|
2475
|
+
*/
|
|
2476
|
+
ORT_API_T(const char*, GetCompiledModelCompatibilityInfo, _In_ OrtEp* this_ptr,
|
|
2477
|
+
_In_ const OrtGraph* graph);
|
|
2478
|
+
|
|
2479
|
+
/** \brief Gets the execution provider's kernel registry, if any.
|
|
2480
|
+
*
|
|
2481
|
+
* A kernel registry contains kernel creation information for operator kernels supported by an EP.
|
|
2482
|
+
*
|
|
2483
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2484
|
+
* \param[out] kernel_registry Output parameter set to the EP's kernel registry, which must remain valid throughout
|
|
2485
|
+
* the lifetime of the EP. Can be NULL if the EP doesn't use a kernel registry.
|
|
2486
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2487
|
+
*
|
|
2488
|
+
* \note Implementation of this function is optional. If set to NULL, ORT assumes the EP compiles nodes.
|
|
2489
|
+
*
|
|
2490
|
+
* \since Version 1.24.
|
|
2491
|
+
*/
|
|
2492
|
+
ORT_API2_STATUS(GetKernelRegistry, _In_ OrtEp* this_ptr,
|
|
2493
|
+
_Outptr_result_maybenull_ const OrtKernelRegistry** kernel_registry);
|
|
2494
|
+
|
|
2495
|
+
/** \brief Gets whether the execution provider supports concurrent run calls made on the session.
|
|
2496
|
+
*
|
|
2497
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2498
|
+
* \param[out] is_supported Whether concurrent runs are supported.
|
|
2499
|
+
*
|
|
2500
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2501
|
+
*
|
|
2502
|
+
* \note Implementation of this function is optional and it may be set to NULL.
|
|
2503
|
+
* If not implemented, ORT assumes that concurrent runs are supported.
|
|
2504
|
+
*
|
|
2505
|
+
* \since Version 1.24.
|
|
2506
|
+
*/
|
|
2507
|
+
ORT_API2_STATUS(IsConcurrentRunSupported, _In_ OrtEp* this_ptr, _Outptr_ bool* is_supported);
|
|
2508
|
+
|
|
2509
|
+
/** \brief Called by ORT to block until the device has completed all preceding requested tasks.
|
|
2510
|
+
*
|
|
2511
|
+
* Currently this is primarily used by the IOBinding object to ensure that all inputs have been copied
|
|
2512
|
+
* to the device before execution begins.
|
|
2513
|
+
*
|
|
2514
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2515
|
+
*
|
|
2516
|
+
* \note Implementation of this function is optional.
|
|
2517
|
+
*
|
|
2518
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2519
|
+
*
|
|
2520
|
+
* \since Version 1.25.
|
|
2521
|
+
*/
|
|
2522
|
+
ORT_API2_STATUS(Sync, _In_ OrtEp* this_ptr);
|
|
2523
|
+
|
|
2524
|
+
/** \brief Return a new profiler for the execution provider.
|
|
2525
|
+
*
|
|
2526
|
+
* If the EP supports profiling, it should create and return an OrtEpProfilerImpl instance.
|
|
2527
|
+
* ORT takes ownership of each non-NULL instance returned and will call OrtEpProfilerImpl::Release when
|
|
2528
|
+
* it is no longer needed.
|
|
2529
|
+
*
|
|
2530
|
+
* ORT may call this function multiple times over the lifetime of a single OrtEp instance, for example
|
|
2531
|
+
* during EP registration and again per run if run-level profiling is enabled. Each call is independent and
|
|
2532
|
+
* the EP must return a new profiler instance (or NULL if profiling is not supported).
|
|
2533
|
+
*
|
|
2534
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2535
|
+
* \param[out] profiler Output parameter set to a new OrtEpProfilerImpl instance created by the EP.
|
|
2536
|
+
* Set to NULL if the EP does not support profiling.
|
|
2537
|
+
*
|
|
2538
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2539
|
+
*
|
|
2540
|
+
* \note Implementation of this function is optional. If set to NULL, ORT assumes the EP does not
|
|
2541
|
+
* support profiling.
|
|
2542
|
+
*
|
|
2543
|
+
* \since Version 1.25.
|
|
2544
|
+
*/
|
|
2545
|
+
ORT_API2_STATUS(CreateProfiler, _In_ OrtEp* this_ptr,
|
|
2546
|
+
_Outptr_result_maybenull_ OrtEpProfilerImpl** profiler);
|
|
2547
|
+
|
|
2548
|
+
/** \brief Indicate whether the graph capturing mode (e.g., CUDA graph) is enabled for the provider.
|
|
2549
|
+
*
|
|
2550
|
+
* Graph capture allows an EP to record a sequence of device (e.g., GPU) operations during an initial run and replay
|
|
2551
|
+
* them on subsequent runs, bypassing per-kernel CPU launch overhead.
|
|
2552
|
+
*
|
|
2553
|
+
* Applications enable graph capture via EP-specific provider options (e.g., `enable_cuda_graph=1`
|
|
2554
|
+
* for the CUDA EP). An EP should return true from this function if it has been configured to enable
|
|
2555
|
+
* graph capture/replay.
|
|
2556
|
+
*
|
|
2557
|
+
* **ORT graph capture/replay summary:**
|
|
2558
|
+
* During OrtSession initialization, ORT calls OrtEp::IsGraphCaptureEnabled() on each EP in the order specified during
|
|
2559
|
+
* provider registration with the session. If an EP returns true, ORT validates that the graph is suitable for
|
|
2560
|
+
* graph capture, and if so, caches the EP for graph capture during the next run. The graph validation ensures
|
|
2561
|
+
* that there are no control flow nodes and that node-to-EP assignments are compatible with the policy specified
|
|
2562
|
+
* by the EP via OrtEp::GetGraphCaptureNodeAssignmentPolicy().
|
|
2563
|
+
* Note that an OrtSession only supports graph capture for one EP (i.e., the first EP to claim support).
|
|
2564
|
+
*
|
|
2565
|
+
* During the first call to OrtApi::Run() for the OrtSession, ORT performs multiple internal runs of the model
|
|
2566
|
+
* until the EP indicates that the graph has been captured by returning `true` from `OrtEp::IsGraphCaptured()`.
|
|
2567
|
+
* If the EP is unable to capture the graph within 8 runs, the call to OrtApi::Run() returns an error OrtStatus.
|
|
2568
|
+
* Each internal run invokes `OrtEp::OnRunStart()`, normal execution, and `OrtEp::OnRunEnd()`. EPs should use
|
|
2569
|
+
* these run callbacks to track the number of necessary warm-up runs and begin/end graph capture when ready.
|
|
2570
|
+
*
|
|
2571
|
+
* After successful graph capture, subsequent calls to OrtApi::Run() skip normal execution and ORT instead calls
|
|
2572
|
+
* `OrtEp::ReplayGraph()` directly.
|
|
2573
|
+
*
|
|
2574
|
+
* Applications can capture and replay multiple graphs (e.g., one per distinct input shape) by setting the
|
|
2575
|
+
* `"gpu_graph_id"` run config entry via `OrtApi::AddRunConfigEntry()` to different integer values. ORT passes
|
|
2576
|
+
* the value as the `graph_annotation_id` parameter to `OrtEp::IsGraphCaptured()` and `OrtEp::ReplayGraph()`.
|
|
2577
|
+
*
|
|
2578
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2579
|
+
* \return true if graph capture mode is enabled, false otherwise.
|
|
2580
|
+
*
|
|
2581
|
+
* \note Implementation of this function is optional. If set to NULL, ORT assumes graph capture is not enabled.
|
|
2582
|
+
* \note If this function returns true, `OrtEp::IsGraphCaptured` and `OrtEp::ReplayGraph` must also be implemented.
|
|
2583
|
+
* If either is NULL, ORT will log a warning and ignore this EP for graph capture.
|
|
2584
|
+
*
|
|
2585
|
+
* \since Version 1.26.
|
|
2586
|
+
*/
|
|
2587
|
+
ORT_API_T(bool, IsGraphCaptureEnabled, _In_ const OrtEp* this_ptr);
|
|
2588
|
+
|
|
2589
|
+
/** \brief Indicate whether a graph has been captured and instantiated.
|
|
2590
|
+
*
|
|
2591
|
+
* ORT calls this before each `Session::Run()`. If true, ORT calls `ReplayGraph()` instead of
|
|
2592
|
+
* normal execution. After a run where this returns false, ORT automatically retries until it
|
|
2593
|
+
* returns true (handling warm-up runs transparently).
|
|
2594
|
+
*
|
|
2595
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2596
|
+
* \param[in] graph_annotation_id Identifies which captured graph to query.
|
|
2597
|
+
* Applications can set this value via `OrtApi::AddRunConfigEntry()` with the key `"gpu_graph_id"`.
|
|
2598
|
+
* The default value is 0 when the run config entry is not set.
|
|
2599
|
+
* Setting different IDs allows the EP to capture and manage multiple graphs (e.g., one per
|
|
2600
|
+
* distinct input shape). A value of -1 means graph capture/replay should be skipped for this run.
|
|
2601
|
+
* \return true if the graph has been captured, false otherwise.
|
|
2602
|
+
*
|
|
2603
|
+
* \note This function must be implemented if `OrtEp::IsGraphCaptureEnabled` is implemented and may return true.
|
|
2604
|
+
*
|
|
2605
|
+
* \since Version 1.26.
|
|
2606
|
+
*/
|
|
2607
|
+
ORT_API_T(bool, IsGraphCaptured, _In_ const OrtEp* this_ptr, _In_ int graph_annotation_id);
|
|
2608
|
+
|
|
2609
|
+
/** \brief Run the instantiated (captured) graph.
|
|
2610
|
+
*
|
|
2611
|
+
* Called by ORT instead of normal execution when `IsGraphCaptured()` returns true.
|
|
2612
|
+
*
|
|
2613
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2614
|
+
* \param[in] graph_annotation_id Identifies which captured graph to replay.
|
|
2615
|
+
* Applications can set this value via `OrtApi::AddRunConfigEntry()` with the key `"gpu_graph_id"`.
|
|
2616
|
+
* The default value is 0 when the run config entry is not set.
|
|
2617
|
+
* A value of -1 means graph replay should be skipped for this run.
|
|
2618
|
+
*
|
|
2619
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2620
|
+
*
|
|
2621
|
+
* \note This function must be implemented if `OrtEp::IsGraphCaptureEnabled` is implemented and may return true.
|
|
2622
|
+
*
|
|
2623
|
+
* \since Version 1.26.
|
|
2624
|
+
*/
|
|
2625
|
+
ORT_API2_STATUS(ReplayGraph, _In_ OrtEp* this_ptr, _In_ int graph_annotation_id);
|
|
2626
|
+
|
|
2627
|
+
/** \brief Get the node assignment validation policy for graph capture.
|
|
2628
|
+
*
|
|
2629
|
+
* When graph capture is enabled, ORT validates that nodes are assigned to EPs in a way that is
|
|
2630
|
+
* compatible with graph capture. This function tells ORT which validation policy to apply.
|
|
2631
|
+
*
|
|
2632
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2633
|
+
* \return The node assignment policy for graph capture.
|
|
2634
|
+
*
|
|
2635
|
+
* \note Implementation of this function is optional. If set to NULL, ORT uses
|
|
2636
|
+
* OrtGraphCaptureNodeAssignmentPolicy_ALL_NODES_ON_EP (strictest validation).
|
|
2637
|
+
*
|
|
2638
|
+
* \since Version 1.26.
|
|
2639
|
+
*/
|
|
2640
|
+
ORT_API_T(OrtGraphCaptureNodeAssignmentPolicy, GetGraphCaptureNodeAssignmentPolicy,
|
|
2641
|
+
_In_ const OrtEp* this_ptr);
|
|
2642
|
+
|
|
2643
|
+
/** \brief Query the available device resource for partitioning budget.
|
|
2644
|
+
*
|
|
2645
|
+
* Called by ORT during graph partitioning when no explicit resource budget threshold
|
|
2646
|
+
* has been configured via session options. The EP should query its device for the
|
|
2647
|
+
* currently available resource (e.g., free GPU memory) and return it as an OrtResourceCount.
|
|
2648
|
+
*
|
|
2649
|
+
* If the EP does not support resource querying, set this function pointer to NULL.
|
|
2650
|
+
* ORT will skip threshold-based budget enforcement in that case.
|
|
2651
|
+
*
|
|
2652
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2653
|
+
* \param[out] available The available device resource.
|
|
2654
|
+
*
|
|
2655
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2656
|
+
*
|
|
2657
|
+
* \note Implementation of this function is optional. If set to NULL, no automatic
|
|
2658
|
+
* resource threshold is established and budget enforcement requires an explicit
|
|
2659
|
+
* threshold from session options.
|
|
2660
|
+
*
|
|
2661
|
+
* \since Version 1.26.
|
|
2662
|
+
*/
|
|
2663
|
+
ORT_API2_STATUS(GetAvailableResource, _In_ const OrtEp* this_ptr, _Out_ OrtResourceCount* available);
|
|
2664
|
+
|
|
2665
|
+
/** \brief Called by ORT when session initialization is complete.
|
|
2666
|
+
*
|
|
2667
|
+
* This provides an opportunity for execution providers to optionally synchronize and
|
|
2668
|
+
* clean up temporary resources to reduce memory usage and ensure the first inference run is fast.
|
|
2669
|
+
*
|
|
2670
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2671
|
+
*
|
|
2672
|
+
* \note Implementation of this function is optional. If set to NULL, ORT assumes no
|
|
2673
|
+
* post-initialization work is needed and treats it as a no-op success.
|
|
2674
|
+
*
|
|
2675
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2676
|
+
*
|
|
2677
|
+
* \since Version 1.27.
|
|
2678
|
+
*/
|
|
2679
|
+
ORT_API2_STATUS(OnSessionInitializationEnd, _In_ OrtEp* this_ptr);
|
|
2680
|
+
|
|
2681
|
+
/** \brief Get the EP's default memory device.
|
|
2682
|
+
*
|
|
2683
|
+
* The EP's default memory device identifies the hardware the EP operates on. ORT uses it to:
|
|
2684
|
+
* - Determine if data copies are needed between EPs (inserting memcpy nodes at EP boundaries)
|
|
2685
|
+
* - Determine if the EP is CPU-based (which affects synchronization and data transfer decisions)
|
|
2686
|
+
* - Bind execution streams to the correct device
|
|
2687
|
+
*
|
|
2688
|
+
* If the implementation allows an EP to be created with multiple EpDevices this should return the OrtMemoryDevice
|
|
2689
|
+
* that ORT should consider as default for this EP instance.
|
|
2690
|
+
*
|
|
2691
|
+
* An OrtMemoryDevice is obtained from an OrtMemoryInfo via `OrtEpApi::MemoryInfo_GetMemoryDevice()`.
|
|
2692
|
+
* Typically, an EP creates OrtMemoryInfo instances and registers them with its OrtEpDevice(s) via
|
|
2693
|
+
* `OrtEpApi::EpDevice_AddAllocatorInfo()`. The OrtMemoryDevice returned here must correspond to an
|
|
2694
|
+
* OrtMemoryInfo registered as an `OrtDeviceAllocator` entry (either `OrtDeviceMemoryType_DEFAULT` or
|
|
2695
|
+
* `OrtDeviceMemoryType_HOST_ACCESSIBLE`). An OrtMemoryDevice from an `OrtReadOnlyAllocator` entry is
|
|
2696
|
+
* not accepted as the EP's default/identity device.
|
|
2697
|
+
*
|
|
2698
|
+
* The returned pointer must remain valid for the lifetime of the OrtEp instance
|
|
2699
|
+
* (typically by storing the parent OrtMemoryInfo as a member of the EP).
|
|
2700
|
+
*
|
|
2701
|
+
* If this function is not implemented (NULL), or if it sets `device` to NULL, ORT infers
|
|
2702
|
+
* the default memory device from the first OrtEpDevice's `OrtDeviceAllocator` entry with
|
|
2703
|
+
* `OrtDeviceMemoryType_DEFAULT` registered via `EpDevice_AddAllocatorInfo`. EPs created against
|
|
2704
|
+
* multiple OrtEpDevices whose default memory devices differ should implement this function to
|
|
2705
|
+
* disambiguate; otherwise the first OrtEpDevice's default memory device is used and the others
|
|
2706
|
+
* are ignored for identity purposes. If no such allocator entry is registered, the EP defaults
|
|
2707
|
+
* to a CPU memory device.
|
|
2708
|
+
*
|
|
2709
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2710
|
+
* \param[out] device Set to the EP's default OrtMemoryDevice, or NULL to use the default behavior (described above).
|
|
2711
|
+
*
|
|
2712
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2713
|
+
*
|
|
2714
|
+
* \note Implementation of this function is optional. If set to NULL (not implemented), ORT
|
|
2715
|
+
* infers the default memory device using the default behavior described above.
|
|
2716
|
+
*
|
|
2717
|
+
* \since Version 1.27.
|
|
2718
|
+
*/
|
|
2719
|
+
ORT_API2_STATUS(GetDefaultMemoryDevice, _In_ const OrtEp* this_ptr,
|
|
2720
|
+
_Outptr_result_maybenull_ const OrtMemoryDevice** device);
|
|
2721
|
+
|
|
2722
|
+
/** \brief Release a previously captured graph and its associated resources.
|
|
2723
|
+
*
|
|
2724
|
+
* Called when the caller no longer needs the captured graph for the given annotation ID.
|
|
2725
|
+
* This allows the EP to free buffers and other resources tied to this graph.
|
|
2726
|
+
*
|
|
2727
|
+
* \param[in] this_ptr The EP instance.
|
|
2728
|
+
* \param[in] graph_annotation_id The annotation ID of the graph to release.
|
|
2729
|
+
*
|
|
2730
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2731
|
+
*
|
|
2732
|
+
* \note Implementation of this function is optional. If set to NULL, ORT assumes
|
|
2733
|
+
* no captured graph release is needed and treats it as a no-op success.
|
|
2734
|
+
*
|
|
2735
|
+
* \note Thread safety: For EPs that support concurrent Run() calls, this method may be
|
|
2736
|
+
* called concurrently with Run(). The EP is responsible for ensuring thread safety
|
|
2737
|
+
* of its own state in that case. For non-concurrent EPs, the session serializes
|
|
2738
|
+
* calls via its internal mutex.
|
|
2739
|
+
*
|
|
2740
|
+
* \since Version 1.27.
|
|
2741
|
+
*/
|
|
2742
|
+
ORT_API2_STATUS(ReleaseCapturedGraph, _In_ OrtEp* this_ptr, _In_ int graph_annotation_id);
|
|
2743
|
+
|
|
2744
|
+
/** \brief Query the execution provider's weightless mode support.
|
|
2745
|
+
*
|
|
2746
|
+
* When weightless mode is enabled (via the "ep.enable_weightless" session option), ORT calls this function
|
|
2747
|
+
* to determine the scope of the EP's weightless support. The EP returns an OrtWeightlessSupport value
|
|
2748
|
+
* indicating whether it supports weightless mode for all initializers, external initializers only, or not
|
|
2749
|
+
* at all.
|
|
2750
|
+
*
|
|
2751
|
+
* The EP's response may depend on the underlying hardware or driver capabilities. For example, an EP may
|
|
2752
|
+
* support weightless mode for all initializers on newer hardware but only for external initializers on
|
|
2753
|
+
* older hardware that requires weight transformation.
|
|
2754
|
+
*
|
|
2755
|
+
* EPs that support weightless mode should set drop_constant_initializers to false in OrtNodeFusionOptions
|
|
2756
|
+
* so that ORT provides the initializer data as inputs to the compiled/fused node. The EP can then access
|
|
2757
|
+
* these initializers at Compute() time via KernelContext_GetInput().
|
|
2758
|
+
*
|
|
2759
|
+
* \note Extending the lifetime of initializer data obtained via ValueInfo_GetInitializerValue() during
|
|
2760
|
+
* Compile() so that the EP can cache and reuse data pointers directly (without going through
|
|
2761
|
+
* KernelContext) is planned but not yet implemented. Until then, KernelContext_GetInput() is the
|
|
2762
|
+
* only supported way to access initializer data at Compute() time.
|
|
2763
|
+
*
|
|
2764
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2765
|
+
* \param[out] support Output parameter set to the EP's weightless support scope.
|
|
2766
|
+
*
|
|
2767
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2768
|
+
*
|
|
2769
|
+
* \note Implementation of this function is optional. If set to NULL, ORT assumes the EP does not
|
|
2770
|
+
* support weightless mode (equivalent to OrtWeightlessSupport_NONE).
|
|
2771
|
+
*
|
|
2772
|
+
* \since Version 1.29.
|
|
2773
|
+
*/
|
|
2774
|
+
ORT_API2_STATUS(GetWeightlessSupport, _In_ const OrtEp* this_ptr, _Out_ OrtWeightlessSupport* support);
|
|
2775
|
+
|
|
2776
|
+
/** \brief Query support for application-managed external EPContext data.
|
|
2777
|
+
*
|
|
2778
|
+
* The EP sets `supported_flags` to a bitwise combination of OrtEpContextDataCallbackSupportFlags values.
|
|
2779
|
+
* READ indicates support for OrtReadNamedBufferFunc, and WRITE indicates support for OrtWriteNamedBufferFunc.
|
|
2780
|
+
*
|
|
2781
|
+
* If the EP advertises READ or WRITE support and the corresponding callback is registered, the EP must use the
|
|
2782
|
+
* callback or return an error. It must not fall back to another method such as filesystem I/O. Callback errors
|
|
2783
|
+
* must be returned to ORT. The EP is responsible for validating the returned data and imposing deserialization
|
|
2784
|
+
* limits before consuming it; ORT does not invoke the callback or validate its result.
|
|
2785
|
+
*
|
|
2786
|
+
* These flags cover provider-owned EPContext artifacts only. They do not describe temporary files that an EP's
|
|
2787
|
+
* backend or driver may create internally.
|
|
2788
|
+
*
|
|
2789
|
+
* \param[in] this_ptr The OrtEp instance.
|
|
2790
|
+
* \param[out] supported_flags The supported OrtEpContextDataCallbackSupportFlags values.
|
|
2791
|
+
*
|
|
2792
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2793
|
+
*
|
|
2794
|
+
* \note Implementation of this function is optional. If set to NULL, ORT assumes the EP does not support
|
|
2795
|
+
* application-managed external EPContext data.
|
|
2796
|
+
*
|
|
2797
|
+
* \since Version 1.31.
|
|
2798
|
+
*/
|
|
2799
|
+
ORT_API2_STATUS(GetEpContextDataCallbackSupport, _In_ const OrtEp* this_ptr, _Out_ uint32_t* supported_flags);
|
|
2800
|
+
};
|
|
2801
|
+
|
|
2802
|
+
/** \brief The function signature that ORT will call to create OrtEpFactory instances.
|
|
2803
|
+
*
|
|
2804
|
+
* This must be available in a function called 'CreateEpFactories' in the execution provider library.
|
|
2805
|
+
*
|
|
2806
|
+
* \param[in] registered_name The name the execution library is registered with by RegisterExecutionProviderLibrary
|
|
2807
|
+
* \param[in] ort_api_base The OrtApiBase instance that is used by the factory to get the OrtApi instance for the
|
|
2808
|
+
* version of ORT that the library was compiled against.
|
|
2809
|
+
* \param[in] default_logger The default ORT logger that can be used for logging outside of an inference session.
|
|
2810
|
+
* \param[in,out] factories The implementation should create and add OrtEpFactory instances to this
|
|
2811
|
+
* pre-allocated array.
|
|
2812
|
+
* i.e. usage is `factories[0] = new MyEpFactory();`
|
|
2813
|
+
* \param[in] max_factories The maximum number of OrtEpFactory instances that can be added to `factories`.
|
|
2814
|
+
* Current default is to allow 4 factories. This can be increased in the future if needed.
|
|
2815
|
+
* \param[out] num_factories The number of OrtEpFactory instances created by the factory and added to `factories`.
|
|
2816
|
+
*
|
|
2817
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2818
|
+
*
|
|
2819
|
+
* \since Version 1.22.
|
|
2820
|
+
*/
|
|
2821
|
+
typedef OrtStatus* (*CreateEpApiFactoriesFn)(_In_ const char* registered_name, _In_ const OrtApiBase* ort_api_base,
|
|
2822
|
+
_In_ const OrtLogger* default_logger,
|
|
2823
|
+
_Inout_ OrtEpFactory** factories, _In_ size_t max_factories,
|
|
2824
|
+
_Out_ size_t* num_factories);
|
|
2825
|
+
|
|
2826
|
+
/** \brief The function signature that ORT will call to release an OrtEpFactory instance.
|
|
2827
|
+
*
|
|
2828
|
+
* This must be available in a function called 'ReleaseEpFactory' in the execution provider library.
|
|
2829
|
+
*
|
|
2830
|
+
* \param[in] factory The OrtEpFactory instance to release.
|
|
2831
|
+
*
|
|
2832
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2833
|
+
*
|
|
2834
|
+
* \since Version 1.22.
|
|
2835
|
+
*/
|
|
2836
|
+
typedef OrtStatus* (*ReleaseEpApiFactoryFn)(_In_ OrtEpFactory* factory);
|
|
2837
|
+
|
|
2838
|
+
/**
|
|
2839
|
+
* \brief The OrtEpFactory provides functions to create and manage execution providers.
|
|
2840
|
+
* \since Version 1.22.
|
|
2841
|
+
*/
|
|
2842
|
+
struct OrtEpFactory {
|
|
2843
|
+
/** \brief The ONNX Runtime version the execution provider was compiled with.
|
|
2844
|
+
*
|
|
2845
|
+
* Implementation should set to ORT_API_VERSION.
|
|
2846
|
+
* ORT will use this to ensure it does not call functions that were not available when the library was compiled.
|
|
2847
|
+
*
|
|
2848
|
+
* \since Version 1.22.
|
|
2849
|
+
*/
|
|
2850
|
+
uint32_t ort_version_supported;
|
|
2851
|
+
|
|
2852
|
+
/** \brief Get the name of the execution provider that the factory creates.
|
|
2853
|
+
*
|
|
2854
|
+
* The returned string should be a null-terminated, UTF-8 encoded string. ORT will copy it.
|
|
2855
|
+
*
|
|
2856
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
2857
|
+
* \return The name of the execution provider the factory creates.
|
|
2858
|
+
*
|
|
2859
|
+
* \since Version 1.22.
|
|
2860
|
+
*/
|
|
2861
|
+
ORT_API_T(const char*, GetName, const OrtEpFactory* this_ptr);
|
|
2862
|
+
|
|
2863
|
+
/** \brief Get the name of vendor who owns the execution provider that the factory creates.
|
|
2864
|
+
*
|
|
2865
|
+
* The returned string should be a null-terminated, UTF-8 encoded string. ORT will copy it.
|
|
2866
|
+
*
|
|
2867
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
2868
|
+
* \return vendor The vendor name of the execution provider the factory creates.
|
|
2869
|
+
*
|
|
2870
|
+
* \since Version 1.22.
|
|
2871
|
+
*/
|
|
2872
|
+
ORT_API_T(const char*, GetVendor, const OrtEpFactory* this_ptr); // return EP vendor
|
|
2873
|
+
|
|
2874
|
+
/** \brief Get information from the execution provider about OrtHardwareDevice support.
|
|
2875
|
+
*
|
|
2876
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
2877
|
+
* Non-const as the factory is passed through to the CreateEp call via the OrtEpDevice.
|
|
2878
|
+
* \param[in] devices The OrtHardwareDevice instances that are available.
|
|
2879
|
+
* \param[in] num_devices The number of OrtHardwareDevice instances.
|
|
2880
|
+
* \param[out] ep_devices OrtEpDevice instances for each OrtHardwareDevice that the EP can use.
|
|
2881
|
+
* The implementation should call OrtEpApi::CreateEpDevice to create, and add the OrtEpDevice
|
|
2882
|
+
* instances to this pre-allocated array. ORT will take ownership of the values returned.
|
|
2883
|
+
* i.e. usage is `ep_devices[0] = <ptr to OrtEpDevice created with OrtEpApi::CreateEpDevice>;`
|
|
2884
|
+
* \param[in] max_ep_devices The maximum number of OrtEpDevices that can be added to ep_devices.
|
|
2885
|
+
* Current default is 8. This can be increased if needed.
|
|
2886
|
+
* \param[out] num_ep_devices The number of EP devices added to ep_devices.
|
|
2887
|
+
*
|
|
2888
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2889
|
+
*
|
|
2890
|
+
* \remarks Called during execution provider library registration. The OrtEpDevice instances returned are added to
|
|
2891
|
+
* the environment after this returns. An implementation should not depend on other OrtEpDevices returned by
|
|
2892
|
+
* OrtApi::GetEpDevices since those depend on the execution provider library registration order.
|
|
2893
|
+
*
|
|
2894
|
+
* Environment configuration entries are populated before any library is registered, so
|
|
2895
|
+
* OrtEpApi::GetEnvConfigEntries may be called from this function, but it must be called synchronously on
|
|
2896
|
+
* the thread invoking GetSupportedDevices. The implementation must not wait for another thread that calls
|
|
2897
|
+
* OrtEpApi::GetEnvConfigEntries.
|
|
2898
|
+
*
|
|
2899
|
+
* \since Version 1.22.
|
|
2900
|
+
*/
|
|
2901
|
+
ORT_API2_STATUS(GetSupportedDevices, _In_ OrtEpFactory* this_ptr,
|
|
2902
|
+
_In_reads_(num_devices) const OrtHardwareDevice* const* devices,
|
|
2903
|
+
_In_ size_t num_devices,
|
|
2904
|
+
_Inout_ OrtEpDevice** ep_devices,
|
|
2905
|
+
_In_ size_t max_ep_devices,
|
|
2906
|
+
_Out_ size_t* num_ep_devices);
|
|
2907
|
+
|
|
2908
|
+
/** \brief Function to create an OrtEp instance for use in a Session.
|
|
2909
|
+
*
|
|
2910
|
+
* ORT will call ReleaseEp to release the instance when it is no longer needed.
|
|
2911
|
+
*
|
|
2912
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
2913
|
+
* \param[in] devices The OrtHardwareDevice instances that the execution provider was selected to use.
|
|
2914
|
+
* May be a subset of the OrtHardwareDevice instances that the execution provider's factory
|
|
2915
|
+
* set as supported in the call to OrtEpFactory::GetSupportedDevices.
|
|
2916
|
+
* \param[in] ep_metadata_pairs Execution provider metadata that was provided to OrtEpApi::CreateEpDevice, for each
|
|
2917
|
+
* device.
|
|
2918
|
+
* \param[in] num_devices The number of devices the execution provider was selected for.
|
|
2919
|
+
* \param[in] session_options The OrtSessionOptions instance that contains the configuration options for the
|
|
2920
|
+
* session. This will include ep_options from GetSupportedDevices as well as any
|
|
2921
|
+
* user provided overrides.
|
|
2922
|
+
* Execution provider options will have been added with a prefix of 'ep.[ep name].'.
|
|
2923
|
+
* The OrtSessionOptions instance will NOT be valid after this call and should not be
|
|
2924
|
+
* stored for later use.
|
|
2925
|
+
* \param[in] logger The OrtLogger instance for the session that the execution provider should use for logging.
|
|
2926
|
+
* \param[out] ep The OrtEp instance created by the factory.
|
|
2927
|
+
*
|
|
2928
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
2929
|
+
*
|
|
2930
|
+
* \since Version 1.22.
|
|
2931
|
+
*/
|
|
2932
|
+
ORT_API2_STATUS(CreateEp, _In_ OrtEpFactory* this_ptr,
|
|
2933
|
+
_In_reads_(num_devices) const OrtHardwareDevice* const* devices,
|
|
2934
|
+
_In_reads_(num_devices) const OrtKeyValuePairs* const* ep_metadata_pairs,
|
|
2935
|
+
_In_ size_t num_devices,
|
|
2936
|
+
_In_ const OrtSessionOptions* session_options,
|
|
2937
|
+
_In_ const OrtLogger* logger, _Outptr_ OrtEp** ep);
|
|
2938
|
+
|
|
2939
|
+
/** \brief Release the OrtEp instance.
|
|
2940
|
+
*
|
|
2941
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
2942
|
+
* \param[in] ep The OrtEp instance to release.
|
|
2943
|
+
*
|
|
2944
|
+
* \since Version 1.22.
|
|
2945
|
+
*/
|
|
2946
|
+
ORT_API_T(void, ReleaseEp, OrtEpFactory* this_ptr, struct OrtEp* ep);
|
|
2947
|
+
|
|
2948
|
+
/** \brief Get the vendor id who owns the execution provider that the factory creates.
|
|
2949
|
+
*
|
|
2950
|
+
* This is typically the PCI vendor ID. See https://pcisig.com/membership/member-companies
|
|
2951
|
+
*
|
|
2952
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
2953
|
+
* \return vendor_id The vendor ID of the execution provider the factory creates.
|
|
2954
|
+
*
|
|
2955
|
+
* \since Version 1.23.
|
|
2956
|
+
*/
|
|
2957
|
+
ORT_API_T(uint32_t, GetVendorId, const OrtEpFactory* this_ptr);
|
|
2958
|
+
|
|
2959
|
+
/** \brief Get the version of the execution provider that the factory creates.
|
|
2960
|
+
*
|
|
2961
|
+
* The version string should adhere to the Semantic Versioning 2.0 specification
|
|
2962
|
+
* (https://github.com/semver/semver/blob/v2.0.0/semver.md).
|
|
2963
|
+
*
|
|
2964
|
+
* The returned string should be a null-terminated, UTF-8 encoded string. ORT will copy it.
|
|
2965
|
+
*
|
|
2966
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
2967
|
+
* \return The execution provider version string.
|
|
2968
|
+
*
|
|
2969
|
+
* \since Version 1.23.
|
|
2970
|
+
*/
|
|
2971
|
+
ORT_API_T(const char*, GetVersion, _In_ const OrtEpFactory* this_ptr);
|
|
2972
|
+
|
|
2973
|
+
/** \brief Validate a compiled model against an ordered execution provider device configuration.
|
|
2974
|
+
*
|
|
2975
|
+
* Given a compatibility info string produced during model compilation, the EP factory determines whether the compiled
|
|
2976
|
+
* model can run when the EP is created with the provided hardware devices. The string is opaque to ORT and the caller;
|
|
2977
|
+
* the caller is not expected to know which devices were used to compile the model.
|
|
2978
|
+
*
|
|
2979
|
+
* `devices` is the non-empty, ordered device configuration that the caller intends to use. The caller should pass the
|
|
2980
|
+
* corresponding OrtEpDevice values, in the same order, to OrtApi::SessionOptionsAppendExecutionProvider_V2 if it
|
|
2981
|
+
* subsequently creates a session for the compiled model. Device order may be significant.
|
|
2982
|
+
*
|
|
2983
|
+
* The implementation must interpret the configuration using the same device selection, fallback, and participation
|
|
2984
|
+
* rules as OrtEpFactory::CreateEp:
|
|
2985
|
+
*
|
|
2986
|
+
* - If CreateEp would select one effective device and ignore the remaining entries, validate that effective device.
|
|
2987
|
+
* - If CreateEp would treat the entries as alternative or fallback devices, determine whether it can select a
|
|
2988
|
+
* compatible execution plan. An unused device must not make the result less compatible.
|
|
2989
|
+
* - If CreateEp would use multiple devices together, every device required by the effective execution plan must be
|
|
2990
|
+
* compatible with its assigned part of the compiled model.
|
|
2991
|
+
*
|
|
2992
|
+
* Do not unconditionally validate each device independently and return the worst result. The meaning of a multi-device
|
|
2993
|
+
* configuration is EP-defined. For example, an artifact compiled for one device can be optimal for an ordered
|
|
2994
|
+
* configuration in which that device is selected and later entries are ignored. Conversely, an artifact partitioned
|
|
2995
|
+
* across two devices is unsupported if either required device is absent.
|
|
2996
|
+
*
|
|
2997
|
+
* A supported result must mean that creating the EP and loading the compiled model with the equivalent device
|
|
2998
|
+
* configuration will not fail due to compiled-model incompatibility. OrtCompiledModelCompatibility_EP_NOT_APPLICABLE
|
|
2999
|
+
* is an overall "no compatibility determination" result; it is not a required identity value for combining
|
|
3000
|
+
* per-device results.
|
|
3001
|
+
*
|
|
3002
|
+
* \note Validation can be performed outside of a session. For example, OrtApi::GetModelCompatibilityForEpDevices
|
|
3003
|
+
* does not require a session, and model package variant selection calls this function to exclude incompatible
|
|
3004
|
+
* variants before a session is created. The session options and per-device EP metadata that may later be passed to
|
|
3005
|
+
* OrtEpFactory::CreateEp may therefore be unknown when this is called, and are not provided to this callback. An EP
|
|
3006
|
+
* whose compatibility decision depends on configuration not represented by the hardware devices or compatibility
|
|
3007
|
+
* string should avoid reporting a supported result unless it can make a reliable determination from the available
|
|
3008
|
+
* information.
|
|
3009
|
+
*
|
|
3010
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
3011
|
+
* \param[in] devices Ordered array of OrtHardwareDevice pointers for the intended EP configuration.
|
|
3012
|
+
* \param[in] num_devices Number of entries in `devices`. Must be greater than zero.
|
|
3013
|
+
* \param[in] compatibility_info The compatibility information string produced when the model was compiled.
|
|
3014
|
+
* \param[out] model_compatibility Compatibility of the model with the intended EP device configuration.
|
|
3015
|
+
*
|
|
3016
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
3017
|
+
*
|
|
3018
|
+
* \since Version 1.23.
|
|
3019
|
+
*/
|
|
3020
|
+
ORT_API2_STATUS(ValidateCompiledModelCompatibilityInfo, _In_ OrtEpFactory* this_ptr,
|
|
3021
|
+
_In_reads_(num_devices) const OrtHardwareDevice* const* devices,
|
|
3022
|
+
_In_ size_t num_devices,
|
|
3023
|
+
_In_ const char* compatibility_info,
|
|
3024
|
+
_Out_ OrtCompiledModelCompatibility* model_compatibility);
|
|
3025
|
+
|
|
3026
|
+
/** \brief Create an OrtAllocator that can be shared across sessions for the given OrtMemoryInfo.
|
|
3027
|
+
*
|
|
3028
|
+
* The factory that creates the EP is responsible for providing the allocators required by the EP.
|
|
3029
|
+
* The OrtMemoryInfo instance will match one of the values set in the OrtEpDevice using EpDevice_AddAllocatorInfo.
|
|
3030
|
+
*
|
|
3031
|
+
* Implementation of this function is optional. It is required if ORT needs to create a shared allocator for an
|
|
3032
|
+
* OrtMemoryInfo advertised by the EP.
|
|
3033
|
+
*
|
|
3034
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
3035
|
+
* \param[in] memory_info The OrtMemoryInfo to create the allocator for. May be nullptr.
|
|
3036
|
+
* \param[in] allocator_options Optional key-value pairs for allocator options, can be nullptr.
|
|
3037
|
+
* \param[out] allocator The created OrtAllocator instance. When called to create an allocator for a session, this
|
|
3038
|
+
* may be set to nullptr if the EP does not provide a preferred allocator for the memory
|
|
3039
|
+
* location. When called to create a shared allocator, this must be set to a non-null value.
|
|
3040
|
+
*
|
|
3041
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
3042
|
+
*
|
|
3043
|
+
* \since Version 1.23.
|
|
3044
|
+
*/
|
|
3045
|
+
ORT_API2_STATUS(CreateAllocator, _In_ OrtEpFactory* this_ptr,
|
|
3046
|
+
_In_ const OrtMemoryInfo* memory_info,
|
|
3047
|
+
_In_opt_ const OrtKeyValuePairs* allocator_options,
|
|
3048
|
+
_Outptr_result_maybenull_ OrtAllocator** allocator);
|
|
3049
|
+
|
|
3050
|
+
/** \brief Release an OrtAllocator created by the factory.
|
|
3051
|
+
*
|
|
3052
|
+
* Implementation of this function is required if OrtEpFactory::CreateAllocator or OrtEp::CreateAllocator is
|
|
3053
|
+
* implemented.
|
|
3054
|
+
*
|
|
3055
|
+
* \since Version 1.23.
|
|
3056
|
+
*/
|
|
3057
|
+
ORT_API_T(void, ReleaseAllocator, _In_ OrtEpFactory* this_ptr, _In_ OrtAllocator* allocator);
|
|
3058
|
+
|
|
3059
|
+
/** \brief Create an OrtDataTransferImpl instance for the factory.
|
|
3060
|
+
*
|
|
3061
|
+
* This is used to create an IDataTransfer implementation that can be used to copy data between devices
|
|
3062
|
+
* that the execution provider supports.
|
|
3063
|
+
*
|
|
3064
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
3065
|
+
* \param[out] data_transfer The created OrtDataTransferImpl instance. Set to nullptr if not required.
|
|
3066
|
+
*
|
|
3067
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
3068
|
+
*
|
|
3069
|
+
* \since Version 1.23.
|
|
3070
|
+
*/
|
|
3071
|
+
ORT_API2_STATUS(CreateDataTransfer, _In_ OrtEpFactory* this_ptr,
|
|
3072
|
+
_Outptr_result_maybenull_ OrtDataTransferImpl** data_transfer);
|
|
3073
|
+
|
|
3074
|
+
/** \brief Check if execution providers created by the factory are stream aware.
|
|
3075
|
+
*
|
|
3076
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
3077
|
+
* \return True if the factory creates execution providers that are stream aware and it implements CreateSyncStreamForDevice.
|
|
3078
|
+
*
|
|
3079
|
+
* \since Version 1.23.
|
|
3080
|
+
*/
|
|
3081
|
+
ORT_API_T(bool, IsStreamAware, _In_ const OrtEpFactory* this_ptr);
|
|
3082
|
+
|
|
3083
|
+
/** \brief Create a synchronization stream for the given memory device.
|
|
3084
|
+
*
|
|
3085
|
+
* This is used to create a synchronization stream for the memory device that can be used for operations outside of
|
|
3086
|
+
* a session.
|
|
3087
|
+
*
|
|
3088
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
3089
|
+
* \param[in] memory_device The OrtMemoryDevice to create the synchronization stream for.
|
|
3090
|
+
* \param[in] stream_options Options for stream creation. May be nullptr.
|
|
3091
|
+
* \param[out] stream The created OrtSyncStreamImpl instance. nullptr if the execution provider is not stream aware.
|
|
3092
|
+
*
|
|
3093
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
3094
|
+
*
|
|
3095
|
+
* \since Version 1.23.
|
|
3096
|
+
*/
|
|
3097
|
+
ORT_API2_STATUS(CreateSyncStreamForDevice, _In_ OrtEpFactory* this_ptr,
|
|
3098
|
+
_In_ const OrtMemoryDevice* memory_device,
|
|
3099
|
+
_In_opt_ const OrtKeyValuePairs* stream_options,
|
|
3100
|
+
_Outptr_ OrtSyncStreamImpl** stream);
|
|
3101
|
+
|
|
3102
|
+
/** \brief Check for known incompatibility reasons between a hardware device and this execution provider.
|
|
3103
|
+
*
|
|
3104
|
+
* This function allows an execution provider to check if a specific hardware device is compatible
|
|
3105
|
+
* with the execution provider. The EP can set specific incompatibility reasons via the
|
|
3106
|
+
* OrtDeviceEpIncompatibilityDetails parameter using OrtEpApi::DeviceEpIncompatibilityDetails_SetDetails.
|
|
3107
|
+
*
|
|
3108
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
3109
|
+
* \param[in] hw The hardware device to check for incompatibility.
|
|
3110
|
+
* \param[in,out] details Pre-allocated incompatibility details object created and initialized by ORT.
|
|
3111
|
+
* The EP can use OrtEpApi::DeviceEpIncompatibilityDetails_SetDetails to set
|
|
3112
|
+
* incompatibility information. If the device is compatible, the EP can
|
|
3113
|
+
* leave the object unchanged (it defaults to no incompatibility).
|
|
3114
|
+
*
|
|
3115
|
+
* \note Implementation of this function is optional.
|
|
3116
|
+
* If not implemented, ORT will assume the device is compatible with this EP.
|
|
3117
|
+
*
|
|
3118
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
3119
|
+
*
|
|
3120
|
+
* \since Version 1.24.
|
|
3121
|
+
*/
|
|
3122
|
+
ORT_API2_STATUS(GetHardwareDeviceIncompatibilityDetails, _In_ OrtEpFactory* this_ptr,
|
|
3123
|
+
_In_ const OrtHardwareDevice* hw,
|
|
3124
|
+
_Inout_ OrtDeviceEpIncompatibilityDetails* details);
|
|
3125
|
+
|
|
3126
|
+
/** \brief Create an OrtExternalResourceImporterImpl for external resource import.
|
|
3127
|
+
*
|
|
3128
|
+
* This is used to create an external resource importer that enables zero-copy import of
|
|
3129
|
+
* external GPU memory (e.g., D3D12 shared resources) and synchronization primitives
|
|
3130
|
+
* (e.g., D3D12 timeline fences).
|
|
3131
|
+
*
|
|
3132
|
+
* EPs that support external resource import (via CUDA, HIP, Vulkan, or D3D12 APIs) can
|
|
3133
|
+
* implement this to allow applications to share GPU resources without copies.
|
|
3134
|
+
*
|
|
3135
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
3136
|
+
* \param[in] ep_device The OrtEpDevice to create the external resource importer for.
|
|
3137
|
+
* \param[out] out_importer The created OrtExternalResourceImporterImpl instance.
|
|
3138
|
+
* Set to nullptr if external resource import is not supported.
|
|
3139
|
+
*
|
|
3140
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
3141
|
+
*
|
|
3142
|
+
* \note Implementation of this function is optional.
|
|
3143
|
+
* An EP factory should only implement this if it supports external resource import.
|
|
3144
|
+
* If not implemented or not supported, return ORT_NOT_IMPLEMENTED or set out_importer to nullptr.
|
|
3145
|
+
*
|
|
3146
|
+
* \since Version 1.24.
|
|
3147
|
+
*/
|
|
3148
|
+
ORT_API2_STATUS(CreateExternalResourceImporterForDevice, _In_ OrtEpFactory* this_ptr,
|
|
3149
|
+
_In_ const OrtEpDevice* ep_device,
|
|
3150
|
+
_Outptr_result_maybenull_ OrtExternalResourceImporterImpl** out_importer);
|
|
3151
|
+
|
|
3152
|
+
/** \brief Returns the number of OrtCustomOpDomains that this factory provides.
|
|
3153
|
+
*
|
|
3154
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
3155
|
+
* \param[out] num_domains Output parameter set to the number of provided OrtCustomOpDomain instances.
|
|
3156
|
+
*
|
|
3157
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
3158
|
+
*
|
|
3159
|
+
* \since Version 1.24.
|
|
3160
|
+
*/
|
|
3161
|
+
ORT_API2_STATUS(GetNumCustomOpDomains, _In_ OrtEpFactory* this_ptr, _Out_ size_t* num_domains);
|
|
3162
|
+
|
|
3163
|
+
/** \brief Gets the EP-specific OrtCustomOpDomains.
|
|
3164
|
+
*
|
|
3165
|
+
* This function is used when running inference on a model that contains EP-specific custom operations.
|
|
3166
|
+
*
|
|
3167
|
+
* Workflow:
|
|
3168
|
+
* 1. The EP factory implements this function to supply a list of OrtCustomOpDomain instances.
|
|
3169
|
+
* 2. The application either 1) calls SessionOptionsAppendExecutionProvider_V2() with an OrtEpDevice containing
|
|
3170
|
+
* the plugin EP's factory or 2) enables auto ep selection.
|
|
3171
|
+
* 3. 1) SessionOptionsAppendExecutionProvider_V2() appends the provided OrtCustomOpDomains to the
|
|
3172
|
+
* session options or 2) ORT registers the OrtCustomOpDomains provided by the EP devices
|
|
3173
|
+
* that could be potentially selected.
|
|
3174
|
+
*
|
|
3175
|
+
* As a result, any session created from these session options will have these custom op domains registered
|
|
3176
|
+
* in ORT, ensuring that the custom ops are properly recognized and validated when the model is loaded.
|
|
3177
|
+
*
|
|
3178
|
+
* Plugin EPs can provide two types of custom ops:
|
|
3179
|
+
* 1. A full OrtCustomOp with a concrete kernel implementation
|
|
3180
|
+
* - A Plugin EP can supply an OrtCustomOp and a corresponding CustomKernel::Compute() implementation.
|
|
3181
|
+
* - In GetCapability(), it calls EpGraphSupportInfo_AddSingleNode() to inform ORT
|
|
3182
|
+
* that the custom node should NOT be fused or compiled. Instead, ORT should invoke
|
|
3183
|
+
* the custom node's Compute() function at runtime.
|
|
3184
|
+
*
|
|
3185
|
+
* 2. A "placeholder" OrtCustomOp with an empty kernel implementation
|
|
3186
|
+
* - A compile-based Plugin EP can supply an OrtCustomOp whose CustomKernel::Compute()
|
|
3187
|
+
* does nothing. The purpose is to satisfy model validation during model loading by
|
|
3188
|
+
* registering the custom op as a valid operator in the session.
|
|
3189
|
+
* - In GetCapability(), the EP should call EpGraphSupportInfo_AddNodesToFuse() to
|
|
3190
|
+
* notify ORT that this custom node should be fused and compiled by the EP.
|
|
3191
|
+
* - In Compile(), the EP executes its compiled bits to perform inference for
|
|
3192
|
+
* the fused custom node.
|
|
3193
|
+
*
|
|
3194
|
+
* Note: The OrtCustomOpDomain instances must be valid while any session is using them.
|
|
3195
|
+
EP factory has the responsibility to release OrtCustomOpDomain instances it creates. It happens
|
|
3196
|
+
* automatically if using the C++ Ort::CustomOpDomain class.
|
|
3197
|
+
*
|
|
3198
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
3199
|
+
* \param[out] domains Array of `num_domains` elements pre-allocated by ORT that should be filled with
|
|
3200
|
+
OrtCustomOpDomain instances created by the EP. The `num_domains` is the value returned by
|
|
3201
|
+
GetNumCustomOpDomains().
|
|
3202
|
+
* \param[in] num_domains The size of the `domains` array pre-allocated by ORT.
|
|
3203
|
+
*
|
|
3204
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
3205
|
+
*
|
|
3206
|
+
* \since Version 1.24.
|
|
3207
|
+
*/
|
|
3208
|
+
ORT_API2_STATUS(GetCustomOpDomains, _In_ OrtEpFactory* this_ptr,
|
|
3209
|
+
_Out_writes_all_(num_domains) OrtCustomOpDomain** domains, _In_ size_t num_domains);
|
|
3210
|
+
|
|
3211
|
+
/** \brief Initialize graphics interop for the EP factory.
|
|
3212
|
+
*
|
|
3213
|
+
* This function sets up graphics interop context that enables synchronization between
|
|
3214
|
+
* external graphics API workloads (D3D12, Vulkan) and ONNX Runtime inference.
|
|
3215
|
+
*
|
|
3216
|
+
* The factory stores the graphics context configuration and uses it when creating
|
|
3217
|
+
* synchronization streams via CreateSyncStreamForDevice. This approach
|
|
3218
|
+
* is more graceful than passing the command queue directly during stream creation.
|
|
3219
|
+
*
|
|
3220
|
+
* The implementation is EP-specific. EPs may create a specialized interop context using
|
|
3221
|
+
* platform-specific APIs to enable GPU-GPU synchronization.
|
|
3222
|
+
*
|
|
3223
|
+
* Key design points:
|
|
3224
|
+
* - Single init function with all required params (avoids multiple init signatures)
|
|
3225
|
+
* - Factory stores context and uses it in stream creation
|
|
3226
|
+
* - Paired with DeinitGraphicsInterop for cleanup
|
|
3227
|
+
*
|
|
3228
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
3229
|
+
* \param[in] ep_device The OrtEpDevice to initialize graphics interop for.
|
|
3230
|
+
* \param[in] config Configuration specifying the graphics API and required handles.
|
|
3231
|
+
*
|
|
3232
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
3233
|
+
*
|
|
3234
|
+
* \note Implementation of this function is optional.
|
|
3235
|
+
* EPs that don't support graphics interop should set this to nullptr or return ORT_NOT_IMPLEMENTED.
|
|
3236
|
+
*
|
|
3237
|
+
* \since Version 1.25.
|
|
3238
|
+
*/
|
|
3239
|
+
ORT_API2_STATUS(InitGraphicsInterop, _In_ OrtEpFactory* this_ptr,
|
|
3240
|
+
_In_ const OrtEpDevice* ep_device,
|
|
3241
|
+
_In_ const OrtGraphicsInteropConfig* config);
|
|
3242
|
+
|
|
3243
|
+
/** \brief Deinitialize graphics interop for the EP factory.
|
|
3244
|
+
*
|
|
3245
|
+
* This function cleans up any graphics interop context that was set up by InitGraphicsInterop.
|
|
3246
|
+
* Should be called when graphics interop is no longer needed.
|
|
3247
|
+
*
|
|
3248
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
3249
|
+
* \param[in] ep_device The OrtEpDevice to deinitialize graphics interop for.
|
|
3250
|
+
*
|
|
3251
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
3252
|
+
*
|
|
3253
|
+
* \note Implementation of this function is optional.
|
|
3254
|
+
* EPs that don't support graphics interop should set this to nullptr or return ORT_NOT_IMPLEMENTED.
|
|
3255
|
+
*
|
|
3256
|
+
* \since Version 1.25.
|
|
3257
|
+
*/
|
|
3258
|
+
ORT_API2_STATUS(DeinitGraphicsInterop, _In_ OrtEpFactory* this_ptr,
|
|
3259
|
+
_In_ const OrtEpDevice* ep_device);
|
|
3260
|
+
|
|
3261
|
+
/** \brief Select the best model variant candidate from metadata.
|
|
3262
|
+
*
|
|
3263
|
+
* Evaluates each candidate's metadata against the given hardware device and optional session options,
|
|
3264
|
+
* and returns the index of the best match.
|
|
3265
|
+
*
|
|
3266
|
+
* Each candidate is an OrtKeyValuePairs representing one model variant. The KVP uses indexed keys
|
|
3267
|
+
* so that the EP can inspect each model's metadata independently. A variant always has num_models >= 1.
|
|
3268
|
+
*
|
|
3269
|
+
* Required and optional keys:
|
|
3270
|
+
* - "num_models" — number of models in this variant (>= 1) (required)
|
|
3271
|
+
* - "\<i\>.ep_compatibility_info" — compatibility string for model i (required per model)
|
|
3272
|
+
* - "\<i\>.role" — role/purpose of model i (e.g., "prefill", "decode") (optional)
|
|
3273
|
+
* - "\<i\>.future_meaningful_info" — additional EP-meaningful metadata for model i (optional)
|
|
3274
|
+
*
|
|
3275
|
+
* where \<i\> is a zero-based index (e.g., "0.ep_compatibility_info", "1.ep_compatibility_info").
|
|
3276
|
+
*
|
|
3277
|
+
* The implementer should loop from 0 to num_models - 1 and validate each "\<i\>.ep_compatibility_info" entry.
|
|
3278
|
+
* An advanced implementation may additionally consider "role" or other metadata when ranking candidates.
|
|
3279
|
+
*
|
|
3280
|
+
* **Why this function exists:**
|
|
3281
|
+
*
|
|
3282
|
+
* The existing ValidateCompiledModelCompatibilityInfo() alone is not sufficient for some EPs to determine the best
|
|
3283
|
+
* compatible model when there are multiple candidates. For example, an EP may support multiple compilation modes
|
|
3284
|
+
* (e.g., "speed optimized" vs "memory optimized") that produce different compatibility strings. The EP can implement
|
|
3285
|
+
* this function to evaluate the candidate metadata and select the best compatible variant based on its own criteria,
|
|
3286
|
+
* the target device, and the session options.
|
|
3287
|
+
*
|
|
3288
|
+
* If all candidates are unsupported, this function succeeds and sets `selected_index` to SIZE_MAX.
|
|
3289
|
+
*
|
|
3290
|
+
* \note The implementer should validate each "\<i\>.ep_compatibility_info" in the candidate (e.g., by calling
|
|
3291
|
+
* ValidateCompiledModelCompatibilityInfo for each one) before determining the best match.
|
|
3292
|
+
*
|
|
3293
|
+
* \param[in] this_ptr The OrtEpFactory instance.
|
|
3294
|
+
* \param[in] device The target hardware device that the EP would run on. Must map to this EP.
|
|
3295
|
+
* \param[in] candidates Array of OrtKeyValuePairs pointers (one per model variant).
|
|
3296
|
+
* \param[in] num_candidates Number of candidates (i.e., number of model variants to evaluate).
|
|
3297
|
+
* \param[in] session_options Optional session options to consider when selecting the best candidate.
|
|
3298
|
+
* May be nullptr if no session-level preferences are relevant.
|
|
3299
|
+
* \param[out] selected_index Selected candidate index, or SIZE_MAX if all unsupported.
|
|
3300
|
+
*
|
|
3301
|
+
* \snippet{doc} snippets.dox OrtStatus Return Value
|
|
3302
|
+
*
|
|
3303
|
+
* \since Version 1.28.
|
|
3304
|
+
*/
|
|
3305
|
+
ORT_API2_STATUS(SelectBestModelCandidate, _In_ OrtEpFactory* this_ptr,
|
|
3306
|
+
_In_ const OrtHardwareDevice* device,
|
|
3307
|
+
_In_reads_(num_candidates) const OrtKeyValuePairs* const* candidates,
|
|
3308
|
+
_In_ size_t num_candidates,
|
|
3309
|
+
_In_opt_ const OrtSessionOptions* session_options,
|
|
3310
|
+
_Out_ size_t* selected_index);
|
|
3311
|
+
};
|
|
3312
|
+
|
|
3313
|
+
#ifdef __cplusplus
|
|
3314
|
+
}
|
|
3315
|
+
#endif
|