Skip to content

Commit

Permalink
Fixed Coverity issues found in NPUW
Browse files Browse the repository at this point in the history
  • Loading branch information
AsyaPronina committed Nov 14, 2024
1 parent b1ff99c commit a797ce2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,6 @@ void ov::npuw::JustInferRequest::unsafe_infer(std::size_t real_idx) {
// Now copy the views from the output full-nway tensor to the output tensors
for (std::size_t out_idx = 0u; out_idx < num_outputs; out_idx++) {
const auto& oport = comp_model_desc.compiled_model->outputs()[out_idx];
auto spatial_tensor_shape = oport.get_shape();

auto in_view = ov::npuw::util::view(m_spatial_io[real_idx].output_tails.at(out_idx),
spatial.out_dim,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ DCOFFPassReshape4::DCOFFPassReshape4(DCOffMode dcoff_mode, ov::element::Type dco
auto matched_paramA = std::static_pointer_cast<ov::op::v0::Parameter>(matched_nodeA);
auto matched_paramC = std::static_pointer_cast<ov::op::v0::Parameter>(matched_nodeC);

auto matched_out_mulply = node_to_output.at(mulply);
const auto& matched_out_mulply = node_to_output.at(mulply);

if (ov::element::i4 == matched_paramA->get_element_type() &&
(ov::element::f16 == matched_paramC->get_element_type() ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ DQMatMulCWi::DQMatMulCWi() {
auto matched_node_cvtw = node_to_output.at(qcvtw).get_node_shared_ptr();
auto matched_node_muls = node_to_output.at(qmuls).get_node_shared_ptr();
auto matched_node_mmi = node_to_output.at(qmmi).get_node_shared_ptr();
auto matched_node_qcoeff_out = uat::_(node_to_output).at_or_at_or_at(qcvtc, reshapec, qcoeff);
auto matched_node_muls_out = uat::_(node_to_output).at_or_at(qcvtm, qmuls);
auto& matched_node_qcoeff_out = uat::_(node_to_output).at_or_at_or_at(qcvtc, reshapec, qcoeff);
auto& matched_node_muls_out = uat::_(node_to_output).at_or_at(qcvtm, qmuls);

// Reconnect MatMul to read from Convert(W) directly.
// Note: ACT has to be converted too.
Expand Down Expand Up @@ -1331,7 +1331,7 @@ SliceLastMatmul::SliceLastMatmul() {
auto callback = [=](ov::pass::pattern::Matcher& m) {
auto& node_to_output = m.get_pattern_value_map();

auto matched_out_matmul = node_to_output.at(matmul);
auto& matched_out_matmul = node_to_output.at(matmul);

auto shape = matched_out_matmul.get_node()->input(0).get_shape();

Expand Down Expand Up @@ -1367,7 +1367,7 @@ SliceLastMatmulAdd::SliceLastMatmulAdd() {
auto callback = [=](ov::pass::pattern::Matcher& m) {
auto& node_to_output = m.get_pattern_value_map();

auto matched_out_matmul = node_to_output.at(matmul);
auto& matched_out_matmul = node_to_output.at(matmul);

auto shape = matched_out_matmul.get_node()->input(0).get_shape();

Expand Down Expand Up @@ -1403,7 +1403,7 @@ SliceLastMatmulTranspose::SliceLastMatmulTranspose() {
auto callback = [=](ov::pass::pattern::Matcher& m) {
auto& node_to_output = m.get_pattern_value_map();

auto matched_out_matmul = node_to_output.at(matmul);
auto& matched_out_matmul = node_to_output.at(matmul);

auto shape = matched_out_matmul.get_node()->input(0).get_shape();

Expand Down Expand Up @@ -1441,7 +1441,7 @@ SliceLastMatmulMultiply::SliceLastMatmulMultiply() {
auto callback = [=](ov::pass::pattern::Matcher& m) {
auto& node_to_output = m.get_pattern_value_map();

auto matched_out_matmul = node_to_output.at(matmul);
auto& matched_out_matmul = node_to_output.at(matmul);

auto shape = matched_out_matmul.get_node()->input(0).get_shape();

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_npu/src/plugin/npuw/spatial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ov::npuw::runtime::spatial::AttentionMask::AttentionMask(std::size_t param_idx,
ov::npuw::runtime::spatial::Selector::Ptr ov::npuw::runtime::spatial::AttentionMask::find(
const ov::ISyncInferRequest& rq) {
auto is_attn_mask = [](const ov::Output<const ov::Node>& p) {
const auto shape = p.get_shape();
const auto& shape = p.get_shape();
return p.get_node()->get_friendly_name() == "attention_mask" &&
(shape.size() == 1 || (shape.size() == 2 && shape[0] == 1));
};
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/intel_npu/src/plugin/npuw/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ ov::SoPtr<ov::ITensor> ov::npuw::util::view(const ov::SoPtr<ov::ITensor>& src,
view_shape.push_back(to[d] - from[d]);
}

const auto strides = src->get_strides();
const auto& strides = src->get_strides();
uint8_t* ptr = static_cast<uint8_t*>(src->data());

// Shift PTR according to the strides
Expand All @@ -352,7 +352,7 @@ ov::SoPtr<ov::ITensor> ov::npuw::util::view(const ov::SoPtr<ov::ITensor>& src,
std::size_t dim,
std::size_t offset,
std::size_t len) {
const auto shape = src->get_shape();
const auto& shape = src->get_shape();
View view_start = View(shape.size(), 0u);
View view_end = shape;
view_start[dim] = offset;
Expand Down

0 comments on commit a797ce2

Please sign in to comment.