Skip to content

Commit 16acdb3

Browse files
authored
[VSINPU EP]Fix logger build error (microsoft#24602)
### Description Fix the build error in VSINPU EP which caused by microsoft#23030 ### 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. --> Signed-off-by: Kee <[email protected]>
1 parent 7d71975 commit 16acdb3

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

onnxruntime/core/providers/vsinpu/vsinpu_ep_graph.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,23 @@ bool GraphEP::Prepare() {
7373
}
7474

7575
bool GraphEP::SupportedOp(const onnxruntime::GraphViewer& graph_viewer,
76-
const NodeUnit& node_unit) {
76+
const NodeUnit& node_unit,
77+
const logging::Logger& logger) {
7778
const auto& supported_builtins = vsi::npu::SupportedBuiltinOps();
7879
const auto& target_node = node_unit.GetNode();
7980
const auto& it = supported_builtins.find(target_node.OpType());
8081
if (supported_builtins.end() != it) {
8182
return it->second->IsSupported(graph_viewer, node_unit);
8283
}
83-
LOGS_DEFAULT(WARNING) << "Fallback unsupported op (node_unit) " << node_unit.OpType()
84+
LOGS(logger, WARNING) << "Fallback unsupported op (node_unit) " << node_unit.OpType()
8485
<< " to cpu.";
8586
return false;
8687
}
8788

88-
bool GraphEP::IsNodeSupportedInGroup(const NodeUnit& node_unit, const GraphViewer& graph_viewer) {
89-
return SupportedOp(graph_viewer, node_unit);
89+
bool GraphEP::IsNodeSupportedInGroup(const NodeUnit& node_unit,
90+
const GraphViewer& graph_viewer,
91+
const logging::Logger& logger) {
92+
return SupportedOp(graph_viewer, node_unit, logger);
9093
}
9194

9295
const NodeUnit& GraphEP::GetNodeUnit(const Node* node) const {
@@ -151,7 +154,7 @@ bool GraphEP::BindTensors(const std::shared_ptr<NodeIOInfo>& nodeio_info) {
151154
if (!input_names.empty()) {
152155
for (auto& name : input_names) {
153156
if (tensors_.find(name) == tensors_.end() || tensors_[name] == nullptr) {
154-
LOGS_DEFAULT(ERROR) << "Input tensor not defined or not found!";
157+
LOGS(logger_, ERROR) << "Input tensor not defined or not found!";
155158
return false;
156159
}
157160
(*op).BindInput(tensors_[name]);
@@ -160,7 +163,7 @@ bool GraphEP::BindTensors(const std::shared_ptr<NodeIOInfo>& nodeio_info) {
160163
if (!output_names.empty()) {
161164
for (auto& name : output_names) {
162165
if (tensors_.find(name) == tensors_.end() || tensors_[name] == nullptr) {
163-
LOGS_DEFAULT(ERROR) << "Output tensor not defined or not found!";
166+
LOGS(logger_, ERROR) << "Output tensor not defined or not found!";
164167
return false;
165168
}
166169
(*op).BindOutput(tensors_[name]);

onnxruntime/core/providers/vsinpu/vsinpu_ep_graph.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ class GraphEP {
5757
bool Prepare();
5858

5959
static bool SupportedOp(const onnxruntime::GraphViewer& graph_viewer,
60-
const NodeUnit& node_unit);
60+
const NodeUnit& node_unit, const logging::Logger& logger);
6161

6262
// If a node is supported by VSINPU in a partition node group
6363
// `node_outputs_in_group` is the set of the output names of the nodes added to this group so far
64-
static bool IsNodeSupportedInGroup(const NodeUnit& node_unit, const GraphViewer& graph_viewer);
64+
static bool IsNodeSupportedInGroup(const NodeUnit& node_unit, const GraphViewer& graph_viewer,
65+
const logging::Logger& logger);
6566

6667
const NodeUnit& GetNodeUnit(const Node* node) const;
6768

onnxruntime/core/providers/vsinpu/vsinpu_execution_provider.cc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
#include "core/optimizer/qdq_transformer/selectors_actions/shared/utils.h"
3838
#include "core/providers/partitioning_utils.h"
3939

40-
#include "core/providers/qnn/ort_api.h"
41-
4240
namespace onnxruntime {
4341
VSINPUExecutionProvider::VSINPUExecutionProvider(const VSINPUExecutionProviderInfo& info)
4442
: IExecutionProvider{onnxruntime::kVSINPUExecutionProvider,
@@ -56,17 +54,17 @@ VSINPUExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph_vie
5654
const GraphOptimizerRegistry& /* graph_optimizer_registry */,
5755
IResourceAccountant* /* resource_accountant */) const {
5856
std::vector<std::unique_ptr<ComputeCapability>> result;
59-
57+
const auto& logger = *GetLogger();
6058
if (graph_viewer.IsSubgraph()) {
6159
return result;
6260
}
6361

6462
for (const auto& tensor : graph_viewer.GetAllInitializedTensors()) {
6563
if (tensor.second->has_data_location()) {
66-
LOGS_DEFAULT(VERBOSE) << "location:" << tensor.second->data_location();
64+
LOGS(logger, VERBOSE) << "location:" << tensor.second->data_location();
6765
if (tensor.second->data_location() ==
6866
ONNX_NAMESPACE::TensorProto_DataLocation_EXTERNAL) {
69-
LOGS_DEFAULT(WARNING) << "VSINPU: Initializers with external data location are not "
67+
LOGS(logger, WARNING) << "VSINPU: Initializers with external data location are not "
7068
"currently supported";
7169
return result;
7270
}
@@ -93,11 +91,11 @@ VSINPUExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph_vie
9391
supported = it->second;
9492
} else {
9593
// We only check the target node of the node unit
96-
supported = vsi::npu::GraphEP::IsNodeSupportedInGroup(*node_unit, graph_viewer);
94+
supported = vsi::npu::GraphEP::IsNodeSupportedInGroup(*node_unit, graph_viewer, logger);
9795
node_unit_supported_result[node_unit] = supported;
9896
}
9997

100-
LOGS_DEFAULT(VERBOSE) << "Node supported: [" << supported
98+
LOGS(logger, VERBOSE) << "Node supported: [" << supported
10199
<< "] Operator type: [" << node.OpType()
102100
<< "] index: [" << node.Index()
103101
<< "] name: [" << node.Name()
@@ -158,9 +156,9 @@ VSINPUExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph_vie
158156
// If the graph is partitioned in multiple subgraphs, and this may impact performance,
159157
// we want to give users a summary message at warning level.
160158
if (num_of_partitions > 1) {
161-
LOGS_DEFAULT(WARNING) << summary_msg;
159+
LOGS(logger, WARNING) << summary_msg;
162160
} else {
163-
LOGS_DEFAULT(INFO) << summary_msg;
161+
LOGS(logger, INFO) << summary_msg;
164162
}
165163

166164
return result;

onnxruntime/core/providers/vsinpu/vsinpu_execution_provider.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class VSINPUExecutionProvider : public IExecutionProvider {
5050
std::mutex& GetMutex() { return mutex_; }
5151

5252
private:
53-
int device_id_;
53+
OrtDevice::DeviceId device_id_;
5454
std::mutex mutex_;
5555
};
5656

0 commit comments

Comments
 (0)