Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GGUF] Fix Coverity copy diagnostics (#37836)

Maxim Vafin51de813b141f
diff --git a/src/frontends/gguf/docs/how_to_add_op.md b/src/frontends/gguf/docs/how_to_add_op.md
index 8f5f0c87fa4..a6fc5d1f922 100644
--- a/src/frontends/gguf/docs/how_to_add_op.md
+++ b/src/frontends/gguf/docs/how_to_add_op.md
@@ -55,7 +55,7 @@ OutputVector translate_<name>(const NodeContext& context) {
std::shared_ptr<ov::Node> res = ...;
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
```
diff --git a/src/frontends/gguf/src/builder/arch/decoder_builder.cpp b/src/frontends/gguf/src/builder/arch/decoder_builder.cpp
index 7cb7e3256db..dafcfb278dc 100644
--- a/src/frontends/gguf/src/builder/arch/decoder_builder.cpp
+++ b/src/frontends/gguf/src/builder/arch/decoder_builder.cpp
@@ -251,7 +251,7 @@ std::string DecoderBuilder::inject_per_layer_embedding(int il, const std::string
std::string DecoderBuilder::build_layer(int il, const std::string& layer_in) {
const std::string p = "blk." + std::to_string(il) + ".";
- const std::string inpSA = layer_in;
+ const std::string& inpSA = layer_in;
std::string cur = layer_in;
// eps for the post-attention / post-FFN norms; 0 in the config means "reuse rms_eps"
diff --git a/src/frontends/gguf/src/builder/blocks/attention.cpp b/src/frontends/gguf/src/builder/blocks/attention.cpp
index 9fc7aacd331..a020cb5436e 100644
--- a/src/frontends/gguf/src/builder/blocks/attention.cpp
+++ b/src/frontends/gguf/src/builder/blocks/attention.cpp
@@ -55,6 +55,10 @@ std::string attention(GraphEmitter& e,
const int n_head_kv_l = cfg.layer_n_head_kv(il);
const float kq_scale = cfg.layer_kq_scale(il);
const RopeConfig rope_config_l = cfg.layer_rope_config(il);
+ // Shape dimensions are int64_t. Widen before multiplication so malformed metadata cannot
+ // overflow the intermediate int expression before it reaches the PartialShape.
+ const int64_t q_width = static_cast<int64_t>(head_size_l) * cfg.n_head;
+ const int64_t kv_width = static_cast<int64_t>(head_size_l) * n_head_kv_l;
// Q/K/V projections: MUL_MAT(w, attn_norm), then conceptual reshape to heads.
// Fused-QKV archs (phi-3, minicpm) carry a single attn_qkv weight; split it into
@@ -78,21 +82,9 @@ std::string attention(GraphEmitter& e,
e.add_weight_from(p + "attn_v.weight", p + "attn_k");
}
}
- auto q = e.add_op("GGML_OP_MUL_MAT",
- p + "Qcur",
- {p + "attn_q.weight", attn_norm},
- ps({1, 1, T, head_size_l * cfg.n_head}),
- f32);
- auto k = e.add_op("GGML_OP_MUL_MAT",
- p + "Kcur",
- {p + "attn_k.weight", attn_norm},
- ps({1, 1, T, head_size_l * n_head_kv_l}),
- f32);
- auto v = e.add_op("GGML_OP_MUL_MAT",
- p + "Vcur",
- {p + "attn_v.weight", attn_norm},
- ps({1, 1, T, head_size_l * n_head_kv_l}),
- f32);
+ auto q = e.add_op("GGML_OP_MUL_MAT", p + "Qcur", {p + "attn_q.weight", attn_norm}, ps({1, 1, T, q_width}), f32);
+ auto k = e.add_op("GGML_OP_MUL_MAT", p + "Kcur", {p + "attn_k.weight", attn_norm}, ps({1, 1, T, kv_width}), f32);
+ auto v = e.add_op("GGML_OP_MUL_MAT", p + "Vcur", {p + "attn_v.weight", attn_norm}, ps({1, 1, T, kv_width}), f32);
// Q/K/V projection biases (qwen2 / qwen2.5: separate attn_{q,k,v}.bias; phi-3-style
// fused-QKV archs: attn_qkv.bias, already split into attn_{q,k,v}.bias by
@@ -267,8 +259,7 @@ std::string attention(GraphEmitter& e,
std::move(attn_attrs));
// reshape back to [1, 1, n_tokens, n_head*head_size]
- auto attn_2d =
- e.add_op("GGML_OP_RESHAPE", p + "kqv_merged", {attn}, ps({1, 1, T, cfg.n_head * head_size_l}), f32, 2);
+ auto attn_2d = e.add_op("GGML_OP_RESHAPE", p + "kqv_merged", {attn}, ps({1, 1, T, q_width}), f32, 2);
// muse-glimmer: sigmoid output gate. The gate is a projection of the PRE-attention
// normed hidden (the same `attn_norm` tensor Q/K/V come from), squashed by sigmoid and
@@ -278,7 +269,7 @@ std::string attention(GraphEmitter& e,
auto gate = e.add_op("GGML_OP_MUL_MAT",
p + "attn_gate",
{p + "attn_gate.weight", attn_norm},
- ps({1, 1, T, cfg.n_head * head_size_l}),
+ ps({1, 1, T, q_width}),
f32);
gate = e.add_op("GGML_UNARY_OP_SIGMOID", p + "attn_gate_sig", {gate}, e.shape_of_tensor(gate), f32);
attn_2d = e.add_op("GGML_OP_MUL", p + "kqv_gated", {attn_2d, gate}, e.shape_of_tensor(attn_2d), f32);
diff --git a/src/frontends/gguf/src/op/add_id.cpp b/src/frontends/gguf/src/op/add_id.cpp
index ad6cb716d04..0b2b6ee414f 100644
--- a/src/frontends/gguf/src/op/add_id.cpp
+++ b/src/frontends/gguf/src/op/add_id.cpp
@@ -27,7 +27,7 @@ namespace {
ov::Output<ov::Node> reshape_add_id_input_to_2d(const ov::Output<ov::Node>& input,
const ov::PartialShape& input_shape,
const std::vector<int>& dims) {
- const auto actual_shape = input.get_partial_shape();
+ const auto& actual_shape = input.get_partial_shape();
if (actual_shape.rank().is_static() && actual_shape.rank().get_length() == 2) {
return input;
}
@@ -75,7 +75,7 @@ OutputVector translate_add_id(const NodeContext& context) {
res = std::make_shared<ov::op::v0::Convert>(res, output_type);
}
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/argsort.cpp b/src/frontends/gguf/src/op/argsort.cpp
index 346b5663893..f1235783d00 100644
--- a/src/frontends/gguf/src/op/argsort.cpp
+++ b/src/frontends/gguf/src/op/argsort.cpp
@@ -46,7 +46,7 @@ OutputVector translate_argsort(const NodeContext& context) {
ov::op::v0::Constant::create(ov::element::i64, {1}, {0}));
auto indices = make_topk_indices(input, k, axis, mode, index_type);
- return rename_outputs_with_suffix({indices}, context.get_name());
+ return rename_outputs_with_suffix({std::move(indices)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/clamp.cpp b/src/frontends/gguf/src/op/clamp.cpp
index ce6e67b86f1..7d7c28d08dd 100644
--- a/src/frontends/gguf/src/op/clamp.cpp
+++ b/src/frontends/gguf/src/op/clamp.cpp
@@ -25,7 +25,7 @@ OutputVector translate_clamp(const NodeContext& context) {
float max = context.get_attribute<float>("clamp_max");
auto res = std::make_shared<ov::op::v0::Clamp>(input, min, max);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/concat.cpp b/src/frontends/gguf/src/op/concat.cpp
index c0106856208..e247422113d 100644
--- a/src/frontends/gguf/src/op/concat.cpp
+++ b/src/frontends/gguf/src/op/concat.cpp
@@ -43,7 +43,7 @@ OutputVector translate_concat(const NodeContext& context) {
const auto axis = static_cast<int64_t>(rank - 1 - ggml_dim);
auto res = std::make_shared<ov::op::v0::Concat>(OutputVector{input_0, input_1}, axis);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/cont.cpp b/src/frontends/gguf/src/op/cont.cpp
index c17ffc02ad7..38a58c49fe7 100644
--- a/src/frontends/gguf/src/op/cont.cpp
+++ b/src/frontends/gguf/src/op/cont.cpp
@@ -54,12 +54,12 @@ OutputVector translate_cont(const NodeContext& context) {
auto tgt_node = ov::op::v0::Constant::create(ov::element::i64, {tgt.size()}, tgt);
res = std::make_shared<ov::op::v1::Reshape>(input, tgt_node, false);
res.get_node_shared_ptr()->set_friendly_name("cont_reshape_" + context.get_name());
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
res = input;
}
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/cpy.cpp b/src/frontends/gguf/src/op/cpy.cpp
index d4992234c1f..61a89be1158 100644
--- a/src/frontends/gguf/src/op/cpy.cpp
+++ b/src/frontends/gguf/src/op/cpy.cpp
@@ -49,7 +49,7 @@ OutputVector translate_cpy(const NodeContext& context) {
}
auto target = ov::op::v0::Constant::create(ov::element::i64, {output_shape.size()}, output_shape.to_shape());
auto res = std::make_shared<ov::op::v1::Reshape>(value, target, false);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
if (op_case == 3 && input_shape.is_static() && ov::shape_size(input_shape.to_shape()) == 0) {
@@ -82,7 +82,7 @@ OutputVector translate_cpy(const NodeContext& context) {
auto head_part = std::make_shared<ov::op::v8::Slice>(base, zero, begin, one, axis);
auto tail_part = std::make_shared<ov::op::v8::Slice>(base, end, int_max, one, axis);
auto res = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{head_part, src, tail_part}, 3);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
const std::string writeback_name = context.get_attribute<std::string>("rs_writeback_name", context.get_name());
@@ -151,7 +151,7 @@ OutputVector translate_cpy(const NodeContext& context) {
auto head_part = std::make_shared<ov::op::v8::Slice>(base, zero, begin, one, axis);
auto tail_part = std::make_shared<ov::op::v8::Slice>(base, end, int_max, one, axis);
auto res = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{head_part, src, tail_part}, slot_axis);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
ov::Output<ov::Node> res =
@@ -210,7 +210,7 @@ OutputVector translate_cpy(const NodeContext& context) {
false);
}
}
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/cumsum.cpp b/src/frontends/gguf/src/op/cumsum.cpp
index 136ed507e8c..a45fe46fa11 100644
--- a/src/frontends/gguf/src/op/cumsum.cpp
+++ b/src/frontends/gguf/src/op/cumsum.cpp
@@ -25,7 +25,7 @@ OutputVector translate_cumsum(const NodeContext& context) {
auto axis = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {-1LL});
auto res = std::make_shared<ov::op::v0::CumSum>(x, axis);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/diag.cpp b/src/frontends/gguf/src/op/diag.cpp
index 8ede7aea6fb..34df8905f49 100644
--- a/src/frontends/gguf/src/op/diag.cpp
+++ b/src/frontends/gguf/src/op/diag.cpp
@@ -46,7 +46,7 @@ OutputVector translate_diag(const NodeContext& context) {
// Multiply broadcasts the [ne3,ne2,1,ne0] input over the row axis, zeroing off-diagonal entries.
auto res = std::make_shared<ov::op::v1::Multiply>(x, eye);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/div.cpp b/src/frontends/gguf/src/op/div.cpp
index 168b963fc57..a85b0d28f4e 100644
--- a/src/frontends/gguf/src/op/div.cpp
+++ b/src/frontends/gguf/src/op/div.cpp
@@ -126,7 +126,7 @@ OutputVector translate_div(const NodeContext& context) {
if (res.get_element_type() != output_type) {
res = std::make_shared<ov::op::v0::Convert>(res, output_type);
}
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
input_1 = repeat_input_to_match(context, input_1, input_0, 1);
@@ -149,7 +149,7 @@ OutputVector translate_div(const NodeContext& context) {
ov::mark_as_precision_sensitive(output_convert->input(0));
res = output_convert;
}
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/fill.cpp b/src/frontends/gguf/src/op/fill.cpp
index 516188ba169..6361c2e12b1 100644
--- a/src/frontends/gguf/src/op/fill.cpp
+++ b/src/frontends/gguf/src/op/fill.cpp
@@ -35,7 +35,7 @@ OutputVector translate_fill(const NodeContext& context) {
auto target_shape = std::make_shared<ov::op::v3::ShapeOf>(x, ov::element::i64);
auto res = std::make_shared<ov::op::v3::Broadcast>(val, target_shape);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/flash_attn_ext.cpp b/src/frontends/gguf/src/op/flash_attn_ext.cpp
index b768d80d861..e4747aa09d5 100644
--- a/src/frontends/gguf/src/op/flash_attn_ext.cpp
+++ b/src/frontends/gguf/src/op/flash_attn_ext.cpp
@@ -199,7 +199,7 @@ OutputVector translate_flash_attn_ext(const NodeContext& context) {
if (kq_soft_cap == 0.0f) {
res = std::make_shared<ov::op::v0::Convert>(res, ov::element::f32);
}
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/gated_delta_net.cpp b/src/frontends/gguf/src/op/gated_delta_net.cpp
index f668fe159a2..6843b84428a 100644
--- a/src/frontends/gguf/src/op/gated_delta_net.cpp
+++ b/src/frontends/gguf/src/op/gated_delta_net.cpp
@@ -107,7 +107,7 @@ OutputVector translate_gated_delta_net(const NodeContext& context) {
auto out_shape = ov::op::v0::Constant::create(ov::element::i64, {4}, std::vector<int64_t>{1, 1, -1, S_v * H_v});
auto res = std::make_shared<ov::op::v1::Reshape>(packed, out_shape, false);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
// Serializable reference path: a recurrent OV Loop scan over the sequence built from core ops,
@@ -272,7 +272,7 @@ static OutputVector translate_gated_delta_net_ref(const NodeContext& context) {
auto out_shape = ov::op::v0::Constant::create(ov::element::i64, {4}, std::vector<int64_t>{1, 1, -1, S_v * H_v});
auto res = std::make_shared<ov::op::v1::Reshape>(packed, out_shape, false);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/get_rows.cpp b/src/frontends/gguf/src/op/get_rows.cpp
index 3810624c6ef..91c313b54c0 100644
--- a/src/frontends/gguf/src/op/get_rows.cpp
+++ b/src/frontends/gguf/src/op/get_rows.cpp
@@ -30,7 +30,7 @@ OutputVector translate_get_rows(const NodeContext& context) {
auto indices = context.get_input(1);
if (op_case == 3) {
- return {data};
+ return {std::move(data)};
}
if (op_case == 4) {
@@ -42,7 +42,7 @@ OutputVector translate_get_rows(const NodeContext& context) {
if (res.get_element_type() != context.get_output_type()) {
res = std::make_shared<ov::op::v0::Convert>(res, context.get_output_type());
}
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
// MoE gating-weight gather (op_case 10): data = probs [1,1,T,E], indices = selected experts
@@ -60,7 +60,7 @@ OutputVector translate_get_rows(const NodeContext& context) {
ge,
ov::op::v0::Constant::create(ov::element::i64, {4}, std::vector<int64_t>{1, -1, K, 1}),
false); // [1,T,K,1]
- return rename_outputs_with_suffix({col}, context.get_name());
+ return rename_outputs_with_suffix({std::move(col)}, context.get_name());
}
if (op_case == 2) {
@@ -95,7 +95,7 @@ OutputVector translate_get_rows(const NodeContext& context) {
}
// The two Squeezes above dropped the leading axes; restore ggml's rank-4 form.
res = std::make_shared<ov::op::v0::Unsqueeze>(res, ov::op::v0::Constant::create(ov::element::i64, {1}, {0}));
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/glu_geglu.cpp b/src/frontends/gguf/src/op/glu_geglu.cpp
index ba513fcc972..f6e5996cac8 100644
--- a/src/frontends/gguf/src/op/glu_geglu.cpp
+++ b/src/frontends/gguf/src/op/glu_geglu.cpp
@@ -57,7 +57,7 @@ OutputVector translate_glu_geglu(const NodeContext& context) {
auto gelu = std::make_shared<ov::op::v7::Gelu>(src0, ov::op::GeluApproximationMode::TANH);
auto res = std::make_shared<ov::op::v1::Multiply>(gelu, src1);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/glu_swiglu.cpp b/src/frontends/gguf/src/op/glu_swiglu.cpp
index 88821b17ec9..d6070fae30e 100644
--- a/src/frontends/gguf/src/op/glu_swiglu.cpp
+++ b/src/frontends/gguf/src/op/glu_swiglu.cpp
@@ -67,7 +67,7 @@ OutputVector translate_glu_swiglu(const NodeContext& context) {
auto silu = std::make_shared<ov::op::v1::Multiply>(src0, sigmoid);
auto res = std::make_shared<ov::op::v1::Multiply>(silu, src1);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
// gpt-oss gated SiLU: clamp gate to (-inf, limit], scale by alpha, sigmoid-gate, then multiply by
@@ -91,7 +91,7 @@ OutputVector translate_glu_swiglu_oai(const NodeContext& context) {
auto up_plus_one = std::make_shared<ov::op::v1::Add>(up, one);
auto res = std::make_shared<ov::op::v1::Multiply>(out_glu, up_plus_one);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/im2col.cpp b/src/frontends/gguf/src/op/im2col.cpp
index 7a341c104c4..92281176f9e 100644
--- a/src/frontends/gguf/src/op/im2col.cpp
+++ b/src/frontends/gguf/src/op/im2col.cpp
@@ -119,7 +119,7 @@ OutputVector translate_im2col(const NodeContext& context) {
res = std::make_shared<ov::op::v0::Convert>(res, output_type);
}
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/l2_norm.cpp b/src/frontends/gguf/src/op/l2_norm.cpp
index 9fbef9c301f..9864ce33685 100644
--- a/src/frontends/gguf/src/op/l2_norm.cpp
+++ b/src/frontends/gguf/src/op/l2_norm.cpp
@@ -36,7 +36,7 @@ OutputVector translate_l2_norm(const NodeContext& context) {
auto clamped_norm = std::make_shared<ov::op::v1::Maximum>(l2_norm, eps_const);
auto res = std::make_shared<ov::op::v1::Divide>(input_node, clamped_norm);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/mul_mat_id.cpp b/src/frontends/gguf/src/op/mul_mat_id.cpp
index 8aec8584637..0caf845554e 100644
--- a/src/frontends/gguf/src/op/mul_mat_id.cpp
+++ b/src/frontends/gguf/src/op/mul_mat_id.cpp
@@ -372,7 +372,7 @@ OutputVector translate_mul_mat_id(const NodeContext& context) {
} else {
result = translate_mul_mat_id_generic(context, expert_weights, activations, ids);
}
- return rename_outputs_with_suffix({result}, context.get_name());
+ return rename_outputs_with_suffix({std::move(result)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/mulmat.cpp b/src/frontends/gguf/src/op/mulmat.cpp
index c0499ab6b1f..7c8b0f7f054 100644
--- a/src/frontends/gguf/src/op/mulmat.cpp
+++ b/src/frontends/gguf/src/op/mulmat.cpp
@@ -97,7 +97,7 @@ OutputVector translate_mulmat(const NodeContext& context) {
res = std::make_shared<ov::op::v0::Convert>(res, output_type);
}
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/norm.cpp b/src/frontends/gguf/src/op/norm.cpp
index 98eb80d1f73..27e9caf8aac 100644
--- a/src/frontends/gguf/src/op/norm.cpp
+++ b/src/frontends/gguf/src/op/norm.cpp
@@ -25,7 +25,7 @@ OutputVector translate_norm(const NodeContext& context) {
auto axes = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {-1});
auto res = std::make_shared<ov::op::v6::MVN>(input_node, axes, true, eps, ov::op::MVNEpsMode::INSIDE_SQRT);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/pad.cpp b/src/frontends/gguf/src/op/pad.cpp
index 84d7357d005..0e73e9ebddc 100644
--- a/src/frontends/gguf/src/op/pad.cpp
+++ b/src/frontends/gguf/src/op/pad.cpp
@@ -64,7 +64,7 @@ OutputVector translate_pad(const NodeContext& context) {
if (context.get_input_shape(0) == context.get_output_shape()) {
auto input_shape = std::make_shared<ov::op::v3::ShapeOf>(input);
auto res = std::make_shared<ov::op::v1::Reshape>(input, input_shape, false);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
auto pad_params = context.get_attribute<std::vector<int32_t>>("pad_params");
@@ -81,7 +81,7 @@ OutputVector translate_pad(const NodeContext& context) {
if (circular) {
auto res = translate_circular_pad(input, pads, context.get_input_shape(0).to_shape());
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
const std::vector<int64_t> pads_begin = {pads[6], pads[4], pads[2], pads[0]};
@@ -92,7 +92,7 @@ OutputVector translate_pad(const NodeContext& context) {
auto res =
std::make_shared<ov::op::v1::Pad>(input, pads_begin_node, pads_end_node, pad_value, ov::op::PadMode::CONSTANT);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/permute.cpp b/src/frontends/gguf/src/op/permute.cpp
index c15a340ec32..d225cedba5d 100644
--- a/src/frontends/gguf/src/op/permute.cpp
+++ b/src/frontends/gguf/src/op/permute.cpp
@@ -106,7 +106,7 @@ OutputVector translate_permute(const NodeContext& context) {
active_cache = std::make_shared<ov::op::v8::Slice>(src, seq_active_start, seq_active_end, one, zero);
}
res = std::make_shared<ov::op::v1::Transpose>(active_cache, perm);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
int64_t ctx_per_seq = cache_shape[2].is_static() ? cache_shape[2].get_length() : -1;
@@ -149,7 +149,7 @@ OutputVector translate_permute(const NodeContext& context) {
}
res = std::make_shared<ov::op::v1::Transpose>(active_cache, perm);
}
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/repeat.cpp b/src/frontends/gguf/src/op/repeat.cpp
index cfce4f44a7c..284dabfee0b 100644
--- a/src/frontends/gguf/src/op/repeat.cpp
+++ b/src/frontends/gguf/src/op/repeat.cpp
@@ -66,7 +66,7 @@ OutputVector translate_repeat(const NodeContext& context) {
if (resolved) {
auto repeats_node = ov::op::v0::Constant::create(ov::element::i64, {repeats.size()}, repeats);
ov::Output<ov::Node> res = std::make_shared<ov::op::v0::Tile>(input, repeats_node);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
}
@@ -85,7 +85,7 @@ OutputVector translate_repeat(const NodeContext& context) {
}
auto repeats_node = std::make_shared<ov::op::v1::Divide>(target_shape_node, input_shape_node);
ov::Output<ov::Node> res = std::make_shared<ov::op::v0::Tile>(input, repeats_node);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/reshape.cpp b/src/frontends/gguf/src/op/reshape.cpp
index 52419a831a4..73c46434d60 100644
--- a/src/frontends/gguf/src/op/reshape.cpp
+++ b/src/frontends/gguf/src/op/reshape.cpp
@@ -115,7 +115,7 @@ OutputVector translate_reshape(const NodeContext& context) {
std::vector<int64_t>(output_shape.begin(), output_shape.end()));
}
auto res = std::make_shared<ov::op::v1::Reshape>(context.get_input(0), new_shape_node, false);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/rms_norm.cpp b/src/frontends/gguf/src/op/rms_norm.cpp
index 0813215f587..3b79fd8fa35 100644
--- a/src/frontends/gguf/src/op/rms_norm.cpp
+++ b/src/frontends/gguf/src/op/rms_norm.cpp
@@ -31,7 +31,7 @@ OutputVector translate_rms_norm(const NodeContext& context) {
ov::pass::NodeRegistry reg;
auto res = ov::decomposition::rms_norm(reg, input_node, axes, eps);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/rope.cpp b/src/frontends/gguf/src/op/rope.cpp
index 978ecd7e3e9..3c06fddf23c 100644
--- a/src/frontends/gguf/src/op/rope.cpp
+++ b/src/frontends/gguf/src/op/rope.cpp
@@ -285,7 +285,7 @@ OutputVector translate_rope(const NodeContext& context) {
res = std::make_shared<ov::op::v0::Convert>(res, output_type);
}
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/scale.cpp b/src/frontends/gguf/src/op/scale.cpp
index f45d5ebada2..b996dc42186 100644
--- a/src/frontends/gguf/src/op/scale.cpp
+++ b/src/frontends/gguf/src/op/scale.cpp
@@ -58,7 +58,7 @@ OutputVector translate_scale(const NodeContext& context) {
res = scaled.get_node_shared_ptr();
}
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/set.cpp b/src/frontends/gguf/src/op/set.cpp
index b45d0723c43..0b88e886bff 100644
--- a/src/frontends/gguf/src/op/set.cpp
+++ b/src/frontends/gguf/src/op/set.cpp
@@ -63,7 +63,7 @@ OutputVector translate_set(const NodeContext& context) {
auto dst_shape = std::make_shared<ov::op::v3::ShapeOf>(dst, ov::element::i64);
auto res = std::make_shared<ov::op::v1::Reshape>(updated_flat, dst_shape, false);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/set_rows.cpp b/src/frontends/gguf/src/op/set_rows.cpp
index 2a9e76b9d30..ae0049203f8 100644
--- a/src/frontends/gguf/src/op/set_rows.cpp
+++ b/src/frontends/gguf/src/op/set_rows.cpp
@@ -55,7 +55,7 @@ OutputVector translate_set_rows(const NodeContext& context) {
true);
auto set_rows = std::make_shared<SetRows>(data_reshaped, ind_squeezed, dst);
- return rename_outputs_with_suffix({set_rows}, context.get_name());
+ return rename_outputs_with_suffix({std::move(set_rows)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/softmax.cpp b/src/frontends/gguf/src/op/softmax.cpp
index 13cb89e76bf..886b68697fe 100644
--- a/src/frontends/gguf/src/op/softmax.cpp
+++ b/src/frontends/gguf/src/op/softmax.cpp
@@ -107,10 +107,10 @@ OutputVector translate_soft_max(const NodeContext& context) {
if (!has_mask) {
if (has_sinks) {
res = apply_sinks(context, scaled_input, context.get_input(sinks_input_idx));
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
res = std::make_shared<ov::op::v8::Softmax>(scaled_input, softmax_axis);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
ov::Output<ov::Node> mask_node_sliced;
@@ -161,12 +161,12 @@ OutputVector translate_soft_max(const NodeContext& context) {
if (has_sinks) {
res = apply_sinks(context, biased_input, context.get_input(sinks_input_idx));
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
res = std::make_shared<ov::op::v8::Softmax>(biased_input, softmax_axis);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/sqr.cpp b/src/frontends/gguf/src/op/sqr.cpp
index a346e2036ff..86510bcaa0b 100644
--- a/src/frontends/gguf/src/op/sqr.cpp
+++ b/src/frontends/gguf/src/op/sqr.cpp
@@ -22,7 +22,7 @@ OutputVector translate_sqr(const NodeContext& context) {
auto input = context.get_input(0);
auto res = std::make_shared<ov::op::v1::Multiply>(input, input);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
// GGML_OP_SQRT: element-wise square root.
@@ -31,7 +31,7 @@ OutputVector translate_sqrt(const NodeContext& context) {
auto res = std::make_shared<ov::op::v0::Sqrt>(context.get_input(0));
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/ssm_conv.cpp b/src/frontends/gguf/src/op/ssm_conv.cpp
index 479e5ba7a67..fdba04921cc 100644
--- a/src/frontends/gguf/src/op/ssm_conv.cpp
+++ b/src/frontends/gguf/src/op/ssm_conv.cpp
@@ -58,7 +58,7 @@ OutputVector translate_ssm_conv(const NodeContext& context) {
auto out_shape = ov::op::v0::Constant::create(ov::element::i64, {4}, std::vector<int64_t>{1, n_s, -1, d_inner});
auto res = std::make_shared<ov::op::v1::Reshape>(transposed, out_shape, false);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/sum_rows.cpp b/src/frontends/gguf/src/op/sum_rows.cpp
index 4f4ecdb1a73..7f086a1d602 100644
--- a/src/frontends/gguf/src/op/sum_rows.cpp
+++ b/src/frontends/gguf/src/op/sum_rows.cpp
@@ -25,7 +25,7 @@ OutputVector translate_sum_rows(const NodeContext& context) {
ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {-1}),
true);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/top_k.cpp b/src/frontends/gguf/src/op/top_k.cpp
index af9c53f7955..6982592c849 100644
--- a/src/frontends/gguf/src/op/top_k.cpp
+++ b/src/frontends/gguf/src/op/top_k.cpp
@@ -44,7 +44,7 @@ OutputVector translate_top_k(const NodeContext& context) {
ov::op::v11::TopK::Mode::MAX,
context.get_attribute<ov::element::Type>("output_type"));
- return rename_outputs_with_suffix({indices}, context.get_name());
+ return rename_outputs_with_suffix({std::move(indices)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/transpose.cpp b/src/frontends/gguf/src/op/transpose.cpp
index f1ad7c2a6ed..9d3da3ff086 100644
--- a/src/frontends/gguf/src/op/transpose.cpp
+++ b/src/frontends/gguf/src/op/transpose.cpp
@@ -27,7 +27,7 @@ OutputVector translate_transpose(const NodeContext& context) {
auto res =
std::make_shared<ov::op::v1::Transpose>(context.get_input(0),
ov::op::v0::Constant::create(ov::element::i64, {perm.size()}, perm));
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/tri.cpp b/src/frontends/gguf/src/op/tri.cpp
index 810b0d869f8..05079ca40e9 100644
--- a/src/frontends/gguf/src/op/tri.cpp
+++ b/src/frontends/gguf/src/op/tri.cpp
@@ -72,7 +72,7 @@ OutputVector translate_tri(const NodeContext& context) {
auto res = std::make_shared<ov::op::v1::Multiply>(x, keep_mask);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/unary_elu.cpp b/src/frontends/gguf/src/op/unary_elu.cpp
index 9a7954e1efe..d70575fc4ed 100644
--- a/src/frontends/gguf/src/op/unary_elu.cpp
+++ b/src/frontends/gguf/src/op/unary_elu.cpp
@@ -20,7 +20,7 @@ OutputVector translate_unary_elu(const NodeContext& context) {
// ggml's op_elu is `x > 0 ? x : expm1(x)`, i.e. ELU with alpha fixed at 1; it takes no param.
auto res = std::make_shared<ov::op::v0::Elu>(input, 1.0);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/unary_gelu.cpp b/src/frontends/gguf/src/op/unary_gelu.cpp
index 1f854272187..067f57d9ab0 100644
--- a/src/frontends/gguf/src/op/unary_gelu.cpp
+++ b/src/frontends/gguf/src/op/unary_gelu.cpp
@@ -23,7 +23,7 @@ OutputVector translate_unary_gelu(const NodeContext& context) {
// ggml GELU is the tanh approximation; v7::Gelu defaults to ERF.
auto res = std::make_shared<ov::op::v7::Gelu>(input, ov::op::GeluApproximationMode::TANH);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
OutputVector translate_unary_gelu_quick(const NodeContext& context) {
@@ -36,7 +36,7 @@ OutputVector translate_unary_gelu_quick(const NodeContext& context) {
auto scaled = std::make_shared<ov::op::v1::Multiply>(input, coef);
auto res = std::make_shared<ov::op::v1::Multiply>(input, std::make_shared<ov::op::v0::Sigmoid>(scaled));
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/unary_silu.cpp b/src/frontends/gguf/src/op/unary_silu.cpp
index 4295b8be677..0d6cb14ea91 100644
--- a/src/frontends/gguf/src/op/unary_silu.cpp
+++ b/src/frontends/gguf/src/op/unary_silu.cpp
@@ -21,7 +21,7 @@ OutputVector translate_unary_silu(const NodeContext& context) {
auto sigmoid = std::make_shared<ov::op::v0::Sigmoid>(input);
auto res = std::make_shared<ov::op::v1::Multiply>(input, sigmoid);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/op/view.cpp b/src/frontends/gguf/src/op/view.cpp
index c31b7ef3215..2227d111426 100644
--- a/src/frontends/gguf/src/op/view.cpp
+++ b/src/frontends/gguf/src/op/view.cpp
@@ -67,8 +67,8 @@ void place_dynamic_token_axis(std::vector<int64_t>& tgt, const ov::PartialShape&
OutputVector translate_view(const NodeContext& context) {
num_inputs_check(context, 1, 2);
- const auto output_shape = context.get_output_shape();
- const auto input_shape = context.get_input_shape(0);
+ const auto& output_shape = context.get_output_shape();
+ const auto& input_shape = context.get_input_shape(0);
if ((output_shape.is_static() && ov::shape_size(output_shape.to_shape()) == 0) ||
(input_shape.is_static() && ov::shape_size(input_shape.to_shape()) == 0)) {
// Empty recurrent-cache reorder views have no values and their CPY
@@ -135,9 +135,9 @@ OutputVector translate_view(const NodeContext& context) {
ov::op::v0::Constant::create(ov::element::i64, {tgt.size()}, tgt),
false);
res->set_friendly_name("gdn_view_reshape_" + context.get_name());
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
- return rename_outputs_with_suffix({sliced}, context.get_name());
+ return rename_outputs_with_suffix({std::move(sliced)}, context.get_name());
}
if (context.get_attribute<int>("op_case", 0) == 4) {
// qwen3-next GDN packed output view. The GATED_DELTA_NET result is [1, 1, T + S_v, S_v*H_v]
@@ -177,9 +177,9 @@ OutputVector translate_view(const NodeContext& context) {
std::make_shared<ov::op::v1::Reshape>(sliced,
ov::op::v0::Constant::create(ov::element::i64, {tgt.size()}, tgt),
false);
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
- return rename_outputs_with_suffix({sliced}, context.get_name());
+ return rename_outputs_with_suffix({std::move(sliced)}, context.get_name());
}
if (context.get_attribute<int>("op_case", 0) == 3) {
auto input = context.get_input(0);
@@ -208,7 +208,7 @@ OutputVector translate_view(const NodeContext& context) {
// A one-past-end recurrent cache view represents an empty
// slot-reorder destination. Its CPY consumer is routed to the
// cache base, so no standalone slice is needed.
- return {input};
+ return {std::move(input)};
}
auto begin = ov::op::v0::Constant::create(ov::element::i64, {1}, {start});
// A negative start is an end-anchored TAIL slice (conv_state_last: last d_conv-1 columns
@@ -240,9 +240,9 @@ OutputVector translate_view(const NodeContext& context) {
// still the producer's output, so renaming it here would rename a node owned by another
// ggml tensor (and the suffix compounds, since the helper appends).
if (result == context.get_input(0)) {
- return {result};
+ return {std::move(result)};
}
- return rename_outputs_with_suffix({result}, context.get_name());
+ return rename_outputs_with_suffix({std::move(result)}, context.get_name());
}
// op_case 104 (builder): layer-index slice for per-layer embedding.
// Input [1, n_layer, T, D] -> slice the layer axis (1) -> [1, 1, T, D].
@@ -343,7 +343,7 @@ OutputVector translate_view(const NodeContext& context) {
ov::op::v0::Constant::create(ov::element::i64, {end.size()}, end),
ov::op::v0::Constant::create(ov::element::i64, {step.size()}, step),
ov::op::v0::Constant::create(ov::element::i64, {axes.size()}, axes));
- return rename_outputs_with_suffix({result}, context.get_name());
+ return rename_outputs_with_suffix({std::move(result)}, context.get_name());
}
// A ggml view may start inside a row and continue into the next row while preserving
@@ -369,7 +369,7 @@ OutputVector translate_view(const NodeContext& context) {
ov::op::v0::Constant::create(ov::element::i64, {1}, {2}));
auto target = ov::op::v0::Constant::create(ov::element::i64, {dst_shape.size()}, dst_shape);
auto result = std::make_shared<ov::op::v1::Reshape>(selected, target, false);
- return rename_outputs_with_suffix({result}, context.get_name());
+ return rename_outputs_with_suffix({std::move(result)}, context.get_name());
}
}
}
@@ -420,14 +420,14 @@ OutputVector translate_view(const NodeContext& context) {
ov::op::v0::Constant::create(ov::element::i64, {end.size()}, end),
ov::op::v0::Constant::create(ov::element::i64, {step.size()}, step),
ov::op::v0::Constant::create(ov::element::i64, {axes.size()}, axes));
- return rename_outputs_with_suffix({result}, context.get_name());
+ return rename_outputs_with_suffix({std::move(result)}, context.get_name());
}
}
if (byte_offset == 0 && ov::shape_size(src_shape) == ov::shape_size(dst_shape)) {
auto target = ov::op::v0::Constant::create(ov::element::i64, {dst_shape.size()}, dst_shape);
auto result = std::make_shared<ov::op::v1::Reshape>(context.get_input(0), target, false);
- return rename_outputs_with_suffix({result}, context.get_name());
+ return rename_outputs_with_suffix({std::move(result)}, context.get_name());
}
}
return {context.get_input(0)};
diff --git a/src/frontends/gguf/src/op/weight.cpp b/src/frontends/gguf/src/op/weight.cpp
index 0e49143510c..ffb1dccd6fa 100644
--- a/src/frontends/gguf/src/op/weight.cpp
+++ b/src/frontends/gguf/src/op/weight.cpp
@@ -47,7 +47,7 @@ OutputVector translate_weight(const NodeContext& context) {
FRONT_END_OP_CONVERSION_CHECK(tensors.weight, "GGML_OP_NONE weight leaf has no 'gguf.blob.weight' attribute");
auto qtype = static_cast<GgufTensorType>(context.get_attribute<int>("gguf_qtype"));
auto node = make_weight_node(tensors, qtype, context.get_name());
- return rename_outputs_with_suffix({node}, context.get_name());
+ return rename_outputs_with_suffix({std::move(node)}, context.get_name());
}
// Path 2: raw ggml bytes from a live cgraph decoder.
@@ -71,7 +71,7 @@ OutputVector translate_weight(const NodeContext& context) {
FRONT_END_OP_CONVERSION_CHECK(data.get_byte_size() == n_expert * m * k_blocks * kBlockBytes,
"MXFP4 MoE packed byte size mismatch");
auto packed = std::make_shared<ov::op::v0::Constant>(ov::element::u8, packed_shape, data.data());
- return rename_outputs_with_suffix({packed}, context.get_name());
+ return rename_outputs_with_suffix({std::move(packed)}, context.get_name());
}
// MoE expert weights are rank > 2 ([1, n_expert, m, k]). The dequant path works on a 2D
@@ -84,11 +84,11 @@ OutputVector translate_weight(const NodeContext& context) {
std::vector<int64_t> full(shape.begin(), shape.end());
auto target = ov::op::v0::Constant::create(ov::element::i64, {full.size()}, full);
auto reshaped = std::make_shared<ov::op::v1::Reshape>(node, target, false);
- return rename_outputs_with_suffix({reshaped}, context.get_name());
+ return rename_outputs_with_suffix({std::move(reshaped)}, context.get_name());
}
auto node = make_weight_node(data, quant_type, shape, context.get_name());
- return rename_outputs_with_suffix({node}, context.get_name());
+ return rename_outputs_with_suffix({std::move(node)}, context.get_name());
}
} // namespace op
diff --git a/src/frontends/gguf/src/pass/adapt_to_genai.cpp b/src/frontends/gguf/src/pass/adapt_to_genai.cpp
index a9908d6f0c6..504aa316ccc 100644
--- a/src/frontends/gguf/src/pass/adapt_to_genai.cpp
+++ b/src/frontends/gguf/src/pass/adapt_to_genai.cpp
@@ -376,7 +376,8 @@ bool AdaptToGenAI::run_on_model(const std::shared_ptr<ov::Model>& model) {
// and both layouts hold seq*vocab contiguous values, so collapse everything ahead of vocab into
// the sequence axis with a fixed batch of 1. (batch > 1 is not part of the genai stateful
// contract this pass targets; token_len_per_seq above is likewise a whole-input token count.)
- auto old_result = model->get_results()[0];
+ // Keep ownership while add_results() may reallocate the model's ResultVector below.
+ const std::shared_ptr<ov::op::v0::Result> old_result = model->get_results()[0];
auto logits_src = old_result->input_value(0);
auto vocab = get_dimensions(logits_src, {-1}); // [1]
auto batch_seq_flat = v0::Constant::create(ov::element::i64, {2}, {1, -1});
diff --git a/src/frontends/gguf/src/pass/make_stateful.cpp b/src/frontends/gguf/src/pass/make_stateful.cpp
index d80da4e4f3e..c664a309fc1 100644
--- a/src/frontends/gguf/src/pass/make_stateful.cpp
+++ b/src/frontends/gguf/src/pass/make_stateful.cpp
@@ -110,7 +110,7 @@ static bool make_recurrent_states_stateful(const std::shared_ptr<ov::Model>& mod
if (it == model->get_rt_info().end()) {
return false;
}
- const auto flat = it->second.as<std::vector<std::string>>();
+ const auto& flat = it->second.as<std::vector<std::string>>();
if (flat.empty() || flat.size() % 2 != 0) {
return false;
}
diff --git a/src/frontends/gguf/src/pass/prune_orphaned_parameters.cpp b/src/frontends/gguf/src/pass/prune_orphaned_parameters.cpp
index fede1b156d3..52f443c6bd2 100644
--- a/src/frontends/gguf/src/pass/prune_orphaned_parameters.cpp
+++ b/src/frontends/gguf/src/pass/prune_orphaned_parameters.cpp
@@ -50,7 +50,7 @@ PruneParametersOrphanedSince::PruneParametersOrphanedSince(
bool PruneParametersOrphanedSince::run_on_model(const std::shared_ptr<ov::Model>& model) {
const auto live_after = live_parameters(model);
// remove_parameter() mutates the model's parameter list, so snapshot it before iterating.
- const auto parameters = model->get_parameters();
+ const ov::ParameterVector parameters = model->get_parameters();
bool changed = false;
for (const auto& param : parameters) {
if (m_live_before->count(param.get()) && !live_after.count(param.get())) {
diff --git a/src/frontends/gguf/src/quant/gguf.cpp b/src/frontends/gguf/src/quant/gguf.cpp
index c39716854b4..40cbb9c535d 100644
--- a/src/frontends/gguf/src/quant/gguf.cpp
+++ b/src/frontends/gguf/src/quant/gguf.cpp
@@ -857,20 +857,14 @@ std::map<std::string, GGUFMetaData> decoder_config_from_meta(
const std::string arch = *arch_ptr;
config["architecture"] = arch;
config["layer_num"] = metadata_to_int(metadata, arch + ".block_count");
- config["head_num"] = metadata_to_int(metadata, arch + ".attention.head_count");
- // When key_length is absent, head_size falls back to embedding_length / head_count, which
- // runs before supported_archs() can reject anything; a malformed/adversarial file with
- // head_count == 0 would otherwise be an uncatchable SIGFPE crash rather than a clear error.
- if (!metadata.count(arch + ".attention.key_length")) {
- OPENVINO_ASSERT(std::get<int>(config["head_num"]) > 0,
- "[GGUF] '",
- arch,
- ".attention.head_count' must be positive");
- }
+ const int head_count = metadata_to_int(metadata, arch + ".attention.head_count");
+ // Validate this independently of key_length: head_count is also used by the builder and,
+ // when key_length is absent, is the divisor for the head-size fallback below.
+ OPENVINO_ASSERT(head_count > 0, "[GGUF] '", arch, ".attention.head_count' must be positive");
+ config["head_num"] = head_count;
config["head_size"] = metadata.count(arch + ".attention.key_length")
? metadata_to_int(metadata, arch + ".attention.key_length")
- : (metadata_to_int(metadata, arch + ".embedding_length") /
- metadata_to_int(metadata, arch + ".attention.head_count"));
+ : (metadata_to_int(metadata, arch + ".embedding_length") / head_count);
{
const std::string kv_key = arch + ".attention.head_count_kv";
if (metadata.count(kv_key)) {
diff --git a/src/frontends/gguf/src/quant/gguf_quants.cpp b/src/frontends/gguf/src/quant/gguf_quants.cpp
index ed3fc9e1c66..2aaf99c86f5 100644
--- a/src/frontends/gguf/src/quant/gguf_quants.cpp
+++ b/src/frontends/gguf/src/quant/gguf_quants.cpp
@@ -326,7 +326,12 @@ bool requantize_q8_0_channelwise_faithful(const GgufTensor& tensor,
amax = std::max(amax, std::fabs(rowf[c]));
}
const float d = amax / 127.0f;
- const float id = d ? 1.0f / d : 0.0f;
+ // A zero row has a zero scale and must remain zero. Keep the division in a
+ // branch where its divisor is known to be non-zero.
+ float id = 0.0f;
+ if (d != 0.0f) {
+ id = 1.0f / d;
+ }
out_scales[r] = ov::float16(d);
for (size_t c = 0; c < cols; ++c) {
out_weights[r * cols + c] = static_cast<int8_t>(std::lround(rowf[c] * id));
diff --git a/src/frontends/gguf/src/quant/weights.cpp b/src/frontends/gguf/src/quant/weights.cpp
index 8496eb7723c..798ccbd3324 100644
--- a/src/frontends/gguf/src/quant/weights.cpp
+++ b/src/frontends/gguf/src/quant/weights.cpp
@@ -402,7 +402,12 @@ std::shared_ptr<ov::Node> requantize_q8_0_channelwise(const std::vector<float>&
amax = std::max(amax, std::fabs(x[r * cols + c]));
}
const float d = amax / 127.0f;
- const float id = d ? 1.0f / d : 0.0f;
+ // A zero row has a zero scale and must remain zero. Keep the division in a
+ // branch where its divisor is known to be non-zero.
+ float id = 0.0f;
+ if (d != 0.0f) {
+ id = 1.0f / d;
+ }
s[r] = ov::float16(d);
for (size_t c = 0; c < cols; ++c) {
w[r * cols + c] = static_cast<int8_t>(std::lround(x[r * cols + c] * id));
diff --git a/src/frontends/gguf/src/translate_session.cpp b/src/frontends/gguf/src/translate_session.cpp
index 663b6f6df70..a55e5cc2962 100644
--- a/src/frontends/gguf/src/translate_session.cpp
+++ b/src/frontends/gguf/src/translate_session.cpp
@@ -80,7 +80,10 @@ void add_rope_sin_cos(TensorMap& tensor_map, GgufDecoder& gguf_model_decoder) {
// small cgraph (a single-op test) has no such attribute -> default RopeConfig (n_dims == 0,
// "no RoPE") so the shared table is skipped and the op falls back to its own sin/cos.
const auto rope_config_any = gguf_model_decoder.get_attribute("rope_config");
- const auto rope_config = rope_config_any.empty() ? RopeConfig{} : rope_config_any.as<RopeConfig>();
+ if (rope_config_any.empty()) {
+ return;
+ }
+ const auto& rope_config = rope_config_any.as<RopeConfig>();
// n_dims == 0 means the model uses no RoPE; per_op means each ROPE op builds its own sin/cos
// (e.g. gemma4 where SWA and global layers differ), so skip the shared table entirely.
if (tensor_map.find("inp_pos") == tensor_map.end() || rope_config.n_dims == 0 || rope_config.per_op) {
@@ -133,7 +136,7 @@ std::shared_ptr<Model> TranslateSession::translate_graph(const frontend::InputMo
std::shared_ptr<Model> resulting_model;
const auto& gguf_model = std::dynamic_pointer_cast<InputModel>(input_model);
- std::shared_ptr<GgufDecoder> gguf_model_decoder = gguf_model->get_model_decoder();
+ const auto& gguf_model_decoder = gguf_model->get_model_decoder();
// Auxiliary input Parameters may only get a consumer from a later normalization pass, after
// the unused-Parameter pruning below. Track them so pruning never drops one for lack of a
@@ -172,7 +175,7 @@ std::shared_ptr<Model> TranslateSession::translate_graph(const frontend::InputMo
// lazy (never materialized to f32) and keeps one weight-loading path for both ingest paths.
auto node_visitor = [&](std::shared_ptr<GgufDecoder> decoder) {
- auto operation_type = decoder->get_op_type();
+ const auto& operation_type = decoder->get_op_type();
if (operation_type == "GGML_OP_NONE") {
// A GGML_OP_NONE leaf is a weight if the decoder marks it as one: either the native
// builder's pre-extracted payload (bool "gguf_weight") or the cgraph decoder's raw
@@ -206,7 +209,7 @@ std::shared_ptr<Model> TranslateSession::translate_graph(const frontend::InputMo
" respectively.");
for (size_t i = 0; i < node_output_names.size(); ++i) {
- auto output_name = node_output_names[i];
+ const auto& output_name = node_output_names[i];
if (i < converted_outputs.size() && converted_outputs[i].get_node_shared_ptr() != nullptr) {
(*tensor_map)[output_name] = converted_outputs[i];
}
diff --git a/src/frontends/gguf/src/utils.cpp b/src/frontends/gguf/src/utils.cpp
index 4312943d5c9..c0142b1d226 100644
--- a/src/frontends/gguf/src/utils.cpp
+++ b/src/frontends/gguf/src/utils.cpp
@@ -72,7 +72,7 @@ std::shared_ptr<ov::Node> get_dimensions(const ov::Output<ov::Node>& output, con
return get_dimensions(std::make_shared<ov::op::v3::ShapeOf>(output), dims);
}
-OutputVector rename_outputs_with_suffix(const OutputVector& outputs, const std::string& suffix) {
+OutputVector rename_outputs_with_suffix(OutputVector outputs, const std::string& suffix) {
for (const auto& output : outputs) {
auto node = output.get_node_shared_ptr();
std::string name = node->get_friendly_name();
diff --git a/src/frontends/gguf/src/utils.hpp b/src/frontends/gguf/src/utils.hpp
index a645d62f0ac..6923bb28aa6 100644
--- a/src/frontends/gguf/src/utils.hpp
+++ b/src/frontends/gguf/src/utils.hpp
@@ -50,7 +50,9 @@ std::shared_ptr<ov::Node> get_dimensions(const std::shared_ptr<ov::op::v3::Shape
// Takes the Output rather than the node so a producer with several outputs keeps the right port.
std::shared_ptr<ov::Node> get_dimensions(const ov::Output<ov::Node>& output, const std::vector<int>& dims);
-OutputVector rename_outputs_with_suffix(const OutputVector& outputs, const std::string& suffix);
+// Take ownership of the temporary output vector assembled by translators, rename its producers,
+// then return the same vector without an extra copy.
+OutputVector rename_outputs_with_suffix(OutputVector outputs, const std::string& suffix);
/// \brief Build a TopK over `axis` and return its INDICES port.
///
@@ -85,14 +87,14 @@ template <typename T>
OutputVector translate_1to1_match_1_input(const NodeContext& context) {
num_inputs_check(context, 1, 1);
auto res = std::make_shared<T>(context.get_input(0));
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
template <typename T>
OutputVector translate_1to1_match_2_inputs(const NodeContext& context) {
num_inputs_check(context, 2, 2);
auto res = std::make_shared<T>(context.get_input(0), context.get_input(1));
- return rename_outputs_with_suffix({res}, context.get_name());
+ return rename_outputs_with_suffix({std::move(res)}, context.get_name());
}
} // namespace op