mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-26 19:52:38 +00:00
### Description This PR is to refactor ExecutionProvider API for memory management, which is to move allocators from EP level to SessionState level and indexed by OrtDevice ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> This PR is to refactor ExecutionProvider API for memory management, which is to move allocators from EP level to SessionState level and indexed by OrtDevice. By this change, EP level will shift the burden of maintaining allocators, which will be user friendly for EP developers --------- Co-authored-by: Lei Cao <leca@microsoft.com@orttrainingdev8.d32nl1ml4oruzj4qz3bqlggovf.px.internal.cloudapp.net>
38 lines
1.2 KiB
C++
38 lines
1.2 KiB
C++
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
#include "test_utils.h"
|
|
#include "core/graph/graph.h"
|
|
|
|
namespace onnxruntime {
|
|
namespace test {
|
|
IExecutionProvider* TestCPUExecutionProvider() {
|
|
static CPUExecutionProviderInfo info;
|
|
static CPUExecutionProvider cpu_provider(info);
|
|
return &cpu_provider;
|
|
}
|
|
|
|
static void CountOpsInGraphImpl(const Graph& graph, bool recurse_into_subgraphs, OpCountMap& ops) {
|
|
for (auto& node : graph.Nodes()) {
|
|
std::string key = node.Domain() + (node.Domain().empty() ? "" : ".") + node.OpType();
|
|
|
|
++ops[key];
|
|
|
|
if (recurse_into_subgraphs && node.ContainsSubgraph()) {
|
|
for (auto& subgraph : node.GetSubgraphs()) {
|
|
CountOpsInGraphImpl(*subgraph, recurse_into_subgraphs, ops);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Returns a map with the number of occurrences of each operator in the graph.
|
|
// Helper function to check that the graph transformations have been successfully applied.
|
|
OpCountMap CountOpsInGraph(const Graph& graph, bool recurse_into_subgraphs) {
|
|
OpCountMap ops;
|
|
CountOpsInGraphImpl(graph, recurse_into_subgraphs, ops);
|
|
|
|
return ops;
|
|
}
|
|
|
|
} // namespace test
|
|
} // namespace onnxruntime
|