@@ -413,6 +413,8 @@ static Status PartitionOnnxFormatModelImpl(Graph& graph, FuncManager& func_mgr,
413
413
return Status::OK ();
414
414
}
415
415
416
+ const volatile auto & load_cancellaton_flag = graph_optimizer_registry.GetLoadCancellationFlagRef ();
417
+
416
418
// recurse into nested graphs first to partition bottom up.
417
419
for (auto & node : graph.Nodes ()) {
418
420
for (auto & entry : node.GetAttributeNameToMutableSubgraphMap ()) {
@@ -506,6 +508,7 @@ static Status PartitionOnnxFormatModelImpl(Graph& graph, FuncManager& func_mgr,
506
508
capabilities_to_complete_fuse.push_back (std::move (capability));
507
509
}
508
510
}
511
+ ORT_RETURN_IF (load_cancellaton_flag, " Graph partitioning is canceled due to user request." );
509
512
}
510
513
511
514
// NOTE: if mode_ is kAssignOnly, nodes_to_compile will be empty at this point due to logic in PlaceNode
@@ -561,6 +564,7 @@ static Status PartitionOnnxFormatModelImpl(Graph& graph, FuncManager& func_mgr,
561
564
graph.FinalizeFuseSubGraph (indexed_sub_graph, *node);
562
565
}
563
566
}
567
+ ORT_RETURN_IF (load_cancellaton_flag, " Graph partitioning is canceled due to user request." );
564
568
}
565
569
566
570
if (!nodes_to_complete_fuse.empty ()) {
@@ -641,6 +645,8 @@ static Status InlineFunctionsAOTImpl(const ExecutionProviders& execution_provide
641
645
return Status::OK ();
642
646
}
643
647
648
+ const volatile bool & load_cancellation_flag = graph_optimizer_registry.GetLoadCancellationFlagRef ();
649
+
644
650
for (auto & node : graph.Nodes ()) {
645
651
for (auto & entry : node.GetAttributeNameToMutableSubgraphMap ()) {
646
652
Graph* subgraph = entry.second ;
@@ -689,6 +695,7 @@ static Status InlineFunctionsAOTImpl(const ExecutionProviders& execution_provide
689
695
}
690
696
}
691
697
}
698
+ ORT_RETURN_IF (load_cancellation_flag, " AOT inlining is canceled due to user request." );
692
699
}
693
700
694
701
// TODO: Insert version check. We need to collect all the versions
@@ -701,6 +708,7 @@ static Status InlineFunctionsAOTImpl(const ExecutionProviders& execution_provide
701
708
if (claimed_by_ep.count (node_index) == 0 ) {
702
709
ORT_RETURN_IF_ERROR (graph.InlineFunction (*node));
703
710
++inlined_count;
711
+ ORT_RETURN_IF (load_cancellation_flag, " AOT inlining is canceled due to user request." );
704
712
} else {
705
713
// OpType is the same as function name.
706
714
auto function_id = function_utils::GetFunctionIdentifier (node->Domain (), node->OpType ());
@@ -1032,6 +1040,8 @@ Status GraphPartitioner::InlineFunctionsAOT(Model& model,
1032
1040
return Status::OK ();
1033
1041
}
1034
1042
1043
+ ORT_RETURN_IF (IsLoadCancellationFlagSet (), " AOT inlining is canceled due to user request." );
1044
+
1035
1045
auto & graph = model.MainGraph ();
1036
1046
InlinedHashSet<std::string> not_inlined;
1037
1047
do {
@@ -1048,6 +1058,7 @@ Status GraphPartitioner::InlineFunctionsAOT(Model& model,
1048
1058
break ;
1049
1059
}
1050
1060
1061
+ ORT_RETURN_IF (IsLoadCancellationFlagSet (), " AOT inlining is canceled due to user request." );
1051
1062
ORT_RETURN_IF_ERROR (graph.Resolve ());
1052
1063
} while (true );
1053
1064
@@ -1082,6 +1093,9 @@ Status GraphPartitioner::Partition(Graph& graph, FuncManager& func_mgr,
1082
1093
return ORT_MAKE_STATUS (ONNXRUNTIME, INVALID_ARGUMENT, " No provider specified." );
1083
1094
}
1084
1095
1096
+ const volatile auto & load_cancellaton_flag = graph_optimizer_registry_->GetLoadCancellationFlagRef ();
1097
+ ORT_RETURN_IF (load_cancellaton_flag, " Graph partitioning is canceled due user request." );
1098
+
1085
1099
#if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)
1086
1100
// fused_kernel_registry is preparing the kernels created on the fly for fused sub graph.
1087
1101
// It is only visible for current session.
0 commit comments