@@ -4926,6 +4926,19 @@ struct OrtApi {
4926
4926
ORT_API2_STATUS (SessionOptionsSetLoadCancellationFlag, _Inout_ OrtSessionOptions* options,
4927
4927
_In_ bool cancel);
4928
4928
4929
+ /* * \brief Get the Compile API instance.
4930
+ *
4931
+ * Get the Compile API instance to compile ONNX models. Execution providers that support compilation fuse a subgraph
4932
+ * into an EPContext node that wraps a provider-specific binary representation of the subgraph.
4933
+ * For more details about the EPContext design, refer to:
4934
+ * \htmlonly
4935
+ * <a href="https://onnxruntime.ai/docs/execution-providers/EP-Context-Design.html">EPContext design document.</a>
4936
+ * \endhtmlonly
4937
+ *
4938
+ * \return Compile API struct instance.
4939
+ *
4940
+ * \since Version 1.22.
4941
+ */
4929
4942
const OrtCompileApi*(ORT_API_CALL* GetCompileApi)();
4930
4943
};
4931
4944
@@ -5448,20 +5461,25 @@ struct OrtModelEditorApi {
5448
5461
*
5449
5462
* Execution providers that support compilation fuse a subgraph into an EPContext node that wraps a provider-specific
5450
5463
* binary representation of the subgraph.
5451
- * More details relate to EPContext design refers to:
5464
+ * For more details about the EPContext design, refer to:
5452
5465
* \htmlonly
5453
5466
* <a href="https://onnxruntime.ai/docs/execution-providers/EP-Context-Design.html">EPContext design document.</a>
5454
5467
* \endhtmlonly
5455
5468
*
5469
+ * Example (error handling not shown):
5470
+ * OrtStatus* status = NULL;
5471
+ * OrtCompileApi* compile_api = ort_api->GetCompileApi();
5472
+ * OrtModelCompilationOptions* compile_options = NULL;
5473
+ *
5474
+ * status = compile_api->CreateModelCompilationOptionsFromSessionOptions(env, session_options, &compile_options);
5475
+ * status = compile_api->ModelCompilationOptions_SetInputModelPath(compile_options, ORT_TSTR("model.onnx"));
5476
+ * status = compile_api->ModelCompilationOptions_SetOutputModelPath(compile_options, ORT_TSTR("model.compiled.onnx"));
5477
+ * status = compile_api->CompileModel(env, compile_options);
5478
+ * compile_api->ReleaseModelCompilationOptions(compile_options);
5479
+ *
5456
5480
* \since Version 1.22.
5457
5481
*/
5458
5482
struct OrtCompileApi {
5459
- // Model compilation requires a full build. We return nullptr from GetCompileApi if this is a minimal
5460
- // build, so it doesn't matter if there are no function pointers in this struct as a user will never get an
5461
- // OrtCompileApi instance. We do however need a dummy field to avoid empty struct warning.
5462
- #if defined(ORT_MINIMAL_BUILD)
5463
- const bool not_defined_in_this_build;
5464
- #else
5465
5483
// / @}
5466
5484
// / \name OrtModelCompilationOptions
5467
5485
// / @{
@@ -5486,6 +5504,9 @@ struct OrtCompileApi {
5486
5504
_In_ const OrtSessionOptions* session_options, _Outptr_ OrtModelCompilationOptions** out);
5487
5505
5488
5506
/* * \brief Sets the file path to the input ONNX model to compile.
5507
+ *
5508
+ * The input model's location (e.g., file path or memory buffer) must be set with either
5509
+ * ModelCompilationOptions_SetInputModelPath or ModelCompilationOptions_SetInputModelFromBuffer.
5489
5510
*
5490
5511
* \param[in] model_compile_options The OrtModelCompilationOptions instance.
5491
5512
* \param[in] input_model_path Null terminated string of the path (wchar on Windows, char otherwise).
@@ -5498,6 +5519,9 @@ struct OrtCompileApi {
5498
5519
_In_ const ORTCHAR_T* input_model_path);
5499
5520
5500
5521
/* * \brief Sets the buffer that stores the bytes of the loaded ONNX model to compile.
5522
+ *
5523
+ * The input model's location (e.g., file path or memory buffer) must be set with either
5524
+ * ModelCompilationOptions_SetInputModelPath or ModelCompilationOptions_SetInputModelFromBuffer.
5501
5525
*
5502
5526
* \param[in] model_compile_options The OrtModelCompilationOptions instance.
5503
5527
* \param[in] input_model_data Buffer containing the loaded ONNX model bytes.
@@ -5514,9 +5538,11 @@ struct OrtCompileApi {
5514
5538
5515
5539
/* * \brief Sets the file path for the output ONNX model generated by CompileModel.
5516
5540
*
5517
- * If the output model path is not specified and the output model is not to be stored in a buffer,
5518
- * ONNX Runtime will generate a path based on the input model's file path.
5519
- * Examples:
5541
+ * The output model's location (e.g., file path or memory buffer) can be set with either
5542
+ * ModelCompilationOptions_SetOutputModelPath or ModelCompilationOptions_SetOutputModelBuffer.
5543
+ *
5544
+ * If the output model's location is not set, ONNX Runtime will generate an output file with a path based on
5545
+ * the input model's file path. Examples:
5520
5546
* /Path/my_model.onnx -> /Path/my_model_ctx.onnx
5521
5547
* /Path/my_model -> /Path/my_model_ctx.onnx
5522
5548
*
@@ -5554,10 +5580,18 @@ struct OrtCompileApi {
5554
5580
*
5555
5581
* The caller passes an OrtAllocator that ONNX Runtime uses to allocate memory for the buffer.
5556
5582
*
5583
+ * The output model's location (e.g., file path or memory buffer) can be set with either
5584
+ * ModelCompilationOptions_SetOutputModelPath or ModelCompilationOptions_SetOutputModelBuffer.
5585
+ *
5586
+ * If the output model's location is not set, ONNX Runtime will generate an output file with a path based on
5587
+ * the input model's file path. Examples:
5588
+ * /Path/my_model.onnx -> /Path/my_model_ctx.onnx
5589
+ * /Path/my_model -> /Path/my_model_ctx.onnx
5590
+ *
5557
5591
* \param[in] model_compile_options The OrtModelCompilationOptions instance.
5558
5592
* \param[in] allocator The allocator used to allocate the buffer for the compiled model.
5559
5593
* \param[out] output_model_buffer_ptr Pointer to the buffer that stores the compiled model.
5560
- * \param[out] output_model_buffer_size_ptr Pointer set to the size of output buffer in bytes.
5594
+ * \param[out] output_model_buffer_size_ptr Pointer set to the size of output model in bytes.
5561
5595
*
5562
5596
* \snippet{doc} snippets.dox OrtStatus Return Value
5563
5597
*
@@ -5604,7 +5638,6 @@ struct OrtCompileApi {
5604
5638
* \since Version 1.22.
5605
5639
*/
5606
5640
ORT_API2_STATUS (CompileModel, _In_ const OrtEnv* env, _In_ const OrtModelCompilationOptions* model_options);
5607
- #endif
5608
5641
};
5609
5642
/*
5610
5643
* This is the old way to add the CUDA provider to the session, please use SessionOptionsAppendExecutionProvider_CUDA above to access the latest functionality
0 commit comments