@@ -138,7 +138,8 @@ class PlannerImpl {
138
138
const SubgraphsKernelCreateInfoMaps& subgraphs_kernel_create_info_maps,
139
139
const InlinedHashMap<OrtValueName, OrtDevice>& outer_scope_node_arg_to_location_map,
140
140
const OrtValueNameIdxMap& ort_value_name_idx_map,
141
- const ISequentialPlannerContext& context, SequentialExecutionPlan& plan)
141
+ const ISequentialPlannerContext& context, SequentialExecutionPlan& plan,
142
+ const logging::Logger& logger)
142
143
: context_(&context),
143
144
plan_ (plan),
144
145
parent_node_(parent_node),
@@ -148,14 +149,15 @@ class PlannerImpl {
148
149
kernel_create_info_map_(kernel_create_info_map),
149
150
subgraphs_kernel_create_info_maps_(subgraphs_kernel_create_info_maps),
150
151
outer_scope_node_arg_to_location_map_(outer_scope_node_arg_to_location_map),
151
- ort_value_name_idx_map_(ort_value_name_idx_map) {}
152
+ ort_value_name_idx_map_(ort_value_name_idx_map),
153
+ logger_(logger) {
154
+ }
152
155
153
156
Status CreatePlan (
154
157
#ifdef ORT_ENABLE_STREAM
155
158
const IStreamCommandHandleRegistry& stream_handle_registry,
156
159
#endif
157
- const PathString& partition_config_file,
158
- const logging::Logger& logger);
160
+ const PathString& partition_config_file);
159
161
160
162
private:
161
163
gsl::not_null<const ISequentialPlannerContext*> context_;
@@ -183,6 +185,12 @@ class PlannerImpl {
183
185
InlinedHashMap<onnxruntime::NodeIndex, InlinedHashSet<onnxruntime::NodeIndex>> dependence_graph_;
184
186
InlinedHashMap<onnxruntime::OrtValueIndex, onnxruntime::NodeIndex> value_node_map_;
185
187
188
+ // logger_ is not currently used in a minimal build
189
+ #if defined(ORT_MINIMAL_BUILD) && !defined(ORT_EXTENDED_MINIMAL_BUILD)
190
+ [[maybe_unused]]
191
+ #endif
192
+ const logging::Logger& logger_;
193
+
186
194
// OrtValueInfo: Auxiliary information about an OrtValue used only during plan-generation:
187
195
struct OrtValueInfo {
188
196
const onnxruntime::NodeArg* p_def_site; // the (unique) NodeArg corresponding to the MLValue
@@ -213,6 +221,7 @@ class PlannerImpl {
213
221
FreeBufferInfo (OrtValueIndex ort_value, size_t dealloc_point)
214
222
: ml_value(ort_value), deallocate_point(dealloc_point) {}
215
223
};
224
+
216
225
// freelist_ : a list of ml-values whose buffers are free to be reused, sorted by when
217
226
// they became free (more recently freed earlier in the list).
218
227
std::list<FreeBufferInfo> freelist_;
@@ -225,7 +234,8 @@ class PlannerImpl {
225
234
}
226
235
227
236
int & UseCount (OrtValueIndex n) {
228
- ORT_ENFORCE (n >= 0 && static_cast <size_t >(n) < ort_value_info_.size (), " invalid value index: " , n, " against size " , ort_value_info_.size ());
237
+ ORT_ENFORCE (n >= 0 && static_cast <size_t >(n) < ort_value_info_.size (),
238
+ " invalid value index: " , n, " against size " , ort_value_info_.size ());
229
239
return ort_value_info_[n].usecount ;
230
240
}
231
241
int & UseCount (const OrtValueName& name) { return UseCount (Index (name)); }
@@ -335,9 +345,9 @@ class PlannerImpl {
335
345
// we cannot.
336
346
const Node* producer_node = graph.GetProducerNode (p_input_arg->Name ());
337
347
if (producer_node && HasExternalOutputs (*producer_node)) {
338
- LOGS_DEFAULT ( VERBOSE) << " Be noted Node " << node.Name () << " is reusing input buffer of node "
339
- << producer_node->Name () << " which has external outputs. "
340
- << " Be cautious the reuse MUST be a read-only usage." ;
348
+ LOGS (logger_, VERBOSE) << " Be noted Node " << node.Name () << " is reusing input buffer of node "
349
+ << producer_node->Name () << " which has external outputs. "
350
+ << " Be cautious the reuse MUST be a read-only usage." ;
341
351
}
342
352
#endif
343
353
*reusable_input = Index (p_input_arg->Name ());
@@ -361,9 +371,9 @@ class PlannerImpl {
361
371
// we cannot.
362
372
const Node* producer_node = graph.GetProducerNode (p_input_arg->Name ());
363
373
if (producer_node && HasExternalOutputs (*producer_node)) {
364
- LOGS_DEFAULT ( VERBOSE) << " Be noted Node " << node.Name () << " is reusing input buffer of node "
365
- << producer_node->Name () << " which has external outputs. "
366
- << " Be cautious the reuse MUST be a read-only usage." ;
374
+ LOGS (logger_, VERBOSE) << " Be noted Node " << node.Name () << " is reusing input buffer of node "
375
+ << producer_node->Name () << " which has external outputs. "
376
+ << " Be cautious the reuse MUST be a read-only usage." ;
367
377
}
368
378
#endif
369
379
*reusable_input = Index (p_input_arg->Name ());
@@ -397,8 +407,8 @@ class PlannerImpl {
397
407
}
398
408
} else {
399
409
#if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)
400
- LOGS_DEFAULT ( VERBOSE) << " Node " << node.Name () << " cannot reuse input buffer for node "
401
- << producer_node->Name () << " as it has external outputs" ;
410
+ LOGS (logger_, VERBOSE) << " Node " << node.Name () << " cannot reuse input buffer for node "
411
+ << producer_node->Name () << " as it has external outputs" ;
402
412
#endif
403
413
}
404
414
}
@@ -448,8 +458,8 @@ class PlannerImpl {
448
458
return true ;
449
459
} else {
450
460
#if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)
451
- LOGS_DEFAULT ( VERBOSE) << " Node " << node.Name () << " cannot reuse strided output buffer for node "
452
- << producer_node->Name () << " as it has external outputs." ;
461
+ LOGS (logger_, VERBOSE) << " Node " << node.Name () << " cannot reuse strided output buffer for node "
462
+ << producer_node->Name () << " as it has external outputs." ;
453
463
#endif
454
464
}
455
465
}
@@ -1198,9 +1208,9 @@ class PlannerImpl {
1198
1208
// Otherwise, we cannot reuse the buffer.
1199
1209
const Node* producer_node = graph_viewer.GetProducerNode (p_input_arg->Name ());
1200
1210
if (producer_node && HasExternalOutputs (*producer_node)) {
1201
- LOGS_DEFAULT ( VERBOSE) << " Be noted input buffer " << p_output_arg->Name () << " of node "
1202
- << producer_node->Name () << " which has external outputs is reused. "
1203
- << " Be cautious the reuse MUST be a read-only usage." ;
1211
+ LOGS (logger_, VERBOSE) << " Be noted input buffer " << p_output_arg->Name () << " of node "
1212
+ << producer_node->Name () << " which has external outputs is reused. "
1213
+ << " Be cautious the reuse MUST be a read-only usage." ;
1204
1214
}
1205
1215
#endif
1206
1216
@@ -1241,9 +1251,9 @@ class PlannerImpl {
1241
1251
// Otherwise, we cannot reuse the buffer.
1242
1252
const Node* producer_node = graph_viewer.GetProducerNode (p_input_arg->Name ());
1243
1253
if (producer_node && HasExternalOutputs (*producer_node)) {
1244
- LOGS_DEFAULT ( VERBOSE) << " Be noted input buffer " << p_output_arg->Name () << " of node "
1245
- << producer_node->Name () << " which has external outputs is reused. "
1246
- << " Be cautious the reuse MUST be a read-only usage." ;
1254
+ LOGS (logger_, VERBOSE) << " Be noted input buffer " << p_output_arg->Name () << " of node "
1255
+ << producer_node->Name () << " which has external outputs is reused. "
1256
+ << " Be cautious the reuse MUST be a read-only usage." ;
1247
1257
}
1248
1258
#endif
1249
1259
@@ -1290,8 +1300,8 @@ class PlannerImpl {
1290
1300
}
1291
1301
} else {
1292
1302
#if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)
1293
- LOGS_DEFAULT ( VERBOSE) << " Node " << node->Name () << " cannot reuse input buffer for node "
1294
- << producer_node->Name () << " as it has external outputs" ;
1303
+ LOGS (logger_, VERBOSE) << " Node " << node->Name () << " cannot reuse input buffer for node "
1304
+ << producer_node->Name () << " as it has external outputs" ;
1295
1305
#endif
1296
1306
}
1297
1307
}
@@ -1869,8 +1879,7 @@ class PlannerImpl {
1869
1879
}
1870
1880
1871
1881
#ifndef ORT_ENABLE_STREAM
1872
- void PartitionIntoStreams (const logging::Logger& /* logger*/ ,
1873
- const ExecutionProviders& /* execution_providers*/ ,
1882
+ void PartitionIntoStreams (const ExecutionProviders& /* execution_providers*/ ,
1874
1883
const PathString& /* partition_config_file*/ ) {
1875
1884
if (graph_viewer_.NumberOfNodes () > 0 ) {
1876
1885
stream_nodes_.push_back ({});
@@ -1915,11 +1924,11 @@ class PlannerImpl {
1915
1924
1916
1925
#else
1917
1926
1918
- void
1919
- PartitionIntoStreams ( const logging::Logger& logger, const ExecutionProviders& execution_providers,
1920
- const PathString& partition_config_file) {
1921
- auto partitioner = IGraphPartitioner::CreateGraphPartitioner (logger, partition_config_file);
1922
- auto status = partitioner-> PartitionGraph (graph_viewer_, execution_providers, stream_nodes_, context_->GetExecutionOrder ());
1927
+ void PartitionIntoStreams ( const ExecutionProviders& execution_providers,
1928
+ const PathString& partition_config_file) {
1929
+ auto partitioner = IGraphPartitioner::CreateGraphPartitioner (logger_, partition_config_file);
1930
+ auto status = partitioner-> PartitionGraph (graph_viewer_, execution_providers, stream_nodes_,
1931
+ context_->GetExecutionOrder ());
1923
1932
ORT_ENFORCE (status.IsOK (), status.ErrorMessage ());
1924
1933
plan_.node_stream_map_ .resize (SafeInt<size_t >(graph_viewer_.MaxNodeIndex ()) + 1 );
1925
1934
for (size_t i = 0 ; i < stream_nodes_.size (); ++i) {
@@ -2282,10 +2291,9 @@ Status PlannerImpl::CreatePlan(
2282
2291
#ifdef ORT_ENABLE_STREAM
2283
2292
const IStreamCommandHandleRegistry& stream_handle_registry,
2284
2293
#endif
2285
- const PathString& partition_config_file,
2286
- const logging::Logger& logger) {
2294
+ const PathString& partition_config_file) {
2287
2295
// 1. partition graph into streams
2288
- PartitionIntoStreams (logger, execution_providers_, this -> parent_node_ ? PathString{} : partition_config_file);
2296
+ PartitionIntoStreams (execution_providers_, parent_node_ ? PathString{} : partition_config_file);
2289
2297
2290
2298
// 2. initialize the plan based on stream partition result
2291
2299
int num_ml_values = ort_value_name_idx_map_.MaxIdx () + 1 ;
@@ -2354,14 +2362,13 @@ Status SequentialPlanner::CreatePlan(
2354
2362
PlannerImpl planner (parent_node, graph_viewer, outer_scope_node_args, providers,
2355
2363
kernel_create_info_map, subgraphs_kernel_create_info_maps,
2356
2364
outer_scope_node_arg_to_location_map,
2357
- ort_value_name_idx_map, context, *plan);
2365
+ ort_value_name_idx_map, context, *plan, logger );
2358
2366
2359
2367
return planner.CreatePlan (
2360
2368
#ifdef ORT_ENABLE_STREAM
2361
2369
stream_handle_registry,
2362
2370
#endif
2363
- partition_config_file,
2364
- logger);
2371
+ partition_config_file);
2365
2372
}
2366
2373
2367
2374
#ifdef ORT_ENABLE_STREAM
0 commit comments