mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
Do not run AOT function inlining when the model does not define any local functions (#18302)
### Description Check if the model defines any local functions. if not, skip AOT inlining including any schema based functions. The latter would be inlined during partitioning. ### Motivation and Context This prevents calls GetCapability() to EPs and enhahces compatibility. <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> --------- Co-authored-by: Pranav Sharma <prs@microsoft.com>
This commit is contained in:
parent
606356d0b1
commit
096307c64b
3 changed files with 22 additions and 3 deletions
|
|
@ -798,7 +798,16 @@ static Status PartitionOrtFormatModel(const PartitionParams& partition_params,
|
|||
|
||||
Status GraphPartitioner::InlineFunctionsAOT(Model& model,
|
||||
const ExecutionProviders& execution_providers,
|
||||
const KernelRegistryManager& kernel_registry_manager) const {
|
||||
const KernelRegistryManager& kernel_registry_manager,
|
||||
const logging::Logger& logger) const {
|
||||
const auto local_functions_num = model.GetModelLocalFunctionTemplates().size();
|
||||
const bool is_there_local_functions = local_functions_num > 0;
|
||||
|
||||
if (!is_there_local_functions) {
|
||||
LOGS(logger, INFO) << "This model does not have any local functions defined. AOT Inlining is not performed";
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
auto& graph = model.MainGraph();
|
||||
InlinedHashSet<std::string> not_inlined;
|
||||
do {
|
||||
|
|
@ -818,6 +827,12 @@ Status GraphPartitioner::InlineFunctionsAOT(Model& model,
|
|||
|
||||
model.RemoveLocalFunctionsProtos(not_inlined);
|
||||
|
||||
LOGS(logger, INFO)
|
||||
<< "AOT inlining completed. (" << (local_functions_num - model.GetModelLocalFunctionTemplates().size())
|
||||
<< ") functions of ("
|
||||
<< local_functions_num
|
||||
<< ") pruned.";
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,10 +48,12 @@ class GraphPartitioner {
|
|||
/// <param name="model">model instance</param>
|
||||
/// <param name="execution_providers">execution providers considered</param>
|
||||
/// <param name="kernel_registry_manager">registry manager</param>
|
||||
/// <param name="logger">session logger</param>
|
||||
/// <returns></returns>
|
||||
Status InlineFunctionsAOT(Model& model,
|
||||
const ExecutionProviders& execution_providers,
|
||||
const KernelRegistryManager& kernel_registry_manager) const;
|
||||
const KernelRegistryManager& kernel_registry_manager,
|
||||
const logging::Logger& logger) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -1029,7 +1029,9 @@ common::Status InferenceSession::TransformGraph(onnxruntime::Graph& graph, bool
|
|||
kOrtSessionOptionsDisableAheadOfTimeFunctionInlining, "0") == "1";
|
||||
!disable_aot_function_inlining) {
|
||||
ORT_RETURN_IF_ERROR_SESSIONID_(partitioner.InlineFunctionsAOT(*model_,
|
||||
execution_providers_, kernel_registry_manager_));
|
||||
execution_providers_,
|
||||
kernel_registry_manager_,
|
||||
*session_logger_));
|
||||
}
|
||||
|
||||
auto apply_transformer_once = [](const GraphTransformer& transformer, const logging::Logger& logger,
|
||||
|
|
|
|||
Loading…
Reference in a new issue