OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[GGUF FE] Default ENABLE_OV_GGUF_FRONTEND to ON (#37571)
Maxim Vafin41454ccb1104
diff --git a/.github/workflows/gguf_llamacpp_validation.yml b/.github/workflows/gguf_llamacpp_validation.ymldeleted file mode 100644index 49d32b219eb..00000000000--- a/.github/workflows/gguf_llamacpp_validation.yml+++ /dev/null@@ -1,120 +0,0 @@-name: GGUF Frontend x llama.cpp validation--# Smart CI: only build/test when the GGUF frontend itself (or this workflow) changes. The-# frontend is consumed directly by llama.cpp's ggml-openvino backend, which has its own, much-# stricter accuracy tolerance (test-backend-ops) than genai; this job is the only place that-# exercises that path against a freshly built frontend before it reaches either consumer.-on:- pull_request:- paths:- - 'src/frontends/gguf/**'- - '.github/workflows/gguf_llamacpp_validation.yml'- push:- branches:- - 'mvafin/gguf/**'- paths:- - 'src/frontends/gguf/**'- workflow_dispatch:- inputs:- llama_cpp_ref:- description: 'llama.cpp commit/branch to test against'- type: string- required: false- default: ''--concurrency:- group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}- cancel-in-progress: true--permissions: read-all--env:- # mvafin/llama.cpp@ov-frontend-swap-llamacpp-sync, pinned to the commit that carries the- # ggml-openvino decoder/backend fixes this frontend snapshot requires. Bump alongside any- # GGUF-frontend change that needs a matching llama.cpp-side update.- LLAMA_CPP_REPO: mvafin/llama.cpp- LLAMA_CPP_REF: 16fb7d9d326a3fe69a331ce5fbe7a679a1a281bb- OV_INSTALL_DIR: ${{ github.workspace }}/ov_install--jobs:- gguf-llamacpp-tests:- name: Build GGUF frontend and run llama.cpp tests- runs-on: ubuntu-24.04- timeout-minutes: 180- steps:- - name: Checkout OpenVINO- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1- with:- submodules: recursive-- - name: Install build dependencies- run: sudo -E ./install_build_dependencies.sh-- - name: Cache ccache- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0- with:- path: ~/.ccache- key: gguf-llamacpp-ccache-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ github.sha }}- restore-keys: |- gguf-llamacpp-ccache-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-- gguf-llamacpp-ccache-${{ runner.os }}--- - name: Configure OpenVINO (CPU plugin + GGUF frontend only)- run: |- cmake -G Ninja -B build \- -DCMAKE_BUILD_TYPE=Release \- -DCMAKE_INSTALL_PREFIX=${{ env.OV_INSTALL_DIR }} \- -DCMAKE_C_COMPILER_LAUNCHER=ccache \- -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \- -DENABLE_INTEL_CPU=ON \- -DENABLE_INTEL_GPU=OFF \- -DENABLE_INTEL_NPU=OFF \- -DENABLE_OV_GGUF_FRONTEND=ON \- -DENABLE_OV_ONNX_FRONTEND=OFF \- -DENABLE_OV_PADDLE_FRONTEND=OFF \- -DENABLE_OV_PYTORCH_FRONTEND=OFF \- -DENABLE_OV_TF_FRONTEND=OFF \- -DENABLE_OV_TF_LITE_FRONTEND=OFF \- -DENABLE_OV_JAX_FRONTEND=OFF \- -DENABLE_SAMPLES=OFF \- -DENABLE_TESTS=OFF \- -DENABLE_PYTHON=OFF \- -DENABLE_WHEEL=OFF \- -DENABLE_DOCS=OFF-- - name: Build and install OpenVINO- run: |- cmake --build build --parallel "$(nproc)"- cmake --install build-- - name: Checkout llama.cpp- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1- with:- repository: ${{ env.LLAMA_CPP_REPO }}- ref: ${{ inputs.llama_cpp_ref || env.LLAMA_CPP_REF }}- path: llama.cpp-- - name: Configure llama.cpp against the freshly built OpenVINO- run: |- source ${{ env.OV_INSTALL_DIR }}/setupvars.sh- cmake -G Ninja -S llama.cpp -B llama.cpp/build \- -DCMAKE_BUILD_TYPE=Release \- -DGGML_OPENVINO=ON-- - name: Build llama.cpp- run: cmake --build llama.cpp/build --parallel "$(nproc)"-- - name: Run llama.cpp tests against the ggml-openvino backend- env:- # Q4_K's zero-point defaults to an integer (u8) constant for production (genai) speed.- # llama.cpp's test-backend-ops compares against an f32 CPU reference within a tolerance- # the rounded u8 zero-point can miss, so request the faithful f16 zero-point here. See- # gguf_zero_point_type in src/frontends/gguf/src/quant/weights.cpp.- OV_GGUF_Q4_K_ZP_F16: "1"- run: |- source ${{ env.OV_INSTALL_DIR }}/setupvars.sh- # test-llama-archs needs an arch fixture this frontend snapshot doesn't carry; excluded- # to match llama.cpp's own upstream CI (see ci/run.sh) until that lands separately.- ctest --test-dir llama.cpp/build -L main \- -E "test-opt|test-llama-archs" \- --output-on-failure --timeout 2000diff --git a/.github/workflows/job_gguf_llamacpp_validation.yml b/.github/workflows/job_gguf_llamacpp_validation.ymlnew file mode 100644index 00000000000..44fde3552cb--- /dev/null+++ b/.github/workflows/job_gguf_llamacpp_validation.yml@@ -0,0 +1,100 @@+name: GGUF Frontend x llama.cpp validation++# The GGUF frontend is consumed directly by llama.cpp's ggml-openvino backend, which has its+# own, much stricter accuracy tolerance (test-backend-ops) than genai; this job is the only+# place that exercises that path, against the frontend already built by this workflow's own+# Build job -- no separate OpenVINO build needed here.+on:+ workflow_call:+ inputs:+ runner:+ description: 'Machine on which the job would run'+ type: string+ required: true+ image:+ description: 'Docker image to use for the job'+ type: string+ required: false+ default: null++permissions: read-all++env:+ # mvafin/llama.cpp@ov-frontend-swap-llamacpp-sync, pinned to the commit that carries the+ # ggml-openvino decoder/backend fixes this frontend snapshot requires. Bump alongside any+ # GGUF-frontend change that needs a matching llama.cpp-side update.+ LLAMA_CPP_REPO: mvafin/llama.cpp+ LLAMA_CPP_REF: 16fb7d9d326a3fe69a331ce5fbe7a679a1a281bb+ INSTALL_DIR: ${{ github.workspace }}/install+ SCCACHE_DIR: ${{ github.workspace }}/.sccache++jobs:+ GGUF_LlamaCpp_Validation:+ name: Build llama.cpp and run its tests against the GGUF frontend+ timeout-minutes: 60+ runs-on: ${{ inputs.runner }}+ container:+ image: ${{ inputs.image }}+ volumes:+ - /mount:/mount+ - ${{ github.workspace }}:${{ github.workspace }} # Needed as ${{ github.workspace }} is not working correctly when using Docker+ defaults:+ run:+ shell: bash+ steps:+ - name: Download OpenVINO package+ uses: akashchi/download-artifact@d59a9c15fec3fdb7c9adf09464124d00f9c11415 # main+ with:+ name: openvino_package+ path: ${{ env.INSTALL_DIR }}++ - name: Extract OpenVINO package+ run: pigz -dc openvino_package.tar.gz | tar -xf - -v+ working-directory: ${{ env.INSTALL_DIR }}++ - name: Cache sccache+ uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ path: ${{ env.SCCACHE_DIR }}+ key: gguf-llamacpp-sccache-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ github.sha }}+ restore-keys: |+ gguf-llamacpp-sccache-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-+ gguf-llamacpp-sccache-${{ runner.os }}-++ - name: Checkout llama.cpp+ uses: ababushk/checkout@dd591a6a2ac25618db4eda86e7e0d938f88cf01b # cherry_pick_retries+ timeout-minutes: 15+ with:+ repository: ${{ env.LLAMA_CPP_REPO }}+ ref: ${{ env.LLAMA_CPP_REF }}+ path: llama.cpp++ - name: Configure llama.cpp against the OpenVINO package+ run: |+ source ${{ env.INSTALL_DIR }}/setupvars.sh+ cmake -G Ninja -S llama.cpp -B llama.cpp/build \+ -DCMAKE_BUILD_TYPE=Release \+ -DCMAKE_C_COMPILER_LAUNCHER=sccache \+ -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \+ -DGGML_OPENVINO=ON++ - name: Build llama.cpp+ run: cmake --build llama.cpp/build --parallel "$(nproc)"++ - name: Show sccache stats+ run: sccache --show-stats++ - name: Run llama.cpp tests against the ggml-openvino backend+ env:+ # Q4_K's zero-point defaults to an integer (u8) constant for production (genai) speed.+ # llama.cpp's test-backend-ops compares against an f32 CPU reference within a tolerance+ # the rounded u8 zero-point can miss, so request the faithful f16 zero-point here. See+ # gguf_zero_point_type in src/frontends/gguf/src/quant/weights.cpp.+ OV_GGUF_Q4_K_ZP_F16: "1"+ run: |+ source ${{ env.INSTALL_DIR }}/setupvars.sh+ # test-llama-archs needs an arch fixture this frontend snapshot doesn't carry; excluded+ # to match llama.cpp's own upstream CI (see ci/run.sh) until that lands separately.+ ctest --test-dir llama.cpp/build -L main \+ -E "test-opt|test-llama-archs" \+ --output-on-failure --timeout 2000diff --git a/.github/workflows/ubuntu_22.yml b/.github/workflows/ubuntu_22.ymlindex 0c6b26e8a37..9dca62f0957 100644--- a/.github/workflows/ubuntu_22.yml+++ b/.github/workflows/ubuntu_22.yml@@ -515,6 +515,15 @@ jobs:model_scope: 'nightly'image: ${{ fromJSON(needs.docker.outputs.images).ov_test.ubuntu_22_04_x64 }}+ GGUF_LlamaCpp_Validation:+ name: GGUF Frontend x llama.cpp validation+ if: ${{ github.event_name != 'schedule' && fromJSON(needs.smart_ci.outputs.affected_components).GGUF_FE.test }}+ needs: [ Docker, Build, Smart_CI ]+ uses: ./.github/workflows/job_gguf_llamacpp_validation.yml+ with:+ runner: 'aks-linux-16-cores-32gb'+ image: ${{ fromJSON(needs.docker.outputs.images).ov_build.ubuntu_22_04_x64 }}+NVIDIA_Plugin:name: NVIDIA pluginneeds: [ Docker, Build, Smart_CI ]diff --git a/cmake/features.cmake b/cmake/features.cmakeindex 382245e3ce7..743240ff139 100644--- a/cmake/features.cmake+++ b/cmake/features.cmake@@ -157,7 +157,7 @@ ov_option(ENABLE_OV_PYTORCH_FRONTEND "Enable PyTorch FrontEnd" ON)ov_option(ENABLE_OV_JAX_FRONTEND "Enable JAX FrontEnd" ON)ov_option(ENABLE_OV_TF_FRONTEND "Enable TensorFlow FrontEnd" ON)ov_option(ENABLE_OV_TF_LITE_FRONTEND "Enable TensorFlow Lite FrontEnd" ON)-ov_option(ENABLE_OV_GGUF_FRONTEND "Enable GGUF FrontEnd" OFF)+ov_option(ENABLE_OV_GGUF_FRONTEND "Enable GGUF FrontEnd" ON)if(WIN32 AND AARCH64 AND CMAKE_CL_64)# Failed: openvino/src/bindings/js/node/thirdparty/node-lib.def: no such file or directorydiff --git a/src/frontends/gguf/include/openvino/frontend/gguf/adapt_to_genai.hpp b/src/frontends/gguf/include/openvino/frontend/gguf/adapt_to_genai.hppindex ca53c581678..5229968b9f3 100644--- a/src/frontends/gguf/include/openvino/frontend/gguf/adapt_to_genai.hpp+++ b/src/frontends/gguf/include/openvino/frontend/gguf/adapt_to_genai.hpp@@ -46,12 +46,12 @@ public:OPENVINO_MODEL_PASS_RTTI("ov::frontend::gguf::pass::AdaptToGenAI");/// \brief Which genai input contract to expose.- /// IdsToLogits : input_ids -> logits (text LLMPipeline). The only mode implemented today.- /// EmbedsToLogits: inputs_embeds -> logits (reserved for the VLM language model, where+ /// IDS_TO_LOGITS : input_ids -> logits (text LLMPipeline). The only mode implemented today.+ /// EMBEDS_TO_LOGITS: inputs_embeds -> logits (reserved for the VLM language model, where/// image+text embeddings are merged outside the graph). Not yet implemented.- enum class InputMode { IdsToLogits, EmbedsToLogits };+ enum class InputMode { IDS_TO_LOGITS, EMBEDS_TO_LOGITS };- explicit AdaptToGenAI(InputMode mode = InputMode::IdsToLogits) : m_mode(mode) {}+ explicit AdaptToGenAI(InputMode mode = InputMode::IDS_TO_LOGITS) : m_mode(mode) {}bool run_on_model(const std::shared_ptr<ov::Model>& model) override;diff --git a/src/frontends/gguf/include/openvino/frontend/gguf/decoder.hpp b/src/frontends/gguf/include/openvino/frontend/gguf/decoder.hppindex 35e2146bd3c..6a02f187098 100644--- a/src/frontends/gguf/include/openvino/frontend/gguf/decoder.hpp+++ b/src/frontends/gguf/include/openvino/frontend/gguf/decoder.hpp@@ -81,10 +81,7 @@ public:// DecoderBase override: GGUF resolves connectivity through the TensorMap (name-keyed),// not through port-to-port decoder traversal, so this is never called.- void get_input_node(size_t,- std::string&,- std::string&,- size_t&) const override {}+ void get_input_node(size_t, std::string&, std::string&, size_t&) const override {}virtual std::vector<std::string> get_input_names() const = 0;diff --git a/src/frontends/gguf/include/openvino/frontend/gguf/set_rows_op.hpp b/src/frontends/gguf/include/openvino/frontend/gguf/set_rows_op.hppindex 4b050900194..2066a866574 100644--- a/src/frontends/gguf/include/openvino/frontend/gguf/set_rows_op.hpp+++ b/src/frontends/gguf/include/openvino/frontend/gguf/set_rows_op.hpp@@ -28,9 +28,7 @@ public:OPENVINO_OP("SetRows", "gguf");SetRows() = default;- SetRows(const ov::Output<ov::Node>& data,- const ov::Output<ov::Node>& indices,- const ov::Output<ov::Node>& dst);+ SetRows(const ov::Output<ov::Node>& data, const ov::Output<ov::Node>& indices, const ov::Output<ov::Node>& dst);void validate_and_infer_types() override;std::shared_ptr<ov::Node> clone_with_new_inputs(const ov::OutputVector& new_args) const override;diff --git a/src/frontends/gguf/src/CMakeLists.txt b/src/frontends/gguf/src/CMakeLists.txtindex fd8c994233e..e5c7a60c0ca 100644--- a/src/frontends/gguf/src/CMakeLists.txt+++ b/src/frontends/gguf/src/CMakeLists.txt@@ -12,7 +12,7 @@ov_add_frontend(NAME ggufLINKABLE_FRONTENDFILEDESCRIPTION "FrontEnd to convert GGUF models"- LINK_LIBRARIES openvino::util openvino::core::dev openvino::offline_transformations)+ LINK_LIBRARIES openvino::util openvino::core::dev)ov_build_target_faster(openvino_gguf_frontend PCH)diff --git a/src/frontends/gguf/src/builder/arch/decoder_builder.cpp b/src/frontends/gguf/src/builder/arch/decoder_builder.cppindex bbaa0f90cfc..7cb7e3256db 100644--- a/src/frontends/gguf/src/builder/arch/decoder_builder.cpp+++ b/src/frontends/gguf/src/builder/arch/decoder_builder.cpp@@ -37,7 +37,7 @@ constexpr int64_t D = -1;DecoderBuilder::DecoderBuilder(const std::map<std::string, GGUFMetaData>& config,std::unordered_map<std::string, ov::Tensor>& weights,- std::unordered_map<std::string, gguf_tensor_type>& qtypes)+ std::unordered_map<std::string, GgufTensorType>& qtypes): m_cfg(config, weights),m_emit(weights, qtypes, m_cfg.arch),m_kv(blocks::KvCachePlan::build(m_cfg)) {@@ -289,7 +289,7 @@ std::string DecoderBuilder::build_layer(int il, const std::string& layer_in) {// real model has no per-layer dense FFN tensors here and dense_ffn's weight_tensor lookup// would assert.const bool is_moe_layer_r = m_cfg.is_moe && (il >= m_cfg.n_dense_lead);- auto down_r = is_moe_layer_r ? blocks::moe_ffn(m_emit, m_cfg, p, ffn_norm_r, T)+ auto down_r = is_moe_layer_r ? blocks::moe_ffn(m_emit, m_cfg, p, ffn_norm_r, T): m_cfg.is_geglu ? blocks::geglu_ffn(m_emit, m_cfg, p, ffn_norm_r, T): blocks::dense_ffn(m_emit, m_cfg, p, ffn_norm_r, T);return m_emit.add_op("GGML_OP_ADD", p + "l_out", {down_r, ffn_inp_r}, ps({1, 1, T, m_cfg.n_embd}), f32);diff --git a/src/frontends/gguf/src/builder/arch/decoder_builder.hpp b/src/frontends/gguf/src/builder/arch/decoder_builder.hppindex 018c8a96b95..9d4e5ec7789 100644--- a/src/frontends/gguf/src/builder/arch/decoder_builder.hpp+++ b/src/frontends/gguf/src/builder/arch/decoder_builder.hpp@@ -36,7 +36,7 @@ class DecoderBuilder : public ModelBuilder {public:DecoderBuilder(const std::map<std::string, GGUFMetaData>& config,std::unordered_map<std::string, ov::Tensor>& weights,- std::unordered_map<std::string, gguf_tensor_type>& qtypes);+ std::unordered_map<std::string, GgufTensorType>& qtypes);std::shared_ptr<GgufGraph> build() override;diff --git a/src/frontends/gguf/src/builder/blocks/gated_delta_net.cpp b/src/frontends/gguf/src/builder/blocks/gated_delta_net.cppindex a073565411f..fd6bdfbcad6 100644--- a/src/frontends/gguf/src/builder/blocks/gated_delta_net.cpp+++ b/src/frontends/gguf/src/builder/blocks/gated_delta_net.cpp@@ -24,9 +24,9 @@ std::string gated_delta_net(GraphEmitter& e,auto& graph = *e.graph();const int64_t d_conv = cfg.ssm_conv_kernel;- const int64_t S = cfg.ssm_state_size; // head_k_dim == head_v_dim- const int64_t H_k = cfg.ssm_group_count; // num_k_heads- const int64_t H_v = cfg.ssm_dt_rank; // num_v_heads+ const int64_t S = cfg.ssm_state_size; // head_k_dim == head_v_dim+ const int64_t H_k = cfg.ssm_group_count; // num_k_heads+ const int64_t H_v = cfg.ssm_dt_rank; // num_v_headsOPENVINO_ASSERT(H_v > 0 && cfg.ssm_inner_size % H_v == 0,"[GGUF] Gated-DeltaNet: ssm_inner_size (",cfg.ssm_inner_size,diff --git a/src/frontends/gguf/src/builder/gguf_builder.cpp b/src/frontends/gguf/src/builder/gguf_builder.cppindex 8a2392304e7..1628f1fe707 100644--- a/src/frontends/gguf/src/builder/gguf_builder.cpp+++ b/src/frontends/gguf/src/builder/gguf_builder.cpp@@ -73,7 +73,7 @@ std::shared_ptr<GgufGraph> build_ggml_graph_from_gguf(const std::string& file) {// Decide the family FIRST: the metadata key layout differs per family, so reading any// decoder hyperparameter before this point would misreport an mmproj file as a broken LLM.const ModelKind kind = detect_model_kind(metadata);- OPENVINO_ASSERT(kind == ModelKind::Decoder,+ OPENVINO_ASSERT(kind == ModelKind::DECODER,"[GGUF] this file holds a ",model_kind_name(kind)," model; the native GGUF builder currently implements the decoder family only. "diff --git a/src/frontends/gguf/src/builder/graph_emitter.cpp b/src/frontends/gguf/src/builder/graph_emitter.cppindex 333422c9560..0c67983a877 100644--- a/src/frontends/gguf/src/builder/graph_emitter.cpp+++ b/src/frontends/gguf/src/builder/graph_emitter.cpp@@ -25,7 +25,7 @@ std::string strip_weight_suffix(const std::string& name) {} // namespaceGraphEmitter::GraphEmitter(std::unordered_map<std::string, ov::Tensor>& weights,- std::unordered_map<std::string, gguf_tensor_type>& qtypes,+ std::unordered_map<std::string, GgufTensorType>& qtypes,std::string arch): m_weights(weights),m_qtypes(qtypes),@@ -128,7 +128,7 @@ void GraphEmitter::add_extra_input_node(const std::string& name, const std::sharvoid GraphEmitter::emit_weight_op(const std::string& node_name,const std::unordered_map<std::string, ov::Tensor>& extracted,- gguf_tensor_type qtype,+ GgufTensorType qtype,const ov::PartialShape& shape_4d) {if (m_emitted_weights.count(node_name)) {return;@@ -171,7 +171,7 @@ void GraphEmitter::add_weight(const std::string& ggml_name) {extracted[base + sub] = it->second;}}- gguf_tensor_type qtype = GGUF_TYPE_F16;+ GgufTensorType qtype = GGUF_TYPE_F16;if (auto it = m_qtypes.find(base + ".qtype"); it != m_qtypes.end()) {qtype = it->second;}@@ -199,7 +199,7 @@ void GraphEmitter::add_weight_from(const std::string& node_name, const std::striextracted[dst_base + sub] = it->second;}}- gguf_tensor_type qtype = GGUF_TYPE_F16;+ GgufTensorType qtype = GGUF_TYPE_F16;if (auto it = m_qtypes.find(src_base + ".qtype"); it != m_qtypes.end()) {qtype = it->second;}@@ -221,9 +221,9 @@ void GraphEmitter::add_named_weight(const std::string& ggml_name) {const ov::Tensor& w = it->second;// Map the OV element type back to the ggml float qtype so translate_weight rebuilds a plain// Constant of the right precision.- gguf_tensor_type qtype = w.get_element_type() == ov::element::f32 ? GGUF_TYPE_F32- : w.get_element_type() == ov::element::bf16 ? GGUF_TYPE_BF16- : GGUF_TYPE_F16;+ GgufTensorType qtype = w.get_element_type() == ov::element::f32 ? GGUF_TYPE_F32+ : w.get_element_type() == ov::element::bf16 ? GGUF_TYPE_BF16+ : GGUF_TYPE_F16;// emit_weight_op re-keys by the last '.'; a bias ends in ".bias", so key it as ".weight"// explicitly (make_weight_node's plain-Constant path reads "<base>.weight").std::unordered_map<std::string, ov::Tensor> extracted{{ggml_name + ".weight", w}};diff --git a/src/frontends/gguf/src/builder/graph_emitter.hpp b/src/frontends/gguf/src/builder/graph_emitter.hppindex ea18ed0b975..1f82682adae 100644--- a/src/frontends/gguf/src/builder/graph_emitter.hpp+++ b/src/frontends/gguf/src/builder/graph_emitter.hpp@@ -41,7 +41,7 @@ public:// `weights` / `qtypes` are the parser's tensor tables; they are referenced, not copied, and// must outlive the emitter.GraphEmitter(std::unordered_map<std::string, ov::Tensor>& weights,- std::unordered_map<std::string, gguf_tensor_type>& qtypes,+ std::unordered_map<std::string, GgufTensorType>& qtypes,std::string arch);// ---- graph under construction ----@@ -66,7 +66,7 @@ public:std::unordered_map<std::string, ov::Tensor>& weights() {return m_weights;}- std::unordered_map<std::string, gguf_tensor_type>& qtypes() {+ std::unordered_map<std::string, GgufTensorType>& qtypes() {return m_qtypes;}@@ -118,7 +118,7 @@ public:// `extracted` maps "<base>.weight"/".scales"/".zp" -> tensor; `qtype` is the ggml type.void emit_weight_op(const std::string& node_name,const std::unordered_map<std::string, ov::Tensor>& extracted,- gguf_tensor_type qtype,+ GgufTensorType qtype,const ov::PartialShape& shape_4d);// `ggml_name` is the full tensor name ending in ".weight" (the name translators reference).@@ -141,7 +141,7 @@ public:private:std::unordered_map<std::string, ov::Tensor>& m_weights;- std::unordered_map<std::string, gguf_tensor_type>& m_qtypes;+ std::unordered_map<std::string, GgufTensorType>& m_qtypes;// Architecture name, used only to make a missing-tensor diagnostic actionable.std::string m_arch;diff --git a/src/frontends/gguf/src/builder/model_kind.cpp b/src/frontends/gguf/src/builder/model_kind.cppindex 8233c295ff5..8f4953bca8a 100644--- a/src/frontends/gguf/src/builder/model_kind.cpp+++ b/src/frontends/gguf/src/builder/model_kind.cpp@@ -43,21 +43,21 @@ ModelKind detect_model_kind(const std::unordered_map<std::string, GGUFMetaData>&// "clip", which is not an LLM architecture name, and reading any "<arch>.block_count"-style// key on it would fail with a misleading "missing config key" error.if (meta_flag(metadata, "clip.has_vision_encoder")) {- return ModelKind::Vision;+ return ModelKind::VISION;}if (meta_flag(metadata, "clip.has_audio_encoder")) {- return ModelKind::Audio;+ return ModelKind::AUDIO;}- return ModelKind::Decoder;+ return ModelKind::DECODER;}const char* model_kind_name(ModelKind kind) {switch (kind) {- case ModelKind::Vision:+ case ModelKind::VISION:return "vision (mmproj)";- case ModelKind::Audio:+ case ModelKind::AUDIO:return "audio (mmproj)";- case ModelKind::Decoder:+ case ModelKind::DECODER:default:return "decoder";}diff --git a/src/frontends/gguf/src/builder/model_kind.hpp b/src/frontends/gguf/src/builder/model_kind.hppindex f543aa4b0aa..a658110cbe5 100644--- a/src/frontends/gguf/src/builder/model_kind.hpp+++ b/src/frontends/gguf/src/builder/model_kind.hpp@@ -22,9 +22,9 @@ namespace gguf {// ...) are data, detected from the tensor table; families are code, one ModelBuilder subclass// each.enum class ModelKind {- Decoder, // causal decoder-only LLM: the "llama family" (dense + MoE + hybrid recurrent)- Vision, // mmproj vision encoder + projector (clip.has_vision_encoder)- Audio, // mmproj audio encoder + projector (clip.has_audio_encoder)+ DECODER, // causal decoder-only LLM: the "llama family" (dense + MoE + hybrid recurrent)+ VISION, // mmproj vision encoder + projector (clip.has_vision_encoder)+ AUDIO, // mmproj audio encoder + projector (clip.has_audio_encoder)};// Classify a parsed GGUF file from its raw metadata.diff --git a/src/frontends/gguf/src/helper_ops/set_rows_op.cpp b/src/frontends/gguf/src/helper_ops/set_rows_op.cppindex c675c3ed60d..1b36605a270 100644--- a/src/frontends/gguf/src/helper_ops/set_rows_op.cpp+++ b/src/frontends/gguf/src/helper_ops/set_rows_op.cpp@@ -8,9 +8,7 @@ namespace ov {namespace frontend {namespace gguf {-SetRows::SetRows(const ov::Output<ov::Node>& data,- const ov::Output<ov::Node>& indices,- const ov::Output<ov::Node>& dst)+SetRows::SetRows(const ov::Output<ov::Node>& data, const ov::Output<ov::Node>& indices, const ov::Output<ov::Node>& dst): ov::op::Op({data, indices, dst}) {constructor_validate_and_infer_types();}diff --git a/src/frontends/gguf/src/op/add_id.cpp b/src/frontends/gguf/src/op/add_id.cppindex 88a230de081..ad6cb716d04 100644--- a/src/frontends/gguf/src/op/add_id.cpp+++ b/src/frontends/gguf/src/op/add_id.cpp@@ -3,6 +3,9 @@//#include <memory>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/core/node.hpp"#include "openvino/core/node_output.hpp"#include "openvino/op/add.hpp"@@ -11,9 +14,6 @@#include "openvino/op/gather.hpp"#include "openvino/op/reshape.hpp"#include "openvino/op/shape_of.hpp"--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {@@ -60,8 +60,10 @@ OutputVector translate_add_id(const NodeContext& context) {auto gather_axis = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {0});ov::Output<ov::Node> selected_bias = std::make_shared<ov::op::v8::Gather>(bias, ids, gather_axis);- selected_bias = std::make_shared<ov::op::v1::Reshape>(- selected_bias, std::make_shared<ov::op::v3::ShapeOf>(input, ov::element::i64), false);+ selected_bias =+ std::make_shared<ov::op::v1::Reshape>(selected_bias,+ std::make_shared<ov::op::v3::ShapeOf>(input, ov::element::i64),+ false);if (selected_bias.get_element_type() != input.get_element_type()) {selected_bias = std::make_shared<ov::op::v0::Convert>(selected_bias, input.get_element_type());diff --git a/src/frontends/gguf/src/op/argsort.cpp b/src/frontends/gguf/src/op/argsort.cppindex 8470ae009cf..346b5663893 100644--- a/src/frontends/gguf/src/op/argsort.cpp+++ b/src/frontends/gguf/src/op/argsort.cpp@@ -3,13 +3,13 @@//#include <memory>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/frontend/exception.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/squeeze.hpp"#include "openvino/op/topk.hpp"--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {diff --git a/src/frontends/gguf/src/op/clamp.cpp b/src/frontends/gguf/src/op/clamp.cppindex 58b6472a6dc..ce6e67b86f1 100644--- a/src/frontends/gguf/src/op/clamp.cpp+++ b/src/frontends/gguf/src/op/clamp.cpp@@ -2,9 +2,10 @@// SPDX-License-Identifier: Apache-2.0//-#include <memory>#include "openvino/op/clamp.hpp"+#include <memory>+#include "node_context.hpp"#include "op_table.hpp"#include "utils.hpp"diff --git a/src/frontends/gguf/src/op/concat.cpp b/src/frontends/gguf/src/op/concat.cppindex a52edaa7b32..c0106856208 100644--- a/src/frontends/gguf/src/op/concat.cpp+++ b/src/frontends/gguf/src/op/concat.cpp@@ -2,13 +2,14 @@// SPDX-License-Identifier: Apache-2.0//-#include <memory>-#include "openvino/frontend/exception.hpp"#include "openvino/op/concat.hpp"-#include "openvino/op/convert.hpp"++#include <memory>#include "node_context.hpp"#include "op_table.hpp"+#include "openvino/frontend/exception.hpp"+#include "openvino/op/convert.hpp"#include "utils.hpp"namespace ov {diff --git a/src/frontends/gguf/src/op/cont.cpp b/src/frontends/gguf/src/op/cont.cppindex 82e68f26ec3..c17ffc02ad7 100644--- a/src/frontends/gguf/src/op/cont.cpp+++ b/src/frontends/gguf/src/op/cont.cpp@@ -2,22 +2,22 @@// SPDX-License-Identifier: Apache-2.0//-#include "node_context.hpp"-#include "op_table.hpp"-#include "utils.hpp"-#include <cstdint>#include <memory>#include <vector>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/reshape.hpp"+#include "utils.hpp"namespace ov {namespace frontend {namespace gguf {namespace op {-OutputVector translate_cont(const NodeContext & context) {+OutputVector translate_cont(const NodeContext& context) {num_inputs_check(context, 1, 1);int op_case = context.get_attribute<int>("op_case", 0);diff --git a/src/frontends/gguf/src/op/cpy.cpp b/src/frontends/gguf/src/op/cpy.cppindex a474b91c35f..d4992234c1f 100644--- a/src/frontends/gguf/src/op/cpy.cpp+++ b/src/frontends/gguf/src/op/cpy.cpp@@ -2,14 +2,13 @@// SPDX-License-Identifier: Apache-2.0//-#include "node_context.hpp"-#include "op_table.hpp"-#include "utils.hpp"-#include <climits>#include <cstdint>#include <memory>#include <vector>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/op/add.hpp"#include "openvino/op/concat.hpp"#include "openvino/op/constant.hpp"@@ -20,33 +19,31 @@#include "openvino/op/reshape.hpp"#include "openvino/op/shape_of.hpp"#include "openvino/op/slice.hpp"+#include "utils.hpp"namespace ov {namespace frontend {namespace gguf {namespace op {-OutputVector translate_cpy(const NodeContext & context) {+OutputVector translate_cpy(const NodeContext& context) {const int op_case = context.get_op_case();const auto input_shape = context.get_input_shape(0);const auto output_shape = context.get_output_shape();- if (op_case == 1 &&- (context.get_input_size() == 1 || !context.has_input(context.get_input_names()[1]))) {+ if (op_case == 1 && (context.get_input_size() == 1 || !context.has_input(context.get_input_names()[1]))) {ov::Output<ov::Node> value = context.get_input(0);// The translated GDN value intentionally has a dynamic packed-row axis, while the CPY's// declared input layout may already be reinterpreted as the destination cache. Get the// actual packed row width directly from the producing GGML tensor metadata.const int64_t packed_width = context.get_attribute<int64_t>("gdn_packed_width", -1);FRONT_END_OP_CONVERSION_CHECK(packed_width > 0, "GDN cache copy requires a static packed-row width");- const int64_t state_rows = static_cast<int64_t>(ov::shape_size(output_shape.to_shape())) /- packed_width;- value = std::make_shared<ov::op::v8::Slice>(- value,- ov::op::v0::Constant::create(ov::element::i64, {1}, {-state_rows}),- ov::op::v0::Constant::create(ov::element::i64, {1}, {INT_MAX}),- ov::op::v0::Constant::create(ov::element::i64, {1}, {1}),- ov::op::v0::Constant::create(ov::element::i64, {1}, {2}));+ const int64_t state_rows = static_cast<int64_t>(ov::shape_size(output_shape.to_shape())) / packed_width;+ value = std::make_shared<ov::op::v8::Slice>(value,+ ov::op::v0::Constant::create(ov::element::i64, {1}, {-state_rows}),+ ov::op::v0::Constant::create(ov::element::i64, {1}, {INT_MAX}),+ ov::op::v0::Constant::create(ov::element::i64, {1}, {1}),+ ov::op::v0::Constant::create(ov::element::i64, {1}, {2}));if (value.get_element_type() != context.get_output_type()) {value = std::make_shared<ov::op::v0::Convert>(value, context.get_output_type());}@@ -64,7 +61,7 @@ OutputVector translate_cpy(const NodeContext & context) {auto base = context.get_input(1);int64_t n_elems = 1;- for (const auto & dim : input_shape.to_shape()) {+ for (const auto& dim : input_shape.to_shape()) {n_elems *= static_cast<int64_t>(dim);}@@ -99,10 +96,13 @@ OutputVector translate_cpy(const NodeContext & context) {const int64_t feature_width = output_shape[3].get_length();auto reshape_writeback = [&](const ov::Output<ov::Node>& value) {auto value_shape = std::make_shared<ov::op::v3::ShapeOf>(value, ov::element::i64);- auto total = std::make_shared<ov::op::v1::ReduceProd>(- value_shape, ov::op::v0::Constant::create(ov::element::i64, {1}, {0}), true);+ auto total =+ std::make_shared<ov::op::v1::ReduceProd>(value_shape,+ ov::op::v0::Constant::create(ov::element::i64, {1}, {0}),+ true);auto rows = std::make_shared<ov::op::v1::Divide>(- total, ov::op::v0::Constant::create(ov::element::i64, {1}, {feature_width}));+ total,+ ov::op::v0::Constant::create(ov::element::i64, {1}, {feature_width}));auto target = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{ov::op::v0::Constant::create(ov::element::i64, {2}, {1, 1}),rows,@@ -118,18 +118,20 @@ OutputVector translate_cpy(const NodeContext & context) {FRONT_END_OP_CONVERSION_CHECK(packed_width > 0, "GDN writeback requires a static packed-row width");const int64_t state_rows = output_shape[3].get_length() / packed_width;auto src_begin = ov::op::v0::Constant::create(ov::element::i64, {1}, {-state_rows});- auto state_part =- std::make_shared<ov::op::v8::Slice>(context.get_input(0), src_begin, int_max, one, axis);+ auto state_part = std::make_shared<ov::op::v8::Slice>(context.get_input(0), src_begin, int_max, one, axis);src = reshape_writeback(state_part);src.get_node_shared_ptr()->set_friendly_name("gdn_writeback_source_" + context.get_name());} else if (op_case == 2) {const int64_t window_size = input_shape[3].get_length();auto src_begin = context.get_input("rs_src_begin_" + writeback_name);- auto src_end = std::make_shared<ov::op::v1::Add>(- src_begin, ov::op::v0::Constant::create(ov::element::i64, {1}, {window_size}));- auto window = std::make_shared<ov::op::v8::Slice>(- context.get_input(0), src_begin, src_end, one,- ov::op::v0::Constant::create(ov::element::i64, {1}, {3}));+ auto src_end =+ std::make_shared<ov::op::v1::Add>(src_begin,+ ov::op::v0::Constant::create(ov::element::i64, {1}, {window_size}));+ auto window = std::make_shared<ov::op::v8::Slice>(context.get_input(0),+ src_begin,+ src_end,+ one,+ ov::op::v0::Constant::create(ov::element::i64, {1}, {3}));src = reshape_writeback(window);src.get_node_shared_ptr()->set_friendly_name("conv_writeback_source_" + context.get_name());} else {@@ -141,9 +143,10 @@ OutputVector translate_cpy(const NodeContext & context) {}auto base = context.get_input(1);- auto src_len = std::make_shared<ov::op::v8::Gather>(- std::make_shared<ov::op::v3::ShapeOf>(src, ov::element::i64), axis,- ov::op::v0::Constant::create(ov::element::i64, {}, {0}));+ auto src_len =+ std::make_shared<ov::op::v8::Gather>(std::make_shared<ov::op::v3::ShapeOf>(src, ov::element::i64),+ axis,+ ov::op::v0::Constant::create(ov::element::i64, {}, {0}));auto end = std::make_shared<ov::op::v1::Add>(begin, src_len);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);@@ -152,14 +155,15 @@ OutputVector translate_cpy(const NodeContext & context) {}ov::Output<ov::Node> res =- std::make_shared<ov::op::v0::Convert>(context.get_input(0), context.get_attribute<ov::element::Type>("output_type"));+ std::make_shared<ov::op::v0::Convert>(context.get_input(0),+ context.get_attribute<ov::element::Type>("output_type"));// A CPY may reinterpret the source layout into its destination's (e.g. qwen3-next's conv-state// writeback flattens the contiguous [S, F] conv_state_last into the flat [S*F] recurrent cache// row). When the destination (output) shape differs from the source but holds the same number of// elements, reshape to the output layout so the model result matches the ggml cache tensor.- const auto & out_ps = context.get_output_shape();- const auto & in_ps = res.get_partial_shape();+ const auto& out_ps = context.get_output_shape();+ const auto& in_ps = res.get_partial_shape();if (out_ps.is_static() && in_ps.is_static() && in_ps != out_ps) {const auto in_shape = in_ps.to_shape();const auto out_shape = out_ps.to_shape();@@ -173,8 +177,10 @@ OutputVector translate_cpy(const NodeContext & context) {// it to the non-empty cache layout would be an invalid element-count change.if (in_elems == out_elems && in_elems != 0) {std::vector<int64_t> tgt(out_shape.begin(), out_shape.end());- res = std::make_shared<ov::op::v1::Reshape>(- res, ov::op::v0::Constant::create(ov::element::i64, {tgt.size()}, tgt), false);+ res =+ std::make_shared<ov::op::v1::Reshape>(res,+ ov::op::v0::Constant::create(ov::element::i64, {tgt.size()}, tgt),+ false);}} else if (out_ps.is_static() && in_ps.rank().is_static() && in_ps != out_ps) {// The input carries a (possibly spurious) dynamic axis but the destination cache row is fully@@ -198,8 +204,10 @@ OutputVector translate_cpy(const NodeContext & context) {// out_elems != 0: an empty destination must not be reshaped (0 % anything == 0).if (has_dyn && in_static != 0 && out_elems != 0 && out_elems % in_static == 0) {std::vector<int64_t> tgt(out_shape.begin(), out_shape.end());- res = std::make_shared<ov::op::v1::Reshape>(- res, ov::op::v0::Constant::create(ov::element::i64, {tgt.size()}, tgt), false);+ res =+ std::make_shared<ov::op::v1::Reshape>(res,+ ov::op::v0::Constant::create(ov::element::i64, {tgt.size()}, tgt),+ false);}}return rename_outputs_with_suffix({res}, context.get_name());diff --git a/src/frontends/gguf/src/op/cumsum.cpp b/src/frontends/gguf/src/op/cumsum.cppindex 34ed59a23e8..136ed507e8c 100644--- a/src/frontends/gguf/src/op/cumsum.cpp+++ b/src/frontends/gguf/src/op/cumsum.cpp@@ -4,11 +4,10 @@#include <memory>-#include "openvino/op/constant.hpp"-#include "openvino/op/cum_sum.hpp"-#include "node_context.hpp"#include "op_table.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/cum_sum.hpp"#include "utils.hpp"namespace ov {diff --git a/src/frontends/gguf/src/op/diag.cpp b/src/frontends/gguf/src/op/diag.cppindex 5df9bdaff8f..8ede7aea6fb 100644--- a/src/frontends/gguf/src/op/diag.cpp+++ b/src/frontends/gguf/src/op/diag.cpp@@ -6,11 +6,10 @@#include <memory>#include <vector>-#include "openvino/op/constant.hpp"-#include "openvino/op/multiply.hpp"-#include "node_context.hpp"#include "op_table.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/multiply.hpp"#include "utils.hpp"namespace ov {diff --git a/src/frontends/gguf/src/op/div.cpp b/src/frontends/gguf/src/op/div.cppindex c0596c1c40b..168b963fc57 100644--- a/src/frontends/gguf/src/op/div.cpp+++ b/src/frontends/gguf/src/op/div.cpp@@ -6,6 +6,8 @@#include <memory>#include <vector>+#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/frontend/exception.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/convert.hpp"@@ -15,9 +17,6 @@#include "openvino/op/sigmoid.hpp"#include "openvino/op/tile.hpp"#include "openvino/op/util/precision_sensitive_attribute.hpp"--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {@@ -89,7 +88,10 @@ ov::Output<ov::Node> repeat_input_to_match(const NodeContext& context,}FRONT_END_OP_CONVERSION_CHECK(input_dim > 0 && target_dim > 0 && target_dim % input_dim == 0,- "DIV input shape ", input_shape, " cannot repeat to match ", target_shape);+ "DIV input shape ",+ input_shape,+ " cannot repeat to match ",+ target_shape);repeats[axis] = target_dim / input_dim;needs_repeat = needs_repeat || repeats[axis] != 1;diff --git a/src/frontends/gguf/src/op/fill.cpp b/src/frontends/gguf/src/op/fill.cppindex f5b64630f3c..516188ba169 100644--- a/src/frontends/gguf/src/op/fill.cpp+++ b/src/frontends/gguf/src/op/fill.cpp@@ -6,12 +6,11 @@#include <memory>#include <vector>+#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/op/broadcast.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/shape_of.hpp"--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {diff --git a/src/frontends/gguf/src/op/gated_delta_net.cpp b/src/frontends/gguf/src/op/gated_delta_net.cppindex bb5dc207137..f668fe159a2 100644--- a/src/frontends/gguf/src/op/gated_delta_net.cpp+++ b/src/frontends/gguf/src/op/gated_delta_net.cpp@@ -2,15 +2,20 @@// SPDX-License-Identifier: Apache-2.0//+#include "openvino/op/gated_delta_net.hpp"+#include <cmath>#include <cstdint>#include <memory>+#include <vector>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/op/add.hpp"#include "openvino/op/broadcast.hpp"#include "openvino/op/concat.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/exp.hpp"-#include "openvino/op/gated_delta_net.hpp"#include "openvino/op/gather.hpp"#include "openvino/op/loop.hpp"#include "openvino/op/matmul.hpp"@@ -22,10 +27,6 @@#include "openvino/op/tile.hpp"#include "openvino/op/transpose.hpp"#include "openvino/op/unsqueeze.hpp"-#include <vector>--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {@@ -103,8 +104,7 @@ OutputVector translate_gated_delta_net(const NodeContext& context) {auto new_state = std::make_shared<ov::op::v1::Reshape>(state_transposed, flat_shape_1d, false);auto packed = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{attn, new_state}, 0);// [1, 1, T*B + S_v*B, S_v*H_v] with the row axis dynamic via -1.- auto out_shape =- ov::op::v0::Constant::create(ov::element::i64, {4}, std::vector<int64_t>{1, 1, -1, S_v * H_v});+ 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());@@ -138,7 +138,7 @@ static OutputVector translate_gated_delta_net_ref(const NodeContext& context) {// T is dynamic at runtime: T-dependent reshapes use -1 and the Loop trip count is read at// runtime, so the convert-time T is only used for the static dims (B/H_v/S_v/H_k).- (void) T;+ (void)T;auto axis_0 = ov::op::v0::Constant::create(ov::element::i64, {1}, {0});auto axis_1 = ov::op::v0::Constant::create(ov::element::i64, {1}, {1});@@ -159,8 +159,10 @@ static OutputVector translate_gated_delta_net_ref(const NodeContext& context) {auto q_unsq = std::make_shared<ov::op::v0::Unsqueeze>(q_t, axis_2);auto k_unsq = std::make_shared<ov::op::v0::Unsqueeze>(k_t, axis_2);auto bcast_shape = ov::op::v0::Constant::create(ov::element::i64, {5}, std::vector<int64_t>{1, 1, rq1, 1, 1});- auto q_bcast = std::make_shared<ov::op::v3::Broadcast>(q_unsq, bcast_shape, ov::op::BroadcastType::BIDIRECTIONAL);- auto k_bcast = std::make_shared<ov::op::v3::Broadcast>(k_unsq, bcast_shape, ov::op::BroadcastType::BIDIRECTIONAL);+ auto q_bcast =+ std::make_shared<ov::op::v3::Broadcast>(q_unsq, bcast_shape, ov::op::BroadcastType::BIDIRECTIONAL);+ auto k_bcast =+ std::make_shared<ov::op::v3::Broadcast>(k_unsq, bcast_shape, ov::op::BroadcastType::BIDIRECTIONAL);auto perm_5d = ov::op::v0::Constant::create(ov::element::i64, {5}, std::vector<int64_t>{0, 2, 1, 3, 4});auto q_transposed = std::make_shared<ov::op::v1::Transpose>(q_bcast, perm_5d);auto k_transposed = std::make_shared<ov::op::v1::Transpose>(k_bcast, perm_5d);@@ -267,8 +269,7 @@ static OutputVector translate_gated_delta_net_ref(const NodeContext& context) {auto packed = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{attn_1d, state_1d}, 0);// [1, 1, -1, S_v*H_v]: the row axis (T*B + S_v*B) is dynamic via -1.- auto out_shape =- ov::op::v0::Constant::create(ov::element::i64, {4}, std::vector<int64_t>{1, 1, -1, S_v * H_v});+ 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());diff --git a/src/frontends/gguf/src/op/get_rows.cpp b/src/frontends/gguf/src/op/get_rows.cppindex f83e74f1605..3810624c6ef 100644--- a/src/frontends/gguf/src/op/get_rows.cpp+++ b/src/frontends/gguf/src/op/get_rows.cpp@@ -34,8 +34,9 @@ OutputVector translate_get_rows(const NodeContext& context) {}if (op_case == 4) {- auto flat_indices = std::make_shared<ov::op::v0::Squeeze>(- indices, ov::op::v0::Constant::create(ov::element::i64, {3}, {0, 1, 2}));+ auto flat_indices =+ std::make_shared<ov::op::v0::Squeeze>(indices,+ ov::op::v0::Constant::create(ov::element::i64, {3}, {0, 1, 2}));auto axis = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {2});res = std::make_shared<ov::op::v8::Gather>(data, flat_indices, axis);if (res.get_element_type() != context.get_output_type()) {diff --git a/src/frontends/gguf/src/op/glu_swiglu.cpp b/src/frontends/gguf/src/op/glu_swiglu.cppindex b0c53eab889..88821b17ec9 100644--- a/src/frontends/gguf/src/op/glu_swiglu.cpp+++ b/src/frontends/gguf/src/op/glu_swiglu.cpp@@ -5,6 +5,10 @@#include <cstdint>#include <limits>#include <memory>+#include <utility>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/core/node_output.hpp"#include "openvino/op/add.hpp"#include "openvino/op/clamp.hpp"@@ -12,10 +16,6 @@#include "openvino/op/multiply.hpp"#include "openvino/op/sigmoid.hpp"#include "openvino/op/slice.hpp"-#include <utility>--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {diff --git a/src/frontends/gguf/src/op/im2col.cpp b/src/frontends/gguf/src/op/im2col.cppindex 1e799186df6..7a341c104c4 100644--- a/src/frontends/gguf/src/op/im2col.cpp+++ b/src/frontends/gguf/src/op/im2col.cpp@@ -5,6 +5,10 @@#include <cstddef>#include <cstdint>#include <memory>+#include <vector>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/core/shape.hpp"#include "openvino/core/strides.hpp"#include "openvino/op/constant.hpp"@@ -14,10 +18,6 @@#include "openvino/op/reshape.hpp"#include "openvino/op/transpose.hpp"#include "openvino/op/util/attr_types.hpp"-#include <vector>--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {@@ -60,7 +60,8 @@ OutputVector translate_im2col(const NodeContext& context) {const size_t N = image_shape[1];const size_t IW = image_shape[3];auto image_reshape_shape = ov::op::v0::Constant::create(- ov::element::i64, ov::Shape{4},+ ov::element::i64,+ ov::Shape{4},std::vector<int64_t>{static_cast<int64_t>(N), static_cast<int64_t>(IC), 1, static_cast<int64_t>(IW)});image = std::make_shared<ov::op::v1::Reshape>(image, image_reshape_shape, false);}@@ -85,24 +86,30 @@ OutputVector translate_im2col(const NodeContext& context) {const size_t N = out_shape[0];const size_t OH = out_shape[1];const size_t OW = out_shape[2];- auto reshape1_shape = ov::op::v0::Constant::create(- ov::element::i64, ov::Shape{5},- std::vector<int64_t>{static_cast<int64_t>(N), static_cast<int64_t>(OH), static_cast<int64_t>(OW),- static_cast<int64_t>(KH * KW), static_cast<int64_t>(IC)});+ auto reshape1_shape = ov::op::v0::Constant::create(ov::element::i64,+ ov::Shape{5},+ std::vector<int64_t>{static_cast<int64_t>(N),+ static_cast<int64_t>(OH),+ static_cast<int64_t>(OW),+ static_cast<int64_t>(KH * KW),+ static_cast<int64_t>(IC)});auto r1 = std::make_shared<ov::op::v1::Reshape>(t1, reshape1_shape, false);auto perm2 = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{5}, std::vector<int64_t>{0, 1, 2, 4, 3});auto t2 = std::make_shared<ov::op::v1::Transpose>(r1, perm2);- auto r2_shape = ov::op::v0::Constant::create(- ov::element::i64, ov::Shape{4},- std::vector<int64_t>{static_cast<int64_t>(N), static_cast<int64_t>(OH), static_cast<int64_t>(OW),- static_cast<int64_t>(IC * KH * KW)});+ auto r2_shape = ov::op::v0::Constant::create(ov::element::i64,+ ov::Shape{4},+ std::vector<int64_t>{static_cast<int64_t>(N),+ static_cast<int64_t>(OH),+ static_cast<int64_t>(OW),+ static_cast<int64_t>(IC * KH * KW)});res = std::make_shared<ov::op::v1::Reshape>(t2, r2_shape, false);if (!is_2D) {auto final_reshape_shape = ov::op::v0::Constant::create(- ov::element::i64, ov::Shape{4},+ ov::element::i64,+ ov::Shape{4},std::vector<int64_t>{1, static_cast<int64_t>(N), static_cast<int64_t>(OW), static_cast<int64_t>(IC * KW)});res = std::make_shared<ov::op::v1::Reshape>(res, final_reshape_shape, false);}diff --git a/src/frontends/gguf/src/op/l2_norm.cpp b/src/frontends/gguf/src/op/l2_norm.cppindex e7596996b74..9fbef9c301f 100644--- a/src/frontends/gguf/src/op/l2_norm.cpp+++ b/src/frontends/gguf/src/op/l2_norm.cpp@@ -3,15 +3,15 @@//#include <memory>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/divide.hpp"#include "openvino/op/maximum.hpp"#include "openvino/op/multiply.hpp"#include "openvino/op/reduce_sum.hpp"#include "openvino/op/sqrt.hpp"--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {@@ -27,8 +27,10 @@ OutputVector translate_l2_norm(const NodeContext& context) {float eps = context.get_attribute<float>("eps");auto squared = std::make_shared<ov::op::v1::Multiply>(input_node, input_node);- auto sum_squared = std::make_shared<ov::op::v1::ReduceSum>(- squared, ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {-1}), true);+ auto sum_squared =+ std::make_shared<ov::op::v1::ReduceSum>(squared,+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {-1}),+ true);auto l2_norm = std::make_shared<ov::op::v0::Sqrt>(sum_squared);auto eps_const = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{1}, {eps});auto clamped_norm = std::make_shared<ov::op::v1::Maximum>(l2_norm, eps_const);diff --git a/src/frontends/gguf/src/op/mul_mat_id.cpp b/src/frontends/gguf/src/op/mul_mat_id.cppindex 23ec998e5b3..8aec8584637 100644--- a/src/frontends/gguf/src/op/mul_mat_id.cpp+++ b/src/frontends/gguf/src/op/mul_mat_id.cpp@@ -6,6 +6,10 @@#include <cstring>#include <limits>#include <memory>+#include <vector>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/op/bitwise_and.hpp"#include "openvino/op/bitwise_right_shift.hpp"#include "openvino/op/broadcast.hpp"@@ -22,10 +26,6 @@#include "openvino/op/unsqueeze.hpp"#include "ov_ops/gather_matmul.hpp"#include "transformations/utils/utils.hpp"-#include <vector>--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {@@ -40,7 +40,10 @@ std::shared_ptr<ov::op::v0::Constant> const_i64(const std::vector<int64_t>& valu}ov::Output<ov::Node> slice_axis(const ov::Output<ov::Node>& input, int64_t axis, int64_t begin, int64_t end) {- return std::make_shared<ov::op::v8::Slice>(input, const_i64({begin}), const_i64({end}), const_i64({1}),+ return std::make_shared<ov::op::v8::Slice>(input,+ const_i64({begin}),+ const_i64({end}),+ const_i64({1}),const_i64({axis}));}@@ -67,30 +70,32 @@ ov::Output<ov::Node> slice_axis(const ov::Output<ov::Node>& input, int64_t axis,// OpenVINO -- and meaningless, as there is nothing to replicate -- whereas here the empty count simply// flows into the token axis and yields an empty result.ov::Output<ov::Node> activations_per_expert(const ov::Output<ov::Node>& activations,- const std::shared_ptr<ov::op::v3::ShapeOf>& activations_shape,- const ov::Output<ov::Node>& ids,- const std::shared_ptr<ov::op::v3::ShapeOf>& ids_shape) {+ const std::shared_ptr<ov::op::v3::ShapeOf>& activations_shape,+ const ov::Output<ov::Node>& ids,+ const std::shared_ptr<ov::op::v3::ShapeOf>& ids_shape) {const auto& acts_ps = activations.get_partial_shape(); // [n_token, 1 | n_used, k], or [1, n_token, k]const auto& ids_ps = ids.get_partial_shape(); // [n_token, n_used]// The expert-axis match alone is ambiguous: the plain 2D layout [1, n_token, k] also satisfies it// when n_token == n_used (the warmup graph). The token axis (1 vs n_token) disambiguates.const bool already_per_expert = acts_ps.rank().is_static() && acts_ps.rank().get_length() == 3 &&ids_ps.rank().is_static() && ids_ps.rank().get_length() == 2 &&- acts_ps[1].is_static() && ids_ps[1].is_static() &&- ids_ps[1].get_length() > 1 && acts_ps[1] == ids_ps[1] &&+ acts_ps[1].is_static() && ids_ps[1].is_static() && ids_ps[1].get_length() > 1 &&+ acts_ps[1] == ids_ps[1] &&(acts_ps[0].is_dynamic() || ids_ps[0].is_dynamic() || acts_ps[0] == ids_ps[0]);ov::Output<ov::Node> rows = activations;if (!already_per_expert) {rows = std::make_shared<ov::op::v1::Reshape>(activations,- std::make_shared<ov::op::v0::Concat>(ov::OutputVector{get_dimensions(ids_shape, {0}), const_i64({1}),+ std::make_shared<ov::op::v0::Concat>(ov::OutputVector{get_dimensions(ids_shape, {0}),+ const_i64({1}),get_dimensions(activations_shape, {2})},0),false);}auto target = std::make_shared<ov::op::v0::Concat>(- ov::OutputVector{get_dimensions(ids_shape, {0, 1}), get_dimensions(activations_shape, {2})}, 0);+ ov::OutputVector{get_dimensions(ids_shape, {0, 1}), get_dimensions(activations_shape, {2})},+ 0);return std::make_shared<ov::op::v3::Broadcast>(rows, target, ov::op::BroadcastType::BIDIRECTIONAL);}@@ -127,8 +132,8 @@ ov::Output<ov::Node> translate_mul_mat_id_mxfp4_packed(const NodeContext& contexauto gather_axis = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {0});- static const std::vector<float> f4e2m1_lut = {0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 3.0f, 4.0f, 6.0f,- -0.0f, -0.5f, -1.0f, -1.5f, -2.0f, -3.0f, -4.0f, -6.0f};+ static const std::vector<float> f4e2m1_lut =+ {0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 3.0f, 4.0f, 6.0f, -0.0f, -0.5f, -1.0f, -1.5f, -2.0f, -3.0f, -4.0f, -6.0f};// Input-independent e8m0 exponent table; build once (was rebuilt per invocation).static const std::vector<float> e8m0_lut = [] {std::vector<float> lut(256);@@ -147,10 +152,14 @@ ov::Output<ov::Node> translate_mul_mat_id_mxfp4_packed(const NodeContext& contexauto selected_packed_weights = std::make_shared<ov::op::v8::Gather>(expert_weights, ids, gather_axis);auto scale_byte = slice_axis(selected_packed_weights, 4, 0, 1);auto qs = slice_axis(selected_packed_weights, 4, 1, 17);- auto low = std::make_shared<ov::op::v13::BitwiseAnd>(- qs, ov::op::v0::Constant::create(ov::element::u8, ov::Shape{}, {0x0F}), ov::op::AutoBroadcastType::NUMPY);+ auto low =+ std::make_shared<ov::op::v13::BitwiseAnd>(qs,+ ov::op::v0::Constant::create(ov::element::u8, ov::Shape{}, {0x0F}),+ ov::op::AutoBroadcastType::NUMPY);auto high_shift = std::make_shared<ov::op::v15::BitwiseRightShift>(- qs, ov::op::v0::Constant::create(ov::element::u8, ov::Shape{}, {4}), ov::op::AutoBroadcastType::NUMPY);+ qs,+ ov::op::v0::Constant::create(ov::element::u8, ov::Shape{}, {4}),+ ov::op::AutoBroadcastType::NUMPY);auto nibbles = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{low, high_shift}, 4);auto nibble_indices = std::make_shared<ov::op::v0::Convert>(nibbles, ov::element::i32);auto weights_f32 = std::make_shared<ov::op::v8::Gather>(f4_lut, nibble_indices, gather_axis);@@ -162,7 +171,8 @@ ov::Output<ov::Node> translate_mul_mat_id_mxfp4_packed(const NodeContext& contexauto ids_shape = std::make_shared<ov::op::v3::ShapeOf>(ids, ov::element::i64);auto selected_weights_target_dims = std::make_shared<ov::op::v0::Concat>(- ov::OutputVector{get_dimensions(ids_shape, {0, 1}), const_i64({rows, cols})}, 0);+ ov::OutputVector{get_dimensions(ids_shape, {0, 1}), const_i64({rows, cols})},+ 0);selected_weights = std::make_shared<ov::op::v1::Reshape>(selected_weights, selected_weights_target_dims, false);auto activations_shape = std::make_shared<ov::op::v3::ShapeOf>(activations, ov::element::i64);@@ -174,8 +184,9 @@ ov::Output<ov::Node> translate_mul_mat_id_mxfp4_packed(const NodeContext& contexauto batch_dim = ov::op::v0::Constant::create(ov::element::i64, {1}, {1});auto row_dim = ov::op::v0::Constant::create(ov::element::i64, {1}, {rows});- auto result_target_dims = std::make_shared<ov::op::v0::Concat>(- ov::OutputVector{batch_dim, get_dimensions(ids_shape, {0, 1}), row_dim}, 0);+ auto result_target_dims =+ std::make_shared<ov::op::v0::Concat>(ov::OutputVector{batch_dim, get_dimensions(ids_shape, {0, 1}), row_dim},+ 0);result = std::make_shared<ov::op::v1::Reshape>(result, result_target_dims, false);const auto output_type = context.get_attribute<ov::element::Type>("output_type");@@ -284,9 +295,8 @@ ov::Output<ov::Node> translate_mul_mat_id_generic(const NodeContext& context,expert_weights = std::make_shared<ov::op::v1::Reshape>(expert_weights,get_dimensions(expert_weights_shape_4d, {1, 2, 3}),false);- activations = std::make_shared<ov::op::v1::Reshape>(activations,- get_dimensions(activations_shape_4d, {1, 2, 3}),- false);+ activations =+ std::make_shared<ov::op::v1::Reshape>(activations, get_dimensions(activations_shape_4d, {1, 2, 3}), false);ids = std::make_shared<ov::op::v1::Reshape>(ids, get_dimensions(ids_shape_4d, {2, 3}), false);if (ids.get_element_type() != ov::element::i32 && ids.get_element_type() != ov::element::i64) {@@ -347,8 +357,9 @@ OutputVector translate_mul_mat_id(const NodeContext& context) {if (expert_weights.get_element_type() == ov::element::u8 && expert_weights.get_partial_shape().rank().is_static() &&expert_weights.get_partial_shape().rank().get_length() == 5) {- return rename_outputs_with_suffix({translate_mul_mat_id_mxfp4_packed(context, expert_weights, activations, ids)},- context.get_name());+ return rename_outputs_with_suffix(+ {translate_mul_mat_id_mxfp4_packed(context, expert_weights, activations, ids)},+ context.get_name());}// The CPU GatherMatmul node requires constant-backed weights. Real .gguf models feed adiff --git a/src/frontends/gguf/src/op/mulmat.cpp b/src/frontends/gguf/src/op/mulmat.cppindex d6852284d49..c0499ab6b1f 100644--- a/src/frontends/gguf/src/op/mulmat.cpp+++ b/src/frontends/gguf/src/op/mulmat.cpp@@ -2,13 +2,13 @@// SPDX-License-Identifier: Apache-2.0//-#include "node_context.hpp"-#include "op_table.hpp"-#include "utils.hpp"-#include <climits>#include <cstdint>#include <memory>+#include <vector>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/core/node.hpp"#include "openvino/core/node_output.hpp"#include "openvino/op/broadcast.hpp"@@ -21,14 +21,14 @@#include "openvino/op/transpose.hpp"#include "openvino/op/unsqueeze.hpp"#include "openvino/op/util/op_types.hpp"-#include <vector>+#include "utils.hpp"namespace ov {namespace frontend {namespace gguf {namespace op {-OutputVector translate_mulmat(const NodeContext & context) {+OutputVector translate_mulmat(const NodeContext& context) {num_inputs_check(context, 2, 2);int op_case = context.get_attribute<int>("op_case", 0);@@ -72,12 +72,15 @@ OutputVector translate_mulmat(const NodeContext & context) {auto unsqueeze_axes = ov::op::v0::Constant::create(ov::element::i64, Shape{}, {2});auto Z_unsqueezed = std::make_shared<ov::op::v0::Unsqueeze>(Z, unsqueeze_axes);- auto broadcast_shape = ov::op::v0::Constant::create(- ov::element::i64, {5}, {(int64_t) 1, (int64_t) 1, factor, (int64_t) 1, (int64_t) 1});- auto new_Z_shape = ov::op::v0::Constant::create(ov::element::i64, {4},- {(int64_t) 0, batch_large, (int64_t) -1, (int64_t) A_shape[3]});+ auto broadcast_shape = ov::op::v0::Constant::create(ov::element::i64,+ {5},+ {(int64_t)1, (int64_t)1, factor, (int64_t)1, (int64_t)1});+ auto new_Z_shape = ov::op::v0::Constant::create(ov::element::i64,+ {4},+ {(int64_t)0, batch_large, (int64_t)-1, (int64_t)A_shape[3]});- auto Z_broadcasted = std::make_shared<ov::op::v3::Broadcast>(Z_unsqueezed, broadcast_shape,+ auto Z_broadcasted = std::make_shared<ov::op::v3::Broadcast>(Z_unsqueezed,+ broadcast_shape,ov::op::BroadcastType::BIDIRECTIONAL);Z = std::make_shared<ov::op::v1::Reshape>(Z_broadcasted, new_Z_shape, true);}diff --git a/src/frontends/gguf/src/op/pad.cpp b/src/frontends/gguf/src/op/pad.cppindex 7b0b02cee41..84d7357d005 100644--- a/src/frontends/gguf/src/op/pad.cpp+++ b/src/frontends/gguf/src/op/pad.cpp@@ -2,18 +2,19 @@// SPDX-License-Identifier: Apache-2.0//+#include "openvino/op/pad.hpp"+#include <array>#include <cstdint>+#include <vector>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/frontend/exception.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/gather.hpp"-#include "openvino/op/pad.hpp"#include "openvino/op/reshape.hpp"#include "openvino/op/shape_of.hpp"-#include <vector>--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {@@ -68,8 +69,14 @@ OutputVector translate_pad(const NodeContext& context) {auto pad_params = context.get_attribute<std::vector<int32_t>>("pad_params");FRONT_END_CHECK_IMPLEMENTED(pad_params.size() >= 8, "PAD requires 8 pad extents");- const std::array<int32_t, 8> pads = {pad_params[0], pad_params[1], pad_params[2], pad_params[3],- pad_params[4], pad_params[5], pad_params[6], pad_params[7]};+ const std::array<int32_t, 8> pads = {pad_params[0],+ pad_params[1],+ pad_params[2],+ pad_params[3],+ pad_params[4],+ pad_params[5],+ pad_params[6],+ pad_params[7]};const bool circular = context.get_attribute<bool>("pad_circular", false);if (circular) {diff --git a/src/frontends/gguf/src/op/permute.cpp b/src/frontends/gguf/src/op/permute.cppindex bf29c2c68f8..c15a340ec32 100644--- a/src/frontends/gguf/src/op/permute.cpp+++ b/src/frontends/gguf/src/op/permute.cpp@@ -53,12 +53,11 @@ OutputVector translate_permute(const NodeContext& context) {// this costs no extra data movement.auto neg_one = ov::op::v0::Constant::create(ov::element::i64, {1}, {-1});auto src_shape = std::make_shared<ov::op::v3::ShapeOf>(src, ov::element::i64);- auto seq_count = std::make_shared<ov::op::v8::Gather>(- src_shape,- ov::op::v0::Constant::create(ov::element::i64, {1}, {0}),- ov::op::v0::Constant::create(ov::element::i64, {}, {0}));- auto seq_pattern =- std::make_shared<ov::op::v0::Concat>(ov::OutputVector{seq_count, neg_one}, 0);+ auto seq_count =+ std::make_shared<ov::op::v8::Gather>(src_shape,+ ov::op::v0::Constant::create(ov::element::i64, {1}, {0}),+ ov::op::v0::Constant::create(ov::element::i64, {}, {0}));+ auto seq_pattern = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{seq_count, neg_one}, 0);auto by_seq = std::make_shared<ov::op::v1::Reshape>(src, seq_pattern, false);auto head_pattern =@@ -100,11 +99,11 @@ OutputVector translate_permute(const NodeContext& context) {} else {const int64_t start = context.get_attribute<int64_t>("view_seq_offset", 0);seq_active_start = ov::op::v0::Constant::create(ov::element::i64, {1}, {start});- seq_active_end = ov::op::v0::Constant::create(- ov::element::i64, {1}, {start + static_cast<int64_t>(output_shape[0])});+ seq_active_end = ov::op::v0::Constant::create(ov::element::i64,+ {1},+ {start + static_cast<int64_t>(output_shape[0])});}- active_cache = std::make_shared<ov::op::v8::Slice>(- src, seq_active_start, seq_active_end, one, zero);+ 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());diff --git a/src/frontends/gguf/src/op/repeat.cpp b/src/frontends/gguf/src/op/repeat.cppindex 96c7c74ddbd..cfce4f44a7c 100644--- a/src/frontends/gguf/src/op/repeat.cpp+++ b/src/frontends/gguf/src/op/repeat.cpp@@ -3,15 +3,15 @@//#include <memory>+#include <vector>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/frontend/exception.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/divide.hpp"#include "openvino/op/shape_of.hpp"#include "openvino/op/tile.hpp"-#include <vector>--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {diff --git a/src/frontends/gguf/src/op/reshape.cpp b/src/frontends/gguf/src/op/reshape.cppindex f92ce097773..52419a831a4 100644--- a/src/frontends/gguf/src/op/reshape.cpp+++ b/src/frontends/gguf/src/op/reshape.cpp@@ -2,21 +2,22 @@// SPDX-License-Identifier: Apache-2.0//-#include "node_context.hpp"-#include "op_table.hpp"-#include "utils.hpp"+#include "openvino/op/reshape.hpp"#include <cstdint>#include <memory>+#include <stdexcept>+#include <vector>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/core/node.hpp"#include "openvino/core/node_output.hpp"#include "openvino/frontend/exception.hpp"#include "openvino/op/concat.hpp"#include "openvino/op/constant.hpp"-#include "openvino/op/reshape.hpp"#include "openvino/op/transpose.hpp"-#include <stdexcept>-#include <vector>+#include "utils.hpp"namespace ov {namespace frontend {@@ -109,10 +110,9 @@ OutputVector translate_reshape(const NodeContext& context) {} else if (op_case == 7) {// General fully-static reshape (no dynamic token axis): reshape straight to the static// output shape. Used by qwen3-next's recurrent-state predelta reshape [262144]->[16,128,128].- new_shape_node = ov::op::v0::Constant::create(- ov::element::i64, {output_shape.size()},- std::vector<int64_t>(output_shape.begin(), output_shape.end()));-+ new_shape_node = ov::op::v0::Constant::create(ov::element::i64,+ {output_shape.size()},+ 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());diff --git a/src/frontends/gguf/src/op/rope.cpp b/src/frontends/gguf/src/op/rope.cppindex d2f91d50c72..978ecd7e3e9 100644--- a/src/frontends/gguf/src/op/rope.cpp+++ b/src/frontends/gguf/src/op/rope.cpp@@ -2,13 +2,16 @@// SPDX-License-Identifier: Apache-2.0//+#include "openvino/decompositions/rope.hpp"+#include <cstdint>#include <memory>#include <vector>+#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/core/node.hpp"#include "openvino/core/node_output.hpp"-#include "openvino/decompositions/rope.hpp"#include "openvino/frontend/exception.hpp"#include "openvino/op/add.hpp"#include "openvino/op/broadcast.hpp"@@ -27,9 +30,6 @@#include "openvino/op/transpose.hpp"#include "openvino/op/unsqueeze.hpp"#include "openvino/pass/node_registry.hpp"--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {@@ -99,7 +99,7 @@ OutputVector translate_rope(const NodeContext& context) {// folds this subgraph into ov::op::internal::RoPE → GPU ocl::rope::opt kernel.// RoPEFusionFlux requires rank-4 x with static last two dims [n_heads, head_size].// After the VIEW prologue the data is already [B,L,n_heads,head_size].- const int64_t n_heads = static_cast<int64_t>(output_shape[2]);+ const int64_t n_heads = static_cast<int64_t>(output_shape[2]);const int64_t head_size = static_cast<int64_t>(output_shape[3]);const int64_t n_rot = rope_config.n_dims > 0 ? rope_config.n_dims : head_size;const int64_t half = n_rot / 2;@@ -132,20 +132,20 @@ OutputVector translate_rope(const NodeContext& context) {auto x1_neg = std::make_shared<ov::op::v1::Multiply>(x1, neg_one_f);auto x_rotated_paired = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{x1_neg, x0}, -1);- auto rotary_shape = ov::op::v0::Constant::create(- ov::element::i64, {4}, std::vector<int64_t>{0, -1, n_heads, n_rot});+ auto rotary_shape =+ ov::op::v0::Constant::create(ov::element::i64, {4}, std::vector<int64_t>{0, -1, n_heads, n_rot});auto x_rotated = std::make_shared<ov::op::v1::Reshape>(x_rotated_paired, rotary_shape, true);// Expand cos/sin from [B, L, 1, half] to [B, L, 1, head_size].auto expand_cos_sin = [&](ov::Output<ov::Node> cs) -> ov::Output<ov::Node> {- auto cs_unsq = std::make_shared<ov::op::v0::Unsqueeze>(- cs, ov::op::v0::Constant::create(ov::element::i64, {1}, {-1LL}));- auto bcast_target = ov::op::v0::Constant::create(- ov::element::i64, {5}, std::vector<int64_t>{1, 1, 1, half, 2});- auto bcast = std::make_shared<ov::op::v3::Broadcast>(- cs_unsq, bcast_target, ov::op::BroadcastType::BIDIRECTIONAL);- auto flat = ov::op::v0::Constant::create(- ov::element::i64, {4}, std::vector<int64_t>{0, 0, 0, n_rot});+ auto cs_unsq =+ std::make_shared<ov::op::v0::Unsqueeze>(cs,+ ov::op::v0::Constant::create(ov::element::i64, {1}, {-1LL}));+ auto bcast_target =+ ov::op::v0::Constant::create(ov::element::i64, {5}, std::vector<int64_t>{1, 1, 1, half, 2});+ auto bcast =+ std::make_shared<ov::op::v3::Broadcast>(cs_unsq, bcast_target, ov::op::BroadcastType::BIDIRECTIONAL);+ auto flat = ov::op::v0::Constant::create(ov::element::i64, {4}, std::vector<int64_t>{0, 0, 0, n_rot});return std::make_shared<ov::op::v1::Reshape>(bcast, flat, /*special_zero=*/true);};auto cos_full = expand_cos_sin(cos_theta_node);@@ -154,9 +154,8 @@ OutputVector translate_rope(const NodeContext& context) {auto y1 = std::make_shared<ov::op::v1::Multiply>(rotary_data, cos_full);auto y2 = std::make_shared<ov::op::v1::Multiply>(x_rotated, sin_full);ov::Output<ov::Node> rotated = std::make_shared<ov::op::v1::Add>(y1, y2);- res = n_rot < head_size- ? std::make_shared<ov::op::v0::Concat>(ov::OutputVector{rotated, pass_through}, -1)- : rotated;+ res = n_rot < head_size ? std::make_shared<ov::op::v0::Concat>(ov::OutputVector{rotated, pass_through}, -1)+ : rotated;} else if (mode == TYPE_NEOX) {// Partial rotary (ggml n_dims < head_dim): only the first n_dims of every head are// rotated; the remaining tail is passed through unchanged. cos/sin have width n_dims/2,@@ -166,20 +165,19 @@ OutputVector translate_rope(const NodeContext& context) {// Split the head into the rotated block [0, n_rot) and the untouched tail [n_rot, head_dim)// on the innermost axis. Both branches below rotate `rotary_in` and re-concatenate the tail.- auto split_rotary = [&](ov::Output<ov::Node> x,- ov::Output<ov::Node>& rotary_in,- ov::Output<ov::Node>& pass_through) {- rotary_in = x;- if (n_rot < head_dim) {- auto neg_one = ov::op::v0::Constant::create(ov::element::i64, {1}, {-1});- auto zero = ov::op::v0::Constant::create(ov::element::i64, {1}, {0});- auto one = ov::op::v0::Constant::create(ov::element::i64, {1}, {1});- auto n_rot_c = ov::op::v0::Constant::create(ov::element::i64, {1}, {n_rot});- auto head_c = ov::op::v0::Constant::create(ov::element::i64, {1}, {head_dim});- rotary_in = std::make_shared<ov::op::v8::Slice>(x, zero, n_rot_c, one, neg_one);- pass_through = std::make_shared<ov::op::v8::Slice>(x, n_rot_c, head_c, one, neg_one);- }- };+ auto split_rotary =+ [&](ov::Output<ov::Node> x, ov::Output<ov::Node>& rotary_in, ov::Output<ov::Node>& pass_through) {+ rotary_in = x;+ if (n_rot < head_dim) {+ auto neg_one = ov::op::v0::Constant::create(ov::element::i64, {1}, {-1});+ auto zero = ov::op::v0::Constant::create(ov::element::i64, {1}, {0});+ auto one = ov::op::v0::Constant::create(ov::element::i64, {1}, {1});+ auto n_rot_c = ov::op::v0::Constant::create(ov::element::i64, {1}, {n_rot});+ auto head_c = ov::op::v0::Constant::create(ov::element::i64, {1}, {head_dim});+ rotary_in = std::make_shared<ov::op::v8::Slice>(x, zero, n_rot_c, one, neg_one);+ pass_through = std::make_shared<ov::op::v8::Slice>(x, n_rot_c, head_c, one, neg_one);+ }+ };// Build the canonical NEOX RoPE via the shared decomposition helper, which emits the exact// split-halves + Multiply(-1)+Add + Concat pattern that ov::pass::RoPEFusion (specifically@@ -213,7 +211,7 @@ OutputVector translate_rope(const NodeContext& context) {return std::make_shared<ov::op::v1::Transpose>(x, perm_bhls);};- auto x_bhls = data_to_bhls(data); // [B, H, L, S]+ auto x_bhls = data_to_bhls(data); // [B, H, L, S]auto cos_bhls = cossin_to_bhls(cos_theta_node); // [B, 1, L, n_rot/2]auto sin_bhls = cossin_to_bhls(sin_theta_node); // [B, 1, L, n_rot/2]diff --git a/src/frontends/gguf/src/op/scale.cpp b/src/frontends/gguf/src/op/scale.cppindex ae614a8350a..f45d5ebada2 100644--- a/src/frontends/gguf/src/op/scale.cpp+++ b/src/frontends/gguf/src/op/scale.cpp@@ -3,15 +3,15 @@//#include <climits>+#include <vector>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/op/add.hpp"#include "openvino/op/concat.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/multiply.hpp"#include "openvino/op/slice.hpp"-#include <vector>--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {diff --git a/src/frontends/gguf/src/op/set.cpp b/src/frontends/gguf/src/op/set.cppindex d38326f8fff..b45d0723c43 100644--- a/src/frontends/gguf/src/op/set.cpp+++ b/src/frontends/gguf/src/op/set.cpp@@ -5,6 +5,8 @@#include <cstdint>#include <memory>+#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/op/add.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/convert.hpp"@@ -13,9 +15,6 @@#include "openvino/op/reshape.hpp"#include "openvino/op/scatter_update.hpp"#include "openvino/op/shape_of.hpp"--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {@@ -43,15 +42,16 @@ OutputVector translate_set(const NodeContext& context) {const int64_t offset_elems = context.get_attribute<int64_t>("set_offset_elems");- auto dst_flat = std::make_shared<ov::op::v1::Reshape>(- dst, ov::op::v0::Constant::create(ov::element::i64, {1}, {-1}), false);- auto src_flat = std::make_shared<ov::op::v1::Reshape>(- src, ov::op::v0::Constant::create(ov::element::i64, {1}, {-1}), false);+ auto dst_flat =+ std::make_shared<ov::op::v1::Reshape>(dst, ov::op::v0::Constant::create(ov::element::i64, {1}, {-1}), false);+ auto src_flat =+ std::make_shared<ov::op::v1::Reshape>(src, ov::op::v0::Constant::create(ov::element::i64, {1}, {-1}), false);// Indices [offset, offset + numel(src)) into the flattened destination.auto src_shape = std::make_shared<ov::op::v3::ShapeOf>(src_flat, ov::element::i64);- auto src_len = std::make_shared<ov::op::v1::ReduceProd>(- src_shape, ov::op::v0::Constant::create(ov::element::i64, {1}, {0}), false);+ auto src_len = std::make_shared<ov::op::v1::ReduceProd>(src_shape,+ ov::op::v0::Constant::create(ov::element::i64, {1}, {0}),+ false);auto start = ov::op::v0::Constant::create(ov::element::i64, {}, {offset_elems});auto stop = std::make_shared<ov::op::v1::Add>(start, src_len);auto step = ov::op::v0::Constant::create(ov::element::i64, {}, {1});diff --git a/src/frontends/gguf/src/op/set_rows.cpp b/src/frontends/gguf/src/op/set_rows.cppindex 48bf85f1985..2a9e76b9d30 100644--- a/src/frontends/gguf/src/op/set_rows.cpp+++ b/src/frontends/gguf/src/op/set_rows.cpp@@ -2,19 +2,19 @@// SPDX-License-Identifier: Apache-2.0//-#include "node_context.hpp"-#include "op_table.hpp"-#include "openvino/frontend/gguf/set_rows_op.hpp"-#include "utils.hpp"-#include <cstdint>#include <memory>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/core/node.hpp"#include "openvino/frontend/exception.hpp"+#include "openvino/frontend/gguf/set_rows_op.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/convert.hpp"#include "openvino/op/reshape.hpp"#include "openvino/op/squeeze.hpp"+#include "utils.hpp"namespace ov {namespace frontend {@@ -26,7 +26,7 @@ namespace op {// ScatterUpdate form; a caller-registered stateful lowering may instead turn the SetRows that// feeds attention into a stateful KV-cache subgraph. This keeps conversion identical regardless// of execution mode and needs no KV-vs-non-KV classification at translate time.-OutputVector translate_set_rows(const NodeContext & context) {+OutputVector translate_set_rows(const NodeContext& context) {num_inputs_check(context, 3, 3);auto data = context.get_input(0);diff --git a/src/frontends/gguf/src/op/softmax.cpp b/src/frontends/gguf/src/op/softmax.cppindex d8f7d3be0b3..13cb89e76bf 100644--- a/src/frontends/gguf/src/op/softmax.cpp+++ b/src/frontends/gguf/src/op/softmax.cpp@@ -2,9 +2,15 @@// SPDX-License-Identifier: Apache-2.0//+#include "openvino/op/softmax.hpp"+#include <cmath>#include <cstdint>#include <memory>+#include <vector>++#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/core/node.hpp"#include "openvino/core/node_output.hpp"#include "openvino/frontend/exception.hpp"@@ -17,11 +23,6 @@#include "openvino/op/reshape.hpp"#include "openvino/op/shape_of.hpp"#include "openvino/op/slice.hpp"-#include "openvino/op/softmax.hpp"-#include <vector>--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {@@ -146,13 +147,12 @@ OutputVector translate_soft_max(const NodeContext& context) {const float m1 = std::pow(2.0f, -(max_bias / 2.0f) / static_cast<float>(n_head_log2));std::vector<float> slopes(n_head);for (uint32_t h = 0; h < n_head; ++h) {- slopes[h] = h < n_head_log2 ? std::pow(m0, static_cast<float>(h + 1)) : std::pow(m1, static_cast<float>(2 * (h - n_head_log2) + 1));+ slopes[h] = h < n_head_log2 ? std::pow(m0, static_cast<float>(h + 1))+ : std::pow(m1, static_cast<float>(2 * (h - n_head_log2) + 1));}ov::Shape slope_shape(rank, 1);slope_shape[head_axis] = n_head;- auto slope_node = std::make_shared<ov::op::v0::Constant>(output_type,- slope_shape,- slopes);+ auto slope_node = std::make_shared<ov::op::v0::Constant>(output_type, slope_shape, slopes);auto slope_mask = std::make_shared<ov::op::v1::Multiply>(mask_node_sliced, slope_node);biased_input = std::make_shared<ov::op::v1::Add>(scaled_input, slope_mask);} else {diff --git a/src/frontends/gguf/src/op/sqr.cpp b/src/frontends/gguf/src/op/sqr.cppindex 1c886348335..a346e2036ff 100644--- a/src/frontends/gguf/src/op/sqr.cpp+++ b/src/frontends/gguf/src/op/sqr.cpp@@ -4,11 +4,10 @@#include <memory>-#include "openvino/op/multiply.hpp"-#include "openvino/op/sqrt.hpp"-#include "node_context.hpp"#include "op_table.hpp"+#include "openvino/op/multiply.hpp"+#include "openvino/op/sqrt.hpp"#include "utils.hpp"namespace ov {diff --git a/src/frontends/gguf/src/op/ssm_conv.cpp b/src/frontends/gguf/src/op/ssm_conv.cppindex f559f50769f..479e5ba7a67 100644--- a/src/frontends/gguf/src/op/ssm_conv.cpp+++ b/src/frontends/gguf/src/op/ssm_conv.cpp@@ -2,14 +2,14 @@// SPDX-License-Identifier: Apache-2.0//-#include "openvino/op/constant.hpp"-#include "openvino/op/group_conv.hpp"-#include "openvino/op/reshape.hpp"-#include "openvino/op/transpose.hpp"#include <vector>#include "node_context.hpp"#include "op_table.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/group_conv.hpp"+#include "openvino/op/reshape.hpp"+#include "openvino/op/transpose.hpp"#include "utils.hpp"namespace ov {@@ -43,8 +43,12 @@ OutputVector translate_ssm_conv(const NodeContext& context) {auto c_new_shape = ov::op::v0::Constant::create(ov::element::i64, {4}, std::vector<int64_t>{d_inner, 1, 1, d_conv});auto c_reshaped = std::make_shared<ov::op::v1::Reshape>(c, c_new_shape, false);- auto conv = std::make_shared<ov::op::v1::GroupConvolution>(- sx_reshaped, c_reshaped, ov::Strides{1}, ov::CoordinateDiff{0}, ov::CoordinateDiff{0}, ov::Strides{1});+ auto conv = std::make_shared<ov::op::v1::GroupConvolution>(sx_reshaped,+ c_reshaped,+ ov::Strides{1},+ ov::CoordinateDiff{0},+ ov::CoordinateDiff{0},+ ov::Strides{1});// [n_s, d_inner, n_t] -> [n_s, n_t, d_inner]auto perm = ov::op::v0::Constant::create(ov::element::i64, {3}, std::vector<int64_t>{0, 2, 1});diff --git a/src/frontends/gguf/src/op/sum_rows.cpp b/src/frontends/gguf/src/op/sum_rows.cppindex be880181c61..4f4ecdb1a73 100644--- a/src/frontends/gguf/src/op/sum_rows.cpp+++ b/src/frontends/gguf/src/op/sum_rows.cpp@@ -3,11 +3,11 @@//#include <memory>-#include "openvino/op/constant.hpp"-#include "openvino/op/reduce_sum.hpp"#include "node_context.hpp"#include "op_table.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/reduce_sum.hpp"#include "utils.hpp"namespace ov {@@ -20,8 +20,10 @@ OutputVector translate_sum_rows(const NodeContext& context) {num_inputs_check(context, 1, 1);auto input = context.get_input(0);- auto res = std::make_shared<ov::op::v1::ReduceSum>(- input, ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {-1}), true);+ auto res =+ std::make_shared<ov::op::v1::ReduceSum>(input,+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {-1}),+ true);return rename_outputs_with_suffix({res}, context.get_name());}diff --git a/src/frontends/gguf/src/op/top_k.cpp b/src/frontends/gguf/src/op/top_k.cppindex 19b38fb82f1..af9c53f7955 100644--- a/src/frontends/gguf/src/op/top_k.cpp+++ b/src/frontends/gguf/src/op/top_k.cpp@@ -30,9 +30,8 @@ OutputVector translate_top_k(const NodeContext& context) {const int64_t axis = rank.is_static() ? rank.get_length() - 1 : -1;ov::Output<ov::Node> k_node;if (rank.is_static() && out_ps[rank.get_length() - 1].is_static()) {- k_node = ov::op::v0::Constant::create(ov::element::i64,- ov::Shape{},- {out_ps[rank.get_length() - 1].get_length()});+ k_node =+ ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {out_ps[rank.get_length() - 1].get_length()});} else {k_node = std::make_shared<ov::op::v0::Squeeze>(get_dimensions(input, {static_cast<int>(rank.is_static() ? rank.get_length() - 1 : 3)}),diff --git a/src/frontends/gguf/src/op/transpose.cpp b/src/frontends/gguf/src/op/transpose.cppindex 0933b986a8f..f1ad7c2a6ed 100644--- a/src/frontends/gguf/src/op/transpose.cpp+++ b/src/frontends/gguf/src/op/transpose.cpp@@ -3,6 +3,7 @@//#include "openvino/op/transpose.hpp"+#include <vector>#include "node_context.hpp"@@ -23,9 +24,9 @@ OutputVector translate_transpose(const NodeContext& context) {// (e.g. single-op tests), matching ggml's plain GGML_OP_TRANSPOSE.auto perm = context.get_attribute<std::vector<int64_t>>("perm", {0, 1, 3, 2});- auto res = std::make_shared<ov::op::v1::Transpose>(- context.get_input(0),- ov::op::v0::Constant::create(ov::element::i64, {perm.size()}, perm));+ 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());}diff --git a/src/frontends/gguf/src/op/tri.cpp b/src/frontends/gguf/src/op/tri.cppindex d4e14421939..810b0d869f8 100644--- a/src/frontends/gguf/src/op/tri.cpp+++ b/src/frontends/gguf/src/op/tri.cpp@@ -6,12 +6,11 @@#include <memory>#include <vector>+#include "node_context.hpp"+#include "op_table.hpp"#include "openvino/frontend/exception.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/multiply.hpp"--#include "node_context.hpp"-#include "op_table.hpp"#include "utils.hpp"namespace ov {@@ -48,10 +47,18 @@ OutputVector translate_tri(const NodeContext& context) {for (size_t col = 0; col < n; ++col) {bool keep = false;switch (tri_type) {- case 0: keep = col >= row; break; // UPPER_DIAG- case 1: keep = col > row; break; // UPPER- case 2: keep = col <= row; break; // LOWER_DIAG- case 3: keep = col < row; break; // LOWER+ case 0:+ keep = col >= row;+ break; // UPPER_DIAG+ case 1:+ keep = col > row;+ break; // UPPER+ case 2:+ keep = col <= row;+ break; // LOWER_DIAG+ case 3:+ keep = col < row;+ break; // LOWERdefault:FRONT_END_GENERAL_CHECK(false, "translate_tri: invalid tri_type ", tri_type);}diff --git a/src/frontends/gguf/src/op/unary_gelu.cpp b/src/frontends/gguf/src/op/unary_gelu.cppindex 51ea9c14a95..1f854272187 100644--- a/src/frontends/gguf/src/op/unary_gelu.cpp+++ b/src/frontends/gguf/src/op/unary_gelu.cpp@@ -4,20 +4,19 @@#include "node_context.hpp"#include "op_table.hpp"-#include "utils.hpp"-#include "openvino/core/node_output.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/gelu.hpp"#include "openvino/op/multiply.hpp"#include "openvino/op/sigmoid.hpp"+#include "utils.hpp"namespace ov {namespace frontend {namespace gguf {namespace op {-OutputVector translate_unary_gelu(const NodeContext & context) {+OutputVector translate_unary_gelu(const NodeContext& context) {num_inputs_check(context, 1, 1);auto input = context.get_input(0);diff --git a/src/frontends/gguf/src/op/unary_silu.cpp b/src/frontends/gguf/src/op/unary_silu.cppindex 0744e234b71..4295b8be677 100644--- a/src/frontends/gguf/src/op/unary_silu.cpp+++ b/src/frontends/gguf/src/op/unary_silu.cpp@@ -4,18 +4,17 @@#include "node_context.hpp"#include "op_table.hpp"-#include "utils.hpp"-#include "openvino/core/node_output.hpp"#include "openvino/op/multiply.hpp"#include "openvino/op/sigmoid.hpp"+#include "utils.hpp"namespace ov {namespace frontend {namespace gguf {namespace op {-OutputVector translate_unary_silu(const NodeContext & context) {+OutputVector translate_unary_silu(const NodeContext& context) {num_inputs_check(context, 1, 1);auto input = context.get_input(0);diff --git a/src/frontends/gguf/src/op/view.cpp b/src/frontends/gguf/src/op/view.cppindex 240806b064a..c31b7ef3215 100644--- a/src/frontends/gguf/src/op/view.cpp+++ b/src/frontends/gguf/src/op/view.cpp@@ -26,7 +26,7 @@ namespace {// Put the reshape target's single -1 on the axis carrying the runtime token count, recovered by// element-count conservation: product(tgt) / product(res_ps's static dims). No-op for a static// res_ps, where the target is already exact and a -1 could land on the wrong axis.-void place_dynamic_token_axis(std::vector<int64_t> & tgt, const ov::PartialShape & res_ps) {+void place_dynamic_token_axis(std::vector<int64_t>& tgt, const ov::PartialShape& res_ps) {if (res_ps.rank().is_dynamic()) {return;}@@ -50,7 +50,7 @@ void place_dynamic_token_axis(std::vector<int64_t> & tgt, const ov::PartialShapereturn;}const int64_t token_len = out_prod / slice_static;- for (auto & d : tgt) {+ for (auto& d : tgt) {if (d == token_len) {d = -1;break;@@ -64,7 +64,7 @@ void place_dynamic_token_axis(std::vector<int64_t> & tgt, const ov::PartialShape// views the same way. Case 104 is builder-only: it takes a second (shape-reference) input the// cgraph path does not supply, so it has a different arity than the shared cases. See its comment// below, and docs/frontend_design.md for the other two builder-only cases in the frontend.-OutputVector translate_view(const NodeContext & context) {+OutputVector translate_view(const NodeContext& context) {num_inputs_check(context, 1, 2);const auto output_shape = context.get_output_shape();@@ -114,8 +114,9 @@ OutputVector translate_view(const NodeContext & context) {// [1, 1, T, F] -> [1, 1, T, group_count, group_stride]. special_zero (0 copies the input dim at// that position) keeps the leading [1, 1, T] intact -- including the dynamic token axis -- so// only the last dim F is factored into the two static group dims.- auto expose = ov::op::v0::Constant::create(- ov::element::i64, {5}, std::vector<int64_t>{0, 0, 0, group_count, group_stride});+ auto expose = ov::op::v0::Constant::create(ov::element::i64,+ {5},+ std::vector<int64_t>{0, 0, 0, group_count, group_stride});auto reshaped = std::make_shared<ov::op::v1::Reshape>(input, expose, /*special_zero=*/true);// Slice the inner sub-window [inner_off, inner_off+inner_len) on the group_stride axis (4).@@ -129,8 +130,10 @@ OutputVector translate_view(const NodeContext & context) {auto tgt = context.get_attribute<std::vector<int64_t>>("view_reshape", {});if (!tgt.empty()) {place_dynamic_token_axis(tgt, sliced.get_partial_shape());- auto res = std::make_shared<ov::op::v1::Reshape>(- sliced, ov::op::v0::Constant::create(ov::element::i64, {tgt.size()}, tgt), false);+ auto res =+ std::make_shared<ov::op::v1::Reshape>(sliced,+ 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());}@@ -145,7 +148,7 @@ OutputVector translate_view(const NodeContext & context) {auto input = context.get_input(0);auto gdn = context.get_attribute<std::vector<int64_t>>("gdn_view", {});FRONT_END_OP_CONVERSION_CHECK(gdn.size() == 2, "GDN view expects {part, s_v}");- const int64_t part = gdn[0]; // 0 = attn (first T rows), 1 = state (last S_v rows)+ const int64_t part = gdn[0]; // 0 = attn (first T rows), 1 = state (last S_v rows)const int64_t s_v = gdn[1];auto axis2 = ov::op::v0::Constant::create(ov::element::i64, {1}, {2});@@ -159,8 +162,7 @@ OutputVector translate_view(const NodeContext & context) {} else {// last S_v rows: [-S_v, end)auto begin = ov::op::v0::Constant::create(ov::element::i64, {1}, {-s_v});- auto end = ov::op::v0::Constant::create(ov::element::i64, {1},- {std::numeric_limits<int64_t>::max()});+ auto end = ov::op::v0::Constant::create(ov::element::i64, {1}, {std::numeric_limits<int64_t>::max()});sliced = std::make_shared<ov::op::v8::Slice>(input, begin, end, step, axis2);}@@ -171,8 +173,10 @@ OutputVector translate_view(const NodeContext & context) {if (part == 0) {place_dynamic_token_axis(tgt, sliced.get_partial_shape());}- auto res = std::make_shared<ov::op::v1::Reshape>(- sliced, ov::op::v0::Constant::create(ov::element::i64, {tgt.size()}, tgt), false);+ auto res =+ 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({sliced}, context.get_name());@@ -226,8 +230,10 @@ OutputVector translate_view(const NodeContext & context) {auto tgt = context.get_attribute<std::vector<int64_t>>("view_reshape", {});if (!tgt.empty()) {place_dynamic_token_axis(tgt, result.get_partial_shape());- result = std::make_shared<ov::op::v1::Reshape>(- result, ov::op::v0::Constant::create(ov::element::i64, {tgt.size()}, tgt), false);+ result =+ std::make_shared<ov::op::v1::Reshape>(result,+ ov::op::v0::Constant::create(ov::element::i64, {tgt.size()}, tgt),+ false);result.get_node_shared_ptr()->set_friendly_name("view_reshape_" + context.get_name());}// A view that neither restores rank, slices nor reshapes is a pass-through: the value is@@ -348,12 +354,12 @@ OutputVector translate_view(const NodeContext & context) {const int64_t src_plane = static_cast<int64_t>(src_shape[2] * src_shape[3]);const int64_t dst_plane = static_cast<int64_t>(dst_shape[2] * dst_shape[3]);if (begin_elem >= 0 && begin_elem + dst_plane <= src_plane) {- auto flat_shape = ov::op::v0::Constant::create(- ov::element::i64,- {3},- std::vector<int64_t>{static_cast<int64_t>(src_shape[0]),- static_cast<int64_t>(src_shape[1]),- src_plane});+ auto flat_shape =+ ov::op::v0::Constant::create(ov::element::i64,+ {3},+ std::vector<int64_t>{static_cast<int64_t>(src_shape[0]),+ static_cast<int64_t>(src_shape[1]),+ src_plane});auto flat = std::make_shared<ov::op::v1::Reshape>(context.get_input(0), flat_shape, false);auto selected = std::make_shared<ov::op::v8::Slice>(flat,@@ -389,8 +395,7 @@ OutputVector translate_view(const NodeContext & context) {starts[d] = remaining / src_strides[d];remaining %= src_strides[d];const size_t ov_axis = src_shape.size() - 1 - d;- const int64_t last = starts[d] +- steps[d] * (static_cast<int64_t>(dst_shape[ov_axis]) - 1);+ const int64_t last = starts[d] + steps[d] * (static_cast<int64_t>(dst_shape[ov_axis]) - 1);if (starts[d] < 0 || last >= static_cast<int64_t>(src_shape[ov_axis])) {valid = false;break;@@ -406,8 +411,7 @@ OutputVector translate_view(const NodeContext & context) {const size_t ggml_dim = src_shape.size() - 1 - ov_axis;begin[ov_axis] = starts[ggml_dim];step[ov_axis] = steps[ggml_dim];- end[ov_axis] = begin[ov_axis] +- step[ov_axis] * (static_cast<int64_t>(dst_shape[ov_axis]) - 1) + 1;+ end[ov_axis] = begin[ov_axis] + step[ov_axis] * (static_cast<int64_t>(dst_shape[ov_axis]) - 1) + 1;axes[ov_axis] = static_cast<int64_t>(ov_axis);}auto result = std::make_shared<ov::op::v8::Slice>(diff --git a/src/frontends/gguf/src/op/weight.cpp b/src/frontends/gguf/src/op/weight.cppindex 8c5e7f6f2dc..8ce7d03fb07 100644--- a/src/frontends/gguf/src/op/weight.cpp+++ b/src/frontends/gguf/src/op/weight.cpp@@ -52,8 +52,8 @@ OutputVector translate_weight(const NodeContext& context) {}FRONT_END_OP_CONVERSION_CHECK(weights.count(base + ".weight"),"GGML_OP_NONE weight leaf has no 'gguf.blob.weight' attribute");- auto qtype = static_cast<gguf_tensor_type>(context.get_attribute<int>("gguf_qtype"));- std::unordered_map<std::string, gguf_tensor_type> qtypes{{base + ".qtype", qtype}};+ auto qtype = static_cast<GgufTensorType>(context.get_attribute<int>("gguf_qtype"));+ std::unordered_map<std::string, GgufTensorType> qtypes{{base + ".qtype", qtype}};auto node = make_weight_node(base, weights, qtypes);return rename_outputs_with_suffix({node}, context.get_name());}diff --git a/src/frontends/gguf/src/op_table.cpp b/src/frontends/gguf/src/op_table.cppindex b6afba509ee..cd971924288 100644--- a/src/frontends/gguf/src/op_table.cpp+++ b/src/frontends/gguf/src/op_table.cpp@@ -20,7 +20,6 @@#include "openvino/op/softplus.hpp"#include "openvino/op/subtract.hpp"#include "openvino/op/tanh.hpp"-#include "utils.hpp"namespace ov {diff --git a/src/frontends/gguf/src/pass/adapt_to_genai.cpp b/src/frontends/gguf/src/pass/adapt_to_genai.cppindex 60dd0ee7a2e..6ddf7386052 100644--- a/src/frontends/gguf/src/pass/adapt_to_genai.cpp+++ b/src/frontends/gguf/src/pass/adapt_to_genai.cpp@@ -3,11 +3,11 @@//#include "openvino/frontend/gguf/adapt_to_genai.hpp"-#include "openvino/frontend/gguf/make_stateful.hpp"#include <memory>#include <unordered_map>+#include "openvino/frontend/gguf/make_stateful.hpp"#include "openvino/op/broadcast.hpp"#include "openvino/op/concat.hpp"#include "openvino/op/constant.hpp"@@ -21,13 +21,13 @@#include "openvino/op/read_value.hpp"#include "openvino/op/reduce_prod.hpp"#include "openvino/op/reshape.hpp"-#include "openvino/op/tile.hpp"#include "openvino/op/result.hpp"#include "openvino/op/scaled_dot_product_attention.hpp"#include "openvino/op/select.hpp"#include "openvino/op/shape_of.hpp"#include "openvino/op/squeeze.hpp"#include "openvino/op/subtract.hpp"+#include "openvino/op/tile.hpp"#include "openvino/op/transpose.hpp"#include "openvino/runtime/properties.hpp"@@ -48,8 +48,7 @@ std::shared_ptr<ov::op::v0::Constant> const_i64(const std::vector<int64_t>& valu}// Find a Parameter whose output tensor names (or friendly name) match `name`.-std::shared_ptr<ov::op::v0::Parameter> find_param(const std::shared_ptr<ov::Model>& model,- const std::string& name) {+std::shared_ptr<ov::op::v0::Parameter> find_param(const std::shared_ptr<ov::Model>& model, const std::string& name) {for (const auto& p : model->get_parameters()) {const auto& names = p->output(0).get_names();if (names.count(name) || p->get_friendly_name() == name) {@@ -87,9 +86,9 @@ int64_t max_kv_cache_head_size(const std::shared_ptr<ov::Model>& model) {} // namespacebool AdaptToGenAI::run_on_model(const std::shared_ptr<ov::Model>& model) {- OPENVINO_ASSERT(m_mode == InputMode::IdsToLogits,- "[gguf] AdaptToGenAI: only InputMode::IdsToLogits is implemented; "- "EmbedsToLogits (VLM language model) is reserved for future work.");+ OPENVINO_ASSERT(m_mode == InputMode::IDS_TO_LOGITS,+ "[gguf] AdaptToGenAI: only InputMode::IDS_TO_LOGITS is implemented; "+ "EMBEDS_TO_LOGITS (VLM language model) is reserved for future work.");// The gguf inputs we rewire. inp_tokens/inp_pos/self_kq_mask/token_len_per_seq are// required; if they are absent the model is not a gguf-IO model (e.g. already adapted),@@ -219,8 +218,8 @@ bool AdaptToGenAI::run_on_model(const std::shared_ptr<ov::Model>& model) {ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {static_cast<int32_t>(window - 1)});auto window_start = make_shared<ov::op::v1::Subtract>(q_pos_col, window_m1); // [seq, 1]auto within_window = make_shared<ov::op::v1::GreaterEqual>(k_row, window_start); // [seq, kv_len]- auto allowed_swa = make_shared<ov::op::v1::LogicalAnd>(allowed, within_window); // [seq, kv_len]- auto mask2d_swa = make_shared<ov::op::v1::Select>(allowed_swa, zero_f, neg_f); // [seq, kv_len]+ auto allowed_swa = make_shared<ov::op::v1::LogicalAnd>(allowed, within_window); // [seq, kv_len]+ auto mask2d_swa = make_shared<ov::op::v1::Select>(allowed_swa, zero_f, neg_f); // [seq, kv_len]swa_mask_4d = make_shared<ov::op::v1::Reshape>(mask2d_swa,make_shared<ov::op::v0::Concat>(ov::OutputVector{const_i64({1, 1}), seq_len, kv_len}, 0),@@ -240,12 +239,10 @@ bool AdaptToGenAI::run_on_model(const std::shared_ptr<ov::Model>& model) {// needs, since it already carries one token per row.if (auto inp_out_ids = find_param(model, "inp_out_ids")) {auto batch_dim =- make_shared<ov::op::v8::Gather>(ids_shape, const_i64({0}), const_i64({0})); // [1]: ids_shape[0]- auto seq_dim =- make_shared<ov::op::v8::Gather>(ids_shape, const_i64({1}), const_i64({0})); // [1]: ids_shape[1]- auto last_index = make_shared<ov::op::v0::Convert>(- make_shared<ov::op::v1::Subtract>(seq_dim, const_i64({1})),- ov::element::i32); // [1]: ids_shape[1] - 1+ make_shared<ov::op::v8::Gather>(ids_shape, const_i64({0}), const_i64({0})); // [1]: ids_shape[0]+ auto seq_dim = make_shared<ov::op::v8::Gather>(ids_shape, const_i64({1}), const_i64({0})); // [1]: ids_shape[1]+ auto last_index = make_shared<ov::op::v0::Convert>(make_shared<ov::op::v1::Subtract>(seq_dim, const_i64({1})),+ ov::element::i32); // [1]: ids_shape[1] - 1auto out_grid = make_shared<ov::op::v3::Broadcast>(last_index,make_shared<ov::op::v0::Concat>(ov::OutputVector{batch_dim, const_i64({1})}, 0)); // [batch, 1]diff --git a/src/frontends/gguf/src/pass/lower_set_rows_stateless.cpp b/src/frontends/gguf/src/pass/lower_set_rows_stateless.cppindex 3c92155f45c..639e609c28b 100644--- a/src/frontends/gguf/src/pass/lower_set_rows_stateless.cpp+++ b/src/frontends/gguf/src/pass/lower_set_rows_stateless.cpp@@ -43,8 +43,9 @@ LowerSetRowsStateless::LowerSetRowsStateless() {return dst_ps[i].is_static() ? dst_ps[i].get_length() : -1;};std::vector<int64_t> shape = {dim_or_dynamic(0), dim_or_dynamic(1), dim_or_dynamic(2), dim_or_dynamic(3)};- res = std::make_shared<ov::op::v1::Reshape>(- res, ov::op::v0::Constant::create(ov::element::i64, {4}, shape), false);+ res = std::make_shared<ov::op::v1::Reshape>(res,+ ov::op::v0::Constant::create(ov::element::i64, {4}, shape),+ false);}res->set_friendly_name(set_rows->get_friendly_name());diff --git a/src/frontends/gguf/src/pass/make_stateful.cpp b/src/frontends/gguf/src/pass/make_stateful.cppindex fb570946aae..043843f62f2 100644--- a/src/frontends/gguf/src/pass/make_stateful.cpp+++ b/src/frontends/gguf/src/pass/make_stateful.cpp@@ -137,10 +137,7 @@ static bool make_recurrent_states_stateful(const std::shared_ptr<ov::Model>& modbreak;}}- OPENVINO_ASSERT(state_result,- "[GGUF] GGUFMakeStateful: no Result produces recurrent state '",- out_name,- "'");+ OPENVINO_ASSERT(state_result, "[GGUF] GGUFMakeStateful: no Result produces recurrent state '", out_name, "'");const auto et = param->get_element_type();auto var = std::make_shared<ov::op::util::Variable>(ov::op::util::VariableInfo{ps, et, in_name});diff --git a/src/frontends/gguf/src/quant/gguf.cpp b/src/frontends/gguf/src/quant/gguf.cppindex bac9e83c344..b3412c0dcb2 100644--- a/src/frontends/gguf/src/quant/gguf.cpp+++ b/src/frontends/gguf/src/quant/gguf.cpp@@ -8,7 +8,6 @@// dependency.#include "gguf.hpp"-#include "weights.hpp"#include <cmath>#include <cstdint>@@ -21,6 +20,7 @@#include "openvino/runtime/shared_buffer.hpp"#include "openvino/util/math_util.hpp"#include "openvino/util/mmap_object.hpp"+#include "weights.hpp"namespace ov {namespace frontend {@@ -31,7 +31,7 @@ namespace {constexpr uint32_t GGUF_MAGIC = 0x46554747; // "GGUF" little-endianconstexpr uint64_t GGUF_DEFAULT_ALIGNMENT = 32;-// (items_per_block, bytes_per_block) per gguf_tensor_type, indexed by the type id.+// (items_per_block, bytes_per_block) per GgufTensorType, indexed by the type id.struct TypeTraits {uint32_t items_per_block;uint32_t bytes_per_block;@@ -267,7 +267,7 @@ void read_metadata_value(Cursor& cur, uint32_t type, GGUFMetaData& out) {// Tensor(view, so) constructor so that the mmap shared_ptr is stored in _so and keeps// the mapping alive for the full lifetime of the returned tensor (and any Constant that// wraps it via Constant(const Tensor&) -> SharedBuffer<Tensor>).-ov::Tensor extract_tensor_data(const gguf_tensor& tensor, const std::shared_ptr<ov::MappedMemory>& mmap) {+ov::Tensor extract_tensor_data(const GgufTensor& tensor, const std::shared_ptr<ov::MappedMemory>& mmap) {auto dtype = gguf_type_to_dtype(tensor.type);OPENVINO_ASSERT(dtype.has_value(),"[load_gguf] tensor '",@@ -285,8 +285,8 @@ ov::Tensor extract_tensor_data(const gguf_tensor& tensor, const std::shared_ptr<// type doesn't match (so a caller can't read past a smaller-than-expected stored type, e.g. a// 1-byte BOOL where a 4-byte scalar is expected).static const ov::Tensor& metadata_scalar_tensor(const std::unordered_map<std::string, GGUFMetaData>& metadata,- const std::string& key,- const ov::element::Type& expected_type) {+ const std::string& key,+ const ov::element::Type& expected_type) {auto it = metadata.find(key);OPENVINO_ASSERT(it != metadata.end(), "[GGUF] required metadata key is missing: '", key, "'");const auto* tensor = std::get_if<ov::Tensor>(&it->second);@@ -341,7 +341,7 @@ bool metadata_to_bool_or(const std::unordered_map<std::string, GGUFMetaData>& me} // namespace-ov::Shape get_shape(const gguf_tensor& tensor) {+ov::Shape get_shape(const GgufTensor& tensor) {ov::Shape shape;// GGUF stores dimensions fastest-varying first; the logical (GGML) order is reversed.for (int i = static_cast<int>(tensor.ndim) - 1; i >= 0; i--) {@@ -353,7 +353,7 @@ ov::Shape get_shape(const gguf_tensor& tensor) {GGUFLoad get_gguf_data(const std::string& file) {std::unordered_map<std::string, GGUFMetaData> metadata;std::unordered_map<std::string, ov::Tensor> arrays;- std::unordered_map<std::string, gguf_tensor_type> qtype;+ std::unordered_map<std::string, GgufTensorType> qtype;auto mapped = ov::load_mmap_object(file);OPENVINO_ASSERT(mapped && mapped->data(), "[load_gguf] failed to mmap '", file, "'");@@ -558,7 +558,7 @@ GGUFLoad get_gguf_data(const std::string& file) {// ---- Pass 2: materialize tensors, slicing into quant_buf for quantized ones ----size_t quant_offset = 0;for (const auto& ti : infos) {- gguf_tensor tensor;+ GgufTensor tensor;tensor.name = ti.name.data();tensor.namelen = ti.name.size();tensor.type = ti.type;@@ -759,7 +759,7 @@ GGUFLoad get_gguf_data(const std::string& file) {arrays.emplace(name, std::move(weights));arrays.emplace(name_prefix + ".scales", std::move(scales));- qtype.emplace(name_prefix + ".qtype", static_cast<gguf_tensor_type>(ti.type));+ qtype.emplace(name_prefix + ".qtype", static_cast<GgufTensorType>(ti.type));} else if (ti.type == GGUF_TYPE_Q4_1 || ti.type == GGUF_TYPE_Q4_K || ti.type == GGUF_TYPE_Q5_K ||ti.type == GGUF_TYPE_Q5_1) {// Asymmetric: weights + f16 scales + integer zp.@@ -788,10 +788,10 @@ GGUFLoad get_gguf_data(const std::string& file) {quant_offset += sb;// Both ingest paths must agree on the zero-point representation; see// gguf_zero_point_type in quant/weights.hpp for why it matters.- const auto zp_elem = gguf_zero_point_type(name, static_cast<gguf_tensor_type>(ti.type));+ const auto zp_elem = gguf_zero_point_type(name, static_cast<GgufTensorType>(ti.type));// Only Q4_K's integer zp actually rounds: Q2_0's zero-point is the exact integer 1.if (zp_elem == ov::element::u8 && ti.type == GGUF_TYPE_Q4_K) {- notify_lossy_weight_approximation(LossyWeightApproximation::IntegerZeroPoint);+ notify_lossy_weight_approximation(LossyWeightApproximation::INTEGER_ZERO_POINT);}ov::Tensor zp(zp_elem, scale_shape);quant_offset += zb;@@ -802,7 +802,7 @@ GGUFLoad get_gguf_data(const std::string& file) {arrays.emplace(name, std::move(weights));arrays.emplace(name_prefix + ".scales", std::move(scales));arrays.emplace(name_prefix + ".zp", std::move(zp));- qtype.emplace(name_prefix + ".qtype", static_cast<gguf_tensor_type>(ti.type));+ qtype.emplace(name_prefix + ".qtype", static_cast<GgufTensorType>(ti.type));} else if (ti.type == GGUF_TYPE_MXFP4) {// MXFP4: slice weight (f4e2m1) + scale (f8e8m0) out of quant_buf.auto [wb, sb, dummy_bb] = quant_sizes(ti);@@ -811,9 +811,6 @@ GGUFLoad get_gguf_data(const std::string& file) {auto shape = get_shape(tensor);const size_t cols = shape.back();- size_t nelems = 1;- for (auto d : shape)- nelems *= d;const size_t groups = cols / 32;ov::Shape scale_shape = shape;scale_shape.back() = groups;@@ -841,7 +838,7 @@ GGUFLoad get_gguf_data(const std::string& file) {constexpr std::string_view weight_suffix = ".weight";if (name.size() >= weight_suffix.size()) {const std::string name_prefix = name.substr(0, name.length() - weight_suffix.length());- qtype.emplace(name_prefix + ".qtype", static_cast<gguf_tensor_type>(ti.type));+ qtype.emplace(name_prefix + ".qtype", static_cast<GgufTensorType>(ti.type));}}}@@ -1051,8 +1048,7 @@ std::map<std::string, GGUFMetaData> decoder_config_from_meta(swa_window_value = v;}}- config["has_swa"] =- (metadata.count(arch + ".attention.sliding_window_pattern") || swa_window_value > 0) ? 1 : 0;+ config["has_swa"] = (metadata.count(arch + ".attention.sliding_window_pattern") || swa_window_value > 0) ? 1 : 0;config["swa_window_size"] = static_cast<int>(swa_window_value);// gpt-oss SWA: alternation period (default 2: even layers are SWA). Matches llama.cpp'sdiff --git a/src/frontends/gguf/src/quant/gguf.hpp b/src/frontends/gguf/src/quant/gguf.hppindex 12b6992ae2a..e58708c90cf 100644--- a/src/frontends/gguf/src/quant/gguf.hpp+++ b/src/frontends/gguf/src/quant/gguf.hpp@@ -20,7 +20,7 @@ namespace ov::frontend::gguf {// GGUF tensor (quantization) type ids, matching the on-disk GGUF format numbering.// Only the subset the frontend handles is enumerated explicitly; others are accepted// numerically but rejected at dequant time.-enum gguf_tensor_type {+enum GgufTensorType {GGUF_TYPE_F32 = 0,GGUF_TYPE_F16 = 1,GGUF_TYPE_Q4_0 = 2,@@ -47,7 +47,7 @@ enum gguf_tensor_type {};// GGUF metadata value type ids (the kv-pair value encoding).-enum gguf_value_type {+enum GgufValueType {GGUF_VALUE_TYPE_UINT8 = 0,GGUF_VALUE_TYPE_INT8 = 1,GGUF_VALUE_TYPE_UINT16 = 2,@@ -67,10 +67,10 @@ enum gguf_value_type {// into the memory-mapped file (zero-copy); the owning reader keeps the mapping alive.// Field names mirror the classic gguf-tools layout so the dequant code in// gguf_quants.cpp reads them unchanged.-struct gguf_tensor {+struct GgufTensor {const char* name = nullptr; // points into the mmap (not null-terminated)size_t namelen = 0;- uint32_t type = 0; // gguf_tensor_type+ uint32_t type = 0; // GgufTensorTypeuint32_t ndim = 0;uint64_t dim[4] = {1, 1, 1, 1};uint64_t offset = 0; // offset from the start of the tensor-data section@@ -91,39 +91,39 @@ using GGUFMetaData =// tensors in `arrays` for quantized weights are SharedBuffer slices into this buffer.using GGUFLoad = std::tuple<std::unordered_map<std::string, GGUFMetaData>,std::unordered_map<std::string, ov::Tensor>,- std::unordered_map<std::string, gguf_tensor_type>,+ std::unordered_map<std::string, GgufTensorType>,std::shared_ptr<ov::MappedMemory>,std::shared_ptr<ov::AlignedBuffer>>;// Fill pre-allocated i4 weights (u32-packed, XORed for i4 sign) and f16 scales from a// Q4_0 tensor. No bias: Q4_0 is symmetric (zp = -8*scale is implicit, not stored).-void gguf_fill_q4_0(const gguf_tensor& tensor, ov::Tensor& weights, ov::Tensor& scales);+void gguf_fill_q4_0(const GgufTensor& tensor, ov::Tensor& weights, ov::Tensor& scales);// Fill pre-allocated weights and f16 scales from a symmetric GGUF tensor// (Q8_0/Q5_0/Q6_K: i8 weights; Q3_K: i4 weights packed as u8).// No zero-point: the center value is subtracted during unpacking so weights are centered at 0.-void gguf_fill_sym(const gguf_tensor& tensor, ov::Tensor& weights, ov::Tensor& scales);+void gguf_fill_sym(const GgufTensor& tensor, ov::Tensor& weights, ov::Tensor& scales);// Fill pre-allocated weights, f16 scales, and integer zero-points from an asymmetric GGUF// tensor (Q4_1: u4 zp; Q4_K: u4 zp; Q5_K/Q5_1: u8 zp; Q2_K: u8 zp).// Tensor shapes must match quant_sizes.-void gguf_fill_asym(const gguf_tensor& tensor, ov::Tensor& weights, ov::Tensor& scales, ov::Tensor& zp);+void gguf_fill_asym(const GgufTensor& tensor, ov::Tensor& weights, ov::Tensor& scales, ov::Tensor& zp);// Fill pre-allocated f4e2m1 weights and f8e8m0 scales from an MXFP4 GGUF tensor.-void gguf_fill_mxfp4(const gguf_tensor& tensor, ov::Tensor& weights, ov::Tensor& scales);+void gguf_fill_mxfp4(const GgufTensor& tensor, ov::Tensor& weights, ov::Tensor& scales);// Fill pre-allocated u2 weights, f16 scales and u8 zero-points from a Q2_0 (ternary) tensor.// The zero-point is the constant 1 for every block: value = (code - 1) * scale.-void gguf_fill_q2_0(const gguf_tensor& tensor, ov::Tensor& weights, ov::Tensor& scales, ov::Tensor& zp);+void gguf_fill_q2_0(const GgufTensor& tensor, ov::Tensor& weights, ov::Tensor& scales, ov::Tensor& zp);// Fused bit-exact ggml dequant + channel-wise Q8_0_C requant for the token_embd/output/Q6_K/Q5_K// requant path. Streams one row at a time (never materializes the full f32 weight). Fills i8// weights [rows,cols] + f16 scales [rows,1]; matches upstream's to_float->quantize_q8_0 exactly so// those tensors are bit-identical to the vendored backend. Returns false for unsupported qtypes.-bool requantize_q8_0_channelwise_faithful(const gguf_tensor& tensor,+bool requantize_q8_0_channelwise_faithful(const GgufTensor& tensor,size_t rows,size_t cols,- gguf_tensor_type qtype,+ GgufTensorType qtype,int8_t* out_weights,ov::float16* out_scales);@@ -151,6 +151,6 @@ std::map<std::string, GGUFMetaData> decoder_config_from_meta(const std::unordered_map<std::string, GGUFMetaData>& metadata);// Reverse of the GGML dimension order (GGUF stores dims fastest-first).-ov::Shape get_shape(const gguf_tensor& tensor);+ov::Shape get_shape(const GgufTensor& tensor);} // namespace ov::frontend::ggufdiff --git a/src/frontends/gguf/src/quant/gguf_quants.cpp b/src/frontends/gguf/src/quant/gguf_quants.cppindex d86aaa5c173..5fc80ba39d3 100644--- a/src/frontends/gguf/src/quant/gguf_quants.cpp+++ b/src/frontends/gguf/src/quant/gguf_quants.cpp@@ -8,10 +8,10 @@#include <cstring>#include <memory>#include <numeric>-#include "openvino/core/parallel.hpp"#include <sstream>#include "gguf.hpp"+#include "openvino/core/parallel.hpp"#include "openvino/core/type/element_type_traits.hpp"namespace ov {@@ -53,7 +53,7 @@ void unpack_32_4(const uint8_t* data, uint8_t* dst) {// - f16 -> FRACTIONAL zp = -mn/sc: numerically faithful, used on the requant path where the// dequant is consumed by channel-wise Q8_0_C rather than fed to the compressed MatMul.// Outputs u32-packed u4 weights + f16 scales + zero-points (one per block).-void fill_q4_1(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr, ov::Tensor& zp_arr) {+void fill_q4_1(const GgufTensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr, ov::Tensor& zp_arr) {const uint64_t bytes_per_block = 20; // 2 bytes scale, 2 bytes min, 32x0.5 byte weightsauto data = static_cast<const uint8_t*>(tensor.weights_data);auto weights = static_cast<uint8_t*>(weights_arr.data());@@ -77,7 +77,7 @@ void fill_q4_1(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& s// Q8_0 symmetric: block = |f16 scale|32x i8 weights|. Weights are stored as i8 on disk.// No zero-point. Output: i8 weights (direct copy) + f16 scales.-void fill_q8_0(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr) {+void fill_q8_0(const GgufTensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr) {const uint64_t weights_per_block = 32;const uint64_t bytes_per_block = 34; // 2 bytes scale, 32x1 byte weights (i8)auto data = static_cast<const uint8_t*>(tensor.weights_data);@@ -92,7 +92,7 @@ void fill_q8_0(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& s// Q5_0 symmetric: block = |f16 scale d|32-bit qh|16 bytes ql (32x4bit low)|.// weight = lo|(hi<<4) in [0..31]; dequant = d*(w - 16). Output: i8 weights [-16..15].-void fill_q5_0(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr) {+void fill_q5_0(const GgufTensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr) {const uint64_t weights_per_block = 32;const uint64_t bytes_per_block = 2 + 4 + 16;auto data = static_cast<const uint8_t*>(tensor.weights_data);@@ -140,7 +140,7 @@ void unpack_256_4(const uint8_t* data, uint8_t* dst) {// into the MatMul -- this is what the original ggml-openvino backend does.// - f16 -> FRACTIONAL zp = min/scale: faithful, used on the requant path (token_embd/output)// where the dequant is re-quantized channel-wise rather than fed to the MatMul.-void fill_q4_k(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr, ov::Tensor& zp_arr) {+void fill_q4_k(const GgufTensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr, ov::Tensor& zp_arr) {const uint64_t bytes_per_block = kQ4K_BLOCK_BYTES;const uint64_t n_super_block = tensor.bsize / bytes_per_block;auto data = static_cast<const uint8_t*>(tensor.weights_data);@@ -291,19 +291,29 @@ static void dequant_row_q6_k_f32(const uint8_t* row, size_t cols, float* y) {// weight is never materialized (holds only `cols` floats). Fills i8 weights [rows,cols] + f16 scales// [rows,1], matching the upstream Q8_0_C path (amax/127 per row, roundf). qtype selects the exact// ggml row dequant. Returns false if qtype is not a supported requant source.-bool requantize_q8_0_channelwise_faithful(const gguf_tensor& tensor,+bool requantize_q8_0_channelwise_faithful(const GgufTensor& tensor,size_t rows,size_t cols,- gguf_tensor_type qtype,+ GgufTensorType qtype,int8_t* out_weights,ov::float16* out_scales) {void (*dq)(const uint8_t*, size_t, float*) = nullptr;uint64_t bytes_per_row = 0;switch (qtype) {- case GGUF_TYPE_Q4_K: dq = dequant_row_q4_k_f32; bytes_per_row = (cols / 256) * kQ4K_BLOCK_BYTES; break;- case GGUF_TYPE_Q5_K: dq = dequant_row_q5_k_f32; bytes_per_row = (cols / 256) * kQ5K_BLOCK_BYTES; break;- case GGUF_TYPE_Q6_K: dq = dequant_row_q6_k_f32; bytes_per_row = (cols / 256) * kQ6K_BLOCK_BYTES; break;- default: return false;+ case GGUF_TYPE_Q4_K:+ dq = dequant_row_q4_k_f32;+ bytes_per_row = (cols / 256) * kQ4K_BLOCK_BYTES;+ break;+ case GGUF_TYPE_Q5_K:+ dq = dequant_row_q5_k_f32;+ bytes_per_row = (cols / 256) * kQ5K_BLOCK_BYTES;+ break;+ case GGUF_TYPE_Q6_K:+ dq = dequant_row_q6_k_f32;+ bytes_per_row = (cols / 256) * kQ6K_BLOCK_BYTES;+ break;+ default:+ return false;}const uint8_t* data = static_cast<const uint8_t*>(tensor.weights_data);ov::parallel_for(rows, [&](size_t r) {@@ -326,15 +336,21 @@ bool requantize_q8_0_channelwise_faithful(const gguf_tensor& tensor,}// Test-only thin wrappers exposing the file-static per-row dequant to the unit tests.-void dequant_row_q4_k_f32_for_test(const uint8_t* row, size_t cols, float* y) { dequant_row_q4_k_f32(row, cols, y); }-void dequant_row_q5_k_f32_for_test(const uint8_t* row, size_t cols, float* y) { dequant_row_q5_k_f32(row, cols, y); }-void dequant_row_q6_k_f32_for_test(const uint8_t* row, size_t cols, float* y) { dequant_row_q6_k_f32(row, cols, y); }+void dequant_row_q4_k_f32_for_test(const uint8_t* row, size_t cols, float* y) {+ dequant_row_q4_k_f32(row, cols, y);+}+void dequant_row_q5_k_f32_for_test(const uint8_t* row, size_t cols, float* y) {+ dequant_row_q5_k_f32(row, cols, y);+}+void dequant_row_q6_k_f32_for_test(const uint8_t* row, size_t cols, float* y) {+ dequant_row_q6_k_f32(row, cols, y);+}// Q5_K asymmetric: super-block = 2(d) + 2(dmin) + 12(scales) + 32(qh) + 128(ql).// 8 sub-blocks of 32 with 6-bit scale and 6-bit min. Output: i8 weights + f16 scales + zp.// Like Q4_K, dequant is w = scale*q - dmin*m; zp = dmin*m/scale. The zp element type selects// integer (u8, fuses) vs fractional (f16, faithful) -- see fill_q4_k.-void fill_q5_k(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr, ov::Tensor& zp_arr) {+void fill_q5_k(const GgufTensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr, ov::Tensor& zp_arr) {const uint64_t bytes_per_block = kQ5K_BLOCK_BYTES;const uint64_t n_super_block = tensor.bsize / bytes_per_block;auto data = static_cast<const uint8_t*>(tensor.weights_data);@@ -387,7 +403,7 @@ void fill_q5_k(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& s// weight = lo|(hi<<4) in [0..31]; dequant = d*w + m = d*(w - zp), zp = -m/d.// Output: i8 weights [0..31] (raw, not centered) + f16 scales + zp (u8 integer or f16// fractional per element type -- see fill_q4_k).-void fill_q5_1(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr, ov::Tensor& zp_arr) {+void fill_q5_1(const GgufTensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr, ov::Tensor& zp_arr) {const uint64_t weights_per_block = 32;const uint64_t bytes_per_block = 2 + 2 + 4 + 16; // d, m, qh, qlauto data = static_cast<const uint8_t*>(tensor.weights_data);@@ -421,7 +437,7 @@ void fill_q5_1(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& s// 16 sub-blocks of 16; 3-bit values (2 low bits from qs, 1 inverted high bit from hmask) centered// to [-4..3]. Mirrors ggml dequantize_row_q3_K: kmask1/kmask2 scale interleave + strided qs order.// Output: i4 weights (2 per byte, low nibble first) + f16 scales (d * (scale6 - 32)). No zp.-void fill_q3_k(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr) {+void fill_q3_k(const GgufTensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr) {const uint64_t bytes_per_block = 32 + 64 + 12 + 2; // 110const uint64_t n_super_block = tensor.bsize / bytes_per_block;auto data = static_cast<const uint8_t*>(tensor.weights_data);@@ -475,7 +491,7 @@ void fill_q3_k(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& s// scales[j] lower nibble = sub-scale, upper nibble = sub-min. qs is not in element order, so unpack// per element into element-order u2 (4 per byte, LSB-first) like ggml dequantize_row_q2_K.// Output: u2 weights + f16 scales (d * sub_scale) + zp = ml/dl per sub-block (see fill_q4_k).-void fill_q2_k(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr, ov::Tensor& zp_arr) {+void fill_q2_k(const GgufTensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr, ov::Tensor& zp_arr) {const uint64_t bytes_per_block = 16 + 64 + 2 + 2; // 84const uint64_t n_super_block = tensor.bsize / bytes_per_block;auto data = static_cast<const uint8_t*>(tensor.weights_data);@@ -486,8 +502,8 @@ void fill_q2_k(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& sauto zp_u8 = int_zp ? static_cast<uint8_t*>(zp_arr.data()) : nullptr;ov::parallel_for(n_super_block, [&](size_t i) {const uint8_t* block = data + i * bytes_per_block;- const uint8_t* sc = block; // 16 bytes: per-sub-block scale+min nibbles- const uint8_t* qs = block + 16; // 64 bytes: 4 weights per byte, 2 bits each+ const uint8_t* sc = block; // 16 bytes: per-sub-block scale+min nibbles+ const uint8_t* qs = block + 16; // 64 bytes: 4 weights per byte, 2 bits eachconst float d = static_cast<float>(ov::float16::from_bits(*(uint16_t*)(block + 80)));const float dmin = static_cast<float>(ov::float16::from_bits(*(uint16_t*)(block + 82)));for (int j = 0; j < 16; ++j) {@@ -523,7 +539,7 @@ void fill_q2_k(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& s// Q6_K symmetric: super-block = 128(ql) + 64(qh) + 16(scales i8) + 2(f16 d).// 16 sub-blocks of 16 with i8 scale each. Values in [0..63]; center = 32 → i8 [-32..31].// Output: i8 weights (value - 32) + f16 scales. No zero-point.-void fill_q6_k(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr) {+void fill_q6_k(const GgufTensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr) {const uint64_t bytes_per_block = kQ6K_BLOCK_BYTES;const uint64_t n_super_block = tensor.bsize / bytes_per_block;auto data = static_cast<const uint8_t*>(tensor.weights_data);@@ -564,7 +580,7 @@ void fill_q6_k(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& s// Value equivalence: gguf MXFP4 value = kvalues_mxfp4[idx] * 2^(e-128); OpenVINO's// f4e2m1 LUT equals kvalues_mxfp4/2 and f8e8m0->f32 = 2^(e-127), so// f4e2m1[idx] * f8e8m0(e) = (kvalues/2) * 2^(e-127) = kvalues * 2^(e-128) -- exact.-void gguf_fill_mxfp4(const gguf_tensor& tensor, ov::Tensor& weights, ov::Tensor& scales) {+void gguf_fill_mxfp4(const GgufTensor& tensor, ov::Tensor& weights, ov::Tensor& scales) {const uint64_t bytes_per_block = 17;const uint64_t qk = 32;// GGUF stores dims fastest-first: dim[0] is the innermost (cols); the remaining dims fold@@ -608,7 +624,7 @@ void gguf_fill_mxfp4(const gguf_tensor& tensor, ov::Tensor& weights, ov::Tensor&// Q4_0 symmetric: same block layout as Q4_0 but XORs each packed byte with 0x88 to// flip the MSB of every nibble, converting u4 [0..15] to i4 [-8..7] in-place. No bias// tensor is produced (zp is exactly -8 * scale = a fixed shift, not per-element).-void gguf_fill_q4_0(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr) {+void gguf_fill_q4_0(const GgufTensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr) {const uint64_t bytes_per_block = 18;auto data = static_cast<const uint8_t*>(tensor.weights_data);auto weights = static_cast<uint8_t*>(weights_arr.data());@@ -624,7 +640,7 @@ void gguf_fill_q4_0(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tens// Q8_K symmetric: block = |f32 d|i8 qs[256]|i16 bsums[16]| (292 bytes/block).// bsums are partial sums for dot-product acceleration; unused in dequant-then-multiply.-void fill_q8_k(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr) {+void fill_q8_k(const GgufTensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr) {const uint64_t weights_per_block = 256;const uint64_t bytes_per_block = 292; // 4(f32 d) + 256(i8) + 32(i16 bsums)auto data = static_cast<const uint8_t*>(tensor.weights_data);@@ -644,7 +660,7 @@ void fill_q8_k(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& s// code in [0..3] -> {-1, 0, +1, +2}. ggml packs the codes 4 per byte LSB-first// (dequantize_row_q2_0: `(qs[j/4] >> ((j%4)*2)) & 3`), which is exactly the order OpenVINO's u2// Constant reads, so the 16 code bytes are copied verbatim. The zero-point is the constant 1.-void gguf_fill_q2_0(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr, ov::Tensor& zp_arr) {+void gguf_fill_q2_0(const GgufTensor& tensor, ov::Tensor& weights_arr, ov::Tensor& scales_arr, ov::Tensor& zp_arr) {const uint64_t bytes_per_block = 18;const uint64_t bytes_per_block_codes = 16;auto data = static_cast<const uint8_t*>(tensor.weights_data);@@ -670,7 +686,7 @@ void gguf_fill_q2_0(const gguf_tensor& tensor, ov::Tensor& weights_arr, ov::Tens// Symmetric types (Q8_0, Q5_0, Q6_K, Q3_K): fill weights + scales (f16), no zero-point.// Q8_K uses f32 scales and is handled by a separate overload dispatched on tensor.type.-void gguf_fill_sym(const gguf_tensor& tensor, ov::Tensor& weights, ov::Tensor& scales) {+void gguf_fill_sym(const GgufTensor& tensor, ov::Tensor& weights, ov::Tensor& scales) {if (tensor.type == GGUF_TYPE_Q8_0) {fill_q8_0(tensor, weights, scales);} else if (tensor.type == GGUF_TYPE_Q5_0) {@@ -687,7 +703,7 @@ void gguf_fill_sym(const gguf_tensor& tensor, ov::Tensor& weights, ov::Tensor& s}// Asymmetric types (Q4_1, Q4_K, Q5_K, Q5_1, Q2_K): fill weights + scales + integer zero-points.-void gguf_fill_asym(const gguf_tensor& tensor, ov::Tensor& weights, ov::Tensor& scales, ov::Tensor& zp) {+void gguf_fill_asym(const GgufTensor& tensor, ov::Tensor& weights, ov::Tensor& scales, ov::Tensor& zp) {if (tensor.type == GGUF_TYPE_Q4_1) {fill_q4_1(tensor, weights, scales, zp);} else if (tensor.type == GGUF_TYPE_Q4_K) {diff --git a/src/frontends/gguf/src/quant/weights.cpp b/src/frontends/gguf/src/quant/weights.cppindex cdb5e9d7b59..8b131a1be9f 100644--- a/src/frontends/gguf/src/quant/weights.cpp+++ b/src/frontends/gguf/src/quant/weights.cpp@@ -127,8 +127,7 @@ std::shared_ptr<ov::Node> make_q4_0(const std::string& name,auto scale_shape = per_group_shape(orig_shape, num_groups);scales.set_shape(scale_shape);- auto weights_node =- make_compressed_weight_constant(ov::element::i4, grouped_shape, weight);+ auto weights_node = make_compressed_weight_constant(ov::element::i4, grouped_shape, weight);auto scales_node = std::make_shared<ov::op::v0::Constant>(scales);auto final_shape_node =std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{orig_shape.size()}, orig_shape);@@ -145,7 +144,7 @@ std::shared_ptr<ov::Node> make_q4_0(const std::string& name,// formats use the compressed-weight decomposition.std::shared_ptr<ov::Node> make_sym_int8(const std::string& name,const std::unordered_map<std::string, ov::Tensor>& weights,- gguf_tensor_type qtype) {+ GgufTensorType qtype) {ov::Tensor weight = get(weights, name + ".weight"); // i8 byte per elementov::Tensor scales = get(weights, name + ".scales");@@ -157,8 +156,7 @@ std::shared_ptr<ov::Node> make_sym_int8(const std::string& name,auto scale_shape = per_group_shape(orig_shape, num_groups);scales.set_shape(scale_shape);- auto weights_node =- make_compressed_weight_constant(ov::element::i8, grouped_shape, weight);+ auto weights_node = make_compressed_weight_constant(ov::element::i8, grouped_shape, weight);auto scales_node = std::make_shared<ov::op::v0::Constant>(scales);auto final_shape_node =std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{orig_shape.size()}, orig_shape);@@ -195,8 +193,7 @@ std::shared_ptr<ov::Node> make_int4(const std::string& name,scales.set_shape(scale_shape);zp_t.set_shape(scale_shape);- auto weights_node =- make_compressed_weight_constant(ov::element::u4, grouped_shape, weight);+ auto weights_node = make_compressed_weight_constant(ov::element::u4, grouped_shape, weight);auto scales_node = std::make_shared<ov::op::v0::Constant>(scales);auto zp_node = std::make_shared<ov::op::v0::Constant>(zp_t);auto final_shape_node =@@ -206,8 +203,8 @@ std::shared_ptr<ov::Node> make_int4(const std::string& name,auto values = std::make_shared<ov::op::v0::Convert>(weights_node, ov::element::f32);auto scales_f32 = std::make_shared<ov::op::v0::Convert>(scales_node, ov::element::f32);auto zp_f32 = std::make_shared<ov::op::v0::Convert>(zp_node, ov::element::f32);- auto dequant = std::make_shared<ov::op::v1::Multiply>(- std::make_shared<ov::op::v1::Subtract>(values, zp_f32), scales_f32);+ auto dequant =+ std::make_shared<ov::op::v1::Multiply>(std::make_shared<ov::op::v1::Subtract>(values, zp_f32), scales_f32);return std::make_shared<ov::op::v1::Reshape>(dequant, final_shape_node, false);}@@ -233,8 +230,7 @@ std::shared_ptr<ov::Node> make_sym_int4(const std::string& name,auto scale_shape = per_group_shape(orig_shape, num_groups);scales.set_shape(scale_shape);- auto weights_node =- make_compressed_weight_constant(ov::element::i4, grouped_shape, weight);+ auto weights_node = make_compressed_weight_constant(ov::element::i4, grouped_shape, weight);auto scales_node = std::make_shared<ov::op::v0::Constant>(scales);auto final_shape_node =std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{orig_shape.size()}, orig_shape);@@ -263,8 +259,7 @@ std::shared_ptr<ov::Node> make_int2(const std::string& name,scales.set_shape(scale_shape);zp_t.set_shape(scale_shape);- auto weights_node =- make_compressed_weight_constant(ov::element::u2, grouped_shape, weight);+ auto weights_node = make_compressed_weight_constant(ov::element::u2, grouped_shape, weight);auto scales_node = std::make_shared<ov::op::v0::Constant>(scales);auto zp_node = std::make_shared<ov::op::v0::Constant>(zp_t);auto final_shape_node =@@ -294,8 +289,7 @@ std::shared_ptr<ov::Node> make_asym_int8(const std::string& name,scales.set_shape(scale_shape);zp_t.set_shape(scale_shape);- auto weights_node =- make_compressed_weight_constant(ov::element::i8, grouped_shape, weight);+ auto weights_node = make_compressed_weight_constant(ov::element::i8, grouped_shape, weight);auto scales_node = std::make_shared<ov::op::v0::Constant>(scales);auto zp_node = std::make_shared<ov::op::v0::Constant>(zp_t);auto final_shape_node =@@ -305,8 +299,8 @@ std::shared_ptr<ov::Node> make_asym_int8(const std::string& name,auto values = std::make_shared<ov::op::v0::Convert>(weights_node, ov::element::f32);auto scales_f32 = std::make_shared<ov::op::v0::Convert>(scales_node, ov::element::f32);auto zp_f32 = std::make_shared<ov::op::v0::Convert>(zp_node, ov::element::f32);- auto dequant = std::make_shared<ov::op::v1::Multiply>(- std::make_shared<ov::op::v1::Subtract>(values, zp_f32), scales_f32);+ auto dequant =+ std::make_shared<ov::op::v1::Multiply>(std::make_shared<ov::op::v1::Subtract>(values, zp_f32), scales_f32);return std::make_shared<ov::op::v1::Reshape>(dequant, final_shape_node, false);}@@ -376,8 +370,7 @@ static std::shared_ptr<ov::Node> build_q8_0_c_node(ov::Tensor weights, ov::Tenso}));auto weights_f16 = std::make_shared<ov::op::v0::Convert>(weights_node, ov::element::f16);auto scales_node = std::make_shared<ov::op::v0::Constant>(scales); // {rows, 1}- auto scaled =- std::make_shared<ov::op::v1::Multiply>(weights_f16, scales_node, ov::op::AutoBroadcastType::NUMPY);+ auto scaled = std::make_shared<ov::op::v1::Multiply>(weights_f16, scales_node, ov::op::AutoBroadcastType::NUMPY);return std::make_shared<ov::op::v0::Convert>(scaled, ov::element::f32);}@@ -450,8 +443,9 @@ std::vector<float> dequant_extracted_to_f32(const std::unordered_map<std::stringfor (size_t c = 0; c < cols; ++c) {uint32_t word = packed[r * per_row_u32 + c / 8];uint8_t nib = (word >> ((c % 8) * 4)) & 0xF;- float qval = signed_u4 ? static_cast<float>(nib < 8 ? static_cast<int>(nib) : static_cast<int>(nib) - 16)- : static_cast<float>(nib);+ float qval = signed_u4+ ? static_cast<float>(nib < 8 ? static_cast<int>(nib) : static_cast<int>(nib) - 16)+ : static_cast<float>(nib);emit(r, c, qval);}}@@ -460,7 +454,7 @@ std::vector<float> dequant_extracted_to_f32(const std::unordered_map<std::string// Decide whether a weight is requantized to Q8_0_C, mirroring llama.cpp's// ggml_openvino_get_requant_type for the CPU/GPU (non-NPU) path.-bool needs_q8_0_c_requant(const std::string& name, gguf_tensor_type qtype) {+bool needs_q8_0_c_requant(const std::string& name, GgufTensorType qtype) {if (name.rfind("token_embd.weight", 0) == 0 || name.rfind("output.weight", 0) == 0) {return true;}@@ -494,7 +488,7 @@ void notify_lossy_weight_approximation(LossyWeightApproximation kind) {static std::once_flag zero_point_once;switch (kind) {- case LossyWeightApproximation::Q8_0_C_Requant:+ case LossyWeightApproximation::Q8_0_C_REQUANT:std::call_once(requant_once, [] {std::cerr << "[GGUF] accuracy notice: the token embedding / output / Q6_K / Q5_K weights are ""requantized channel-wise to Q8_0_C (one int8 scale per row). This is lossy, so results "@@ -503,7 +497,7 @@ void notify_lossy_weight_approximation(LossyWeightApproximation kind) {<< std::endl;});break;- case LossyWeightApproximation::IntegerZeroPoint:+ case LossyWeightApproximation::INTEGER_ZERO_POINT:std::call_once(zero_point_once, [] {std::cerr << "[GGUF] accuracy notice: Q4_K weights use an integer (u8) zero-point, which rounds each ""sub-block's minimum to a multiple of its scale. This is lossy, so results may differ "@@ -515,7 +509,7 @@ void notify_lossy_weight_approximation(LossyWeightApproximation kind) {}}-ov::element::Type gguf_zero_point_type(const std::string& name, gguf_tensor_type qtype) {+ov::element::Type gguf_zero_point_type(const std::string& name, GgufTensorType qtype) {// The CPU compressed-FullyConnected fast path only folds the dequant when the zero-point is an// INTEGER constant; a fractional f16 one leaves a ~2x slower kernel. Q4_K carries the matmul// weights of modern models and Q2_0's zp is the exact integer 1, so both use u8 by default. The@@ -523,15 +517,14 @@ ov::element::Type gguf_zero_point_type(const std::string& name, gguf_tensor_type// injects error into every weight. Tensors that are requantized to Q8_0_C are excluded --// their dequant feeds the channel-wise path, not a compressed FC. Q4_K's u8 zp can be switched// back to a faithful f16 one via OV_GGUF_Q4_K_ZP_F16 (see q4_k_f16_zero_point_enabled).- const bool integer_zp =- qtype == GGUF_TYPE_Q2_0 || (qtype == GGUF_TYPE_Q4_K && !q4_k_f16_zero_point_enabled());+ const bool integer_zp = qtype == GGUF_TYPE_Q2_0 || (qtype == GGUF_TYPE_Q4_K && !q4_k_f16_zero_point_enabled());return (integer_zp && !needs_q8_0_c_requant(name, qtype)) ? ov::element::u8 : ov::element::f16;}std::shared_ptr<ov::Node> make_weight_node(const std::string& base,const std::unordered_map<std::string, ov::Tensor>& weights,- const std::unordered_map<std::string, gguf_tensor_type>& qtypes) {- gguf_tensor_type qtype = GGUF_TYPE_F16;+ const std::unordered_map<std::string, GgufTensorType>& qtypes) {+ GgufTensorType qtype = GGUF_TYPE_F16;if (auto it = qtypes.find(base + ".qtype"); it != qtypes.end()) {qtype = it->second;}@@ -582,24 +575,23 @@ std::shared_ptr<ov::Node> make_weight_node(const std::string& base,return node;}--gguf_tensor_type gguf_type_from_name(const std::string& quant_type) {- static const std::unordered_map<std::string, gguf_tensor_type> names = {{"F32", GGUF_TYPE_F32},- {"F16", GGUF_TYPE_F16},- {"BF16", GGUF_TYPE_BF16},- {"Q4_0", GGUF_TYPE_Q4_0},- {"Q4_1", GGUF_TYPE_Q4_1},- {"Q5_0", GGUF_TYPE_Q5_0},- {"Q5_1", GGUF_TYPE_Q5_1},- {"Q8_0", GGUF_TYPE_Q8_0},- {"Q2_K", GGUF_TYPE_Q2_K},- {"Q3_K", GGUF_TYPE_Q3_K},- {"Q4_K", GGUF_TYPE_Q4_K},- {"Q5_K", GGUF_TYPE_Q5_K},- {"Q6_K", GGUF_TYPE_Q6_K},- {"Q8_K", GGUF_TYPE_Q8_K},- {"MXFP4", GGUF_TYPE_MXFP4},- {"Q2_0", GGUF_TYPE_Q2_0}};+GgufTensorType gguf_type_from_name(const std::string& quant_type) {+ static const std::unordered_map<std::string, GgufTensorType> names = {{"F32", GGUF_TYPE_F32},+ {"F16", GGUF_TYPE_F16},+ {"BF16", GGUF_TYPE_BF16},+ {"Q4_0", GGUF_TYPE_Q4_0},+ {"Q4_1", GGUF_TYPE_Q4_1},+ {"Q5_0", GGUF_TYPE_Q5_0},+ {"Q5_1", GGUF_TYPE_Q5_1},+ {"Q8_0", GGUF_TYPE_Q8_0},+ {"Q2_K", GGUF_TYPE_Q2_K},+ {"Q3_K", GGUF_TYPE_Q3_K},+ {"Q4_K", GGUF_TYPE_Q4_K},+ {"Q5_K", GGUF_TYPE_Q5_K},+ {"Q6_K", GGUF_TYPE_Q6_K},+ {"Q8_K", GGUF_TYPE_Q8_K},+ {"MXFP4", GGUF_TYPE_MXFP4},+ {"Q2_0", GGUF_TYPE_Q2_0}};// Accept ggml's lowercase type names ("q4_0", "q6_K", "f16", ...) as well as the// canonical uppercase form by upper-casing the prefix before the "_K"/"_0" suffix.std::string key = quant_type;@@ -611,14 +603,13 @@ gguf_tensor_type gguf_type_from_name(const std::string& quant_type) {return it->second;}-std::array<FusedQkvPart, 3> split_fused_qkv_extracted(- const std::string& base,- const std::unordered_map<std::string, ov::Tensor>& weights,- const std::unordered_map<std::string, gguf_tensor_type>& qtypes,- size_t n_q,- size_t n_k,- size_t n_v) {- gguf_tensor_type qtype = GGUF_TYPE_F16;+std::array<FusedQkvPart, 3> split_fused_qkv_extracted(const std::string& base,+ const std::unordered_map<std::string, ov::Tensor>& weights,+ const std::unordered_map<std::string, GgufTensorType>& qtypes,+ size_t n_q,+ size_t n_k,+ size_t n_v) {+ GgufTensorType qtype = GGUF_TYPE_F16;if (auto it = qtypes.find(base + ".qtype"); it != qtypes.end()) {qtype = it->second;}@@ -670,9 +661,9 @@ std::array<ov::Tensor, 3> split_fused_qkv_bias(const std::string& base,// into two plain weights so the graph sees ordinary projections. Returns {query, gate}.std::array<FusedQkvPart, 2> split_interleaved_q_gate(const std::string& base,const std::unordered_map<std::string, ov::Tensor>& weights,- const std::unordered_map<std::string, gguf_tensor_type>& qtypes,+ const std::unordered_map<std::string, GgufTensorType>& qtypes,size_t head_dim) {- gguf_tensor_type qtype = GGUF_TYPE_F16;+ GgufTensorType qtype = GGUF_TYPE_F16;if (auto it = qtypes.find(base + ".qtype"); it != qtypes.end()) {qtype = it->second;}@@ -713,9 +704,9 @@ std::shared_ptr<ov::Node> make_weight_node(const ov::Tensor& data,OPENVINO_ASSERT(logical_shape.size() == 2,"[GGUF] weight logical shape must be 2D [rows, cols], got rank ",logical_shape.size());- const uint64_t rows = logical_shape[0];- const uint64_t cols = logical_shape[1];- const gguf_tensor_type qtype = gguf_type_from_name(quant_type);+ const size_t rows = logical_shape[0];+ const size_t cols = logical_shape[1];+ const GgufTensorType qtype = gguf_type_from_name(quant_type);const std::string base = "weight";@@ -754,13 +745,13 @@ std::shared_ptr<ov::Node> make_weight_node(const ov::Tensor& data,: ov::element::bf16;ov::Tensor typed(et, logical_shape, data.data());std::unordered_map<std::string, ov::Tensor> w{{base + ".weight", typed}};- std::unordered_map<std::string, gguf_tensor_type> q{{base + ".qtype", qtype}};+ std::unordered_map<std::string, GgufTensorType> q{{base + ".qtype", qtype}};return make_weight_node(base, w, q);}// Quantized weights: run the matching fill function to extract weights/scales/zp into// OpenVINO-native tensors, then build the decompression subgraph via make_weight_node.- gguf_tensor tensor{};+ GgufTensor tensor{};tensor.type = static_cast<uint32_t>(qtype);tensor.ndim = 2;tensor.dim[0] = cols; // GGUF stores dims fastest-first@@ -769,12 +760,12 @@ std::shared_ptr<ov::Node> make_weight_node(const ov::Tensor& data,tensor.bsize = data.get_byte_size();tensor.weights_data = static_cast<const uint8_t*>(data.data());- const auto sub_blocks_per_row = [&](uint64_t block) {+ const auto sub_blocks_per_row = [&](size_t block) {return cols / block;};std::unordered_map<std::string, ov::Tensor> w;- std::unordered_map<std::string, gguf_tensor_type> q{{base + ".qtype", qtype}};+ std::unordered_map<std::string, GgufTensorType> q{{base + ".qtype", qtype}};// Asymmetric zero-points. The CPU plugin only folds the dequant into the MatMul when the// zp is an INTEGER (u8) low-precision constant; a fractional f16 zp leaves a standalone@@ -787,11 +778,11 @@ std::shared_ptr<ov::Node> make_weight_node(const ov::Tensor& data,const bool requant = needs_q8_0_c_requant(name, qtype);const ov::element::Type zp_type = gguf_zero_point_type(name, qtype);if (requant) {- notify_lossy_weight_approximation(LossyWeightApproximation::Q8_0_C_Requant);+ notify_lossy_weight_approximation(LossyWeightApproximation::Q8_0_C_REQUANT);}// Only Q4_K's integer zp actually rounds: Q2_0's zero-point is the exact integer 1.if (zp_type == ov::element::u8 && qtype == GGUF_TYPE_Q4_K) {- notify_lossy_weight_approximation(LossyWeightApproximation::IntegerZeroPoint);+ notify_lossy_weight_approximation(LossyWeightApproximation::INTEGER_ZERO_POINT);}// K-quant requant sources: the fused dequant -> Q8_0_C streams from the raw bytes, so skip the@@ -799,7 +790,11 @@ std::shared_ptr<ov::Node> make_weight_node(const ov::Tensor& data,if (requant && (qtype == GGUF_TYPE_Q4_K || qtype == GGUF_TYPE_Q5_K || qtype == GGUF_TYPE_Q6_K)) {ov::Tensor rq_weights(ov::element::i8, ov::Shape{rows, cols});ov::Tensor rq_scales(ov::element::f16, ov::Shape{rows, 1});- bool ok = requantize_q8_0_channelwise_faithful(tensor, rows, cols, qtype, rq_weights.data<int8_t>(),+ bool ok = requantize_q8_0_channelwise_faithful(tensor,+ rows,+ cols,+ qtype,+ rq_weights.data<int8_t>(),rq_scales.data<ov::float16>());OPENVINO_ASSERT(ok, "[GGUF] faithful K-quant requant failed for ", base);return build_q8_0_c_node(rq_weights, rq_scales, rows, cols);diff --git a/src/frontends/gguf/src/quant/weights.hpp b/src/frontends/gguf/src/quant/weights.hppindex 311ab571088..8443c656eb6 100644--- a/src/frontends/gguf/src/quant/weights.hpp+++ b/src/frontends/gguf/src/quant/weights.hpp@@ -22,16 +22,16 @@ namespace ov::frontend::gguf {// Q4_K defaults to an integer (u8) zero-point (faster, lossy); set the environment variable// OV_GGUF_Q4_K_ZP_F16=1 to use a faithful f16 zero-point instead (llama.cpp's test-backend-ops// CI does this to meet its accuracy tolerance).-ov::element::Type gguf_zero_point_type(const std::string& name, gguf_tensor_type qtype);+ov::element::Type gguf_zero_point_type(const std::string& name, GgufTensorType qtype);// A lossy weight approximation the frontend deliberately makes, reported to the user once so a// later accuracy investigation starts from the right place.enum class LossyWeightApproximation {// token_embd / output / Q6_K / Q5_K tensors requantized channel-wise to Q8_0_C.- Q8_0_C_Requant,+ Q8_0_C_REQUANT,// Q4_K asymmetric weights expressed with an INTEGER (u8) zero-point, which forces each// sub-block's min to a multiple of its scale.- IntegerZeroPoint,+ INTEGER_ZERO_POINT,};// Warn -- ONCE per process and per approximation kind -- that weights are being converted with a@@ -51,10 +51,10 @@ void notify_lossy_weight_approximation(LossyWeightApproximation kind);//// `weights` holds the parser output (tensors by gguf name; quantized tensors expanded to// "<base>.weight" + "<base>.scales" + "<base>.biases"). `qtypes` maps "<base>.qtype" ->-// gguf_tensor_type.+// GgufTensorType.std::shared_ptr<ov::Node> make_weight_node(const std::string& base,const std::unordered_map<std::string, ov::Tensor>& weights,- const std::unordered_map<std::string, gguf_tensor_type>& qtypes);+ const std::unordered_map<std::string, GgufTensorType>& qtypes);// Build the OpenVINO weight node directly from the raw GGUF weight bytes, as provided by a// decoder (e.g. wrapping llama.cpp's tensor->data). `data` holds the bytes exactly as ggml@@ -72,8 +72,8 @@ std::shared_ptr<ov::Node> make_weight_node(const ov::Tensor& data,const ov::Shape& logical_shape,const std::string& name = "");-// Map a ggml quant type name (e.g. "Q4_K") to its gguf_tensor_type id. Throws if unknown.-gguf_tensor_type gguf_type_from_name(const std::string& quant_type);+// Map a ggml quant type name (e.g. "Q4_K") to its GgufTensorType id. Throws if unknown.+GgufTensorType gguf_type_from_name(const std::string& quant_type);// One split part of a fused attn_qkv weight: the extracted tensors keyed as "<part>.weight"// [+ ".scales" [+ ".zp"]] plus the shared quant type. Used by the GGUF builder to emit a@@ -81,19 +81,18 @@ gguf_tensor_type gguf_type_from_name(const std::string& quant_type);// weight) instead of building the decompression nodes eagerly.struct FusedQkvPart {std::unordered_map<std::string, ov::Tensor> extracted;- gguf_tensor_type qtype = GGUF_TYPE_F16;+ GgufTensorType qtype = GGUF_TYPE_F16;};// Row-slice a fused `<base>` attn_qkv weight into q/k/v extracted-tensor sub-maps (no OV nodes).// The returned parts' tensors are keyed "<base>.q.weight"/".scales"/".zp" etc. Same slicing as// make_fused_qkv_weights, but returns the extracted payload for GGML_OP_NONE emission.-std::array<FusedQkvPart, 3> split_fused_qkv_extracted(- const std::string& base,- const std::unordered_map<std::string, ov::Tensor>& weights,- const std::unordered_map<std::string, gguf_tensor_type>& qtypes,- size_t n_q,- size_t n_k,- size_t n_v);+std::array<FusedQkvPart, 3> split_fused_qkv_extracted(const std::string& base,+ const std::unordered_map<std::string, ov::Tensor>& weights,+ const std::unordered_map<std::string, GgufTensorType>& qtypes,+ size_t n_q,+ size_t n_k,+ size_t n_v);// Row-slice a fused `<base>.bias` (plain, unquantized 1D tensor) into q/k/v parts, using the// same row ranges as split_fused_qkv_extracted. Callers only invoke this when `<base>.bias`@@ -109,7 +108,7 @@ std::array<ov::Tensor, 3> split_fused_qkv_bias(const std::string& base,// Returns {query, gate}, keyed "<base>.q.*" and "<base>.gate.*".std::array<FusedQkvPart, 2> split_interleaved_q_gate(const std::string& base,const std::unordered_map<std::string, ov::Tensor>& weights,- const std::unordered_map<std::string, gguf_tensor_type>& qtypes,+ const std::unordered_map<std::string, GgufTensorType>& qtypes,size_t head_dim);} // namespace ov::frontend::ggufdiff --git a/src/frontends/gguf/src/translate_session.cpp b/src/frontends/gguf/src/translate_session.cppindex fa3638e4d95..663b6f6df70 100644--- a/src/frontends/gguf/src/translate_session.cpp+++ b/src/frontends/gguf/src/translate_session.cpp@@ -65,8 +65,7 @@ void add_sliced_mask(TensorMap& tensor_map) {auto mask = tensor_map.at(mask_name).get_node_shared_ptr();// The decoder binds the mask with its current runtime shape, so its// token axis already is the active token window.- std::shared_ptr<ov::Node> mask_sliced =- std::make_shared<ov::op::v0::Convert>(mask, ov::element::f16);+ std::shared_ptr<ov::Node> mask_sliced = std::make_shared<ov::op::v0::Convert>(mask, ov::element::f16);mask_sliced->set_friendly_name(sliced_name);tensor_map.insert({sliced_name, mask_sliced->output(0)});}@@ -179,8 +178,8 @@ std::shared_ptr<Model> TranslateSession::translate_graph(const frontend::InputMo// builder's pre-extracted payload (bool "gguf_weight") or the cgraph decoder's raw// bytes ("data"). Otherwise it is a model-input leaf (already seeded as a Parameter// above) and there is nothing to translate.- const bool is_builder_weight = decoder->get_attribute("gguf_weight").is<bool>() &&- decoder->get_attribute("gguf_weight").as<bool>();+ const bool is_builder_weight =+ decoder->get_attribute("gguf_weight").is<bool>() && decoder->get_attribute("gguf_weight").as<bool>();const bool is_cgraph_weight = decoder->get_attribute("data").is<ov::Tensor>();if (!is_builder_weight && !is_cgraph_weight) {return;@@ -360,9 +359,10 @@ std::shared_ptr<Model> TranslateSession::apply_transformations(std::shared_ptr<M// Loop: GatedDeltaNetFusion also bundles TransposeFuse, a generic cleanup that would otherwise// touch every architecture's op count.const auto ordered_ops = model->get_ordered_ops();- const auto has_loop = std::any_of(ordered_ops.begin(), ordered_ops.end(), [](const std::shared_ptr<ov::Node>& node) {- return ov::is_type<ov::op::v5::Loop>(node);- });+ const auto has_loop =+ std::any_of(ordered_ops.begin(), ordered_ops.end(), [](const std::shared_ptr<ov::Node>& node) {+ return ov::is_type<ov::op::v5::Loop>(node);+ });if (has_loop) {auto live_before_gdn = std::make_shared<std::unordered_set<const ov::Node*>>();manager.register_pass<pass::SnapshotLiveParameters>(live_before_gdn);diff --git a/src/frontends/gguf/src/utils.cpp b/src/frontends/gguf/src/utils.cppindex 506286751b3..127107510a8 100644--- a/src/frontends/gguf/src/utils.cpp+++ b/src/frontends/gguf/src/utils.cpp@@ -7,6 +7,8 @@#include <cmath>#include <cstddef>#include <memory>+#include <string>+#include "openvino/op/add.hpp"#include "openvino/op/clamp.hpp"#include "openvino/op/convert.hpp"@@ -22,7 +24,6 @@#include "openvino/op/squeeze.hpp"#include "openvino/op/subtract.hpp"#include "openvino/op/transpose.hpp"-#include <string>namespace ov {namespace frontend {@@ -211,9 +212,9 @@ std::pair<ov::Output<Node>, ov::Output<Node>> make_sin_cos(const RopeConfig& ropauto stop = ov::op::v0::Constant::create(ov::element::i64, {1}, {static_cast<int64_t>(n_dims_half)});auto step = ov::op::v0::Constant::create(ov::element::i64, {1}, {1});auto axes = ov::op::v0::Constant::create(ov::element::i64, {1}, {0});- rope_freqs_weight =- std::make_shared<ov::op::v8::Slice>(rope_freqs_weight, start, stop, step, axes)->output(0)- .get_node_shared_ptr();+ rope_freqs_weight = std::make_shared<ov::op::v8::Slice>(rope_freqs_weight, start, stop, step, axes)+ ->output(0)+ .get_node_shared_ptr();}freq_factors = std::make_shared<ov::op::v1::Divide>(freq_factors, rope_freqs_weight);}diff --git a/src/frontends/gguf/src/utils.hpp b/src/frontends/gguf/src/utils.hppindex 82c40ad33c8..251f5a47ae5 100644--- a/src/frontends/gguf/src/utils.hpp+++ b/src/frontends/gguf/src/utils.hpp@@ -7,14 +7,12 @@#include <memory>#include <utility>+#include "node_context.hpp"#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/op/shape_of.hpp"#include "openvino/op/topk.hpp"-#include "openvino/core/node_vector.hpp"--#include "node_context.hpp"-namespace ov {namespace op {namespace v3 {diff --git a/src/frontends/gguf/tests/CMakeLists.txt b/src/frontends/gguf/tests/CMakeLists.txtindex ffd117c3312..8909f98ec8c 100644--- a/src/frontends/gguf/tests/CMakeLists.txt+++ b/src/frontends/gguf/tests/CMakeLists.txt@@ -4,6 +4,15 @@set(TARGET_NAME ov_gguf_frontend_tests)+if(NOT BUILD_SHARED_LIBS)+ # This target compiles the frontend's own sources directly (white-box access to internal+ # helpers) and links openvino::runtime, which in static builds already bundles every+ # registered frontend via ov_target_link_frontends() -- the duplicate frontend.cpp objects+ # then conflict at link time. No other frontend's tests compile their own sources this way,+ # so skip only here rather than changing that shared static-build mechanism.+ return()+endif()+# Compile the frontend sources directly into the test binary instead of linking the# installed library. Explicit source lists (no GLOB); keep in sync when adding sources.set(FE_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../src")diff --git a/src/frontends/gguf/tests/test_extensions.cpp b/src/frontends/gguf/tests/test_extensions.cppindex a83309bc616..65e51371ff8 100644--- a/src/frontends/gguf/tests/test_extensions.cpp+++ b/src/frontends/gguf/tests/test_extensions.cpp@@ -287,8 +287,7 @@ private:TEST(GGUFExtensions, GetModelInputsToleratesNonParameterEntries) {auto base = kv_cache_write_builder();FrontEnd fe;- auto mixed =- std::make_shared<MixedMainInputDecoder>(*std::dynamic_pointer_cast<SingleOpDecoder>(base.decoder()));+ auto mixed = std::make_shared<MixedMainInputDecoder>(*std::dynamic_pointer_cast<SingleOpDecoder>(base.decoder()));EXPECT_NO_THROW(fe.convert(fe.load(std::static_pointer_cast<GgufDecoder>(mixed))));}diff --git a/src/frontends/gguf/tests/test_ops.cpp b/src/frontends/gguf/tests/test_ops.cppindex 0a1346638ff..fb3b060b0cf 100644--- a/src/frontends/gguf/tests/test_ops.cpp+++ b/src/frontends/gguf/tests/test_ops.cpp@@ -54,11 +54,29 @@ TEST_P(GGUFBinaryElementwise, MatchesReference) {INSTANTIATE_TEST_SUITE_P(GGUFOps,GGUFBinaryElementwise,- ::testing::Values(BinaryCase{"add", "GGML_OP_ADD", [](float x, float y) { return x + y; }},- BinaryCase{"mul", "GGML_OP_MUL", [](float x, float y) { return x * y; }},- BinaryCase{"sub", "GGML_OP_SUB", [](float x, float y) { return x - y; }},- BinaryCase{"div", "GGML_OP_DIV", [](float x, float y) { return x / y; }}),- [](const ::testing::TestParamInfo<BinaryCase>& i) { return std::string(i.param.name); });+ ::testing::Values(BinaryCase{"add",+ "GGML_OP_ADD",+ [](float x, float y) {+ return x + y;+ }},+ BinaryCase{"mul",+ "GGML_OP_MUL",+ [](float x, float y) {+ return x * y;+ }},+ BinaryCase{"sub",+ "GGML_OP_SUB",+ [](float x, float y) {+ return x - y;+ }},+ BinaryCase{"div",+ "GGML_OP_DIV",+ [](float x, float y) {+ return x / y;+ }}),+ [](const ::testing::TestParamInfo<BinaryCase>& i) {+ return std::string(i.param.name);+ });// ── Elementwise unary ops (single f32 input) ────────────────────────────────────// Every registered GGML_UNARY_OP_* plus the elementwise GGML_OP_{LOG,SIN,COS} share the same@@ -100,37 +118,75 @@ TEST_P(GGUFUnaryElementwise, MatchesReference) {// frontend maps it to v7::Gelu(TANH), which agrees with ggml's tanh kernel and with erf to 1e-3.// Softplus uses 1e-3 to cover ARM CPU fp16 execution (small outputs where fp16 spacing ~1e-3// dominates); on x86 fp32 the exact reference still matches comfortably within that bound.-INSTANTIATE_TEST_SUITE_P(- GGUFOps,- GGUFUnaryElementwise,- ::testing::Values(- UnaryCase{"silu", "GGML_UNARY_OP_SILU", [](float x) { return x / (1.0f + std::exp(-x)); }, 1e-4f},- UnaryCase{"gelu",- "GGML_UNARY_OP_GELU",- [](float x) { return 0.5f * x * (1.0f + std::erf(x / std::sqrt(2.0f))); },- 1e-3f},- // ggml_gelu_quick_f32: x*(1/(1+expf(-1.702f*x))) -- NOT the tanh GELU above.- UnaryCase{"gelu_quick",- "GGML_UNARY_OP_GELU_QUICK",- [](float x) { return x / (1.0f + std::exp(-1.702f * x)); },- 1e-4f},- UnaryCase{"tanh", "GGML_UNARY_OP_TANH", [](float x) { return std::tanh(x); }, 1e-4f},- UnaryCase{"relu", "GGML_UNARY_OP_RELU", [](float x) { return x > 0.0f ? x : 0.0f; }, 1e-4f},- // ggml_vec_elu_f32: (x > 0) ? x : expm1f(x), i.e. ELU with alpha == 1.- UnaryCase{"elu", "GGML_UNARY_OP_ELU", [](float x) { return x > 0.0f ? x : std::expm1(x); }, 1e-4f},- UnaryCase{"sin", "GGML_OP_SIN", [](float x) { return std::sin(x); }, 1e-4f},- UnaryCase{"cos", "GGML_OP_COS", [](float x) { return std::cos(x); }, 1e-4f},- UnaryCase{"softplus",- "GGML_UNARY_OP_SOFTPLUS",- [](float x) { return std::log1p(std::exp(-std::abs(x))) + std::max(x, 0.0f); },- 1e-3f},- // Log's domain is x > 0, so this case overrides the default ramp.- UnaryCase{"log",- "GGML_OP_LOG",- [](float x) { return std::log(x); },- 1e-4f,- {0.25f, 0.5f, 1.0f, 2.0f, 3.0f, 10.0f, 100.0f, 1e-3f}}),- [](const ::testing::TestParamInfo<UnaryCase>& i) { return std::string(i.param.name); });+INSTANTIATE_TEST_SUITE_P(GGUFOps,+ GGUFUnaryElementwise,+ ::testing::Values(UnaryCase{"silu",+ "GGML_UNARY_OP_SILU",+ [](float x) {+ return x / (1.0f + std::exp(-x));+ },+ 1e-4f},+ UnaryCase{"gelu",+ "GGML_UNARY_OP_GELU",+ [](float x) {+ return 0.5f * x * (1.0f + std::erf(x / std::sqrt(2.0f)));+ },+ 1e-3f},+ // ggml_gelu_quick_f32: x*(1/(1+expf(-1.702f*x))) -- NOT the tanh GELU above.+ UnaryCase{"gelu_quick",+ "GGML_UNARY_OP_GELU_QUICK",+ [](float x) {+ return x / (1.0f + std::exp(-1.702f * x));+ },+ 1e-4f},+ UnaryCase{"tanh",+ "GGML_UNARY_OP_TANH",+ [](float x) {+ return std::tanh(x);+ },+ 1e-4f},+ UnaryCase{"relu",+ "GGML_UNARY_OP_RELU",+ [](float x) {+ return x > 0.0f ? x : 0.0f;+ },+ 1e-4f},+ // ggml_vec_elu_f32: (x > 0) ? x : expm1f(x), i.e. ELU with alpha == 1.+ UnaryCase{"elu",+ "GGML_UNARY_OP_ELU",+ [](float x) {+ return x > 0.0f ? x : std::expm1(x);+ },+ 1e-4f},+ UnaryCase{"sin",+ "GGML_OP_SIN",+ [](float x) {+ return std::sin(x);+ },+ 1e-4f},+ UnaryCase{"cos",+ "GGML_OP_COS",+ [](float x) {+ return std::cos(x);+ },+ 1e-4f},+ UnaryCase{"softplus",+ "GGML_UNARY_OP_SOFTPLUS",+ [](float x) {+ return std::log1p(std::exp(-std::abs(x))) + std::max(x, 0.0f);+ },+ 1e-3f},+ // Log's domain is x > 0, so this case overrides the default ramp.+ UnaryCase{"log",+ "GGML_OP_LOG",+ [](float x) {+ return std::log(x);+ },+ 1e-4f,+ {0.25f, 0.5f, 1.0f, 2.0f, 3.0f, 10.0f, 100.0f, 1e-3f}}),+ [](const ::testing::TestParamInfo<UnaryCase>& i) {+ return std::string(i.param.name);+ });// Log is only defined for x > 0, so it gets its own inputs rather than the shared range above.TEST(GGUFOps, Log) {@@ -179,7 +235,7 @@ TEST(GGUFOps, GetDimensionsKeepsOutputPort) {// through an fp16 lookup table (GGML_GELU_FP16), which costs ~2e-3 / ~3.3e-3 against the exact// fp32 form; SILU runs in fp32 in the reference build and needs only 1e-5.struct GgmlRefCase {- const char* name; // also the test_data/<name>_ggml_{input,expected}.npy stem prefix+ const char* name; // also the test_data/<name>_ggml_{input,expected}.npy stem prefixconst char* op_type;float atol;};@@ -211,7 +267,9 @@ INSTANTIATE_TEST_SUITE_P(GGUFOps,::testing::Values(GgmlRefCase{"silu", "GGML_UNARY_OP_SILU", 1e-5f},GgmlRefCase{"gelu", "GGML_UNARY_OP_GELU", 2.5e-3f},GgmlRefCase{"gelu_quick", "GGML_UNARY_OP_GELU_QUICK", 4e-3f}),- [](const ::testing::TestParamInfo<GgmlRefCase>& i) { return std::string(i.param.name); });+ [](const ::testing::TestParamInfo<GgmlRefCase>& i) {+ return std::string(i.param.name);+ });// Scale: out = in * scale + bias (scale/bias in op-params slots 0,1).TEST(GGUFOps, Scale) {@@ -334,8 +392,8 @@ TEST(GGUFOps, SoftMaxAlibi) {for (size_t i = 0; i < x.size(); ++i)x[i] = 0.1f * static_cast<float>(i) - 2.0f;std::vector<float> mask{0, 0, -1e9f, -1e9f, 0, 0, 0, -1e9f};- auto out = run_on_cpu(model,- {{"x", make_f32_tensor({n_head, T, Kd}, x)}, {"mask", make_f32_tensor({1, T, Kd}, mask)}});+ auto out =+ run_on_cpu(model, {{"x", make_f32_tensor({n_head, T, Kd}, x)}, {"mask", make_f32_tensor({1, T, Kd}, mask)}});const uint32_t n_head_log2 = 1u << static_cast<uint32_t>(std::floor(std::log2(n_head)));const float m0 = std::pow(2.0f, -max_bias / n_head_log2);@@ -343,7 +401,7 @@ TEST(GGUFOps, SoftMaxAlibi) {std::vector<float> expected(x.size());for (uint32_t h = 0; h < n_head; ++h) {float slope = h < n_head_log2 ? static_cast<float>(std::pow(m0, h + 1))- : static_cast<float>(std::pow(m1, 2 * (h - n_head_log2) + 1));+ : static_cast<float>(std::pow(m1, 2 * (h - n_head_log2) + 1));for (size_t t = 0; t < T; ++t) {float mx = -1e30f;std::vector<float> z(Kd);@@ -781,10 +839,9 @@ TEST(GGUFOps, AddId) {ov::Tensor ids_t(ov::element::i32, ov::Shape{1, 1, 2, 1});std::copy(ids.begin(), ids.end(), ids_t.data<int32_t>());- auto out = run_on_cpu(model,- {{"x", make_f32_tensor({1, 2, 1, 3}, x)},- {"bias", make_f32_tensor({1, 1, 3, 3}, bias)},- {"ids", ids_t}});+ auto out = run_on_cpu(+ model,+ {{"x", make_f32_tensor({1, 2, 1, 3}, x)}, {"bias", make_f32_tensor({1, 1, 3, 3}, bias)}, {"ids", ids_t}});// token0 += expert2 (70,80,90); token1 += expert0 (10,20,30)std::vector<float> expected{1 + 70, 2 + 80, 3 + 90, 4 + 10, 5 + 20, 6 + 30};@@ -857,7 +914,7 @@ TEST(GGUFOps, MulMatId) {// expert 0 rows: [1,2,3],[4,5,6]; expert 1 rows: [7,8,9],[10,11,12]std::vector<float> w{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};std::vector<float> a{1, 0, 1, 0, 1, 0}; // token0 act=[1,0,1], token1 act=[0,1,0]- std::vector<int32_t> ids{1, 0}; // token0 -> expert1, token1 -> expert0+ std::vector<int32_t> ids{1, 0}; // token0 -> expert1, token1 -> expert0ov::Tensor ids_t(ov::element::i32, ov::Shape{1, 1, (size_t)n_tokens, 1});std::copy(ids.begin(), ids.end(), ids_t.data<int32_t>());@@ -885,8 +942,8 @@ TEST(GGUFOps, MulMatIdNused2) {// experts: e0 rows [1,0],[0,1]; e1 rows [2,0],[0,2]; e2 rows [3,0],[0,3]std::vector<float> w{1, 0, 0, 1, 2, 0, 0, 2, 3, 0, 0, 3};- std::vector<float> a{1, 2, 3, 4}; // token0 act=[1,2], token1 act=[3,4]- std::vector<int32_t> ids{0, 1, 2, 0}; // tok0 uses experts {0,1}; tok1 uses {2,0}+ std::vector<float> a{1, 2, 3, 4}; // token0 act=[1,2], token1 act=[3,4]+ std::vector<int32_t> ids{0, 1, 2, 0}; // tok0 uses experts {0,1}; tok1 uses {2,0}ov::Tensor ids_t(ov::element::i32, ov::Shape{1, 1, (size_t)n_tokens, (size_t)n_used});std::copy(ids.begin(), ids.end(), ids_t.data<int32_t>());@@ -975,9 +1032,8 @@ TEST(GGUFOps, GetRowsMoeWeights) {ov::Tensor ids_t(ov::element::i32, ov::Shape{1, 1, (size_t)n_tok, (size_t)n_used});std::copy(ids.begin(), ids.end(), ids_t.data<int32_t>());- auto out = run_on_cpu(model,- {{"probs", make_f32_tensor({1, (size_t)n_tok, (size_t)n_expert, 1}, probs)},- {"ids", ids_t}});+ auto out =+ run_on_cpu(model, {{"probs", make_f32_tensor({1, (size_t)n_tok, (size_t)n_expert, 1}, probs)}, {"ids", ids_t}});// tok0: probs[3],probs[1] = 0.4,0.2 ; tok1: probs[0],probs[2] = 0.5,0.7std::vector<float> expected{0.4f, 0.2f, 0.5f, 0.7f};@@ -1029,14 +1085,13 @@ TEST(GGUFOps, SsmConvRealDims) {sx[ch * ncs + j] = static_cast<float>(ch * 10 + j + 1);// c per-channel [d_inner][d_conv]: ch0 weighted, ch1 picks window-start, ch2 picks window-endstd::vector<float> c{0.5f, 0.25f, 0.125f, 0.0625f, 1, 0, 0, 0, 0, 0, 0, 1};- auto out = run_on_cpu(model,- {{"sx", make_f32_tensor({1, 1, d_inner, ncs}, sx)},- {"c", make_f32_tensor({1, 1, d_inner, d_conv}, c)}});+ auto out = run_on_cpu(+ model,+ {{"sx", make_f32_tensor({1, 1, d_inner, ncs}, sx)}, {"c", make_f32_tensor({1, 1, d_inner, d_conv}, c)}});// ggml-CPU oracle (ssm_conv_oracle.c) flat output, layout [n_t][d_inner]:// row t = [ch0_t, ch1_t, ch2_t]. ch1 = sx window-start (11..15), ch2 = window-end (24..28).- std::vector<float> expected{- 1.625f, 11, 24, 2.5625f, 12, 25, 3.5f, 13, 26, 4.4375f, 14, 27, 5.375f, 15, 28};+ std::vector<float> expected{1.625f, 11, 24, 2.5625f, 12, 25, 3.5f, 13, 26, 4.4375f, 14, 27, 5.375f, 15, 28};expect_near(out, expected, 1e-4f);}@@ -1056,11 +1111,10 @@ TEST(GGUFOps, SoftMaxSinks) {.build();std::vector<float> x{1, 2, 3, 3, 2, 1}; // head0 row [1,2,3], head1 row [3,2,1]- std::vector<float> sinks{0.5f, -0.5f}; // one sink logit per head+ std::vector<float> sinks{0.5f, -0.5f}; // one sink logit per headov::Tensor sinks_t(ov::element::f32, ov::Shape{1, 1, 1, n_head});std::copy(sinks.begin(), sinks.end(), sinks_t.data<float>());- auto out =- run_on_cpu(model, {{"x", make_f32_tensor({1, n_head, T, Kd}, x)}, {"sinks", sinks_t}});+ auto out = run_on_cpu(model, {{"x", make_f32_tensor({1, n_head, T, Kd}, x)}, {"sinks", sinks_t}});// Reference: softmax over [logits..., sink] then drop the sink column.std::vector<float> expected(n_head * T * Kd);@@ -1279,9 +1333,9 @@ TEST(GGUFOps, RopeNeoxPartialRotary) {std::vector<float> data{1, 2, 3, 4, 100, 200}; // [d0,d1, d2,d3, p0,p1]; only d0..d3 rotate.ov::Tensor pos_t(ov::element::i32, ov::Shape{1, 1, 1, (size_t)T});pos_t.data<int32_t>()[0] = pos;- auto out = run_on_cpu(model,- {{"data", make_f32_tensor({1, (size_t)T, (size_t)n_head, (size_t)head_dim}, data)},- {"pos", pos_t}});+ auto out =+ run_on_cpu(model,+ {{"data", make_f32_tensor({1, (size_t)T, (size_t)n_head, (size_t)head_dim}, data)}, {"pos", pos_t}});std::vector<float> cos_v, sin_v;neox_ref_cos_sin(static_cast<int>(n_rot), cfg.freq_base, cfg.freq_scale, cfg.attn_factor, pos, cos_v, sin_v);@@ -1322,9 +1376,9 @@ TEST(GGUFOps, RopeNeoxFullRotary) {std::vector<float> data{1, 2, 3, 4};ov::Tensor pos_t(ov::element::i32, ov::Shape{1, 1, 1, (size_t)T});pos_t.data<int32_t>()[0] = pos;- auto out = run_on_cpu(model,- {{"data", make_f32_tensor({1, (size_t)T, (size_t)n_head, (size_t)head_dim}, data)},- {"pos", pos_t}});+ auto out =+ run_on_cpu(model,+ {{"data", make_f32_tensor({1, (size_t)T, (size_t)n_head, (size_t)head_dim}, data)}, {"pos", pos_t}});std::vector<float> cos_v, sin_v;neox_ref_cos_sin(static_cast<int>(head_dim), cfg.freq_base, cfg.freq_scale, cfg.attn_factor, pos, cos_v, sin_v);@@ -1375,30 +1429,141 @@ TEST(GGUFOps, ImropeTextRealDims) {int32_t pos_vals[8] = {0, 1, 0, 1, 0, 1, 0, 1};std::copy(pos_vals, pos_vals + 8, pos_t.data<int32_t>());- auto out = run_on_cpu(model,- {{"data", make_f32_tensor({1, (size_t)T, (size_t)n_head, (size_t)head_dim}, data)},- {"pos", pos_t}});+ auto out =+ run_on_cpu(model,+ {{"data", make_f32_tensor({1, (size_t)T, (size_t)n_head, (size_t)head_dim}, data)}, {"pos", pos_t}});// From imrope_oracle.c (ggml-CPU IMROPE), layout [T][head_dim].- std::vector<float> expected{- // token 0 (pos 0) — identity- 1.000000f, 1.010000f, 1.020000f, 1.030000f, 1.040000f, 1.050000f, 1.060000f, 1.070000f,- 1.080000f, 1.090000f, 1.100000f, 1.110000f, 1.120000f, 1.130000f, 1.140000f, 1.150000f,- 1.160000f, 1.170000f, 1.180000f, 1.190000f, 1.200000f, 1.210000f, 1.220000f, 1.230000f,- 1.240000f, 1.250000f, 1.260000f, 1.270000f, 1.280000f, 1.290000f, 1.300000f, 1.310000f,- 1.320000f, 1.330000f, 1.340000f, 1.350000f, 1.360000f, 1.370000f, 1.380000f, 1.390000f,- 1.400000f, 1.410000f, 1.420000f, 1.430000f, 1.440000f, 1.450000f, 1.460000f, 1.470000f,- 1.480000f, 1.490000f, 1.500000f, 1.510000f, 1.520000f, 1.530000f, 1.540000f, 1.550000f,- 1.560000f, 1.570000f, 1.580000f, 1.590000f, 1.600000f, 1.610000f, 1.620000f, 1.630000f,- // token 1 (pos 1)- -0.871608f, 0.330166f, 1.051162f, 1.466389f, 1.708109f, 1.852569f, 1.941705f, 1.998783f,- 2.036994f, 2.063982f, 2.084241f, 2.100448f, 2.114208f, 2.126487f, 2.137869f, 2.148707f,- 2.159216f, 2.169524f, 2.179711f, 2.189825f, 2.199894f, 2.209936f, 2.219961f, 2.229976f,- 2.239986f, 2.249991f, 2.259995f, 2.269997f, 2.279998f, 2.289999f, 2.299999f, 2.309999f,- 2.936443f, 3.059410f, 2.907070f, 2.737353f, 2.610280f, 2.527328f, 2.477454f, 2.449871f,- 2.436607f, 2.432320f, 2.433586f, 2.438262f, 2.445020f, 2.453050f, 2.461852f, 2.471125f,- 2.480683f, 2.490415f, 2.500252f, 2.510153f, 2.520093f, 2.530056f, 2.540034f, 2.550021f,- 2.560013f, 2.570008f, 2.580004f, 2.590003f, 2.600002f, 2.610001f, 2.620001f, 2.630001f};+ std::vector<float> expected{// token 0 (pos 0) — identity+ 1.000000f,+ 1.010000f,+ 1.020000f,+ 1.030000f,+ 1.040000f,+ 1.050000f,+ 1.060000f,+ 1.070000f,+ 1.080000f,+ 1.090000f,+ 1.100000f,+ 1.110000f,+ 1.120000f,+ 1.130000f,+ 1.140000f,+ 1.150000f,+ 1.160000f,+ 1.170000f,+ 1.180000f,+ 1.190000f,+ 1.200000f,+ 1.210000f,+ 1.220000f,+ 1.230000f,+ 1.240000f,+ 1.250000f,+ 1.260000f,+ 1.270000f,+ 1.280000f,+ 1.290000f,+ 1.300000f,+ 1.310000f,+ 1.320000f,+ 1.330000f,+ 1.340000f,+ 1.350000f,+ 1.360000f,+ 1.370000f,+ 1.380000f,+ 1.390000f,+ 1.400000f,+ 1.410000f,+ 1.420000f,+ 1.430000f,+ 1.440000f,+ 1.450000f,+ 1.460000f,+ 1.470000f,+ 1.480000f,+ 1.490000f,+ 1.500000f,+ 1.510000f,+ 1.520000f,+ 1.530000f,+ 1.540000f,+ 1.550000f,+ 1.560000f,+ 1.570000f,+ 1.580000f,+ 1.590000f,+ 1.600000f,+ 1.610000f,+ 1.620000f,+ 1.630000f,+ // token 1 (pos 1)+ -0.871608f,+ 0.330166f,+ 1.051162f,+ 1.466389f,+ 1.708109f,+ 1.852569f,+ 1.941705f,+ 1.998783f,+ 2.036994f,+ 2.063982f,+ 2.084241f,+ 2.100448f,+ 2.114208f,+ 2.126487f,+ 2.137869f,+ 2.148707f,+ 2.159216f,+ 2.169524f,+ 2.179711f,+ 2.189825f,+ 2.199894f,+ 2.209936f,+ 2.219961f,+ 2.229976f,+ 2.239986f,+ 2.249991f,+ 2.259995f,+ 2.269997f,+ 2.279998f,+ 2.289999f,+ 2.299999f,+ 2.309999f,+ 2.936443f,+ 3.059410f,+ 2.907070f,+ 2.737353f,+ 2.610280f,+ 2.527328f,+ 2.477454f,+ 2.449871f,+ 2.436607f,+ 2.432320f,+ 2.433586f,+ 2.438262f,+ 2.445020f,+ 2.453050f,+ 2.461852f,+ 2.471125f,+ 2.480683f,+ 2.490415f,+ 2.500252f,+ 2.510153f,+ 2.520093f,+ 2.530056f,+ 2.540034f,+ 2.550021f,+ 2.560013f,+ 2.570008f,+ 2.580004f,+ 2.590003f,+ 2.600002f,+ 2.610001f,+ 2.620001f,+ 2.630001f};expect_near(out, expected, 1e-4f);}@@ -1442,20 +1607,19 @@ TEST(GGUFOps, ImropePartialRotary) {int32_t pos_vals[8] = {0, 1, 0, 1, 0, 1, 0, 1};std::copy(pos_vals, pos_vals + 8, pos_t.data<int32_t>());- auto out = run_on_cpu(model,- {{"data", make_f32_tensor({1, (size_t)T, (size_t)n_head, (size_t)head_dim}, data)},- {"pos", pos_t}});+ auto out =+ run_on_cpu(model,+ {{"data", make_f32_tensor({1, (size_t)T, (size_t)n_head, (size_t)head_dim}, data)}, {"pos", pos_t}});// token 1's first 64 rotated dims (from imrope_partial_oracle.c; identical to ImropeTextRealDims).- const float rot1[64] = {- -0.871608f, 0.330166f, 1.051162f, 1.466389f, 1.708109f, 1.852569f, 1.941705f, 1.998783f,- 2.036994f, 2.063982f, 2.084241f, 2.100448f, 2.114208f, 2.126487f, 2.137869f, 2.148707f,- 2.159216f, 2.169524f, 2.179711f, 2.189825f, 2.199894f, 2.209936f, 2.219961f, 2.229976f,- 2.239986f, 2.249991f, 2.259995f, 2.269997f, 2.279998f, 2.289999f, 2.299999f, 2.309999f,- 2.936443f, 3.059410f, 2.907070f, 2.737353f, 2.610280f, 2.527328f, 2.477454f, 2.449871f,- 2.436607f, 2.432320f, 2.433586f, 2.438262f, 2.445020f, 2.453050f, 2.461852f, 2.471125f,- 2.480683f, 2.490415f, 2.500252f, 2.510153f, 2.520093f, 2.530056f, 2.540034f, 2.550021f,- 2.560013f, 2.570008f, 2.580004f, 2.590003f, 2.600002f, 2.610001f, 2.620001f, 2.630001f};+ const float rot1[64] = {-0.871608f, 0.330166f, 1.051162f, 1.466389f, 1.708109f, 1.852569f, 1.941705f, 1.998783f,+ 2.036994f, 2.063982f, 2.084241f, 2.100448f, 2.114208f, 2.126487f, 2.137869f, 2.148707f,+ 2.159216f, 2.169524f, 2.179711f, 2.189825f, 2.199894f, 2.209936f, 2.219961f, 2.229976f,+ 2.239986f, 2.249991f, 2.259995f, 2.269997f, 2.279998f, 2.289999f, 2.299999f, 2.309999f,+ 2.936443f, 3.059410f, 2.907070f, 2.737353f, 2.610280f, 2.527328f, 2.477454f, 2.449871f,+ 2.436607f, 2.432320f, 2.433586f, 2.438262f, 2.445020f, 2.453050f, 2.461852f, 2.471125f,+ 2.480683f, 2.490415f, 2.500252f, 2.510153f, 2.520093f, 2.530056f, 2.540034f, 2.550021f,+ 2.560013f, 2.570008f, 2.580004f, 2.590003f, 2.600002f, 2.610001f, 2.620001f, 2.630001f};std::vector<float> expected(T * head_dim);for (int e = 0; e < head_dim; ++e)@@ -1467,8 +1631,8 @@ TEST(GGUFOps, ImropePartialRotary) {}// The f4e2m1 nibble -> value lookup used by the packed MXFP4 dequant (mirrors mul_mat_id.cpp).-static const float kF4E2M1[16] = {0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 3.0f, 4.0f, 6.0f,- -0.0f, -0.5f, -1.0f, -1.5f, -2.0f, -3.0f, -4.0f, -6.0f};+static const float kF4E2M1[16] =+ {0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 3.0f, 4.0f, 6.0f, -0.0f, -0.5f, -1.0f, -1.5f, -2.0f, -3.0f, -4.0f, -6.0f};// MUL_MAT_ID over PACKED MXFP4 experts (gpt-oss MoE): expert weights are raw u8 rank-5 blocks// [1, n_expert, m, k_blocks, 17] (byte0 = e8m0 scale exponent, bytes1..16 = 32 nibble-packed@@ -1517,18 +1681,17 @@ TEST(GGUFOps, MulMatIdMxfp4Packed) {// activations: token0 = e0 pattern, token1 = e1 pattern; only lane 0 is nonzero.std::vector<float> a(n_tokens * cols, 0.0f);- a[0 * cols + 0] = 1.0f; // token0 act lane0 = 1- a[1 * cols + 0] = 1.0f; // token1 act lane0 = 1+ a[0 * cols + 0] = 1.0f; // token0 act lane0 = 1+ a[1 * cols + 0] = 1.0f; // token1 act lane0 = 1std::vector<int32_t> ids{1, 0}; // token0 -> expert1, token1 -> expert0ov::Tensor w_t(ov::element::u8, ov::Shape{1, (size_t)n_expert, (size_t)m, (size_t)k_blocks, block_bytes});std::memcpy(w_t.data<uint8_t>(), packed.data(), packed.size());ov::Tensor ids_t(ov::element::i32, ov::Shape{1, 1, (size_t)n_tokens, 1});std::copy(ids.begin(), ids.end(), ids_t.data<int32_t>());- auto out = run_on_cpu(model,- {{"w", w_t},- {"a", make_f32_tensor({1, (size_t)n_tokens, 1, (size_t)cols}, a)},- {"ids", ids_t}});+ auto out =+ run_on_cpu(model,+ {{"w", w_t}, {"a", make_f32_tensor({1, (size_t)n_tokens, 1, (size_t)cols}, a)}, {"ids", ids_t}});// Reference: out[token][row] = sum_col dequant(expert=ids[token], row, col) * act[token][col].auto dequant = [&](int e, int row, int col) -> float {@@ -1774,8 +1937,8 @@ TEST(GGUFOps, GatedDeltaNetMultipleSnapshotSlotsRejected) {TEST(GGUFOps, GatedDeltaNetFused) {const int64_t B = 1, T = 2, H = 1, D = 2; // head size D = Dv = 2, scalar gateauto qkv_shp = ov::PartialShape{B, T, H, D};- auto gate_shp = ov::PartialShape{B, T, H, 1}; // scalar gate -> fused path- auto state_shp = ov::PartialShape{B, H, D, D}; // ggml [B, H_v, value_dim, key_dim]+ auto gate_shp = ov::PartialShape{B, T, H, 1}; // scalar gate -> fused path+ auto state_shp = ov::PartialShape{B, H, D, D}; // ggml [B, H_v, value_dim, key_dim]auto model = SingleOpBuilder().op("GGML_OP_GATED_DELTA_NET").input("q", ov::element::f32, qkv_shp)@@ -1812,7 +1975,7 @@ TEST(GGUFOps, GatedDeltaNetFused) {// update state[d][dv] += k[d]*(v[dv]-h_k[dv])*beta; attn[dv] = sum_d state[d][dv]*q_scaled[d].const float scale = 1.0f / std::sqrt((float)D);std::vector<std::vector<float>> st(D, std::vector<float>(D, 0.0f)); // st[d][dv]- std::vector<float> attn; // [T*D]+ std::vector<float> attn; // [T*D]for (int t = 0; t < T; ++t) {std::vector<float> qs(D), kv(D);for (int d = 0; d < D; ++d) {@@ -1880,11 +2043,15 @@ TEST(GGUFOps, GatedDeltaNetFusedMultiHead) {std::vector<float> q{1, 0, 0, 1, /*t1*/ 0, 1, 1, 0};std::vector<float> k{1, 0, 0, 1, /*t1*/ 1, 1, 0, 1};std::vector<float> v{1, 2, 3, 4, /*t1*/ 5, 6, 7, 8};- std::vector<float> g{0.0f, 0.0f, 0.0f, 0.0f}; // exp(g)=1+ std::vector<float> g{0.0f, 0.0f, 0.0f, 0.0f}; // exp(g)=1std::vector<float> beta{1.0f, 1.0f, 1.0f, 1.0f}; // full updatestd::vector<float> state0(H * D * D, 0.0f);- auto idx = [&](int t, int h, int d) { return (t * H + h) * D + d; }; // [T,H,D]- auto gidx = [&](int t, int h) { return t * H + h; }; // [T,H]+ auto idx = [&](int t, int h, int d) {+ return (t * H + h) * D + d;+ }; // [T,H,D]+ auto gidx = [&](int t, int h) {+ return t * H + h;+ }; // [T,H]auto out = run_on_cpu(model,{{"q", make_f32_tensor({(size_t)B, (size_t)T, (size_t)H, (size_t)D}, q)},@@ -1894,8 +2061,8 @@ TEST(GGUFOps, GatedDeltaNetFusedMultiHead) {{"beta", make_f32_tensor({(size_t)B, (size_t)T, (size_t)H, 1}, beta)},{"state", make_f32_tensor({(size_t)B, (size_t)H, (size_t)D, (size_t)D}, state0)}});- (void) idx;- (void) gidx;+ (void)idx;+ (void)gidx;// Authoritative reference: the flat output of ggml's own CPU GGML_OP_GATED_DELTA_NET kernel for// these exact inputs (generated by the standalone oracle in// src/frontends/gguf/tests/gdn_oracle.c, run against llama.cpp's libggml-cpu). Using ggml's@@ -1903,13 +2070,24 @@ TEST(GGUFOps, GatedDeltaNetFusedMultiHead) {// assumptions into the expectation. The packed layout is [S_v*H, T + K*S_v] flattened: T=2// attention rows (width S_v*H, head-outer/value-inner) then K*S_v=2 final-state rows. Note the// state is packed head-outer/value-dim/key-dim -- a multi-head order the H=1 tests can't probe.- std::vector<float> expected{- // attention, token 0 and token 1 (each row: head0[sv0,sv1], head1[sv0,sv1])- 0.707107f, 1.414214f, 2.121320f, 2.828427f,- 2.828427f, 2.828427f, 0.000000f, 0.000000f,- // final state, two rows (head-outer): head0 [dv0(d0,d1), dv1(d0,d1)], head1 [...]- 5.000000f, 4.000000f, 6.000000f, 4.000000f,- 0.000000f, 7.000000f, 0.000000f, 8.000000f};+ std::vector<float> expected{// attention, token 0 and token 1 (each row: head0[sv0,sv1], head1[sv0,sv1])+ 0.707107f,+ 1.414214f,+ 2.121320f,+ 2.828427f,+ 2.828427f,+ 2.828427f,+ 0.000000f,+ 0.000000f,+ // final state, two rows (head-outer): head0 [dv0(d0,d1), dv1(d0,d1)], head1 [...]+ 5.000000f,+ 4.000000f,+ 6.000000f,+ 4.000000f,+ 0.000000f,+ 7.000000f,+ 0.000000f,+ 8.000000f};expect_near(out, expected, 1e-4f);}@@ -1965,11 +2143,22 @@ TEST(GGUFOps, GatedDeltaNetRefMultiHead) {{"state", make_f32_tensor({(size_t)B, (size_t)H, (size_t)D, (size_t)D}, state0)}});// Same ggml-CPU oracle values as the fused multi-head test.- std::vector<float> expected{- 0.707107f, 1.414214f, 2.121320f, 2.828427f,- 2.828427f, 2.828427f, 0.000000f, 0.000000f,- 5.000000f, 4.000000f, 6.000000f, 4.000000f,- 0.000000f, 7.000000f, 0.000000f, 8.000000f};+ std::vector<float> expected{0.707107f,+ 1.414214f,+ 2.121320f,+ 2.828427f,+ 2.828427f,+ 2.828427f,+ 0.000000f,+ 0.000000f,+ 5.000000f,+ 4.000000f,+ 6.000000f,+ 4.000000f,+ 0.000000f,+ 7.000000f,+ 0.000000f,+ 8.000000f};expect_near(out, expected, 1e-4f);}@@ -1982,11 +2171,39 @@ TEST(GGUFOps, GatedDeltaNetRefMultiHead) {// distinct per-head inputs; expected = ggml-CPU oracle gdn_gqa_oracle.c.static const std::vector<float> kGdnGqaExpected{// attention rows (T=2), each row = 4 v-heads x D=2, head-outer/value-inner- 0.707107f, 1.414214f, 2.121320f, 2.828427f, 3.535534f, 4.242640f, 4.949748f, 5.656854f,- 5.656854f, 5.656854f, 0.000000f, 0.000000f, 5.656854f, 5.656854f, 0.000000f, 0.000000f,+ 0.707107f,+ 1.414214f,+ 2.121320f,+ 2.828427f,+ 3.535534f,+ 4.242640f,+ 4.949748f,+ 5.656854f,+ 5.656854f,+ 5.656854f,+ 0.000000f,+ 0.000000f,+ 5.656854f,+ 5.656854f,+ 0.000000f,+ 0.000000f,// final-state rows (D=2), head-outer: each head [dv0(d0,d1), dv1(d0,d1)]- 9.000000f, 8.000000f, 10.000000f, 8.000000f, 0.000000f, 11.000000f, 0.000000f, 12.000000f,- 13.000000f, 8.000000f, 14.000000f, 8.000000f, 0.000000f, 15.000000f, 0.000000f, 16.000000f};+ 9.000000f,+ 8.000000f,+ 10.000000f,+ 8.000000f,+ 0.000000f,+ 11.000000f,+ 0.000000f,+ 12.000000f,+ 13.000000f,+ 8.000000f,+ 14.000000f,+ 8.000000f,+ 0.000000f,+ 15.000000f,+ 0.000000f,+ 16.000000f};static void run_gdn_gqa(bool force_ref) {const int64_t B = 1, T = 2, H_v = 4, H_k = 2, D = 2;@@ -2044,24 +2261,21 @@ TEST(GGUFOps, GatedDeltaNetRefGQA) {namespace {// ggml-CPU oracle output for the T=3,H=2,D=4 inputs below (row-major, 7 rows x 8 cols).const std::vector<float> kGdnTneqDExpected{- 0.037500f, 0.075000f, 0.112500f, 0.150000f, 0.885000f, 1.062000f, 1.239000f, 1.416000f,- 2.495686f, 2.863373f, 3.231059f, 3.598745f, 7.552056f, 8.348866f, 9.145678f, 9.942489f,+ 0.037500f, 0.075000f, 0.112500f, 0.150000f, 0.885000f, 1.062000f, 1.239000f, 1.416000f,+ 2.495686f, 2.863373f, 3.231059f, 3.598745f, 7.552056f, 8.348866f, 9.145678f, 9.942489f,10.676509f, 11.612682f, 12.548857f, 13.485029f, 18.103098f, 19.490808f, 20.878521f, 22.266232f,- 1.785152f, 2.487126f, 3.189099f, 3.891073f, 1.928201f, 2.700328f, 3.472456f, 4.244583f,- 2.071249f, 2.913531f, 3.755813f, 4.598094f, 2.214298f, 3.126734f, 4.039169f, 4.951605f,- 7.141428f, 4.162388f, 2.434744f, 2.688347f, 7.614682f, 4.536554f, 2.686254f, 2.846659f,- 8.087935f, 4.910720f, 2.937764f, 3.004971f, 8.561190f, 5.284886f, 3.189275f, 3.163283f};+ 1.785152f, 2.487126f, 3.189099f, 3.891073f, 1.928201f, 2.700328f, 3.472456f, 4.244583f,+ 2.071249f, 2.913531f, 3.755813f, 4.598094f, 2.214298f, 3.126734f, 4.039169f, 4.951605f,+ 7.141428f, 4.162388f, 2.434744f, 2.688347f, 7.614682f, 4.536554f, 2.686254f, 2.846659f,+ 8.087935f, 4.910720f, 2.937764f, 3.004971f, 8.561190f, 5.284886f, 3.189275f, 3.163283f};// Inputs (row-major [T,H,D] for q/k/v, [T,H] for g/beta), matching gdn_oracle2.c.-const std::vector<float> kGdnTneqDq{- 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f,- 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.1f, 2.2f, 2.3f, 2.4f};-const std::vector<float> kGdnTneqDk{- 0.05f, 0.10f, 0.15f, 0.20f, 0.25f, 0.30f, 0.35f, 0.05f, 0.10f, 0.15f, 0.20f, 0.25f,- 0.30f, 0.35f, 0.05f, 0.10f, 0.15f, 0.20f, 0.25f, 0.30f, 0.35f, 0.05f, 0.10f, 0.15f};-const std::vector<float> kGdnTneqDv{- 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f,- 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f};+const std::vector<float> kGdnTneqDq{0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f,+ 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.1f, 2.2f, 2.3f, 2.4f};+const std::vector<float> kGdnTneqDk{0.05f, 0.10f, 0.15f, 0.20f, 0.25f, 0.30f, 0.35f, 0.05f, 0.10f, 0.15f, 0.20f, 0.25f,+ 0.30f, 0.35f, 0.05f, 0.10f, 0.15f, 0.20f, 0.25f, 0.30f, 0.35f, 0.05f, 0.10f, 0.15f};+const std::vector<float> kGdnTneqDv{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f,+ 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f};const std::vector<float> kGdnTneqDg{0.0f, -0.1f, -0.2f, 0.0f, -0.1f, -0.2f};const std::vector<float> kGdnTneqDbeta{0.5f, 0.6f, 0.7f, 0.8f, 0.5f, 0.6f};@@ -2437,8 +2651,9 @@ TEST(GGUFOps, DivEmptyTokens) {.output("out", ov::element::f32, {ov::Dimension::dynamic(), 4}).build();- auto out = run_on_cpu(model, {{"a", ov::Tensor(ov::element::f32, ov::Shape{0, 4})},- {"b", ov::Tensor(ov::element::f32, ov::Shape{0, 4})}});+ auto out = run_on_cpu(+ model,+ {{"a", ov::Tensor(ov::element::f32, ov::Shape{0, 4})}, {"b", ov::Tensor(ov::element::f32, ov::Shape{0, 4})}});EXPECT_EQ(out.get_shape(), (ov::Shape{0, 4}));}diff --git a/src/frontends/gguf/tests/test_weights.cpp b/src/frontends/gguf/tests/test_weights.cppindex 3add208795c..244ff204586 100644--- a/src/frontends/gguf/tests/test_weights.cpp+++ b/src/frontends/gguf/tests/test_weights.cpp@@ -203,8 +203,8 @@ TEST(GGUFWeightUnsupported, Q8KIsNotAStoredWeight) {// make_weight_node must dequantize those too. f4e2m1 nibble -> value mirrors kF4E2M1 in// test_ops.cpp; scale byte 127 -> e8m0 exponent 0 -> 2^0 = 1.0.TEST(GGUFWeight, Mxfp4TwoDim) {- static const float kF4E2M1[16] = {0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 3.0f, 4.0f, 6.0f,- -0.0f, -0.5f, -1.0f, -1.5f, -2.0f, -3.0f, -4.0f, -6.0f};+ static const float kF4E2M1[16] =+ {0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 3.0f, 4.0f, 6.0f, -0.0f, -0.5f, -1.0f, -1.5f, -2.0f, -3.0f, -4.0f, -6.0f};// 1 row, 1 block (32 cols): byte0 = e8m0 scale, bytes1..16 = nibble-packed codes (low nibble// = element i, high nibble = element i+16, for i in [0,16)).ov::Tensor data(ov::element::u8, ov::Shape{17});