Skip to content

Commit

Permalink
Fixed Coverity issues found in NPUW (#27552)
Browse files Browse the repository at this point in the history
### Details:
 - *Fixed `AUTO_CAUSES_COPY` issues found in NPUW by Coverity*
 
### Tickets:
 - *EISW-146516*
  • Loading branch information
AsyaPronina authored Nov 29, 2024
1 parent e69b138 commit fc0b54e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,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,
0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ DQMatMulConv::DQMatMulConv(const std::shared_ptr<ov::npuw::online::Snapshot>& sn
auto callback = [=](ov::pass::pattern::Matcher& m) {
auto& node_to_output = m.get_pattern_value_map();

auto matched_node_param = node_to_output.at(param);
auto matched_node_param2 = node_to_output.at(param2);
const auto& matched_node_param = node_to_output.at(param);
const auto& matched_node_param2 = node_to_output.at(param2);

auto matched_node_transpose_in = node_to_output.at(transpose_in).get_node_shared_ptr();
auto matched_node_transpose_out = node_to_output.at(transpose_out).get_node_shared_ptr();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,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 @@ -166,8 +166,8 @@ DQMatMulCWi::DQMatMulCWi(Context::Ref ctx) {
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);

if (!ctx.get().mm_dq_full) {
const auto& matm_mul_out_shape = matched_matmul->get_output_shape(0);
Expand Down Expand Up @@ -1432,7 +1432,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 @@ -1468,7 +1468,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 @@ -1504,7 +1504,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 @@ -1542,7 +1542,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 fc0b54e

Please sign in to comment.