Skip to content

Commit 53cf212

Browse files
authored
Include C++ header in native nuget and fix compiler warnings (#1727)
This pull request enhances the native NuGet package by including both the C and C++ header files. Previously, only the C header was bundled. With this update, the package now supports both languages more comprehensively. Additionally, this PR resolves several compiler warnings that stemmed from unchecked return values in calls to the ONNX Runtime API.
1 parent 925298f commit 53cf212

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/models/onnxruntime_api.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,9 @@ std::span<TAlloc> Allocate(OrtAllocator& allocator,
425425
return std::span(unique_ptr.get(), size);
426426
}
427427

428-
inline void RegisterExecutionProviderLibrary(OrtEnv* env, const char* registration_name, const ORTCHAR_T* path) {
429-
Ort::api->RegisterExecutionProviderLibrary(env, registration_name, path);
430-
}
428+
void RegisterExecutionProviderLibrary(OrtEnv* env, const char* registration_name, const ORTCHAR_T* path);
431429

432-
inline void UnregisterExecutionProviderLibrary(OrtEnv* env, const char* registration_name) {
433-
Ort::api->UnregisterExecutionProviderLibrary(env, registration_name);
434-
}
430+
void UnregisterExecutionProviderLibrary(OrtEnv* env, const char* registration_name);
435431

436432
} // namespace Ort
437433

src/models/onnxruntime_inline.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ inline int GetCurrentGpuDeviceId() {
185185
return id;
186186
}
187187

188+
inline void RegisterExecutionProviderLibrary(OrtEnv* env, const char* registration_name, const ORTCHAR_T* path) {
189+
ThrowOnError(Ort::api->RegisterExecutionProviderLibrary(env, registration_name, path));
190+
}
191+
192+
inline void UnregisterExecutionProviderLibrary(OrtEnv* env, const char* registration_name) {
193+
ThrowOnError(Ort::api->UnregisterExecutionProviderLibrary(env, registration_name));
194+
}
195+
188196
} // namespace Ort
189197

190198
inline std::unique_ptr<OrtStatus> OrtStatus::Create(OrtErrorCode code, const std::string& what) {

tools/nuget/generate_nuspec_for_native_nuget.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def add_native_artifact_if_exists(xml_lines, runtime, artifact):
155155

156156
# include
157157
lines.append(f'<file src="{args.sources_path}\src\ort_genai_c.h" target="build\\native\include" />')
158+
lines.append(f'<file src="{args.sources_path}\src\ort_genai.h" target="build\\native\include" />')
158159
lines.append('</files>')
159160

160161

0 commit comments

Comments
 (0)