onnxruntime
8c1156e0 - [Compile] Add API to set compile flags; Fix behavior when no nodes are compiled (#24695)

Commit
284 days ago
[Compile] Add API to set compile flags; Fix behavior when no nodes are compiled (#24695) ### Description #### Original compile approach where an EPContext model is generated as a side-effect of creating a session: - **Restore** previous behavior where: - compiling a model that generates no EPContext nodes is silently ignored (nothing is generated and no error is reported) - compiling a previously compiled model is silently ignored (nothing is generated and no error is reported) #### Explicit compile API: - **Retains** current behavior where compiling a model that does not generate EPContext nodes still generates a model by default. - Adds C/C++/C#/Python API called `setFlags` that allows the user to specify what is considered an error. - `OrtCompileApiFlags_ERROR_IF_NO_NODES_COMPILED`: CompileModel() returns `ORT_FAIL` if no nodes were compiled. - `OrtCompileApiFlags_ERROR_IF_OUTPUT_FILE_EXISTS`: CompileModel() returns `ORT_FAIL` if a file with the same filename as the output model exists. - Adds logic to detect when the user is trying to compile a previously compiled model and returns an `ORT_INVALID_GRAPH` error with a relevant error message. ### Motivation and Context A previous [PR changed the default behavior](https://github.com/microsoft/onnxruntime/commit/b4f7a905b0d636b71bd486c0ef702eb5a44eadf2#diff-e2d3910ae7593ee7ba4fd74e53f738fa973ae2fc32c069f1088ba458b91f8d4bL809) of the original "implicit" compilation approach. This PR was motivated by restoring the original behavior that users currently depend on. At the same time, we want to allow users of the new explicit compile API to determine what is considered an error.
Parents
Loading