Skip to content

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

[GPU][MLIR] MLIR Graph compiler integration (#35336)

Dmitry Chigarevc6df38c7fea4
diff --git a/cmake/developer_package/plugins/plugins.cmake b/cmake/developer_package/plugins/plugins.cmake
index c5af52cf7e4..50f6a453b5a 100644
--- a/cmake/developer_package/plugins/plugins.cmake
+++ b/cmake/developer_package/plugins/plugins.cmake
@@ -31,6 +31,7 @@ endif()
# [SOURCES <sources>]
# [OBJECT_LIBRARIES <object_libs>]
# [VERSION_DEFINES_FOR <source>]
+# [LINKABLE] Build as a shared library so tests can link it
# [SKIP_INSTALL]
# [SKIP_REGISTRATION] Skip creation of <device>.xml
# [ADD_CLANG_FORMAT]
@@ -38,7 +39,7 @@ endif()
# )
#
function(ov_add_plugin)
- set(options SKIP_INSTALL PSEUDO_DEVICE ADD_CLANG_FORMAT ADD_CLANG_TIDY AS_EXTENSION SKIP_REGISTRATION)
+ set(options SKIP_INSTALL PSEUDO_DEVICE ADD_CLANG_FORMAT ADD_CLANG_TIDY AS_EXTENSION SKIP_REGISTRATION LINKABLE)
set(oneValueArgs NAME DEVICE_NAME VERSION_DEFINES_FOR PSEUDO_PLUGIN_FOR)
set(multiValueArgs DEFAULT_CONFIG SOURCES OBJECT_LIBRARIES)
cmake_parse_arguments(OV_PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
@@ -60,7 +61,11 @@ function(ov_add_plugin)
endforeach()
if(BUILD_SHARED_LIBS)
- set(library_type MODULE)
+ if(OV_PLUGIN_LINKABLE)
+ set(library_type SHARED)
+ else()
+ set(library_type MODULE)
+ endif()
else()
set(library_type STATIC)
endif()
diff --git a/cmake/features.cmake b/cmake/features.cmake
index 743240ff139..74761ae8d32 100644
--- a/cmake/features.cmake
+++ b/cmake/features.cmake
@@ -61,6 +61,7 @@ ov_dependent_option (ENABLE_INTEL_NPU_INTERNAL "NPU plugin internal components f
ov_option (ENABLE_DEBUG_CAPS "enable OpenVINO debug capabilities at runtime" OFF)
ov_dependent_option (ENABLE_NPU_DEBUG_CAPS "enable NPU debug capabilities at runtime" ON "ENABLE_DEBUG_CAPS;ENABLE_INTEL_NPU" OFF)
ov_dependent_option (ENABLE_GPU_DEBUG_CAPS "enable GPU debug capabilities at runtime" ON "ENABLE_DEBUG_CAPS;ENABLE_INTEL_GPU" OFF)
+ov_dependent_option (ENABLE_MLIR_FOR_GPU "Enable MLIR / Graph Compiler based execution in GPU plugin [EXPERIMENTAL, NOT PRODUCTION-READY]" OFF "ENABLE_INTEL_GPU;ENABLE_GPU_DEBUG_CAPS" OFF)
ov_dependent_option (ENABLE_CPU_DEBUG_CAPS "enable CPU debug capabilities at runtime" ON "ENABLE_DEBUG_CAPS;ENABLE_INTEL_CPU" OFF)
ov_dependent_option (ENABLE_SNIPPETS_DEBUG_CAPS "enable Snippets debug capabilities at runtime" ON "ENABLE_DEBUG_CAPS" OFF)
diff --git a/src/plugins/intel_gpu/CMakeLists.txt b/src/plugins/intel_gpu/CMakeLists.txt
index 5f79e7f10ea..1c1bb25d359 100644
--- a/src/plugins/intel_gpu/CMakeLists.txt
+++ b/src/plugins/intel_gpu/CMakeLists.txt
@@ -128,15 +128,48 @@ if(CMAKE_COMPILER_IS_GNUCXX)
ov_add_compiler_flags(-Werror)
endif()
+# Directory-wide on purpuse: the macro guards virtual methods in
+# include/intel_gpu/runtime, so ENABLE_MLIR_FOR_GPU must be defined consistently in all targets
+# sharing those headers.
+if(ENABLE_MLIR_FOR_GPU)
+ add_compile_definitions(ENABLE_MLIR_FOR_GPU)
+endif()
+
add_subdirectory(src/runtime)
add_subdirectory(src/kernel_selector)
add_subdirectory(src/graph)
file(GLOB_RECURSE PLUGIN_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/plugin/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/include/intel_gpu/plugin/*.hpp)
+# MLIR sources are always excluded from the main plugin target. When
+# ENABLE_MLIR_FOR_GPU=ON they are built into a dedicated OBJECT library
+# (openvino_intel_gpu_mlir_obj) that has MLIR/Graph-Compiler include paths;
+# when OFF they must not be compiled at all.
+set(OV_GPU_MLIR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/plugin/transformations/mlir)
+file(GLOB_RECURSE GPU_MLIR_SOURCES ${OV_GPU_MLIR_DIR}/*.cpp)
+list(REMOVE_ITEM PLUGIN_SOURCES ${GPU_MLIR_SOURCES})
+
+if(ENABLE_MLIR_FOR_GPU)
+ include(thirdparty/cmake/graph-compiler.cmake)
+
+ set(mlir_lib openvino_intel_gpu_mlir_obj)
+ add_library(${mlir_lib} OBJECT ${GPU_MLIR_SOURCES})
+ target_link_libraries(${mlir_lib} PRIVATE openvino::runtime openvino_intel_gpu_graph GraphCompiler)
+ target_include_directories(${mlir_lib} PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}/include/
+ ${OV_GPU_MLIR_DIR})
+ # Not created via ov_add_plugin, so clang-tidy has to be applied explicitly.
+ ov_apply_clang_tidy(TARGET ${mlir_lib})
+
+ set(GPU_PLUGIN_OBJECT_LIBRARIES ${mlir_lib})
+ set(GPU_PLUGIN_OPTIONS LINKABLE)
+endif()
+
ov_add_plugin(NAME ${TARGET_NAME}
DEVICE_NAME "GPU"
SOURCES ${PLUGIN_SOURCES}
+ OBJECT_LIBRARIES ${GPU_PLUGIN_OBJECT_LIBRARIES}
+ ${GPU_PLUGIN_OPTIONS}
DEFAULT_CONFIG ${PLUGIN_DEFAULT_CONFIG}
VERSION_DEFINES_FOR src/plugin/plugin.cpp
# ADD_CLANG_TIDY makes ov_add_plugin apply clang-tidy to this target.
@@ -161,6 +194,17 @@ endif()
target_include_directories(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include/)
+if(ENABLE_MLIR_FOR_GPU)
+ target_link_libraries(${TARGET_NAME} PRIVATE GraphCompiler)
+ # Per target, unlike ENABLE_MLIR_FOR_GPU: must be defined by everyone linking
+ # openvino_intel_gpu_mlir_obj, since only it provides mlir::transformMLIR().
+ # Workaround to fix tests build: ov_gpu_unit_tests '#includes transformations_pipeline.cpp'
+ # (xattention_kv_cache_transform_test.cpp) but links neither the MLIR objects nor the plugin's
+ # hidden symbols, so guarding the call with ENABLE_MLIR_FOR_GPU alone breaks that link with an
+ # undefined reference to transformMLIR().
+ target_compile_definitions(${TARGET_NAME} PRIVATE OV_GPU_MLIR_BACKEND_LINKED)
+endif()
+
ov_set_threading_interface_for(${TARGET_NAME})
ov_gpu_set_runtime_interface_for(${TARGET_NAME})
diff --git a/src/plugins/intel_gpu/README.md b/src/plugins/intel_gpu/README.md
index 4c1b2744347..7640fbd2e8a 100644
--- a/src/plugins/intel_gpu/README.md
+++ b/src/plugins/intel_gpu/README.md
@@ -56,6 +56,7 @@ This contents explain the internal implementation of dynamic shape support in th
## Additional Documentation
* [How to build with DPC++ support](./docs/gpu_plugin_with_sycl.md)
* [GPU plugin Level Zero support](./docs/gpu_plugin_with_level_zero.md)
+* [Experimental MLIR execution path in GPU plugin](./docs/mlir/overall_flow.md)
## Troubleshooting / Debugging
* [Debug utils](./docs/gpu_debug_utils.md)
diff --git a/src/plugins/intel_gpu/docs/mlir/build_and_test.md b/src/plugins/intel_gpu/docs/mlir/build_and_test.md
new file mode 100644
index 00000000000..9d8c4bb4f66
--- /dev/null
+++ b/src/plugins/intel_gpu/docs/mlir/build_and_test.md
@@ -0,0 +1,58 @@
+# How to build and test OV with MLIR support
+
+MLIR and Graph Compiler are not added as third-party submodules to the project, so a developer has to manually
+build a suitable LLVM & Graph Compiler and then provide cmake-configs during the OpenVINO build.
+
+The pinned Graph Compiler revision can be found in
+[`thirdparty/cmake/graph-compiler.cmake`](../../thirdparty/cmake/graph-compiler.cmake).
+
+## 1. Clone a suitable graph-compiler and build gc + llvm
+
+```sh
+git clone --depth 1 --branch ov_pin/0.1.1 https://github.com/dchigarev/graph-compiler.git
+cd graph-compiler
+export GRAPH_COMPILER_DIR=$(pwd)
+
+# This script clones a suitable llvm to `graph-compiler/externals/llvm-project`;
+# builds llvm; builds graph-compiler
+./scripts/compile.sh -r
+```
+
+## 2. Build OpenVINO with MLIR support
+
+```sh
+export GC_INSTALL_DIR=$GRAPH_COMPILER_DIR/build/install
+export LLVM_INSTALL_DIR=$GRAPH_COMPILER_DIR/externals/llvm-project/build
+
+cmake -S <openvino> -B <build> \
+ -DENABLE_INTEL_GPU=ON \
+ -DENABLE_DEBUG_CAPS=ON \ # enabling DEBUG_CAPS is mandatory for MLIR support
+ -DENABLE_MLIR_FOR_GPU=ON \
+ -DGraphCompiler_DIR="${GC_INSTALL_DIR}/lib/cmake/GraphCompiler" \
+ -DMLIR_DIR="${LLVM_INSTALL_DIR}/lib/cmake/mlir" \
+ -DLLVM_DIR="${LLVM_INSTALL_DIR}/lib/cmake/llvm" \
+ ...
+```
+
+## 3. Run
+
+```sh
+export OV_GPU_ENABLE_MLIR=1 # env variable only, DEBUG_GLOBAL options are not read from the config file
+```
+
+## Testing
+
+```
+OV_GPU_ENABLE_MLIR=1 ./bin/intel64/Release/ov_gpu_func_tests --gtest_filter="*mlir*"
+```
+
+The MLIR path is tested via its own test suites located at `tests/functional/mlir_op` (the suites are **not**
+included to the regular build, they are only built with `ENABLE_MLIR_FOR_GPU=ON`). The suites are mostly
+copied from the usual OV tests (e.g. `functional/single_layer_tests/dynamic/scaled_dot_product_attention.cpp`
+-> `functional/mlir_op/sdpa.cpp`) but redefine the tests base class (to `MlirSubgraphTest`), sometimes include
+additional cases or change the accuracy thresholds that are suitable for the mlir implementations.
+
+## See also
+
+ * [MLIR execution path in GPU plugin](./overall_flow.md)
+ * [OpenVINO GPU Plugin](../../README.md)
diff --git a/src/plugins/intel_gpu/docs/mlir/overall_flow.md b/src/plugins/intel_gpu/docs/mlir/overall_flow.md
new file mode 100644
index 00000000000..d52be064a1e
--- /dev/null
+++ b/src/plugins/intel_gpu/docs/mlir/overall_flow.md
@@ -0,0 +1,111 @@
+# MLIR execution path in GPU plugin
+
+## How to build and test
+
+MLIR and Graph Compiler are not added as third-party submodules, so a suitable LLVM & Graph Compiler have to be
+built manually and then passed to the OpenVINO build via `-DENABLE_MLIR_FOR_GPU=ON` + `GraphCompiler_DIR` /
+`MLIR_DIR` / `LLVM_DIR`. At runtime the path is enabled with `OV_GPU_ENABLE_MLIR=1`
+(`ov::intel_gpu::enable_mlir`), and is tested by the `tests/functional/mlir_op` suites, which are only built
+when `ENABLE_MLIR_FOR_GPU=ON`.
+
+Full instructions: [How to build and test OV with MLIR support](./build_and_test.md).
+
+## Overview
+
+The GPU plugin has an optional MLIR-based execution path for a subset of the model. A stage called
+`transformMLIR` is added to the GPU's transformation pipeline that matches suitable subgraphs in
+`ov::Model`, converts them to mlir-module(s) using [linalg-dialect](https://mlir.llvm.org/docs/Dialects/Linalg/),
+and inserts an `ov::intel_gpu::op::MLIROp` operation representing the converted subgraph.
+
+An actual compilation and execution of the converted MLIR module happens in a separate project called
+`graph-compiler (GC)` - the project is "ingress-agnostic" and doesn't depend on OV specifically, it handles
+an arbitrary mlir-linalg-code as an input and produces a GPU-binary combined with a cpu-side launching code
+(using OpenCL runtime). The OpenVINO side is only responsible for matching a suitable subgraph in `ov::Model`,
+converting it to MLIR as is (all the optimizations are made on the graph-compiler side), and providing the
+runtime-info on inference (OpenCL queue/context handlers, buffers, etc).
+
+`MLIROp` naturally follows the OV's compile/infer semantic: on model compilation the MLIR module is fully
+compiled to a binary (even if the module has dynamic shapes), on `infer()` it launches the compiled binary
+(no extra latency).
+
+## Communication with the graph-compiler
+
+`MLIROp` communicates with the graph-compiler using its public api (the actual communication is delegated to a
+separate `intel_gpu::mlir::MLIREvaluateGcGPU` class that is defined under `transformations/mlir` to avoid
+bringing mlir/gc includes to the main plugin). The simplified flow is following:
+
+**A. Compilation:**
+
+During `transformMLIR` each partitioned subgraph is lowered to an MLIR linalg module and wrapped into an
+`MLIROp`. The op's execution engine, `MLIREvaluateGcGPU`, is constructed first, and its constructor hands the
+module to the Graph Compiler - `gc::gpu::OclModuleBuilder(module).build(device, context)` - which JIT-compiles
+it and returns a `gc::gpu::OclModule`: a binary holding both the generated GPU kernels and the host code that
+launches them.
+
+By the time the `MLIROp` is inserted into the `ov::Model`, the subgraph it replaces is already fully compiled
+into a device binary.
+
+**B. Inference:**
+
+The op becomes a `cldnn::mlir_primitive` that owns nothing but the `MLIROp` itself - there is no GPU kernel to
+compile or cache for it. At inference `mlir_primitive_impl::execute_impl`:
+
+* extracts the native OpenCL handles (`cl_mem` / USM pointers, `cl_command_queue`, dependency `cl_event`s) out
+ of the cldnn runtime;
+* passes them through an `ov::EvaluationContext` into `MLIROp::evaluate()`;
+* turns the resulting `cl_event`s back into cldnn events.
+
+The native handles are exposed by `get_native_handle()` accessors added to `cldnn::memory`, `cldnn::event` and
+`cldnn::stream`. Only the OCL runtime implements them, so the MLIR path is OCL-only for now
+(`mlir_primitive_impl` throws if a handle is unavailable).
+
+## Code organization
+
+All the MLIR/Graph-Compiler dependent sources live under `src/plugin/transformations/mlir/` and are built into a
+dedicated OBJECT library `openvino_intel_gpu_mlir_obj` that alone gets the MLIR/GC include dirs and links
+`GraphCompiler`; the object library is then linked into the plugin. This keeps `mlir/*.h` and `gc/*.h` out of
+every other translation unit.
+
+The only headers other plugin code may include are the ones from `transformations/mlir/interface/`
+(`convert.hpp`, `mlir_evaluate_base.hpp`, `properties.hpp`) - they are MLIR/GC free. The same applies to the
+`MLIROp` (`include/intel_gpu/op/mlir_op.hpp`) and `cldnn::mlir_primitive`
+(`include/intel_gpu/primitives/mlir_primitive.hpp`) declarations: no MLIR/GC types cross this boundary, so the
+whole `graph` library stays MLIR-free.
+
+## Feature enabling
+
+The feature is disabled by default and gated twice:
+* at **build time** by `-DENABLE_MLIR_FOR_GPU=ON` (default `OFF`) - when off, no MLIR related
+ *implementations* are compiled (no pattern matching/conversion/unit tests/inference logic). The MLIR-related
+ *definitions* are still included to the build though (`MLIROp` or `cldnn::mlir_primitive` header files) to
+ avoid sudden broken includes. The option requires `ENABLE_GPU_DEBUG_CAPS` (i.e. `ENABLE_DEBUG_CAPS=ON`),
+ since all the runtime knobs of the feature are DEBUG options and the path would otherwise be impossible
+ to switch on.
+* at **runtime** by `ov::intel_gpu::enable_mlir` property (env variable `OV_GPU_ENABLE_MLIR`) which is also
+ `false` by default. The option is `DEBUG_GLOBAL`, i.e. it applies to all models of the process and is
+ settable via the env variable only - neither the public API nor the GPU config file accept it.
+
+## Supported subgraphs
+
+`ScaledDotProductAttention` is the only operation that is enabled via MLIR path by default.
+
+The MLIR path supports a lot more operations (see `transformations/mlir/common/converters`), there are unit
+tests for them, but they were never tested on a "real model".
+
+Enabling/disabling certain matching patterns can be controlled via the `ov::intel_gpu::mlir_patterns`
+option (`OV_GPU_MLIR_PATTERNS` env variable):
+* unset or empty - fall back to the default patterns (`sdpa=ScaledDotProductAttention`);
+* `"*"` - enables conversion for every supported operation;
+* `"name1=Type1,Type2;name2=Type3,Type4"` - match only the specified chains, e.g.
+ `OV_GPU_MLIR_PATTERNS='mart=MatMul,Add,Reshape,Transpose;rms=Power,ReduceMean,Add,Sqrt,Divide'` would match
+ projection subgraphs.
+
+`mlir_patterns` is a per-model `DEBUG` option, so unlike `enable_mlir` it can also be set via the GPU
+config file. Verbose logging of the pipeline is controlled by `ov::intel_gpu::mlir_debug`
+(`OV_GPU_MLIR_DEBUG`), which is `DEBUG_GLOBAL` like `enable_mlir`.
+
+## See also
+
+ * [How to build and test OV with MLIR support](./build_and_test.md)
+ * [OpenVINO GPU Plugin](../../README.md)
+ * [Developer documentation](../../../../../docs/dev/index.md)
diff --git a/src/plugins/intel_gpu/include/intel_gpu/op/mlir_op.hpp b/src/plugins/intel_gpu/include/intel_gpu/op/mlir_op.hpp
new file mode 100644
index 00000000000..cdc7a3e1247
--- /dev/null
+++ b/src/plugins/intel_gpu/include/intel_gpu/op/mlir_op.hpp
@@ -0,0 +1,50 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <memory>
+#include <tuple>
+#include <vector>
+
+#include "openvino/core/any.hpp"
+#include "openvino/core/partial_shape.hpp"
+#include "openvino/core/type/element_type.hpp"
+#include "openvino/op/op.hpp"
+#include "openvino/runtime/tensor.hpp"
+
+namespace ov::intel_gpu {
+namespace mlir {
+class MLIREvaluateBase;
+} // namespace mlir
+namespace op {
+
+using OVOutputTypes = std::vector<std::tuple<ov::element::Type, ov::PartialShape>>;
+
+// Maps [output index][dimension index] -> [input index][dimension index] to
+// infer shapes for the entire subgraph.
+using DimensionsMap = std::vector<std::vector<std::tuple<size_t, size_t>>>;
+
+class MLIROp : public ov::op::Op {
+ std::shared_ptr<mlir::MLIREvaluateBase> engine;
+ OVOutputTypes output_types;
+ DimensionsMap dimensions_map;
+
+public:
+ OPENVINO_OP("MLIROp");
+
+ MLIROp() = default;
+
+ MLIROp(const ov::OutputVector& args, std::shared_ptr<mlir::MLIREvaluateBase> engine, OVOutputTypes output_types, DimensionsMap dimensions_map);
+
+ void validate_and_infer_types() override;
+ std::shared_ptr<ov::Node> clone_with_new_inputs(const ov::OutputVector& new_args) const override;
+ bool evaluate(ov::TensorVector& outputs, const ov::TensorVector& inputs) const override;
+ bool evaluate(ov::TensorVector& outputs, const ov::TensorVector& inputs, const ov::EvaluationContext& evaluationContext) const override;
+ bool has_evaluate() const override;
+ std::vector<ov::PartialShape> shape_infer(const std::vector<ov::PartialShape>& input_shapes) const;
+};
+
+} // namespace op
+} // namespace ov::intel_gpu
diff --git a/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp b/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp
index 339f340ff61..f54be9fa2e1 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp
@@ -330,3 +330,6 @@ REGISTER_FACTORY(internal, GatherMatmul);
REGISTER_FACTORY(internal, GatherMatmulCompressed);
REGISTER_FACTORY(internal, GroupedMatMulCompressed);
REGISTER_FACTORY(internal, Atan2);
+#ifdef ENABLE_MLIR_FOR_GPU
+REGISTER_FACTORY(internal, MLIR);
+#endif
diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/mlir_primitive.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/mlir_primitive.hpp
new file mode 100644
index 00000000000..577c9a01013
--- /dev/null
+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/mlir_primitive.hpp
@@ -0,0 +1,53 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <functional>
+#include <memory>
+#include <vector>
+
+#include "openvino/core/partial_shape.hpp"
+#include "primitive.hpp"
+
+namespace ov {
+class Node; // forward-decl — the underlying op is ov::intel_gpu::op::MLIROp
+}
+
+namespace cldnn {
+
+/// @brief Primitive that wraps an ov::intel_gpu::op::MLIROp node. Its execute_impl
+/// (see impls/common/mlir_primitive.cpp) forwards to MLIROp::evaluate().
+struct mlir_primitive : public primitive_base<mlir_primitive> {
+ CLDNN_DECLARE_PRIMITIVE(mlir_primitive)
+
+ using shape_infer_function = std::function<std::vector<ov::PartialShape>(const std::vector<ov::PartialShape>&)>;
+
+ mlir_primitive() : primitive_base("", {}) {}
+
+ mlir_primitive(const primitive_id& id,
+ const std::vector<input_info>& inputs,
+ std::shared_ptr<ov::Node> op,
+ shape_infer_function shape_infer_f,
+ size_t num_outputs,
+ const std::vector<optional_data_type>& out_types)
+ : primitive_base(id, inputs, num_outputs, out_types),
+ op(std::move(op)),
+ shape_infer_f(std::move(shape_infer_f)) {}
+
+ std::shared_ptr<ov::Node> op;
+ shape_infer_function shape_infer_f;
+
+ void save(BinaryOutputBuffer& /*ob*/) const override {
+ OPENVINO_THROW("[GPU] Compiled model export / model caching is not supported for models with MLIR "
+ "(Graph Compiler) subgraphs. Disable GPU_ENABLE_MLIR to use ov::cache_dir or export_model()");
+ }
+
+ void load(BinaryInputBuffer& /*ib*/) override {
+ OPENVINO_THROW("[GPU] Import of a compiled model containing MLIR (Graph Compiler) subgraphs "
+ "is not supported");
+ }
+};
+
+} // namespace cldnn
diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/event.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/event.hpp
index 449f22009d0..cb0e35689dd 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/event.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/event.hpp
@@ -45,6 +45,10 @@ public:
// returns true if handler has been successfully added
bool add_event_handler(event_handler handler, void* data);
+#ifdef ENABLE_MLIR_FOR_GPU
+ // return a handle to an underlying event implementation (i.e. cl_event for OpenCL)
+ virtual void* get_native_handle() { return nullptr; }
+#endif
std::vector<instrumentation::profiling_interval> get_profiling_info();
diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/internal_properties.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/internal_properties.hpp
index ca42b88b5be..3198366a46c 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/internal_properties.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/internal_properties.hpp
@@ -137,6 +137,35 @@ static constexpr Property<bool, PropertyMutability::RW> use_onednn{"GPU_USE_ONED
static constexpr Property<bool, PropertyMutability::RW> use_cm{"GPU_USE_CM"};
static constexpr Property<bool, PropertyMutability::RW> enable_zero_copy_cache_load{"GPU_ENABLE_ZERO_COPY_CACHE_LOAD"};
+/**
+ * @brief [EXPERIMENTAL] Enables MLIR-based Graph Compiler execution for supported subgraphs.
+ * When on, matching subgraphs (matmul, elementwise, SDPA, reduction, etc.) are compiled through the
+ * MLIR/Graph-Compiler pipeline and executed as a single fused GPU kernel via cldnn::mlir_primitive.
+ * Requires the plugin to be built with -DENABLE_MLIR_FOR_GPU=ON (which in turn requires
+ * ENABLE_GPU_DEBUG_CAPS); setting this to true on a plugin built without Graph Compiler support
+ * raises an exception at compile_model() time.
+ *
+ * This is an experimental, not production-ready feature: the set of supported subgraphs, the
+ * property itself and the resulting accuracy/performance are all subject to change, so it must
+ * not be enabled in production scenarios.
+ */
+static constexpr Property<bool, PropertyMutability::RW> enable_mlir{"GPU_ENABLE_MLIR"};
+
+/**
+ * @brief Overrides the set of subgraph patterns compiled through the MLIR/Graph-Compiler pipeline.
+ * Format is "name1=Type1,Type2;name2=Type3,Type4", where each entry describes a chain of op types
+ * to be matched and the name of the resulting MLIR function. Empty value keeps the built-in default
+ * set, "*" matches every operation supported by the MLIR pipeline.
+ * Only has an effect together with ov::intel_gpu::enable_mlir.
+ */
+static constexpr Property<std::string, PropertyMutability::RW> mlir_patterns{"GPU_MLIR_PATTERNS"};
+
+/**
+ * @brief Enables verbose logging of the MLIR/Graph-Compiler pipeline: matched subgraphs, generated
+ * MLIR modules and the lowering steps are printed to stdout.
+ */
+static constexpr Property<bool, PropertyMutability::RW> mlir_debug{"GPU_MLIR_DEBUG"};
+
static constexpr Property<bool, ov::PropertyMutability::RW> help{"HELP"};
static constexpr Property<size_t, ov::PropertyMutability::RW> verbose{"VERBOSE"};
static constexpr Property<bool, ov::PropertyMutability::RW> verbose_color{"VERBOSE_COLOR"};
diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp
index 6dbc68ae43a..151a529bf80 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp
@@ -55,6 +55,10 @@ struct memory {
}
// only supports gpu_usm
virtual void* buffer_ptr() const { return nullptr; }
+#ifdef ENABLE_MLIR_FOR_GPU
+ // Returns the handle to the underlying memory object (e.g. cl_mem for OpenCL)
+ virtual void* get_native_handle() const { return nullptr; }
+#endif
size_t size() const { return _bytes_count; }
size_t count() const { return _layout.count(); }
diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl b/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl
index 38641fde629..65ac9d59ff6 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl
+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl
@@ -87,6 +87,8 @@ OV_CONFIG_RELEASE_INTERNAL_OPTION(ov::intel_gpu, moe_disable_fusion, false, "Dis
OV_CONFIG_DEBUG_GLOBAL_OPTION(ov::intel_gpu, help, false, "Print help message for all config options")
OV_CONFIG_DEBUG_GLOBAL_OPTION(ov::intel_gpu, verbose, 0, "Enable logging for debugging purposes. The higher value the more verbose output. 0 - Disabled, 4 - Maximum verbosity")
OV_CONFIG_DEBUG_GLOBAL_OPTION(ov::intel_gpu, verbose_color, true, "Enable coloring for verbose logs")
+OV_CONFIG_DEBUG_GLOBAL_OPTION(ov::intel_gpu, enable_mlir, false, "Enable/Disable MLIR/Graph-Compiler execution for supported subgraphs. Requires ENABLE_MLIR_FOR_GPU=ON at build time [EXPERIMENTAL, NOT PRODUCTION-READY]")
+OV_CONFIG_DEBUG_GLOBAL_OPTION(ov::intel_gpu, mlir_debug, false, "Enable verbose logging of the MLIR/Graph-Compiler pipeline")
OV_CONFIG_DEBUG_GLOBAL_OPTION(ov::intel_gpu, disable_usm, false, "Disable USM memory allocations and use only cl_mem")
OV_CONFIG_DEBUG_GLOBAL_OPTION(ov::intel_gpu, usm_policy, 0, "0: default, 1: use usm_host, 2: do not use usm_host")
OV_CONFIG_DEBUG_GLOBAL_OPTION(ov::intel_gpu, dump_batch_limit, std::numeric_limits<int32_t>::max(), "Max number of batch elements to dump")
@@ -95,6 +97,7 @@ OV_CONFIG_DEBUG_GLOBAL_OPTION(ov::intel_gpu, log_to_file, "", "Save verbose log
OV_CONFIG_DEBUG_GLOBAL_OPTION(ov::intel_gpu, debug_config, "", "Path to debug config in json format")
OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, disable_onednn_post_ops_opt, false, "Disable optimization pass for onednn post-ops")
+OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, mlir_patterns, "", "Overrides the subgraph patterns compiled through MLIR/Graph-Compiler: \"name1=Type1,Type2;name2=Type3,Type4\". Empty keeps the built-in default set, \"*\" matches every supported operation")
OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, dump_profiling_data_path, "", "Save csv file with per-stage and per-primitive profiling data to specified folder")
OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, average_counters, "", "Save csv file with per-primitive averaged execution time. Output format matches benchmark_app --report_type average_counters and OV_CPU_AVERAGE_COUNTERS")
OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, dump_graphs_path, "", "Save intermediate graph representations during model compilation pipeline to specified folder")
diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/stream.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/stream.hpp
index 0c145d9b4ec..3088d095068 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/stream.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/stream.hpp
@@ -67,10 +67,18 @@ public:
virtual void wait_for_events(const std::vector<event::ptr>& events) = 0;
virtual event::ptr create_user_event(bool set) = 0;
virtual event::ptr create_base_event() = 0;
+#ifdef ENABLE_MLIR_FOR_GPU
+ // Wraps an already existing native event handle (i.e. cl_event for OpenCL) into cldnn::event
+ virtual event::ptr create_base_event(void* /*handle*/) { return nullptr; }
+#endif
virtual std::unique_ptr<surfaces_lock> create_surfaces_lock(const std::vector<memory::ptr> &mem) const = 0;
virtual event::ptr aggregate_events(const std::vector<event::ptr>& events, bool group = false, bool is_output = false);
QueueTypes get_queue_type() const { return m_queue_type; }
+#ifdef ENABLE_MLIR_FOR_GPU
+ // Returns the handle to the underlying stream object (e.g. cl_command_queue for OpenCL)
+ virtual void* get_native_handle() const { return nullptr; }
+#endif
SyncMethods get_sync_method() const { return m_sync_method; }
static SyncMethods get_expected_sync_method(const ExecutionConfig& config);
diff --git a/src/plugins/intel_gpu/src/graph/impls/common/mlir_primitive.cpp b/src/plugins/intel_gpu/src/graph/impls/common/mlir_primitive.cpp
new file mode 100644
index 00000000000..e59de03b595
--- /dev/null
+++ b/src/plugins/intel_gpu/src/graph/impls/common/mlir_primitive.cpp
@@ -0,0 +1,191 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#ifdef ENABLE_MLIR_FOR_GPU
+
+# include "mlir_primitive.hpp"
+
+# include <memory>
+# include <vector>
+
+# include "intel_gpu/primitives/mlir_primitive.hpp"
+# include "intel_gpu/runtime/stream.hpp"
+# include "intel_gpu/runtime/tensor_accessor.hpp" // cldnn::make_tensor
+# include "mlir_primitive_inst.h"
+# include "openvino/core/node.hpp"
+# include "openvino/runtime/intel_gpu/remote_properties.hpp"
+# include "plugin/transformations/mlir/interface/properties.hpp"
+# include "register.hpp"
+# include "registry/implementation_map.hpp"
+
+namespace cldnn::common {
+
+struct mlir_primitive_impl : typed_primitive_impl<mlir_primitive> {
+ using parent = typed_primitive_impl<mlir_primitive>;
+ using parent::parent;
+
+ DECLARE_OBJECT_TYPE_SERIALIZATION(cldnn::common::mlir_primitive_impl)
+
+ [[nodiscard]] std::unique_ptr<primitive_impl> clone() const override {
+ return std::make_unique<mlir_primitive_impl>(*this);
+ }
+
+ mlir_primitive_impl() : parent() {}
+
+ explicit mlir_primitive_impl(const mlir_primitive_node& outer) {
+ set_node_params(outer);
+ }
+
+ void set_node_params(const program_node& /*arg*/) override {}
+
+ event::ptr execute_impl(const std::vector<event::ptr>& dependent_events, mlir_primitive_inst& instance) override {
+ auto& stream = instance.get_network().get_stream();
+ const auto& prim = instance.node->get_primitive();
+ const auto& op = prim->op;
+ OPENVINO_ASSERT(op, "[GPU] MLIROp is not set for mlir_primitive '", prim->id);
+
+ ov::TensorVector input_gpu_tensors;
+ ov::TensorVector output_gpu_tensors;
+ std::vector<bool> is_usm_ptr;
+ input_gpu_tensors.reserve(instance.inputs_memory_count());
+ output_gpu_tensors.reserve(instance.outputs_memory_count());
+ is_usm_ptr.reserve(instance.inputs_memory_count() + instance.outputs_memory_count());
+
+ auto process_buffer = [&is_usm_ptr](const memory::ptr& mem, ov::TensorVector& tensors) {
+ // make_tensor() below builds a dense ov::Tensor from the logical shape, so a padded layout
+ // would result in wrong data offset and strides being passed to the MLIR kernel.
+ OPENVINO_ASSERT(!static_cast<bool>(mem->get_layout().data_padding), "[GPU] Padded buffers are not supported by mlir_primitive yet");
+ switch (mem->get_allocation_type()) {
+ case allocation_type::cl_mem: {
+ if (void* cl_buff = mem->get_native_handle()) {
+ tensors.push_back(make_tensor(mem->get_layout(), cl_buff));
+ is_usm_ptr.push_back(false);
+ } else {
+ OPENVINO_THROW("Memory handle is null for cl_mem");
+ }
+ break;
+ }
+ case allocation_type::usm_host:
+ case allocation_type::usm_shared:
+ case allocation_type::usm_device: {
+ auto* usm_ptr = mem->buffer_ptr();
+ // Seems to only occur with Out-Of-Order queues sometimes. Can't reproduce this anymore, uncomment if needed.
+ // HACK: force move to device, can we do better than this?
+ // auto gpu_buff = dynamic_cast<cldnn::ocl::gpu_usm*>(mem.get());
+ // auto& usm_helper = gpu_buff->get_buffer().getUsmHelper();
+ // usm_helper.enqueue_memcpy(
+ // dynamic_cast<cldnn::ocl::ocl_stream&>(stream).get_cl_queue(),
+ // usm_ptr,
+ // usm_ptr,
+ // mem->get_layout().bytes_count());
+ tensors.push_back(make_tensor(mem->get_layout(), usm_ptr));
+ is_usm_ptr.push_back(true);
+ break;
+ }
+ default:
+ OPENVINO_THROW("Unsupported memory type");
+ }
+ };
+
+ for (size_t i = 0; i < instance.inputs_memory_count(); i++) {
+ process_buffer(instance.input_memory_ptr(i), input_gpu_tensors);
+ }
+
+ for (size_t i = 0; i < instance.outputs_memory_count(); i++) {
+ process_buffer(instance.output_memory_ptr(i), output_gpu_tensors);
+ }
+
+ ov::EvaluationContext meta;
+ if (void* queue = stream.get_native_handle()) {
+ meta.insert(ov::intel_gpu::ocl_queue(queue));
+ } else {
+ OPENVINO_THROW("Unsupported queue type");
+ }
+ meta.insert(ov::internal::mlir_meta::is_kernel_arg_usm(is_usm_ptr));
+
+ std::vector<void*> events_list;
+ std::vector<void*> result_events;
+ const bool need_result_events = instance.get_config().get_enable_profiling() || stream.get_queue_type() == QueueTypes::out_of_order;
+ if (need_result_events) {
+ meta.insert(ov::internal::mlir_meta::result_events(&result_events));
+ }
+ event::ptr marker;
+ if (stream.get_queue_type() == QueueTypes::out_of_order) {
+ std::vector<event::ptr> depends;
+ depends.reserve(dependent_events.size());
+ for (const auto& ev : dependent_events) {
+ if (!ev) {
+ continue;
+ }
+ if (void* cl_ev = ev->get_native_handle()) {
+ events_list.push_back(cl_ev);
+ } else {
+ depends.push_back(ev);
+ }
+ }
+ if (!depends.empty()) {
+ marker = stream.enqueue_marker(depends, true);
+ if (void* cl_ev = marker->get_native_handle()) {
+ events_list.push_back(cl_ev);
+ }
+ }
+ if (!events_list.empty()) {
+ meta.insert(ov::internal::mlir_meta::wait_list(events_list));
+ }
+ }
+
+ const bool evaluated = op->evaluate(output_gpu_tensors, input_gpu_tensors, meta);
+ OPENVINO_ASSERT(evaluated, "[GPU] Couldn't execute MLIROp ", op->get_friendly_name());
+
+ if (!result_events.empty()) {
+ std::vector<event::ptr> events;
+ events.reserve(result_events.size());
+ for (auto* event : result_events) {
+ events.push_back(stream.create_base_event(event));
+ }
+ return stream.aggregate_events(events, true);
+ }
+
+ OPENVINO_ASSERT(!need_result_events, "Result cl_events are not set");
+ return stream.create_user_event(true);
+ }
+
+ static std::unique_ptr<primitive_impl> create(const mlir_primitive_node& arg, const kernel_impl_params& /*params*/) {
+ return std::make_unique<mlir_primitive_impl>(arg);
+ }
+
+ void init_kernels(const kernels_cache& /*kernels_cache*/, const kernel_impl_params& /*params*/) override {}
+
+ void save(BinaryOutputBuffer& ob) const override {
+ parent::save(ob);
+ }
+ void load(BinaryInputBuffer& ib) override {
+ parent::load(ib);
+ }
+
+ [[nodiscard]] bool is_cpu() const override {
+ return false;
+ }
+};
+
+std::unique_ptr<primitive_impl> MLIRPrimitiveImplementationManager::create_impl(const program_node& node, const kernel_impl_params& params) const {
+ assert(node.is_type<mlir_primitive>());
+ return mlir_primitive_impl::create(static_cast<const mlir_primitive_node&>(node), params);
+}
+
+namespace detail {
+
+attach_mlir_primitive_common::attach_mlir_primitive_common() {
+ implementation_map<mlir_primitive>::add(impl_types::common, shape_types::dynamic_shape, mlir_primitive_impl::create, {}, {});
+ implementation_map<mlir_primitive>::add(impl_types::common, mlir_primitive_impl::create, {});
+}
+
+} // namespace detail
+
+} // namespace cldnn::common
+
+BIND_BINARY_BUFFER_WITH_TYPE(cldnn::common::mlir_primitive_impl)
+BIND_BINARY_BUFFER_WITH_TYPE(cldnn::mlir_primitive)
+
+#endif // ENABLE_MLIR_FOR_GPU
diff --git a/src/plugins/intel_gpu/src/graph/impls/common/mlir_primitive.hpp b/src/plugins/intel_gpu/src/graph/impls/common/mlir_primitive.hpp
new file mode 100644
index 00000000000..1b676ca3517
--- /dev/null
+++ b/src/plugins/intel_gpu/src/graph/impls/common/mlir_primitive.hpp
@@ -0,0 +1,23 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <memory>
+#include <utility>
+
+#include "program_node.h"
+#include "registry/implementation_manager.hpp"
+
+namespace cldnn::common {
+
+struct MLIRPrimitiveImplementationManager : public ImplementationManager {
+ OV_GPU_PRIMITIVE_IMPL("common::mlir_primitive")
+ MLIRPrimitiveImplementationManager(shape_types shape_type, ValidateFunc vf = nullptr)
+ : ImplementationManager(impl_types::common, shape_type, std::move(vf)) {}
+
+ [[nodiscard]] std::unique_ptr<primitive_impl> create_impl(const program_node& node, const kernel_impl_params& params) const override;
+};
+
+} // namespace cldnn::common
diff --git a/src/plugins/intel_gpu/src/graph/impls/common/register.cpp b/src/plugins/intel_gpu/src/graph/impls/common/register.cpp
index aade2ca4812..ac82c83ad3e 100644
--- a/src/plugins/intel_gpu/src/graph/impls/common/register.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/common/register.cpp
@@ -15,6 +15,9 @@ void register_implementations() {
REGISTER_COMMON(data);
REGISTER_COMMON(input_layout);
REGISTER_COMMON(loop);
+#ifdef ENABLE_MLIR_FOR_GPU
+ REGISTER_COMMON(mlir_primitive);
+#endif
}
} // namespace common
diff --git a/src/plugins/intel_gpu/src/graph/impls/common/register.hpp b/src/plugins/intel_gpu/src/graph/impls/common/register.hpp
index 109ddf9eb3e..b5eb7cbf78d 100644
--- a/src/plugins/intel_gpu/src/graph/impls/common/register.hpp
+++ b/src/plugins/intel_gpu/src/graph/impls/common/register.hpp
@@ -26,6 +26,9 @@ REGISTER_COMMON(condition);
REGISTER_COMMON(data);
REGISTER_COMMON(input_layout);
REGISTER_COMMON(loop);
+#ifdef ENABLE_MLIR_FOR_GPU
+REGISTER_COMMON(mlir_primitive);
+#endif
#undef REGISTER_COMMON
diff --git a/src/plugins/intel_gpu/src/graph/include/mlir_primitive_inst.h b/src/plugins/intel_gpu/src/graph/include/mlir_primitive_inst.h
new file mode 100644
index 00000000000..33f4daf285e
--- /dev/null
+++ b/src/plugins/intel_gpu/src/graph/include/mlir_primitive_inst.h
@@ -0,0 +1,47 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <string>
+
+#include "intel_gpu/primitives/mlir_primitive.hpp"
+#include "primitive_inst.h"
+
+namespace cldnn {
+
+template <>
+struct typed_program_node<mlir_primitive> : public typed_program_node_base<mlir_primitive> {
+ using parent = typed_program_node_base<mlir_primitive>;
+
+public:
+ using parent::parent;
+
+ program_node& input(size_t idx = 0) const {
+ return get_dependency(idx);
+ }
+};
+
+using mlir_primitive_node = typed_program_node<mlir_primitive>;
+
+template <>
+class typed_primitive_inst<mlir_primitive> : public typed_primitive_inst_base<mlir_primitive> {
+ using parent = typed_primitive_inst_base<mlir_primitive>;
+ using parent::parent;
+
+public:
+ template <typename ShapeType>
+ static std::vector<layout> calc_output_layouts(const mlir_primitive_node& node, const kernel_impl_params& impl_param);
+ static layout calc_output_layout(const mlir_primitive_node& node, const kernel_impl_params& impl_param);
+
+ static std::string to_string(const mlir_primitive_node& node);
+
+ typed_primitive_inst(network& network, const mlir_primitive_node& node);
+
+ const mlir_primitive_node* node;
+};
+
+using mlir_primitive_inst = typed_primitive_inst<mlir_primitive>;
+
+} // namespace cldnn
diff --git a/src/plugins/intel_gpu/src/graph/mlir_primitive.cpp b/src/plugins/intel_gpu/src/graph/mlir_primitive.cpp
new file mode 100644
index 00000000000..00f14a93bc2
--- /dev/null
+++ b/src/plugins/intel_gpu/src/graph/mlir_primitive.cpp
@@ -0,0 +1,71 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#ifdef ENABLE_MLIR_FOR_GPU
+
+# include <sstream>
+# include <string>
+
+# include "json_object.h"
+# include "mlir_primitive_inst.h"
+# include "openvino/core/partial_shape.hpp"
+# include "primitive_type_base.h"
+
+namespace cldnn {
+
+GPU_DEFINE_PRIMITIVE_TYPE_ID(mlir_primitive)
+
+layout mlir_primitive_inst::calc_output_layout(const mlir_primitive_node& node, const kernel_impl_params& impl_param) {
+ return calc_output_layouts<ov::PartialShape>(node, impl_param)[0];
+}
+
+template <typename ShapeType>
+std::vector<layout> mlir_primitive_inst::calc_output_layouts(const mlir_primitive_node& /*node*/, const kernel_impl_params& impl_param) {
+ auto prim = impl_param.typed_desc<mlir_primitive>();
+
+ std::vector<ShapeType> input_shapes;
+ input_shapes.reserve(impl_param.input_layouts.size());
+ for (const auto& l : impl_param.input_layouts) {
+ input_shapes.push_back(l.get<ShapeType>());
+ }
+
+ OPENVINO_ASSERT(prim->shape_infer_f,
+ "[GPU] Shape inference function is not set for mlir_primitive '",
+ prim->id,
+ "'. MLIR (Graph Compiler) subgraphs do not support export / model caching");
+
+ std::vector<ov::PartialShape> output_shapes = prim->shape_infer_f(input_shapes);
+
+ std::vector<layout> out_layouts;
+ out_layouts.reserve(output_shapes.size());
+ for (size_t i = 0; i < output_shapes.size(); ++i) {
+ const auto out_dt = prim->get_output_data_type(i);
+ if (!out_dt.has_value()) {
+ OPENVINO_THROW("[GPU] Output data type is not set for mlir_primitive '", prim->id, "', output ", i);
+ }
+ out_layouts.emplace_back(output_shapes[i], *out_dt, format::get_default_format(output_shapes[i].size()));
+ }
+ return out_layouts;
+}
+
+template std::vector<layout> mlir_primitive_inst::calc_output_layouts<ov::PartialShape>(const mlir_primitive_node&, const kernel_impl_params&);
+
+std::string mlir_primitive_inst::to_string(const mlir_primitive_node& node) {
+ auto node_info = node.desc_to_json();
+ std::stringstream primitive_description;
+ json_composite mlir_info;
+ if (const auto& op = node.get_primitive()->op) {
+ mlir_info.add("subgraph_name", op->get_friendly_name());
+ }
+ mlir_info.add("num_outputs", std::to_string(node.get_primitive()->num_outputs));
+ node_info->add("mlir_primitive_info", mlir_info);
+ node_info->dump(primitive_description);
+ return primitive_description.str();
+}
+
+typed_primitive_inst<mlir_primitive>::typed_primitive_inst(network& network, const mlir_primitive_node& node) : parent(network, node), node(&node) {}
+
+} // namespace cldnn
+
+#endif // ENABLE_MLIR_FOR_GPU
diff --git a/src/plugins/intel_gpu/src/graph/registry/mlir_primitive_impls.cpp b/src/plugins/intel_gpu/src/graph/registry/mlir_primitive_impls.cpp
new file mode 100644
index 00000000000..b96d54998f6
--- /dev/null
+++ b/src/plugins/intel_gpu/src/graph/registry/mlir_primitive_impls.cpp
@@ -0,0 +1,28 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#ifdef ENABLE_MLIR_FOR_GPU
+
+# include "intel_gpu/primitives/mlir_primitive.hpp"
+# include "primitive_inst.h"
+# include "registry.hpp"
+
+#if OV_GPU_WITH_COMMON
+# include "impls/common/mlir_primitive.hpp"
+#endif
+
+namespace ov::intel_gpu {
+
+using namespace cldnn;
+
+const std::vector<std::shared_ptr<cldnn::ImplementationManager>>& Registry<mlir_primitive>::get_implementations() {
+ static const std::vector<std::shared_ptr<ImplementationManager>> impls = {
+ OV_GPU_CREATE_INSTANCE_COMMON(common::MLIRPrimitiveImplementationManager, shape_types::static_shape)
+ OV_GPU_CREATE_INSTANCE_COMMON(common::MLIRPrimitiveImplementationManager, shape_types::dynamic_shape)};
+ return impls;
+}
+
+} // namespace ov::intel_gpu
+
+#endif // ENABLE_MLIR_FOR_GPU
diff --git a/src/plugins/intel_gpu/src/graph/registry/registry.hpp b/src/plugins/intel_gpu/src/graph/registry/registry.hpp
index 395b11da900..d373f69e83e 100644
--- a/src/plugins/intel_gpu/src/graph/registry/registry.hpp
+++ b/src/plugins/intel_gpu/src/graph/registry/registry.hpp
@@ -191,6 +191,9 @@ REGISTER_IMPLS(moe_gemm);
REGISTER_IMPLS(moe_scatter_reduction);
REGISTER_IMPLS(moe_gather);
REGISTER_IMPLS(gather_matmul);
+#ifdef ENABLE_MLIR_FOR_GPU
+REGISTER_IMPLS(mlir_primitive);
+#endif
REGISTER_IMPLS(grouped_matmul);
REGISTER_DEFAULT_IMPLS(assign, CPU_S, CPU_D);
diff --git a/src/plugins/intel_gpu/src/plugin/ops/mlir_op.cpp b/src/plugins/intel_gpu/src/plugin/ops/mlir_op.cpp
new file mode 100644
index 00000000000..5661508fd6a
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/ops/mlir_op.cpp
@@ -0,0 +1,42 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#ifdef ENABLE_MLIR_FOR_GPU
+
+# include "intel_gpu/op/mlir_op.hpp"
+
+# include "intel_gpu/plugin/common_utils.hpp"
+# include "intel_gpu/plugin/program_builder.hpp"
+# include "intel_gpu/primitives/mlir_primitive.hpp"
+
+namespace ov::op::internal {
+using MLIR = ov::intel_gpu::op::MLIROp;
+} // namespace ov::op::internal
+
+namespace ov::intel_gpu {
+
+static void CreateMLIROp(ProgramBuilder& p, const std::shared_ptr<ov::op::internal::MLIR>& op) {
+ auto inputs = p.GetInputInfo(op);
+ const std::string layer_name = layer_type_name_ID(op);
+ const size_t num_outputs = op->get_output_size();
+
+ cldnn::mlir_primitive::shape_infer_function shape_infer_f = [op](const std::vector<ov::PartialShape>& input_shapes) {
+ return op->shape_infer(input_shapes);
+ };
+
+ cldnn::mlir_primitive primitive(layer_name,
+ inputs,
+ op, // shared_ptr<ov::Node>
+ std::move(shape_infer_f),
+ num_outputs,
+ get_output_data_types(op));
+
+ p.add_primitive(*op, primitive);
+}
+
+REGISTER_FACTORY_IMPL(internal, MLIR);
+
+} // namespace ov::intel_gpu
+
+#endif // ENABLE_MLIR_FOR_GPU
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/README.md b/src/plugins/intel_gpu/src/plugin/transformations/mlir/README.md
new file mode 100644
index 00000000000..eedd854f23b
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/README.md
@@ -0,0 +1,40 @@
+# MLIR execution path: sources layout
+
+This folder holds every MLIR / Graph-Compiler dependent source of the GPU plugin. It is compiled into a
+dedicated `openvino_intel_gpu_mlir_obj` OBJECT library (only when `-DENABLE_MLIR_FOR_GPU=ON`), which is the single
+place in the plugin allowed to include `mlir/*.h` and `gc/*.h`; the library is then linked into the plugin.
+
+For *what* this path does and how it fits the plugin, see
+[MLIR execution path in GPU plugin](../../../../docs/mlir/overall_flow.md). For how to get a build with it,
+see [How to build and test OV with MLIR support](../../../../docs/mlir/build_and_test.md).
+
+The entry point is `ov::intel_gpu::mlir::transformMLIR()`, declared in `interface/convert.hpp` and called from
+the GPU transformation pipeline.
+
+## Layout
+
+| Path | Contents |
+| --- | --- |
+| `interface/` | The only headers the rest of the plugin should include. They are MLIR/GC-free. |
+| `conversion/` | `ov::pass::MatcherPass` patterns, one per supported operation or class of operations. A pattern decides whether a node is eligible for the MLIR path (rank/precision/attribute checks) and attaches the converter that will lower it. |
+| `common/` | Reusable conversion infrastructure shared by all converters: the per-operation converters themselves, the conversion context handed to them, and shape/type/constant helpers. See [common/README.md](common/README.md). |
+| root `*.cpp` / `*.hpp` | The pass implementation: subgraph partitioning, whole-graph OV → MLIR-linalg conversion, and the Graph-Compiler-backed execution engine. |
+
+## Adding support for a new operation
+
+1. Add a converter under `common/converters/` following the interface described in
+ [common/README.md](common/README.md).
+2. Add a matcher pattern under `conversion/` that binds the new converter to the matched node, and register that
+ pattern in the pass list built by `transformMLIR()`.
+3. Add a functional test under `tests/functional/mlir_op/` (built only with `ENABLE_MLIR_FOR_GPU=ON`).
+
+Note that being *supported* and being *enabled by default* are different things: the set of patterns applied by
+default is narrow and can be overridden with the `ov::intel_gpu::mlir_patterns` option (`OV_GPU_MLIR_PATTERNS` env variable)
+(see [overall_flow.md](../../../../docs/mlir/overall_flow.md)).
+
+## See also
+
+ * [MLIR execution path in GPU plugin](../../../../docs/mlir/overall_flow.md)
+ * [How to build and test OV with MLIR support](../../../../docs/mlir/build_and_test.md)
+ * [OV-nodes to MLIR-linalg converters](common/README.md)
+ * [OpenVINO GPU Plugin](../../../../README.md)
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/README.md b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/README.md
new file mode 100644
index 00000000000..8be87d7eedd
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/README.md
@@ -0,0 +1,87 @@
+# OV-nodes to MLIR-linalg converters
+
+This folder contains converters and helper classes to convert certain OV operations to MLIR-linalg code.
+
+The module is intentionally self-contained: it depends on nothing but OV core (`ov::Node`, `ov::PartialShape`,
+symbols) and MLIR itself (linalg / tensor / arith dialects). It knows nothing about the GPU plugin or about the
+GPU MLIR execution path — everything specific to that path (deciding which subgraphs are eligible, partitioning
+the model, invoking the Graph Compiler, passing OpenCL runtime handles) lives one level up, in
+[`transformations/mlir/`](../README.md).
+
+Because of that, this folder can be potentially lifted to a common / public OV location and reused by another component or
+plugin that needs to lower `ov::Model` fragments to linalg. The only thing such a consumer has to provide is a
+graph-level driver that owns a `ConversionContext` and resolves node inputs and dynamic dimensions for it — see
+[Whole-graph conversion](#whole-graph-conversion).
+
+## Structure
+
+### `converters/`
+
+Contains `.hpp` files, each representing a converter for a specific OV operation or a class of operations
+(matmul, reduction, binary-elementwise). A converter must implement the following interface — it takes a
+conversion context and an OV node, produces a sequence of MLIR operations, and returns the final op:
+
+```c++
+mlir::Operation* operator()(ov::intel_gpu::mlir::ConversionContext& context, const std::shared_ptr<ov::Node>& node)
+```
+
+In the GPU plugin this contract is spelled as the `GraphConverter::Convertor` alias, see
+[`graph_converter.hpp`](../graph_converter.hpp).
+
+### `conversion_context`
+
+`ov::intel_gpu::mlir::ConversionContext` is a class that provides converters with:
+- `mlir::Context`
+- `mlir::OpBuilder`
+- Mapping between `ov::Node` inputs and MLIR tensors
+- Mapping between dynamic-dimension symbols and their MLIR values
+
+For the exact declaration (constructor and the `getInputs` / `getDimValue` callbacks it expects) see
+[`conversion_context.hpp`](conversion_context.hpp).
+
+### Whole-graph conversion
+
+A higher-level class responsible for whole-graph conversion is expected to encapsulate a `ConversionContext`
+instance and provide the necessary callbacks to resolve mapped inputs.
+
+The snippet below is **only an illustration** — a sketch of how these converters could be driven from a
+component that reuses this module, not code that exists in the repository. For the real implementation used by
+the GPU plugin see `GraphConverter` in [`graph_converter.hpp`](../graph_converter.hpp) /
+[`graph_converter.cpp`](../graph_converter.cpp).
+
+```c++
+class OvGraphImporter {
+ ov::intel_gpu::mlir::ConversionContext _ctx;
+ ov::Model _model;
+ mlir::ModuleOp _module;
+ ...
+ using Converter = std::function<Operation*(ConversionContext&, NodePtr)>;
+
+public:
+ OvGraphImporter(mlir::Context ctx, mlir::OpBuilder builder, ov::Model model):
+ _ctx(
+ ctx, builder,
+ [this](Node node){this->getInputs(node)},
+ [this](Dimension dim) {this->getDimension(dim)}
+ )
+ {
+ // build main-func-op in _module;
+ // build ov-inputs -> mlir-tensors mapping
+ }
+
+ void import() {
+ for (auto op : model.get_ordered_ops()) {
+ // find a suitable converter from 'mlir/common/converters/*.hpp'
+ Converter converter = findMatchingConverter(op);
+ auto mlirOp = converter(_ctx, op);
+ addToOutputsMapping(mlirOp, op);
+ }
+ }
+ ...
+}
+```
+
+### `convert_common`
+
+Contains general utility functions (creating MLIR locations/constants, shape/type importing) used by the
+converters.
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/conversion_context.cpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/conversion_context.cpp
new file mode 100644
index 00000000000..f0fe37111ca
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/conversion_context.cpp
@@ -0,0 +1,32 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+// #include "mlir/IR/BuiltinAttributes.h"
+// #include "mlir/IR/BuiltinTypes.h"
+
+#include "conversion_context.hpp"
+
+#include <utility>
+
+namespace ov::intel_gpu::mlir {
+
+using namespace ::mlir;
+
+ConversionContext::ConversionContext(mlir::MLIRContext* context, mlir::OpBuilder* block_builder, getInputsFn getInputs, getDimValueFn getDimValue)
+ : context(context),
+ block_builder(block_builder),
+ getInputs(std::move(getInputs)),
+ getDimValue(std::move(getDimValue)) {}
+
+SmallVector<Value> ConversionContext::get_dynamic_dimension_values(const PartialShape& shape) const {
+ SmallVector<Value> dims;
+ for (const auto& dim : shape) {
+ if (dim.is_dynamic()) {
+ dims.push_back(getDimValue(dim));
+ }
+ }
+ return dims;
+}
+
+} // namespace ov::intel_gpu::mlir
\ No newline at end of file
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/conversion_context.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/conversion_context.hpp
new file mode 100644
index 00000000000..5aa8580ef14
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/conversion_context.hpp
@@ -0,0 +1,44 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <openvino/pass/graph_rewrite.hpp>
+
+#include "convert_common.hpp"
+#include "mlir/IR/Builders.h"
+#include "mlir/IR/MLIRContext.h"
+#include "mlir/IR/Value.h"
+#include "typedefs.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+using ::mlir::MLIRContext;
+using ::mlir::OpBuilder;
+using ::mlir::Operation;
+using ::mlir::SmallVector;
+using ::mlir::Value;
+using ::mlir::ValueRange;
+
+class ConversionContext {
+public:
+ using getInputsFn = std::function<SmallVector<mlir::Value>(NodePtr)>;
+ using getDimValueFn = std::function<Value(const Dimension&)>;
+ using NodeOutputMap = std::map<ov::Output<ov::Node>, mlir::Value>;
+
+ mlir::MLIRContext* context;
+ mlir::OpBuilder* block_builder;
+ getInputsFn getInputs;
+ getDimValueFn getDimValue;
+
+ ConversionContext(mlir::MLIRContext* context, mlir::OpBuilder* block_builder, getInputsFn getInputs, getDimValueFn getDimValue);
+
+ [[nodiscard]] mlir::OpBuilder& builder() const {
+ return *block_builder;
+ }
+
+ [[nodiscard]] SmallVector<Value> get_dynamic_dimension_values(const PartialShape& shape) const;
+};
+
+} // namespace ov::intel_gpu::mlir
\ No newline at end of file
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/convert_common.cpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/convert_common.cpp
new file mode 100644
index 00000000000..e62e04bf5de
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/convert_common.cpp
@@ -0,0 +1,204 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "convert_common.hpp"
+
+#include <utility>
+
+#include "intel_gpu/runtime/execution_config.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+Location createLayerLocation(MLIRContext* ctx, const std::string& layerName, const std::string& layerType) {
+ const auto layerNameAttr = StringAttr::get(ctx, layerName);
+ const auto nameLoc = NameLoc::get(layerNameAttr);
+
+ SmallVector<NamedAttribute> fields;
+ fields.emplace_back(StringAttr::get(ctx, "type"), StringAttr::get(ctx, layerType));
+ fields.emplace_back(StringAttr::get(ctx, "name"), layerNameAttr);
+ auto metadata = DictionaryAttr::get(ctx, fields);
+
+ return FusedLoc::get(ctx, {nameLoc}, metadata);
+}
+
+SmallVector<int64_t> importShape(const ov::PartialShape& shape) {
+ if (shape.rank().is_dynamic()) {
+ OPENVINO_THROW("Dynamic ranks are not supported.");
+ }
+ SmallVector<int64_t> out(shape.rank().get_length());
+ // TODO: Add support for dynamically ranked shapes
+ for (size_t i = 0; i < out.size(); ++i) {
+ const auto& dim = shape[i];
+ out[i] = dim.is_static() ? dim.get_length() : ShapedType::kDynamic;
+ }
+ return out;
+}
+
+Type importPrecision(MLIRContext* ctx, const ov::element::Type& precision) {
+ switch (precision) {
+ case ov::element::Type_t::f64:
+ return Float64Type::get(ctx);
+ case ov::element::Type_t::f32:
+ return Float32Type::get(ctx);
+ case ov::element::Type_t::f16:
+ return Float16Type::get(ctx);
+ case ov::element::Type_t::bf16:
+ return BFloat16Type::get(ctx);
+ // FIXME: Distinguishing between signed and unsigned integers (and integer
+ // handling overall) is not properly supported by the MLIR path at the moment:
+ // sign-factor is lost here and everything downstream treats the value as signed
+ // (linalg named ops build signed arith payloads, e.g. linalg.div -> arith.divsi).
+ // Actual data computation is only tested on float types; the integer types are kept
+ // mainly for 'technical' values like axes, shapes and indices. Unsigned values that do not
+ // fit into the signed range of the same bit width may silently produce incorrect results.
+ case ov::element::Type_t::i64:
+ case ov::element::Type_t::u64:
+ return IntegerType::get(ctx, 64);
+ case ov::element::Type_t::i32:
+ case ov::element::Type_t::u32:
+ return IntegerType::get(ctx, 32);
+ case ov::element::Type_t::i16:
+ case ov::element::Type_t::u16:
+ return IntegerType::get(ctx, 16);
+ case ov::element::Type_t::i8:
+ case ov::element::Type_t::u8:
+ case ov::element::Type_t::boolean:
+ return IntegerType::get(ctx, 8);
+ case ov::element::Type_t::i4:
+ case ov::element::Type_t::u4:
+ return IntegerType::get(ctx, 4);
+ default:
+ OPENVINO_THROW("Unsupported element_type: ", precision);
+ }
+}
+
+RankedTensorType importTensor(MLIRContext* ctx, const ov::PartialShape& shape, const ov::element::Type& elemType) {
+ return RankedTensorType::get(ArrayRef(importShape(shape)), importPrecision(ctx, elemType));
+}
+
+Location createLocation(MLIRContext* ctx, const NodePtr& node) {
+ return createLayerLocation(ctx, node->get_friendly_name(), node->get_type_name());
+}
+
+BroadcastDimensions broadcast_dimensions(const PartialShape& src, const PartialShape& dst) {
+ assert(statically_broadcastable(src, dst));
+
+ auto src_rank = src.rank().get_length();
+ auto dst_rank = dst.rank().get_length();
+ auto offset = dst_rank - src_rank;
+
+ BroadcastDimensions result;
+ auto& [collapse_groups, dimensions] = result;
+ ReassociationIndices group;
+ bool group_bonded = false; // true if `group` has a non-brodcasted dimension
+
+ int64_t dst_i = 0; // dimension index in the `dst` shape
+ for (; dst_i < offset; ++dst_i) {
+ dimensions.push_back(dst_i);
+ }
+ for (; dst_i < dst_rank; ++dst_i) {
+ auto src_i = dst_i - offset;
+ const auto& src_d = src[src_i];
+ const auto& dst_d = dst[dst_i];
+ if (has_broadcast(src_d, dst_d)) {
+ dimensions.push_back(dst_i);
+ } else {
+ if (group_bonded) {
+ collapse_groups.emplace_back(group);
+ group = ReassociationIndices();
+ } else {
+ group_bonded = true;
+ }
+ }
+ group.push_back(src_i);
+ }
+
+ if (group_bonded && !group.empty()) {
+ collapse_groups.emplace_back(group);
+ }
+
+ assert(dst_rank - dimensions.size() == collapse_groups.size());
+
+ return result;
+}
+
+bool symbol_ancestor_less(const SymbolPtr& x, const SymbolPtr& y) {
+ return ov::symbol::ancestor_of(x) < ov::symbol::ancestor_of(y);
+}
+
+bool elementwise_no_broadcast_predicate(const ov::Output<ov::Node>& output) {
+ if (has_dynamic_rank(output.get_node_shared_ptr())) {
+ return false;
+ }
+ // Check if implicit broadcast is possible, reject in this case
+ // Relies on symbolic information -- register SymbolicPropagation before applying this pattern
+ auto inputs = output.get_node_shared_ptr()->inputs();
+ auto output_shape = output.get_partial_shape();
+
+ return !std::any_of(inputs.begin(), inputs.end(), [&](const ov::Input<ov::Node>& input) {
+ auto input_shape = input.get_partial_shape();
+ if (output_shape.rank().get_length() != input_shape.rank().get_length()) {
+ return true;
+ }
+ for (size_t i = 0; i < output_shape.size(); ++i) {
+ if (!are_equal_dimensions(input_shape[i], output_shape[i])) {
+ return true;
+ }
+ }
+ return false;
+ });
+}
+
+bool has_dynamic_rank(const NodePtr& node) {
+ auto inputs = node->inputs();
+ auto outputs = node->outputs();
+ if (std::any_of(inputs.begin(), inputs.end(), [&](const ov::Input<ov::Node>& input) {
+ return input.get_partial_shape().rank().is_dynamic();
+ })) {
+ return true;
+ }
+ return std::any_of(outputs.begin(), outputs.end(), [&](const ov::Output<ov::Node>& output) {
+ return output.get_partial_shape().rank().is_dynamic();
+ });
+}
+
+bool are_equal_dimensions(const Dimension& d1, const Dimension& d2) {
+ return (d1.is_static() && d2.is_static() && d1 == d2) || ov::symbol::are_equal(d1.get_symbol(), d2.get_symbol());
+}
+
+bool has_broadcast(const Dimension& from, const Dimension& to) {
+ return from.is_static() && from.get_length() == 1 && !are_equal_dimensions(from, to);
+}
+
+bool statically_broadcastable(const PartialShape& from, const PartialShape& to) {
+ if (from.rank().is_dynamic() || to.rank().is_dynamic()) { // FIXME: `from` can has dynamic rank
+ return false;
+ }
+
+ auto from_rank = from.rank().get_length();
+ auto to_rank = to.rank().get_length();
+
+ if (from_rank > to_rank) { // such cases shouldn't be allowed to this function, but kept to make the function generic
+ return false;
+ }
+
+ auto offset = to_rank - from_rank;
+ for (int64_t i = 0; i < from_rank; ++i) {
+ const auto& d_from = from[i];
+ const auto& d_to = to[offset + i];
+ if (!are_equal_dimensions(d_from, d_to) && !has_broadcast(d_from, d_to)) {
+ // cannot deduce neither dimensions broadcast nor dimensions equality
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool is_debug() {
+ // The option is DEBUG-only, but ENABLE_MLIR_FOR_GPU requires ENABLE_GPU_DEBUG_CAPS, so it always exists here
+ return ov::intel_gpu::ExecutionConfig::get_mlir_debug();
+}
+
+} // namespace ov::intel_gpu::mlir
\ No newline at end of file
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/convert_common.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/convert_common.hpp
new file mode 100644
index 00000000000..faf37aeba91
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/convert_common.hpp
@@ -0,0 +1,95 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <iostream>
+
+#include "mlir/Dialect/Arith/IR/Arith.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "mlir/IR/BuiltinAttributes.h"
+#include "mlir/IR/BuiltinTypes.h"
+#include "mlir/IR/Location.h"
+#include "mlir/IR/MLIRContext.h"
+#include "openvino/op/constant.hpp"
+#include "typedefs.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+using namespace ::mlir;
+
+// Verbose logging of the MLIR pipeline, controlled by the global ov::intel_gpu::mlir_debug option
+bool is_debug();
+
+#define OPENVINO_MLIR_DEBUG(X) \
+ do \
+ if (::ov::intel_gpu::mlir::is_debug()) { \
+ X; \
+ } \
+ while (false)
+// Variadic on purpose: the argument is a '<<' chain, so it must not be wrapped in parentheses.
+#define OPENVINO_MLIR_DEBUG_PRINT(...) \
+ do \
+ if (::ov::intel_gpu::mlir::is_debug()) { \
+ ::std::cerr << "[DEBUG] " << __VA_ARGS__ << '\n'; \
+ } \
+ while (false)
+
+Location createLayerLocation(MLIRContext* ctx, const std::string& layerName, const std::string& layerType);
+
+SmallVector<int64_t> importShape(const ov::PartialShape& shape);
+
+Type importPrecision(MLIRContext* ctx, const ov::element::Type& precision);
+
+RankedTensorType importTensor(MLIRContext* ctx, const ov::PartialShape& shape, const ov::element::Type& elemType);
+
+Location createLocation(MLIRContext* ctx, const NodePtr& node);
+
+template <typename T>
+mlir::arith::ConstantOp getConstant(OpBuilder& builder, const mlir::Type& type, T value, std::optional<mlir::Location> loc = std::nullopt) {
+ TypedAttr attr;
+ if (type.isInteger()) {
+ attr = builder.getIntegerAttr(type, int64_t(value));
+ } else if (type.isFloat()) {
+ attr = builder.getFloatAttr(type, double(value));
+ }
+ assert(attr && "Unsupported ConstantOp type");
+ return arith::ConstantOp::create(builder, loc.value_or(builder.getUnknownLoc()), type, attr);
+}
+
+template <typename T>
+mlir::arith::ConstantOp getConstant(OpBuilder& builder, const ov::element::Type& precision, T value, std::optional<mlir::Location> loc = std::nullopt) {
+ return getConstant(builder, importPrecision(builder.getContext(), precision), value, loc);
+}
+
+inline arith::ConstantOp getConstant(OpBuilder& builder, const ov::op::v0::Constant* constant, std::optional<Location> loc = std::nullopt) {
+ auto tensorTy = dyn_cast<RankedTensorType>(importTensor(builder.getContext(), constant->get_output_partial_shape(0), constant->get_element_type()));
+ DenseElementsAttr attr;
+ if (constant->get_all_data_elements_bitwise_identical()) {
+ auto raw = llvm::ArrayRef<char>(static_cast<const char*>(constant->get_data_ptr()), constant->get_element_type().size());
+ auto scalarAttr = DenseElementsAttr::getFromRawBuffer(tensorTy.cloneWith({}, tensorTy.getElementType()), raw);
+ attr = DenseElementsAttr::get(tensorTy, scalarAttr.getSplatValue<Attribute>());
+ } else {
+ auto raw = llvm::ArrayRef<char>(static_cast<const char*>(constant->get_data_ptr()), constant->get_byte_size());
+ attr = DenseElementsAttr::getFromRawBuffer(tensorTy, raw);
+ }
+ return arith::ConstantOp::create(builder, loc.value_or(builder.getUnknownLoc()), tensorTy, attr);
+}
+
+using BroadcastDimensions = std::tuple<SmallVector<ReassociationIndices>, SmallVector<int64_t>>;
+BroadcastDimensions broadcast_dimensions(const PartialShape& src, const PartialShape& dst);
+
+bool elementwise_no_broadcast_predicate(const ov::Output<ov::Node>& output);
+
+bool symbol_ancestor_less(const SymbolPtr& x, const SymbolPtr& y);
+
+bool has_dynamic_rank(const NodePtr& node);
+
+bool are_equal_dimensions(const Dimension& d1, const Dimension& d2);
+
+bool has_broadcast(const Dimension& from, const Dimension& to);
+
+bool statically_broadcastable(const PartialShape& from, const PartialShape& to);
+
+} // namespace ov::intel_gpu::mlir
\ No newline at end of file
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/binary_eltwise.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/binary_eltwise.hpp
new file mode 100644
index 00000000000..dc38f6581ac
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/binary_eltwise.hpp
@@ -0,0 +1,56 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <openvino/op/relu.hpp>
+
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "mlir/IR/Builders.h"
+#include "mlir/IR/MLIRContext.h"
+#include "mlir/IR/Value.h"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+using namespace ov;
+using namespace ov::intel_gpu::mlir;
+using ::mlir::ValueRange;
+
+template <typename MlirBinOpBuilder>
+struct ConvertBinaryEltwise {
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ auto loc = createLocation(context.context, node);
+ auto& builder = context.builder();
+ const auto inputs = context.getInputs(node);
+ const auto ov_output_element_type = node->get_output_element_type(0);
+ const auto ov_output_shape = node->get_output_partial_shape(0);
+ auto outType = importTensor(context.context, ov_output_shape, ov_output_element_type);
+
+ SmallVector<Value> dynamic_dimensions = context.get_dynamic_dimension_values(ov_output_shape);
+
+ SmallVector<Value> broadcasted_inputs;
+ for (size_t i = 0; i < inputs.size(); ++i) {
+ auto [collapse_groups, dimensions] = broadcast_dimensions(node->get_input_partial_shape(i), ov_output_shape);
+ if (!dimensions.empty()) {
+ // FIXME: Find a way to avoid dimension squeezing before applying linalg.broadcast
+ // Step 1: Squeeze input shape to eliminate broadcasted dimensions
+ auto squeezed = tensor::CollapseShapeOp::create(builder, loc, inputs[i], collapse_groups);
+ // Step 2: Broadcast squeezed shape to the target shape
+ auto empty = tensor::EmptyOp::create(builder, loc, outType, dynamic_dimensions);
+ auto op = linalg::BroadcastOp::create(builder, loc, squeezed, empty, dimensions);
+ broadcasted_inputs.push_back(op.getResult()[0]);
+ } else {
+ broadcasted_inputs.push_back(inputs[i]);
+ }
+ }
+
+ auto empty = tensor::EmptyOp::create(builder, loc, outType, dynamic_dimensions);
+ auto op = MlirBinOpBuilder::create(builder, loc, ValueRange(broadcasted_inputs), ValueRange{empty});
+ return op;
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/concat.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/concat.hpp
new file mode 100644
index 00000000000..3781ac294fc
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/concat.hpp
@@ -0,0 +1,37 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <openvino/op/concat.hpp>
+
+#include "../convert_common.hpp"
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "openvino/opsets/opset1.hpp"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+struct ConvertConcat {
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ auto loc = createLocation(context.context, node);
+ auto& builder = context.builder();
+ const auto inputs = context.getInputs(node);
+
+ const auto src_partial_shape = node->get_input_partial_shape(0);
+ const auto rank = src_partial_shape.rank().get_length();
+
+ auto concat_node = std::dynamic_pointer_cast<ov::opset1::Concat>(node);
+ int64_t axis = concat_node->get_axis();
+ if (axis < 0) {
+ axis += rank;
+ }
+
+ auto concat = tensor::ConcatOp::create(builder, loc, axis, mlir::ValueRange{inputs});
+ return concat;
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/floor.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/floor.hpp
new file mode 100644
index 00000000000..a88e6dbb259
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/floor.hpp
@@ -0,0 +1,31 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <openvino/op/floor.hpp>
+
+#include "../convert_common.hpp"
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+struct ConvertFloor {
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ auto loc = createLocation(context.context, node);
+ auto& builder = context.builder();
+ const auto input = context.getInputs(node)[0];
+ const auto ov_output_element_type = node->get_output_element_type(0);
+ const auto ov_output_shape = node->get_output_partial_shape(0);
+ auto outType = importTensor(context.context, ov_output_shape, ov_output_element_type);
+ auto dynamic_dimensions = context.get_dynamic_dimension_values(ov_output_shape);
+ auto empty = tensor::EmptyOp::create(builder, loc, outType, dynamic_dimensions);
+ auto floor = linalg::FloorOp::create(builder, loc, mlir::ValueRange{input}, mlir::ValueRange{empty});
+ return floor;
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/gather.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/gather.hpp
new file mode 100644
index 00000000000..777f09aef5f
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/gather.hpp
@@ -0,0 +1,75 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <openvino/op/gather.hpp>
+
+#include "../convert_common.hpp"
+#include "mlir/Dialect/Arith/IR/Arith.h"
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Dialect/Shape/IR/Shape.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+// TODO: add signed/unsigned integers support
+struct ConvertGather {
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ // TODO: support batch attribute
+ auto loc = createLocation(context.context, node);
+ auto& builder = context.builder();
+ const auto input = context.getInputs(node)[0];
+ const auto indices = context.getInputs(node)[1];
+ // get_axis() seems to be enough?
+ // const auto axis = context.getInputs(node)[2];
+
+ const auto ov_index_element_type = node->get_input_element_type(1);
+ const auto ov_index_shape = node->get_input_partial_shape(1);
+ auto dynamic_index_dims = context.get_dynamic_dimension_values(ov_index_shape);
+ const auto ov_output_element_type = node->get_output_element_type(0);
+ const auto ov_output_shape = node->get_output_partial_shape(0);
+ auto out_type = importTensor(context.context, ov_output_shape, ov_output_element_type);
+ RankedTensorType indices_type = importTensor(context.context, ov_index_shape, ov_index_element_type);
+
+ bool is_input_scalar = ov_index_shape.rank().is_static() && ov_index_shape.rank().get_length() == 0;
+
+ // `shape_of` returns tensor<1xindex> for scalars, gather requires dimention match at `gather_dims` indices.
+ // This expands the shape of input indices to be <1xi64> in case of scalars to resolve types mismatch.
+ Value indices_expanded = indices;
+ if (is_input_scalar) {
+ SmallVector<int64_t> new_shape({1});
+ indices_type = RankedTensorType::get(new_shape, importPrecision(context.context, ov_index_element_type));
+ SmallVector<ReassociationIndices> reassociation; // intentionally empty for scalar
+ auto expanded = tensor::ExpandShapeOp::create(builder, loc, indices_type, indices, reassociation);
+ indices_expanded = expanded.getResult();
+ }
+
+ // Convert negative indices into positive ones: compare to zero and select from orinal or a sum based on
+ // the resulting predicate.
+ auto empty = tensor::EmptyOp::create(builder, loc, indices_type, dynamic_index_dims);
+ auto zero = getConstant(builder, ov_index_element_type, 0);
+ auto fill = linalg::FillOp::create(builder, loc, mlir::ValueRange{zero}, mlir::ValueRange{empty});
+ auto pred = arith::CmpIPredicate::slt;
+ auto cmpi = arith::CmpIOp::create(builder, loc, pred, indices_expanded, fill.getResult(0));
+ auto shape_of = shape::ShapeOfOp::create(builder, loc, mlir::ValueRange{input});
+ auto cast = arith::IndexCastOp::create(builder, loc, indices_type, mlir::ValueRange{shape_of});
+
+ auto empty_add = tensor::EmptyOp::create(builder, loc, indices_expanded.getType(), dynamic_index_dims);
+ auto add = linalg::AddOp::create(builder, loc, mlir::ValueRange{cast.getResult(), indices_expanded}, mlir::ValueRange{empty_add});
+ auto select =
+ linalg::SelectOp::create(builder, loc, mlir::ValueRange{cmpi.getResult(), add.getResult(0), indices_expanded}, mlir::ValueRange{empty_add});
+
+ auto gather_node = std::dynamic_pointer_cast<ov::op::util::GatherBase>(node);
+ assert(gather_node && "Expected a gather node");
+ int64_t axis = gather_node->get_axis();
+
+ llvm::SmallVector<int64_t> gather_dims{axis};
+ auto gather = tensor::GatherOp::create(builder, loc, out_type, input, select.getResult(0), gather_dims, false);
+ return gather;
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/matmul.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/matmul.hpp
new file mode 100644
index 00000000000..6e35fd1de03
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/matmul.hpp
@@ -0,0 +1,115 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <openvino/op/matmul.hpp>
+
+#include "../convert_common.hpp"
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+struct ConvertMatMul {
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ auto loc = createLocation(context.context, node);
+ auto& builder = context.builder();
+ // TODO: Support broadcasts
+ const auto inputs = context.getInputs(node);
+ const auto ov_output_element_type = node->get_output_element_type(0);
+ const auto ov_output_shape = node->get_output_partial_shape(0);
+ auto outType = importTensor(context.context, ov_output_shape, ov_output_element_type);
+ auto dynamic_dimensions = context.get_dynamic_dimension_values(ov_output_shape);
+ auto empty = tensor::EmptyOp::create(builder, loc, outType, dynamic_dimensions);
+ auto zero = getConstant(builder, ov_output_element_type, 0);
+ auto fill = linalg::FillOp::create(builder, loc, mlir::ValueRange{zero}, mlir::ValueRange{empty});
+
+ mlir::SmallVector<Value, 2> ins{inputs[0], inputs[1]};
+ mlir::SmallVector<Value, 1> outs{fill.getResult(0)};
+
+ auto matmul_node = std::dynamic_pointer_cast<ov::op::v0::MatMul>(node);
+ assert(matmul_node);
+ bool isTransposedA = matmul_node->get_transpose_a();
+ bool isTransposedB = matmul_node->get_transpose_b();
+ assert(!(isTransposedA && isTransposedB));
+
+ // TODO: move the unit-dimension-folding logic to the graph-compiler
+ bool batch = true;
+ auto canCollapse = [](mlir::Value tensor) { // rank <= 2 or all leading dimensions are 1
+ auto shape = mlir::cast<RankedTensorType>(tensor.getType()).getShape().drop_back(2);
+ return std::all_of(shape.begin(), shape.end(), [](int64_t d) {
+ return d == 1;
+ });
+ };
+ if (canCollapse(ins[0]) && canCollapse(ins[1]) && canCollapse(outs[0])) {
+ auto collapse = [&](Value tensor) -> Value { // Has no-op if rank <= 2
+ auto shape = mlir::cast<RankedTensorType>(tensor.getType()).getShape();
+ int64_t rank = shape.size();
+ if (rank <= 2) {
+ return tensor;
+ }
+ SmallVector<ReassociationIndices> reassoc;
+ ReassociationIndices leading;
+ for (int64_t i = 0; i < rank - 1; ++i) {
+ leading.push_back(i);
+ }
+ reassoc.push_back(leading);
+ reassoc.push_back(ReassociationIndices{rank - 1});
+ return tensor::CollapseShapeOp::create(builder, loc, tensor, reassoc).getResult();
+ };
+ ins[0] = collapse(ins[0]);
+ ins[1] = collapse(ins[1]);
+ outs[0] = collapse(outs[0]);
+ batch = false;
+ }
+
+ auto expand = [&](Value tensor) -> Value {
+ int64_t rank = ov_output_shape.size();
+ auto type = mlir::cast<RankedTensorType>(tensor.getType());
+ auto shape = type.getShape();
+ if (static_cast<int64_t>(shape.size()) == rank) {
+ return tensor;
+ }
+ SmallVector<ReassociationIndices> reassoc;
+ ReassociationIndices leading;
+ for (int64_t i = 0; i < rank - 1; ++i) {
+ leading.push_back(i);
+ }
+ reassoc.push_back(leading);
+ reassoc.push_back(ReassociationIndices{rank - 1});
+ SmallVector<int64_t> new_shape(rank, 1);
+ std::copy(shape.begin(), shape.end(), new_shape.end() - shape.size());
+ auto new_type = mlir::RankedTensorType::get(new_shape, type.getElementType());
+ return tensor::ExpandShapeOp::create(builder, loc, new_type, tensor, reassoc).getResult();
+ };
+
+ Operation* matmul = nullptr;
+ if (batch) {
+ // Expand if required, to have all inputs of the same rank.
+ ins[0] = expand(ins[0]);
+ ins[1] = expand(ins[1]);
+ if (isTransposedA) {
+ matmul = linalg::BatchMatmulTransposeAOp::create(builder, loc, ins, outs);
+ } else if (isTransposedB) {
+ matmul = linalg::BatchMatmulTransposeBOp::create(builder, loc, ins, outs);
+ } else {
+ matmul = linalg::BatchMatmulOp::create(builder, loc, ins, outs);
+ }
+ } else {
+ if (isTransposedA) {
+ matmul = linalg::MatmulTransposeAOp::create(builder, loc, ins, outs);
+ } else if (isTransposedB) {
+ matmul = linalg::MatmulTransposeBOp::create(builder, loc, ins, outs);
+ } else {
+ matmul = linalg::MatmulOp::create(builder, loc, ins, outs);
+ }
+ matmul = expand(matmul->getResult(0)).getDefiningOp();
+ }
+ return matmul;
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
\ No newline at end of file
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/reduce.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/reduce.hpp
new file mode 100644
index 00000000000..6eeacb94166
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/reduce.hpp
@@ -0,0 +1,181 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <openvino/op/constant.hpp>
+#include <openvino/op/reduce_max.hpp>
+#include <openvino/op/reduce_mean.hpp>
+#include <openvino/op/reduce_min.hpp>
+#include <openvino/op/reduce_prod.hpp>
+#include <openvino/op/reduce_sum.hpp>
+#include <openvino/op/util/arithmetic_reductions_keep_dims.hpp>
+
+#include "../convert_common.hpp"
+#include "mlir/Dialect/Arith/IR/Arith.h"
+#include "mlir/Dialect/Linalg/IR/Linalg.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/MLIRContext.h"
+#include "mlir/IR/Value.h"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+using Value = ::mlir::Value;
+using ValueRange = ::mlir::ValueRange;
+
+template <typename OVOp>
+struct ConvertReduce {
+ ConvertReduce() = default;
+
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ auto el_type = importPrecision(context.context, node->get_input_element_type(0));
+ auto input_shape = node->get_input_partial_shape(0);
+ auto input_rank = input_shape.rank().get_length();
+ SmallVector<int64_t> reduction_axes;
+ {
+ auto* input1 = dynamic_cast<ov::op::v0::Constant*>(node->get_input_node_ptr(1));
+ assert(input1 && "Only constant axes are supported");
+ auto axes = input1->cast_vector<int64_t>();
+ reduction_axes.reserve(axes.size());
+ for (int64_t axis : axes) {
+ reduction_axes.push_back(axis < 0 ? axis + input_rank : axis);
+ }
+ }
+ ::mlir::RankedTensorType result_type;
+ {
+ SmallVector<int64_t> shape;
+ for (int64_t i = 0; i < input_rank; ++i) {
+ if (!llvm::is_contained(reduction_axes, i)) {
+ auto dim = input_shape[i];
+ assert(dim.is_static() && "Dynamic shapes not supported");
+ shape.push_back(dim.get_length());
+ }
+ }
+ result_type = RankedTensorType::get(shape, el_type);
+ }
+
+ auto& builder = context.builder();
+ auto loc = createLocation(context.context, node);
+ auto empty = ::mlir::tensor::EmptyOp::create(builder, loc, result_type, ValueRange{});
+ Value init_value = create_init_value(builder, loc, el_type);
+ auto output = ::mlir::linalg::FillOp::create(builder, loc, ValueRange{init_value}, ValueRange{empty});
+ Value result = ::mlir::linalg::ReduceOp::create(builder,
+ loc,
+ ValueRange{context.getInputs(node)[0]},
+ ValueRange{output.getResult(0)},
+ reduction_axes,
+ [&](::mlir::OpBuilder& b, ::mlir::Location loc, ValueRange inputs) {
+ Value result = create_payload_op(b, loc, inputs[0], inputs[1], el_type);
+ ::mlir::linalg::YieldOp::create(b, loc, result);
+ })
+ .getResult(0);
+
+ // For ReduceMean, divide by the number of elements
+ if constexpr (std::is_same_v<OVOp, ov::op::v1::ReduceMean>) {
+ // Calculate the number of elements in the reduction dimensions
+ int64_t num_els = 1;
+ for (auto axis : reduction_axes) {
+ num_els *= input_shape[axis].get_length();
+ }
+ ::mlir::TypedAttr divisor_attr;
+ if (el_type.isInteger()) {
+ divisor_attr = builder.getIntegerAttr(el_type, num_els);
+ } else {
+ divisor_attr = builder.getFloatAttr(el_type, static_cast<double>(num_els));
+ }
+ auto divisor = ::mlir::arith::ConstantOp::create(builder, loc, ::mlir::DenseElementsAttr::get(result_type, divisor_attr));
+ auto empty = ::mlir::tensor::EmptyOp::create(builder, loc, result_type, ValueRange{});
+ result = ::mlir::linalg::DivOp::create(builder, loc, ValueRange{result, divisor}, ValueRange{empty}).getResult(0);
+ }
+
+ // If keep_dims is true, broadcast along the reduced dimensions
+ if (const auto* keep_dims = dynamic_cast<const ov::op::util::ArithmeticReductionKeepDims*>(node.get()); keep_dims && keep_dims->get_keep_dims()) {
+ auto shape = llvm::map_to_vector(node->get_output_partial_shape(0), [](const ov::Dimension& dim) {
+ return dim.get_length();
+ });
+ auto empty = ::mlir::tensor::EmptyOp::create(builder, loc, shape, el_type);
+ result = ::mlir::linalg::BroadcastOp::create(builder, loc, result, empty, reduction_axes).getResult()[0];
+ }
+
+ return result.getDefiningOp();
+ }
+
+private:
+ // FIXME: mlir::Type does not carry the 'isUnsigned' information at this level, so we have
+ // to use the ov::element::Type instead (TODO: add tests for the integer case).
+ Value create_init_value(::mlir::OpBuilder& builder, ::mlir::Location loc, ::mlir::Type type) {
+ if constexpr (std::is_same_v<OVOp, ov::op::v1::ReduceMax>) {
+ if (type.isFloat()) {
+ return getConstant(builder, type, -std::numeric_limits<double>::infinity(), loc);
+ }
+ // The 'bitwidth >= 64' cases are spelled out separately: shifting by the full width of the
+ // type is undefined behavior, so '1 << 64' must never be evaluated.
+ const unsigned bitwidth = type.getIntOrFloatBitWidth();
+ int64_t min_val = 0;
+ if (!type.isUnsignedInteger()) {
+ min_val = bitwidth >= 64 ? std::numeric_limits<int64_t>::min() : -(1LL << (bitwidth - 1));
+ }
+ return getConstant(builder, type, min_val, loc);
+ } else if constexpr (std::is_same_v<OVOp, ov::op::v1::ReduceMin>) {
+ if (type.isFloat()) {
+ return getConstant(builder, type, std::numeric_limits<double>::infinity(), loc);
+ }
+ const unsigned bitwidth = type.getIntOrFloatBitWidth();
+ int64_t max_val = 0;
+ if (type.isUnsignedInteger()) {
+ // All-ones of the target width. Passing it through int64_t is fine: getIntegerAttr()
+ // truncates the value to the type's bitwidth.
+ max_val = static_cast<int64_t>(bitwidth >= 64 ? ~0ULL : (1ULL << bitwidth) - 1ULL);
+ } else {
+ max_val = bitwidth >= 64 ? std::numeric_limits<int64_t>::max() : (1LL << (bitwidth - 1)) - 1;
+ }
+ return getConstant(builder, type, max_val, loc);
+ } else if constexpr (std::is_same_v<OVOp, ov::op::v1::ReduceSum> || std::is_same_v<OVOp, ov::op::v1::ReduceMean>) {
+ return getConstant(builder, type, 0, loc);
+ } else if constexpr (std::is_same_v<OVOp, ov::op::v1::ReduceProd>) {
+ return getConstant(builder, type, 1, loc);
+ } else {
+ static_assert(sizeof(OVOp) == 0, "Unsupported reduction operation");
+ }
+ }
+
+ // FIXME: mlir::Type does not carry the 'isUnsigned' information at this level, so we have
+ // to use the ov::element::Type instead (TODO: add tests for the integer case).
+ Value create_payload_op(::mlir::OpBuilder& builder, ::mlir::Location loc, Value lhs, Value rhs, ::mlir::Type type) {
+ if constexpr (std::is_same_v<OVOp, ov::op::v1::ReduceMax>) {
+ if (type.isFloat()) {
+ return ::mlir::arith::MaximumFOp::create(builder, loc, lhs, rhs);
+ }
+ if (type.isUnsignedInteger()) {
+ return ::mlir::arith::MaxUIOp::create(builder, loc, lhs, rhs);
+ }
+ return ::mlir::arith::MaxSIOp::create(builder, loc, lhs, rhs);
+ } else if constexpr (std::is_same_v<OVOp, ov::op::v1::ReduceMin>) {
+ if (type.isFloat()) {
+ return ::mlir::arith::MinimumFOp::create(builder, loc, lhs, rhs);
+ }
+ if (type.isUnsignedInteger()) {
+ return ::mlir::arith::MinUIOp::create(builder, loc, lhs, rhs);
+ }
+ return ::mlir::arith::MinSIOp::create(builder, loc, lhs, rhs);
+ } else if constexpr (std::is_same_v<OVOp, ov::op::v1::ReduceSum> || std::is_same_v<OVOp, ov::op::v1::ReduceMean>) {
+ if (type.isFloat()) {
+ return ::mlir::arith::AddFOp::create(builder, loc, lhs, rhs);
+ }
+ return ::mlir::arith::AddIOp::create(builder, loc, lhs, rhs);
+ } else if constexpr (std::is_same_v<OVOp, ov::op::v1::ReduceProd>) {
+ if (type.isFloat()) {
+ return ::mlir::arith::MulFOp::create(builder, loc, lhs, rhs);
+ }
+ return ::mlir::arith::MulIOp::create(builder, loc, lhs, rhs);
+ } else {
+ static_assert(sizeof(OVOp) == 0, "Unsupported reduction operation");
+ }
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/relu.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/relu.hpp
new file mode 100644
index 00000000000..57ad13a424e
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/relu.hpp
@@ -0,0 +1,34 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <openvino/op/relu.hpp>
+
+#include "../convert_common.hpp"
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+// TODO: add signed/unsigned integers support
+struct ConvertRelu {
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ auto loc = createLocation(context.context, node);
+ auto& builder = context.builder();
+ const auto input = context.getInputs(node)[0];
+ const auto ov_output_element_type = node->get_output_element_type(0);
+ const auto ov_output_shape = node->get_output_partial_shape(0);
+ auto outType = importTensor(context.context, ov_output_shape, ov_output_element_type);
+ auto dynamic_dimensions = context.get_dynamic_dimension_values(ov_output_shape);
+ auto empty = tensor::EmptyOp::create(builder, loc, outType, dynamic_dimensions);
+ auto zero = getConstant(builder, ov_output_element_type, 0);
+ auto fill = linalg::FillOp::create(builder, loc, mlir::ValueRange{zero}, mlir::ValueRange{empty});
+ auto relu = linalg::MaxOp::create(builder, loc, mlir::ValueRange{input, fill.getResult(0)}, mlir::ValueRange{empty});
+ return relu;
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/reshape.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/reshape.hpp
new file mode 100644
index 00000000000..a31a4468441
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/reshape.hpp
@@ -0,0 +1,62 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <openvino/op/reshape.hpp>
+
+#include "../convert_common.hpp"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+struct ConvertReshape {
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ const auto in_shape = node->get_input_partial_shape(0);
+ const auto out_shape = node->get_output_partial_shape(0);
+ assert(in_shape.rank().is_static() && out_shape.rank().is_static());
+ assert(llvm::all_of(in_shape, std::mem_fn(&ov::Dimension::is_static)));
+ assert(llvm::all_of(out_shape, std::mem_fn(&ov::Dimension::is_static)));
+ const auto in_rank = static_cast<size_t>(in_shape.rank().get_length());
+ const auto out_rank = static_cast<size_t>(out_shape.rank().get_length());
+ const bool expand = out_rank >= in_rank;
+
+ // Build reassociation by matching accumulated products of src/dst dims.
+ // Each group maps one src dim to multiple dst dims (expand) or vice versa (collapse).
+ SmallVector<ReassociationIndices> reassociation;
+ for (size_t src_i = 0, dst_i = 0; src_i < in_rank && dst_i < out_rank; ++src_i, ++dst_i) {
+ ReassociationIndices group;
+ int64_t src_prod = in_shape[src_i].get_length();
+ int64_t dst_prod = out_shape[dst_i].get_length();
+ if (expand) {
+ // one src dim -> multiple dst dims
+ group.push_back(dst_i);
+ while (src_prod != dst_prod && (dst_i + 1) < out_rank) {
+ dst_prod *= out_shape[++dst_i].get_length();
+ group.push_back(dst_i);
+ }
+ } else {
+ // multiple src dims -> one dst dim
+ group.push_back(src_i);
+ while (src_prod != dst_prod && (src_i + 1) < in_rank) {
+ src_prod *= in_shape[++src_i].get_length();
+ group.push_back(src_i);
+ }
+ }
+ assert(src_prod == dst_prod && "shape mismatch: incompatible reshape");
+ reassociation.push_back(group);
+ }
+
+ auto dst_shape = llvm::to_vector(llvm::map_range(out_shape, std::mem_fn(&ov::Dimension::get_length)));
+ auto dst_type = RankedTensorType::get(dst_shape, importPrecision(context.context, node->get_output_element_type(0)));
+ auto loc = createLocation(context.context, node);
+ auto& builder = context.builder();
+ const auto input = context.getInputs(node)[0];
+ return expand ? tensor::ExpandShapeOp::create(builder, loc, dst_type, input, reassociation)
+ : tensor::CollapseShapeOp::create(builder, loc, dst_type, input, reassociation);
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/rms.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/rms.hpp
new file mode 100644
index 00000000000..a0645296c63
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/rms.hpp
@@ -0,0 +1,111 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <ov_ops/rms.hpp>
+
+#include "../convert_common.hpp"
+#include "mlir/Dialect/Arith/IR/Arith.h"
+#include "mlir/Dialect/Linalg/IR/Linalg.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+
+namespace ov::intel_gpu::mlir {
+
+// y = x / sqrt(mean(x^2, last_dim) + eps) [* gamma]
+struct ConvertRMS {
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ auto rms = ov::as_type_ptr<ov::op::internal::RMS>(node);
+ OPENVINO_ASSERT(rms, "Failed to cast to RMS");
+
+ auto loc = createLocation(context.context, node);
+ auto& builder = context.builder();
+ const auto inputs = context.getInputs(node);
+ const auto x = inputs[0];
+
+ const auto el_type = node->get_input_element_type(0);
+ const auto mlir_el_type = importPrecision(context.context, el_type);
+ const auto shape = node->get_output_partial_shape(0);
+ const auto rank = shape.rank().get_length();
+ const int64_t axis = rank - 1;
+ const int64_t num_els = shape[axis].get_length();
+
+ auto out_type = importTensor(context.context, shape, el_type);
+ auto out_dims = context.get_dynamic_dimension_values(shape);
+
+ PartialShape reduced_shape(std::vector<Dimension>(shape.begin(), shape.begin() + axis));
+ auto reduced_type = importTensor(context.context, reduced_shape, el_type);
+ auto reduced_dims = context.get_dynamic_dimension_values(reduced_shape);
+
+ // x^2
+ auto two = arith::ConstantOp::create(builder, loc, ::mlir::DenseElementsAttr::get(out_type, builder.getFloatAttr(mlir_el_type, 2.0)));
+ auto sq_empty = tensor::EmptyOp::create(builder, loc, out_type, out_dims);
+ Value squared = linalg::PowFOp::create(builder, loc, ValueRange{x, two}, ValueRange{sq_empty}).getResult(0);
+
+ // sum(x^2, axis)
+ auto sum_empty = tensor::EmptyOp::create(builder, loc, reduced_type, reduced_dims);
+ auto zero = getConstant(builder, mlir_el_type, 0, loc);
+ auto sum_init = linalg::FillOp::create(builder, loc, ValueRange{zero}, ValueRange{sum_empty});
+ Value sum = linalg::ReduceOp::create(builder,
+ loc,
+ ValueRange{squared},
+ ValueRange{sum_init.getResult(0)},
+ SmallVector<int64_t>{axis},
+ [&](::mlir::OpBuilder& b, ::mlir::Location l, ValueRange args) {
+ linalg::YieldOp::create(b, l, Value{arith::AddFOp::create(b, l, args[0], args[1])});
+ })
+ .getResult(0);
+
+ // sum / N
+ auto n_const =
+ arith::ConstantOp::create(builder,
+ loc,
+ ::mlir::DenseElementsAttr::get(reduced_type, builder.getFloatAttr(mlir_el_type, static_cast<double>(num_els))));
+ auto div_empty = tensor::EmptyOp::create(builder, loc, reduced_type, reduced_dims);
+ Value mean = linalg::DivOp::create(builder, loc, ValueRange{sum, n_const}, ValueRange{div_empty}).getResult(0);
+
+ // 1 / sqrt(mean + eps)
+ PartialShape scale_shape = reduced_shape;
+ scale_shape.push_back(Dimension(1));
+ auto scale_type = importTensor(context.context, scale_shape, el_type);
+ auto scale_dims = context.get_dynamic_dimension_values(scale_shape);
+ auto scale_const = [&](double v) {
+ return Value{arith::ConstantOp::create(builder, loc, ::mlir::DenseElementsAttr::get(scale_type, builder.getFloatAttr(mlir_el_type, v)))};
+ };
+ auto scale_empty = [&] {
+ return tensor::EmptyOp::create(builder, loc, scale_type, scale_dims);
+ };
+ Value inv_rms = linalg::BroadcastOp::create(builder, loc, mean, scale_empty(), SmallVector<int64_t>{axis}).getResult()[0];
+ inv_rms = linalg::AddOp::create(builder, loc, ValueRange{inv_rms, scale_const(rms->get_epsilon())}, ValueRange{scale_empty()}).getResult(0);
+ inv_rms = linalg::SqrtOp::create(builder, loc, ValueRange{inv_rms}, ValueRange{scale_empty()}).getResult(0);
+ inv_rms = linalg::DivOp::create(builder, loc, ValueRange{scale_const(1.0), inv_rms}, ValueRange{scale_empty()}).getResult(0);
+
+ // broadcast back over the reduced axis and scale x
+ SmallVector<::mlir::ReassociationIndices> collapse(axis);
+ for (int64_t i = 0; i < axis; ++i) {
+ collapse[i].push_back(i);
+ }
+ collapse.back().push_back(axis);
+ Value squeezed = tensor::CollapseShapeOp::create(builder, loc, inv_rms, collapse);
+ auto bcast_empty = tensor::EmptyOp::create(builder, loc, out_type, out_dims);
+ Value bcast = linalg::BroadcastOp::create(builder, loc, squeezed, bcast_empty, SmallVector<int64_t>{axis}).getResult()[0];
+ auto mul_empty = tensor::EmptyOp::create(builder, loc, out_type, out_dims);
+ Operation* result = linalg::MulOp::create(builder, loc, ValueRange{bcast, x}, ValueRange{mul_empty});
+
+ if (rms->get_elementwise_affine()) {
+ Value gamma = inputs[1];
+ auto [collapse_groups, dimensions] = broadcast_dimensions(node->get_input_partial_shape(1), shape);
+ if (!dimensions.empty()) {
+ auto squeezed = tensor::CollapseShapeOp::create(builder, loc, gamma, collapse_groups);
+ auto empty = tensor::EmptyOp::create(builder, loc, out_type, out_dims);
+ gamma = linalg::BroadcastOp::create(builder, loc, squeezed, empty, dimensions).getResult()[0];
+ }
+ auto empty = tensor::EmptyOp::create(builder, loc, out_type, out_dims);
+ result = linalg::MulOp::create(builder, loc, ValueRange{result->getResult(0), gamma}, ValueRange{empty});
+ }
+ return result;
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/sdpa.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/sdpa.hpp
new file mode 100644
index 00000000000..60f94a3d7d6
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/sdpa.hpp
@@ -0,0 +1,162 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <cmath>
+#include <iostream>
+#include <openvino/op/constant.hpp>
+#include <openvino/op/scaled_dot_product_attention.hpp>
+
+#include "../convert_common.hpp"
+#include "gc/Dialect/Linalgx/LinalgxDialect.h"
+#include "gc/Dialect/Linalgx/LinalgxOps.h"
+#include "mlir/Dialect/Arith/IR/Arith.h"
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Dialect/Math/IR/Math.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "mlir/IR/AffineExpr.h"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+struct ConvertSDPA {
+ static SmallVector<AffineMap> getStandardAttentionIndexingMaps(MLIRContext* ctx, bool hasMask, int rank) {
+ if (rank == 3) {
+ // 3D: (batch, seq, hidden)
+ AffineExpr batch, m, k1, k2, n;
+ bindDims(ctx, batch, m, k1, k2, n);
+
+ auto qMap = AffineMap::get(/*dimCount=*/5, /*symbolCount=*/0, {batch, m, k1}, ctx);
+ auto kMap = AffineMap::get(/*dimCount=*/5, /*symbolCount=*/0, {batch, k2, k1}, ctx);
+ auto vMap = AffineMap::get(/*dimCount=*/5, /*symbolCount=*/0, {batch, k2, n}, ctx);
+ auto sMap = AffineMap::get(/*dimCount=*/5, /*symbolCount=*/0, ctx);
+ auto rMap = AffineMap::get(/*dimCount=*/5, /*symbolCount=*/0, {batch, m, n}, ctx);
+ if (hasMask) {
+ auto mMap = AffineMap::get(/*dimCount=*/5, /*symbolCount=*/0, {m, k2}, ctx);
+ return {qMap, kMap, vMap, sMap, mMap, rMap};
+ }
+ return {qMap, kMap, vMap, sMap, rMap};
+ }
+ if (rank == 4) {
+ // 4D: (batch, head, seq, hidden)
+ AffineExpr batch, head, m, k1, k2, n;
+ bindDims(ctx, batch, head, m, k1, k2, n);
+
+ auto qMap = AffineMap::get(/*dimCount=*/6, /*symbolCount=*/0, {batch, head, m, k1}, ctx);
+ auto kMap = AffineMap::get(/*dimCount=*/6, /*symbolCount=*/0, {batch, head, k2, k1}, ctx);
+ auto vMap = AffineMap::get(/*dimCount=*/6, /*symbolCount=*/0, {batch, head, k2, n}, ctx);
+ auto sMap = AffineMap::get(/*dimCount=*/6, /*symbolCount=*/0, ctx);
+ auto rMap = AffineMap::get(/*dimCount=*/6, /*symbolCount=*/0, {batch, head, m, n}, ctx);
+ if (hasMask) {
+ auto mMap = AffineMap::get(/*dimCount=*/6, /*symbolCount=*/0, {m, k2}, ctx);
+ return {qMap, kMap, vMap, sMap, mMap, rMap};
+ }
+ return {qMap, kMap, vMap, sMap, rMap};
+ }
+ // Should never reach here due to validation
+ return {};
+ }
+
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ auto loc = createLocation(context.context, node);
+ auto& builder = context.builder();
+ const auto inputs = context.getInputs(node);
+
+ // Validate input ranks
+ auto qShape = node->get_input_partial_shape(0);
+ auto kShape = node->get_input_partial_shape(1);
+ auto vShape = node->get_input_partial_shape(2);
+
+ auto qRank = qShape.rank().get_length();
+ auto kRank = kShape.rank().get_length();
+ auto vRank = vShape.rank().get_length();
+
+ OPENVINO_ASSERT(qRank == kRank && qRank == vRank,
+ "SDPA: Query, Key, and Value must have equal ranks, but got Q rank=",
+ qRank,
+ ", K rank=",
+ kRank,
+ ", V rank=",
+ vRank);
+
+ OPENVINO_ASSERT(qRank == 3 || qRank == 4, "SDPA: Only 3D and 4D inputs are supported, but got rank=", qRank);
+
+ auto sdpa_node = std::dynamic_pointer_cast<ov::op::v13::ScaledDotProductAttention>(node);
+ OPENVINO_ASSERT(sdpa_node, "Failed to cast to ScaledDotProductAttention");
+
+ const auto input_size = node->get_input_size();
+ const bool causal = sdpa_node->get_causal();
+ OPENVINO_ASSERT(!causal, "SDPA: Causal attention is not supported in this version");
+ OPENVINO_ASSERT(input_size < 6, "SDPA: sink parameter is not supported");
+
+ const auto ov_output_element_type = node->get_output_element_type(0);
+
+ // Extract mask (input 3) if present and not causal
+ Value mask = nullptr;
+ bool hasMask = false;
+ if (input_size > 3 && !causal && node->get_input_partial_shape(3).rank().get_length() > 0) {
+ mask = inputs[3];
+ hasMask = true;
+
+ // Squeeze mask to 2D: mask can be 2D [M,N], 3D [1,M,N], or 4D [1,1,M,N]
+ // linalgx::AttentionOp expects a 2D mask [seq_q, seq_k]
+ auto maskShape = node->get_input_partial_shape(3);
+ auto maskRank = maskShape.rank().get_length();
+ if (maskRank == 3) {
+ // [1, M, N] → [M, N]: collapse dims [0,1] and [2]
+ SmallVector<ReassociationIndices> reassoc = {{0, 1}, {2}};
+ mask = tensor::CollapseShapeOp::create(builder, loc, mask, reassoc);
+ } else if (maskRank == 4) {
+ // [1, 1, M, N] → [M, N]: collapse dims [0,1,2] and [3]
+ SmallVector<ReassociationIndices> reassoc = {{0, 1, 2}, {3}};
+ mask = tensor::CollapseShapeOp::create(builder, loc, mask, reassoc);
+ }
+ // maskRank == 2: already 2D, no change needed
+ }
+
+ // Extract or compute scale (input 4)
+ Value scale;
+ if (input_size > 4) {
+ // Scale is provided as input tensor
+ // Check if it's an ov::Constant — if so, extract scalar value directly
+ auto scale_node = node->get_input_node_shared_ptr(4);
+ auto scale_const = std::dynamic_pointer_cast<ov::op::v0::Constant>(scale_node);
+ if (scale_const) {
+ auto scale_val = scale_const->cast_vector<float>()[0];
+ scale = getConstant(builder, ov_output_element_type, scale_val);
+ } else {
+ OPENVINO_ASSERT(false, "SDPA: dynamic scale input is not supported in this version");
+ }
+ } else {
+ // Default scale: 1 / sqrt(head_dim), where head_dim is last dim of Q
+ auto head_dim = qShape[qRank - 1].get_length();
+ float default_scale = 1.0F / std::sqrt(static_cast<float>(head_dim));
+ scale = getConstant(builder, ov_output_element_type, default_scale);
+ }
+
+ const auto ov_output_shape = node->get_output_partial_shape(0);
+ auto outType = importTensor(context.context, ov_output_shape, ov_output_element_type);
+ auto dynamic_dimensions = context.get_dynamic_dimension_values(ov_output_shape);
+ auto empty = tensor::EmptyOp::create(builder, loc, outType, dynamic_dimensions);
+ auto zero = getConstant(builder, ov_output_element_type, 0);
+ auto fill = linalg::FillOp::create(builder, loc, mlir::ValueRange{zero}, mlir::ValueRange{empty});
+
+ SmallVector<AffineMap> indexingMaps = getStandardAttentionIndexingMaps(context.context, hasMask, qRank);
+
+ Operation* sdpa = linalgx::AttentionOp::create(builder,
+ loc,
+ fill.getResult(0).getType(),
+ inputs[0],
+ inputs[1],
+ inputs[2],
+ scale,
+ fill.getResult(0),
+ builder.getAffineMapArrayAttr(indexingMaps),
+ mask);
+ return sdpa;
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/shape_of.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/shape_of.hpp
new file mode 100644
index 00000000000..aea539edaea
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/shape_of.hpp
@@ -0,0 +1,32 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <openvino/op/shape_of.hpp>
+
+#include "../convert_common.hpp"
+#include "mlir/Dialect/Arith/IR/Arith.h"
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Dialect/Shape/IR/Shape.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+struct ConvertShapeOf {
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ auto loc = createLocation(context.context, node);
+ auto& builder = context.builder();
+ const auto ov_output_element_type = node->get_output_element_type(0);
+ const auto ov_output_shape = node->get_output_partial_shape(0);
+ const auto input = context.getInputs(node)[0];
+ auto shapeOf = shape::ShapeOfOp::create(builder, loc, mlir::ValueRange{input});
+ auto casted_type = RankedTensorType::get(ArrayRef(importShape(ov_output_shape)), importPrecision(context.context, ov_output_element_type));
+ auto cast = arith::IndexCastOp::create(builder, loc, casted_type, mlir::ValueRange{shapeOf});
+ return cast;
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/slice.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/slice.hpp
new file mode 100644
index 00000000000..956313bca23
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/slice.hpp
@@ -0,0 +1,39 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <openvino/op/slice.hpp>
+
+#include "../convert_common.hpp"
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+struct ConvertSlice {
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ auto loc = createLocation(context.context, node);
+ auto& builder = context.builder();
+ const auto input = context.getInputs(node)[0];
+ const auto start = context.getInputs(node)[1];
+ const auto stop = context.getInputs(node)[2];
+ const auto step = context.getInputs(node)[3];
+
+ const auto ov_index_shape = node->get_input_partial_shape(1);
+ const auto ov_index_element_type = node->get_input_element_type(1);
+ auto dynamic_index_dims = context.get_dynamic_dimension_values(ov_index_shape);
+
+ auto index_type = importTensor(context.context, ov_index_shape, ov_index_element_type);
+ auto empty = tensor::EmptyOp::create(builder, loc, index_type, dynamic_index_dims);
+
+ // TODO: this only works for the all-positive numbers case.
+ auto sizes = linalg::SubOp::create(builder, loc, mlir::ValueRange{stop, start}, mlir::ValueRange{empty});
+ auto slice = tensor::ExtractSliceOp::create(builder, loc, input, mlir::ValueRange{start}, mlir::ValueRange{sizes.getResults()}, mlir::ValueRange{step});
+ return slice;
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/squeeze.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/squeeze.hpp
new file mode 100644
index 00000000000..d42099e214b
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/squeeze.hpp
@@ -0,0 +1,42 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <openvino/op/squeeze.hpp>
+
+#include "../convert_common.hpp"
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+struct ConvertSqueeze {
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ auto loc = createLocation(context.context, node);
+ auto& builder = context.builder();
+ const auto input = context.getInputs(node)[0];
+
+ auto src_partial_shape = node->get_input_partial_shape(0);
+ auto src_rank = src_partial_shape.rank().get_length();
+ SmallVector<ReassociationIndices> collapse_groups;
+ ReassociationIndices group = ReassociationIndices();
+ for (int64_t src_i = 0; src_i < src_rank; src_i++) {
+ auto src_d = src_partial_shape[src_i];
+ group.push_back(src_i);
+ if (src_d.is_static() && src_d.get_length() == 1) {
+ // continue collecting
+ } else {
+ collapse_groups.emplace_back(group);
+ group = ReassociationIndices();
+ }
+ }
+
+ auto reshape = tensor::CollapseShapeOp::create(builder, loc, input, collapse_groups);
+ return reshape;
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/transpose.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/transpose.hpp
new file mode 100644
index 00000000000..4cec8b5d706
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/transpose.hpp
@@ -0,0 +1,40 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <openvino/op/transpose.hpp>
+
+#include "../convert_common.hpp"
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+struct ConvertTranspose {
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ auto loc = createLocation(context.context, node);
+ auto& builder = context.builder();
+ const auto input = context.getInputs(node)[0];
+ // TODO: support dynamic inputs
+ // const auto order = context.getInputs(node)[1];
+
+ const auto ov_output_element_type = node->get_output_element_type(0);
+ const auto ov_output_shape = node->get_output_partial_shape(0);
+ auto out_type = importTensor(context.context, ov_output_shape, ov_output_element_type);
+ auto dynamic_dimensions = context.get_dynamic_dimension_values(ov_output_shape);
+
+ auto* const_order = dynamic_cast<ov::op::v0::Constant*>(node->get_input_node_ptr(1));
+ assert(const_order && "non-const order not supported");
+ auto coords = const_order->cast_vector<int64_t>();
+ SmallVector<int64_t> order(coords.begin(), coords.end());
+
+ auto empty = tensor::EmptyOp::create(builder, loc, out_type, dynamic_dimensions);
+ auto transpose = linalg::TransposeOp::create(builder, loc, input, empty, order);
+ return transpose;
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/unary_eltwise.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/unary_eltwise.hpp
new file mode 100644
index 00000000000..388cc90627b
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/unary_eltwise.hpp
@@ -0,0 +1,28 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "../convert_common.hpp"
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+
+namespace ov::intel_gpu::mlir {
+
+template <typename MlirUnaryOp>
+struct ConvertUnaryEltwise {
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ auto loc = createLocation(context.context, node);
+ auto& builder = context.builder();
+ const auto input = context.getInputs(node)[0];
+ const auto ov_out_el_ty = node->get_output_element_type(0);
+ const auto ov_out_shape = node->get_output_partial_shape(0);
+ auto out_ty = importTensor(context.context, ov_out_shape, ov_out_el_ty);
+ auto dims = context.get_dynamic_dimension_values(ov_out_shape);
+ auto empty = tensor::EmptyOp::create(builder, loc, out_ty, dims);
+ return MlirUnaryOp::create(builder, loc, ::mlir::ValueRange{input}, ::mlir::ValueRange{empty});
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/unsqueeze.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/unsqueeze.hpp
new file mode 100644
index 00000000000..2db5cfde5ca
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/converters/unsqueeze.hpp
@@ -0,0 +1,60 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <openvino/op/constant.hpp>
+#include <openvino/op/unsqueeze.hpp>
+
+#include "../convert_common.hpp"
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Dialect/Shape/IR/Shape.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+struct ConvertUnsqueeze {
+ Operation* operator()(ConversionContext& context, const NodePtr& node) {
+ auto loc = createLocation(context.context, node);
+ auto& builder = context.builder();
+ const auto input = context.getInputs(node)[0];
+ // TODO: support dynamic inputs
+ // const auto axes = context.getInputs(node)[1];
+
+ const auto ov_output_element_type = node->get_output_element_type(0);
+ const auto ov_input_shape = node->get_input_partial_shape(0);
+
+ assert(ov_input_shape.rank().is_static() && "expecting static output shape");
+
+ auto* const_axes = dynamic_cast<ov::op::v0::Constant*>(node->get_input_node_ptr(1));
+ assert(const_axes && "non-const axes not supported");
+ ov::Coordinate coords = const_axes->get_coordinate_val();
+
+ // Calculate the resulting shape.
+ // E.g., for an input tensor<4x2xf32> and axes [0, 2] (tensor<2xi64>) need to build a shape 1x4x1x2
+ SmallVector<ReassociationIndices> expand_groups;
+ ReassociationIndices group = ReassociationIndices();
+ SmallVector<int64_t> shape(coords.size() + ov_input_shape.rank().get_length());
+ for (size_t input_idx = 0, coord_idx = 0, i = 0; i < shape.size(); ++i) {
+ group.push_back(i);
+ if (coord_idx < coords.size() && i == coords[coord_idx]) {
+ shape[i] = 1;
+ coord_idx++;
+ } else {
+ const auto& dim = ov_input_shape[input_idx];
+ shape[i] = dim.is_dynamic() ? ShapedType::kDynamic : dim.get_length();
+ input_idx++;
+ expand_groups.push_back(group);
+ group = ReassociationIndices();
+ }
+ }
+
+ auto result_type = RankedTensorType::get(shape, importPrecision(context.context, ov_output_element_type));
+ auto expand_shape = tensor::ExpandShapeOp::create(builder, loc, result_type, input, expand_groups);
+ return expand_shape;
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/typedefs.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/typedefs.hpp
new file mode 100644
index 00000000000..0b282a978b8
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/common/typedefs.hpp
@@ -0,0 +1,16 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "openvino/core/node.hpp"
+#include "openvino/core/symbol.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+using NodePtr = std::shared_ptr<ov::Node>;
+using SymbolPtr = std::shared_ptr<ov::Symbol>;
+using InputVector = std::vector<ov::Input<ov::Node>>;
+
+} // namespace ov::intel_gpu::mlir
\ No newline at end of file
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/conversion/patterns.cpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/conversion/patterns.cpp
new file mode 100644
index 00000000000..d2fb5b6b19b
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/conversion/patterns.cpp
@@ -0,0 +1,341 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "patterns.hpp"
+
+#include <algorithm>
+#include <functional>
+#include <openvino/op/abs.hpp>
+#include <openvino/op/add.hpp>
+#include <openvino/op/ceiling.hpp>
+#include <openvino/op/concat.hpp>
+#include <openvino/op/constant.hpp>
+#include <openvino/op/divide.hpp>
+#include <openvino/op/exp.hpp>
+#include <openvino/op/floor.hpp>
+#include <openvino/op/gather.hpp>
+#include <openvino/op/log.hpp>
+#include <openvino/op/matmul.hpp>
+#include <openvino/op/multiply.hpp>
+#include <openvino/op/negative.hpp>
+#include <openvino/op/power.hpp>
+#include <openvino/op/reduce_max.hpp>
+#include <openvino/op/reduce_mean.hpp>
+#include <openvino/op/reduce_min.hpp>
+#include <openvino/op/reduce_prod.hpp>
+#include <openvino/op/reduce_sum.hpp>
+#include <openvino/op/relu.hpp>
+#include <openvino/op/reshape.hpp>
+#include <openvino/op/scaled_dot_product_attention.hpp>
+#include <openvino/op/shape_of.hpp>
+#include <openvino/op/slice.hpp>
+#include <openvino/op/sqrt.hpp>
+#include <openvino/op/squeeze.hpp>
+#include <openvino/op/subtract.hpp>
+#include <openvino/op/tanh.hpp>
+#include <openvino/op/transpose.hpp>
+#include <openvino/op/unsqueeze.hpp>
+#include <ov_ops/rms.hpp>
+
+#include "../common/converters/binary_eltwise.hpp"
+#include "../common/converters/concat.hpp"
+#include "../common/converters/floor.hpp"
+#include "../common/converters/gather.hpp"
+#include "../common/converters/matmul.hpp"
+#include "../common/converters/reduce.hpp"
+#include "../common/converters/relu.hpp"
+#include "../common/converters/reshape.hpp"
+#include "../common/converters/rms.hpp"
+#include "../common/converters/sdpa.hpp"
+#include "../common/converters/shape_of.hpp"
+#include "../common/converters/slice.hpp"
+#include "../common/converters/squeeze.hpp"
+#include "../common/converters/transpose.hpp"
+#include "../common/converters/unary_eltwise.hpp"
+#include "../common/converters/unsqueeze.hpp"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+using namespace ov::pass::pattern;
+using namespace ov::op;
+
+ReluPattern::ReluPattern() : MarkPattern(wrap_type<v0::Relu>({any_input()}, elementwise_no_broadcast_predicate), ConvertRelu()) {}
+
+ConcatPattern::ConcatPattern() : MarkPattern(wrap_type<v0::Concat>(), ConvertConcat()) {}
+
+FloorPattern::FloorPattern() : MarkPattern(wrap_type<v0::Floor>({any_input()}), ConvertFloor()) {}
+
+GatherPattern::GatherPattern() : MarkPattern(wrap_type<v8::Gather>({any_input(), any_input(), any_input()}), ConvertGather()) {}
+
+MatMulPattern::MatMulPattern()
+ : MarkPattern(wrap_type<v0::MatMul>({any_input(), any_input()},
+ [](const Output<Node>& output) {
+ auto node = std::dynamic_pointer_cast<v0::MatMul>(output.get_node_shared_ptr());
+ assert(node);
+ return !has_dynamic_rank(node) && (!node->get_transpose_a() || !node->get_transpose_b());
+ }),
+ ConvertMatMul()) {}
+
+template <typename OVOp>
+ReducePattern<OVOp>::ReducePattern() : MarkPattern(std::make_shared<pass::pattern::op::WrapType>(OVOp::get_type_info_static()), ConvertReduce<OVOp>()) {}
+
+// Explicit template instantiations
+template class ReducePattern<ov::op::v1::ReduceMax>;
+template class ReducePattern<ov::op::v1::ReduceMean>;
+template class ReducePattern<ov::op::v1::ReduceMin>;
+template class ReducePattern<ov::op::v1::ReduceProd>;
+template class ReducePattern<ov::op::v1::ReduceSum>;
+
+RMSPattern::RMSPattern()
+ : MarkPattern(wrap_type<ov::op::internal::RMS>([](const Output<Node>& output) {
+ auto node = ov::as_type_ptr<ov::op::internal::RMS>(output.get_node_shared_ptr());
+ if (!node || has_dynamic_rank(node) || !output.get_element_type().is_real()) {
+ return false;
+ }
+ // The converter computes the mean over the last dimension, so it must be static.
+ const auto& shape = output.get_partial_shape();
+ if (shape[shape.rank().get_length() - 1].is_dynamic()) {
+ return false;
+ }
+ // Mixed input/output precision (RMS output_type attribute) is not supported
+ if (node->get_input_element_type(0) != output.get_element_type()) {
+ return false;
+ }
+ return !node->get_elementwise_affine() || (node->get_input_element_type(1) == output.get_element_type() &&
+ statically_broadcastable(node->get_input_partial_shape(1), shape));
+ }),
+ ConvertRMS()) {}
+
+ReshapePattern::ReshapePattern() : MarkPattern(wrap_type<v1::Reshape>({any_input(), any_input()}), ConvertReshape()) {}
+
+SDPAPattern::SDPAPattern()
+ : MarkPattern(
+ wrap_type<v13::ScaledDotProductAttention>([](const Output<Node>& output) {
+ auto node = std::dynamic_pointer_cast<v13::ScaledDotProductAttention>(output.get_node_shared_ptr());
+ if (!node) {
+ return false;
+ }
+
+ // Query, Key, Value ranks must be static, equal, and either 3D or 4D
+ const auto q_shape = node->get_input_partial_shape(0);
+ const auto k_shape = node->get_input_partial_shape(1);
+ const auto v_shape = node->get_input_partial_shape(2);
+ if (q_shape.rank().is_dynamic() || k_shape.rank().is_dynamic() || v_shape.rank().is_dynamic()) {
+ OPENVINO_MLIR_DEBUG_PRINT("SDPAPattern: rejected " << node->get_friendly_name() << " — dynamic Q/K/V rank");
+ return false;
+ }
+ const auto q_rank = q_shape.rank().get_length();
+ if (q_rank != k_shape.rank().get_length() || q_rank != v_shape.rank().get_length()) {
+ OPENVINO_MLIR_DEBUG_PRINT("SDPAPattern: rejected " << node->get_friendly_name() << " — Q/K/V rank mismatch");
+ return false;
+ }
+ if (q_rank != 3 && q_rank != 4) {
+ OPENVINO_MLIR_DEBUG_PRINT("SDPAPattern: rejected " << node->get_friendly_name() << " — unsupported rank " << q_rank << " (expected 3 or 4)");
+ return false;
+ }
+
+ // The attention tiling fully unrolls the head size dimension, so a large head size
+ // multiplies kernel size and register pressure. Past this limit the generated kernel
+ // spills heavily and loses to the native SDPA implementations both in compile time and
+ // in execution time, so leave those nodes alone.
+ constexpr int64_t max_head_size = 128;
+ const auto& q_head_size = q_shape[q_rank - 1];
+ const auto& v_head_size = v_shape[q_rank - 1];
+ if (q_head_size.get_min_length() > max_head_size || v_head_size.get_min_length() > max_head_size) {
+ OPENVINO_MLIR_DEBUG_PRINT("SDPAPattern: rejected " << node->get_friendly_name() << " — head size " << q_head_size << "/" << v_head_size
+ << " exceeds the limit of " << max_head_size);
+ return false;
+ }
+
+ // Causal attention is not supported
+ if (node->get_causal()) {
+ OPENVINO_MLIR_DEBUG_PRINT("SDPAPattern: rejected " << node->get_friendly_name() << " — causal attention");
+ return false;
+ }
+
+ const auto input_size = node->get_input_size();
+ // Sink parameter (6th input) is not supported
+ if (input_size >= 6) {
+ OPENVINO_MLIR_DEBUG_PRINT("SDPAPattern: rejected " << node->get_friendly_name() << " — sink parameter (6th input) is not supported");
+ return false;
+ }
+
+ // Mask (input 3): only static shapes are supported, dynamic ones are rejected
+ if (input_size > 3) {
+ const auto mask_shape = node->get_input_partial_shape(3);
+ const bool has_mask = mask_shape.rank().is_dynamic() || mask_shape.rank().get_length() > 0;
+ if (has_mask && mask_shape.is_dynamic()) {
+ OPENVINO_MLIR_DEBUG_PRINT("SDPAPattern: rejected " << node->get_friendly_name() << " — dynamic mask shape");
+ return false;
+ }
+ }
+
+ // Scale (input 4) must be a Constant, dynamic scale input is not supported
+ if (input_size > 4 && !std::dynamic_pointer_cast<v0::Constant>(node->get_input_node_shared_ptr(4))) {
+ OPENVINO_MLIR_DEBUG_PRINT("SDPAPattern: rejected " << node->get_friendly_name() << " — non-constant scale input");
+ return false;
+ }
+
+ return true;
+ }),
+ ConvertSDPA()) {}
+
+ShapeOfPattern::ShapeOfPattern() : MarkPattern(wrap_type<v3::ShapeOf>({any_input()}), ConvertShapeOf()) {}
+
+// ConvertSlice only implements the static, all-positive, unit-step case.
+SlicePattern::SlicePattern()
+ : MarkPattern(wrap_type<v8::Slice>({any_input(), any_input(), any_input(), any_input(), any_input()},
+ [](const Output<Node>& output) {
+ auto node = ov::as_type_ptr<v8::Slice>(output.get_node_shared_ptr());
+ if (!node || has_dynamic_rank(node)) {
+ OPENVINO_MLIR_DEBUG_PRINT("SlicePattern: rejected " << node->get_friendly_name() << " — dynamic rank");
+ return false;
+ }
+
+ const auto start = ov::as_type_ptr<v0::Constant>(node->get_input_node_shared_ptr(1));
+ const auto stop = ov::as_type_ptr<v0::Constant>(node->get_input_node_shared_ptr(2));
+ const auto step = ov::as_type_ptr<v0::Constant>(node->get_input_node_shared_ptr(3));
+ if (!start || !stop || !step) {
+ OPENVINO_MLIR_DEBUG_PRINT("SlicePattern: rejected " << node->get_friendly_name()
+ << " — start/stop/step must be Constants");
+ return false;
+ }
+
+ // Only unit step is supported (sizes = stop - start assumes step == 1).
+ const auto step_values = step->cast_vector<int64_t>();
+ if (std::any_of(step_values.begin(), step_values.end(), [](int64_t s) {
+ return s != 1;
+ })) {
+ OPENVINO_MLIR_DEBUG_PRINT("SlicePattern: rejected " << node->get_friendly_name() << " — non-unit step");
+ return false;
+ }
+
+ // Negative start/stop are not handled (no bounds normalization in the converter).
+ const auto start_values = start->cast_vector<int64_t>();
+ const auto stop_values = stop->cast_vector<int64_t>();
+ if (std::any_of(start_values.begin(),
+ start_values.end(),
+ [](int64_t v) {
+ return v < 0;
+ }) ||
+ std::any_of(stop_values.begin(), stop_values.end(), [](int64_t v) {
+ return v < 0;
+ })) {
+ OPENVINO_MLIR_DEBUG_PRINT("SlicePattern: rejected " << node->get_friendly_name() << " — negative start/stop");
+ return false;
+ }
+ return true;
+ }),
+ ConvertSlice()) {}
+
+SqueezePattern::SqueezePattern() : MarkPattern(wrap_type<v0::Squeeze>({any_input()}), ConvertSqueeze()) {}
+
+// ConvertTranspose requires an explicit Constant order covering all input dimensions.
+TransposePattern::TransposePattern()
+ : MarkPattern(wrap_type<v1::Transpose>(
+ {any_input(), any_input()},
+ [](const Output<Node>& output) {
+ auto node = ov::as_type_ptr<v1::Transpose>(output.get_node_shared_ptr());
+ if (!node || has_dynamic_rank(node)) {
+ OPENVINO_MLIR_DEBUG_PRINT("TransposePattern: rejected " << output.get_node()->get_friendly_name() << " — dynamic rank");
+ return false;
+ }
+
+ const auto order = ov::as_type_ptr<v0::Constant>(node->get_input_node_shared_ptr(1));
+ if (!order) {
+ OPENVINO_MLIR_DEBUG_PRINT("TransposePattern: rejected " << node->get_friendly_name() << " — non-constant order");
+ return false;
+ }
+
+ // An empty order means "reverse the dimensions" in OpenVINO, but linalg::TransposeOp
+ // needs an explicit permutation. A non-empty order is already validated to be a
+ // permutation of the input rank by the Transpose shape inference.
+ if (order->cast_vector<int64_t>().empty()) {
+ OPENVINO_MLIR_DEBUG_PRINT("TransposePattern: rejected " << node->get_friendly_name() << " — empty (implicit reverse) order");
+ return false;
+ }
+ return true;
+ }),
+ ConvertTranspose()) {}
+
+// ConvertUnsqueeze requires Constant axes that are already normalized: non-negative, unique and
+// sorted ascending.
+UnsqueezePattern::UnsqueezePattern()
+ : MarkPattern(
+ wrap_type<v0::Unsqueeze>(
+ {any_input(), any_input()},
+ [](const Output<Node>& output) {
+ auto node = ov::as_type_ptr<v0::Unsqueeze>(output.get_node_shared_ptr());
+ if (!node || has_dynamic_rank(node)) {
+ OPENVINO_MLIR_DEBUG_PRINT("UnsqueezePattern: rejected " << output.get_node()->get_friendly_name() << " — dynamic rank");
+ return false;
+ }
+
+ const auto axes = ov::as_type_ptr<v0::Constant>(node->get_input_node_shared_ptr(1));
+ if (!axes) {
+ OPENVINO_MLIR_DEBUG_PRINT("UnsqueezePattern: rejected " << node->get_friendly_name() << " — non-constant axes");
+ return false;
+ }
+
+ // The converter reads the axes via Constant::get_coordinate_val(), which requires i64.
+ if (axes->get_element_type() != element::i64) {
+ OPENVINO_MLIR_DEBUG_PRINT("UnsqueezePattern: rejected " << node->get_friendly_name() << " — only i64 axes are supported, got "
+ << axes->get_element_type());
+ return false;
+ }
+
+ const auto axes_values = axes->cast_vector<int64_t>();
+ if (axes_values.empty() || axes_values.front() < 0 || !std::is_sorted(axes_values.begin(), axes_values.end(), std::less_equal<int64_t>{})) {
+ OPENVINO_MLIR_DEBUG_PRINT("UnsqueezePattern: rejected " << node->get_friendly_name()
+ << " — axes must be non-negative, unique and sorted ascending");
+ return false;
+ }
+ return true;
+ }),
+ ConvertUnsqueeze()) {}
+
+BinaryEltwisePatternBase::BinaryEltwisePatternBase(NodeTypeInfo wrapped_type,
+ const GraphConverter::Convertor& convertor,
+ const std::set<element::Type>& element_types)
+ : MarkPattern(std::make_shared<pass::pattern::op::WrapType>(
+ wrapped_type,
+ [element_types](const Output<Node>& output) {
+ if (!element_types.empty() && !element_types.count(output.get_element_type())) {
+ return false;
+ }
+ auto node = output.get_node_shared_ptr();
+ const auto inputs = node->inputs();
+ return std::all_of(inputs.begin(), inputs.end(), [&output](const Input<Node>& input) {
+ return statically_broadcastable(input.get_partial_shape(), output.get_partial_shape());
+ });
+ },
+ OutputVector{any_input(), any_input()}),
+ convertor) {}
+
+template <typename OVOp, typename LinalgOp>
+BinaryEltwisePattern<OVOp, LinalgOp>::BinaryEltwisePattern(const std::set<element::Type>& element_types)
+ : BinaryEltwisePatternBase(OVOp::get_type_info_static(), ConvertBinaryEltwise<LinalgOp>(), element_types) {}
+
+// Explicit template instantiations
+// TODO: add signed/unsigned integers support
+template class BinaryEltwisePattern<v1::Add, linalg::AddOp>;
+template class BinaryEltwisePattern<v1::Subtract, linalg::SubOp>;
+template class BinaryEltwisePattern<v1::Multiply, linalg::MulOp>;
+template class BinaryEltwisePattern<v1::Divide, linalg::DivOp>;
+template class BinaryEltwisePattern<v1::Power, linalg::PowFOp>;
+
+template <typename OVOp, typename LinalgOp>
+UnaryEltwisePattern<OVOp, LinalgOp>::UnaryEltwisePattern() : MarkPattern(wrap_type<OVOp>({any_input()}), ConvertUnaryEltwise<LinalgOp>()) {}
+
+// Explicit template instantiations
+template class UnaryEltwisePattern<v0::Abs, linalg::AbsOp>;
+template class UnaryEltwisePattern<v0::Ceiling, linalg::CeilOp>;
+template class UnaryEltwisePattern<v0::Exp, linalg::ExpOp>;
+template class UnaryEltwisePattern<v0::Log, linalg::LogOp>;
+template class UnaryEltwisePattern<v0::Negative, linalg::NegFOp>;
+template class UnaryEltwisePattern<v0::Sqrt, linalg::SqrtOp>;
+template class UnaryEltwisePattern<v0::Tanh, linalg::TanhOp>;
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/conversion/patterns.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/conversion/patterns.hpp
new file mode 100644
index 00000000000..75f71868afc
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/conversion/patterns.hpp
@@ -0,0 +1,120 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "../graph_converter.hpp"
+// #include <openvino/op/add.hpp>
+// #include <openvino/op/divide.hpp>
+// #include <openvino/op/multiply.hpp>
+// #include <openvino/op/subtract.hpp>
+
+namespace ov::intel_gpu::mlir {
+
+class ReluPattern : public MarkPattern {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("ReluPattern");
+ ReluPattern();
+};
+
+class ConcatPattern : public MarkPattern {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("ConcatPattern");
+ ConcatPattern();
+};
+
+class FloorPattern : public MarkPattern {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("FloorPattern");
+ FloorPattern();
+};
+
+class GatherPattern : public MarkPattern {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("GatherPattern");
+ GatherPattern();
+};
+
+class MatMulPattern : public MarkPattern {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("MatMulPattern");
+ MatMulPattern();
+};
+
+template <typename OVOp>
+class ReducePattern : public MarkPattern {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("ReducePattern");
+ ReducePattern();
+};
+
+class RMSPattern : public MarkPattern {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("RMSPattern");
+ RMSPattern();
+};
+
+class ReshapePattern : public MarkPattern {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("ReshapePattern");
+ ReshapePattern();
+};
+
+class SDPAPattern : public MarkPattern {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("SDPAPattern");
+ SDPAPattern();
+};
+
+class ShapeOfPattern : public MarkPattern {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("ShapeOfPattern");
+ ShapeOfPattern();
+};
+
+class SlicePattern : public MarkPattern {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("SlicePattern");
+ SlicePattern();
+};
+
+class SqueezePattern : public MarkPattern {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("SqueezePattern");
+ SqueezePattern();
+};
+
+class TransposePattern : public MarkPattern {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("TransposePattern");
+ TransposePattern();
+};
+
+class UnsqueezePattern : public MarkPattern {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("UnsqueezePattern");
+ UnsqueezePattern();
+};
+
+class BinaryEltwisePatternBase : public MarkPattern {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("BinaryEltwisePatternBase");
+ BinaryEltwisePatternBase(NodeTypeInfo wrapped_type, const GraphConverter::Convertor& convertor, const std::set<element::Type>& element_types = {});
+};
+
+template <typename OVOp, typename LinalgOp>
+class BinaryEltwisePattern : public BinaryEltwisePatternBase {
+public:
+ BinaryEltwisePattern(const std::set<element::Type>& element_types = {});
+
+ BinaryEltwisePattern(const element::Type& element_type) : BinaryEltwisePattern(std::set<element::Type>{element_type}) {}
+};
+
+template <typename OVOp, typename LinalgOp>
+class UnaryEltwisePattern : public MarkPattern {
+public:
+ UnaryEltwisePattern();
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/convert.cpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/convert.cpp
new file mode 100644
index 00000000000..3b22693182d
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/convert.cpp
@@ -0,0 +1,550 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "interface/convert.hpp"
+
+#include <algorithm>
+#include <array>
+#include <openvino/op/abs.hpp>
+#include <openvino/op/add.hpp>
+#include <openvino/op/ceiling.hpp>
+#include <openvino/op/constant.hpp>
+#include <openvino/op/divide.hpp>
+#include <openvino/op/exp.hpp>
+#include <openvino/op/log.hpp>
+#include <openvino/op/multiply.hpp>
+#include <openvino/op/negative.hpp>
+#include <openvino/op/power.hpp>
+#include <openvino/op/reduce_max.hpp>
+#include <openvino/op/reduce_mean.hpp>
+#include <openvino/op/reduce_min.hpp>
+#include <openvino/op/reduce_prod.hpp>
+#include <openvino/op/reduce_sum.hpp>
+#include <openvino/op/sqrt.hpp>
+#include <openvino/op/subtract.hpp>
+#include <openvino/op/tanh.hpp>
+#include <openvino/pass/manager.hpp>
+#include <unordered_map>
+#include <unordered_set>
+#include <utility>
+
+// TODO: Prune unused headers -- it's hard to understand needed ones
+#include "common/convert_common.hpp"
+#include "conversion/patterns.hpp"
+#include "gc/Transforms/Passes.h"
+#include "graph_converter.hpp"
+#include "intel_gpu/op/mlir_op.hpp"
+#include "intel_gpu/runtime/execution_config.hpp"
+#include "mlir/Dialect/Bufferization/Transforms/Passes.h"
+#include "mlir/Dialect/Func/IR/FuncOps.h"
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Dialect/Linalg/TransformOps/DialectExtension.h"
+#include "mlir/Dialect/MemRef/IR/MemRef.h"
+#include "mlir/Dialect/Tensor/IR/Tensor.h"
+#include "mlir/Dialect/Vector/IR/VectorOps.h"
+#include "mlir/IR/BuiltinAttributes.h"
+#include "mlir/IR/BuiltinTypes.h"
+#include "mlir/IR/Diagnostics.h"
+#include "mlir/IR/Dialect.h"
+#include "mlir/IR/Location.h"
+#include "mlir/IR/ValueRange.h"
+#include "mlir/InitAllDialects.h"
+#include "mlir/Pass/PassManager.h"
+#include "mlir/Support/LLVM.h"
+#include "mlir/Target/LLVMIR/ModuleTranslation.h"
+#include "mlir_evaluate.hpp"
+#include "openvino/core/dimension.hpp"
+#include "openvino/core/symbol.hpp"
+#include "subgraph_tracker.hpp"
+#include "transformations/symbolic_transformations/symbolic_optimizations.hpp"
+
+namespace {
+
+using namespace mlir;
+using namespace ov::intel_gpu::mlir;
+
+MemRefType convertTensorToMemRef(TensorType tensorType) {
+ ArrayRef<int64_t> shape = tensorType.getShape();
+ Type elementType = tensorType.getElementType();
+ return MemRefType::get(shape, elementType);
+}
+
+SmallVector<mlir::Type> tensorsToMemRefs(const SmallVector<mlir::Type>& tensors) {
+ SmallVector<mlir::Type> out;
+ out.reserve(tensors.size());
+ for (const auto& tensor : tensors) {
+ out.push_back(convertTensorToMemRef(dyn_cast<TensorType>(tensor)));
+ }
+ return out;
+}
+
+SmallVector<mlir::Type> get_types_for_values(mlir::MLIRContext* context, const ov::OutputVector& values) {
+ SmallVector<mlir::Type> types;
+ types.reserve(values.size());
+ for (const auto& output : values) {
+ types.push_back(importTensor(context, output.get_partial_shape(), output.get_element_type()));
+ }
+ return types;
+}
+
+// Erases input function args that have no uses.
+void dropUnusedInputArgs(mlir::func::FuncOp func, size_t numInputs, SmallVector<size_t>& kept) {
+ llvm::BitVector toErase(func.getNumArguments());
+ for (size_t i = 0; i < numInputs; ++i) {
+ auto arg = func.getArgument(i);
+ if (arg.use_empty()) {
+ toErase.set(i);
+ continue;
+ }
+ if (arg.hasOneUse()) {
+ auto toTensor = mlir::dyn_cast<mlir::bufferization::ToTensorOp>(*arg.user_begin());
+ if (toTensor && toTensor.getResult().use_empty()) {
+ toTensor.erase();
+ toErase.set(i);
+ continue;
+ }
+ }
+ kept.push_back(i);
+ }
+ [[maybe_unused]] auto result = func.eraseArguments(toErase);
+ assert(mlir::succeeded(result) && "Failed to erase unused function arguments");
+}
+
+mlir::OwningOpRef<mlir::ModuleOp> ngraph_to_mlir(MLIRContext* context,
+ const ov::OutputVector& inputs,
+ const ov::NodeVector& nodes,
+ const ov::OutputVector& outputs,
+ SmallVector<size_t>& keptInputIndices,
+ const std::string& function_name = "entry") {
+ // Split inputs: splat constants are inlined, runtime inputs become function args.
+ ov::OutputVector runtime_inputs;
+ SmallVector<bool> is_constant(inputs.size(), false);
+ for (size_t i = 0; i < inputs.size(); ++i) {
+ auto* c = ov::as_type<ov::op::v0::Constant>(inputs[i].get_node());
+ if (c && c->get_all_data_elements_bitwise_identical()) {
+ is_constant[i] = true;
+ } else {
+ runtime_inputs.push_back(inputs[i]);
+ }
+ }
+
+ auto inputTypes = tensorsToMemRefs(get_types_for_values(context, runtime_inputs));
+ auto outputTypes = tensorsToMemRefs(get_types_for_values(context, outputs));
+
+ const auto moduleLoc = createLayerLocation(context, "module", "Module");
+ auto module = mlir::ModuleOp::create(moduleLoc, StringRef("fragment_name"));
+
+ auto moduleBuilder = mlir::OpBuilder::atBlockBegin(module.getBody() /* TODO: building log here */);
+
+ const auto funcLoc = createLayerLocation(context, "entry", "Func");
+ auto memref_args = inputTypes;
+ memref_args.append(outputTypes);
+ const auto funcType = mlir::FunctionType::get(context, ArrayRef(memref_args), ArrayRef(SmallVector<mlir::Type>()));
+ auto trunc = function_name.rfind('#');
+ auto name = trunc == std::string::npos ? function_name : function_name.substr(0, trunc);
+ auto func = mlir::func::FuncOp::create(moduleBuilder, funcLoc, name, funcType);
+ auto block_builder = mlir::OpBuilder::atBlockBegin(func.addEntryBlock() /* TODO: Add logger here */);
+
+ GraphConverter graph_converter(context, &block_builder);
+
+ for (size_t i = 0, r = 0; i < inputs.size(); ++i) {
+ auto loc = createLocation(context, inputs[i].get_node_shared_ptr());
+ if (is_constant[i]) {
+ auto* cst = ov::as_type<ov::op::v0::Constant>(inputs[i].get_node());
+ graph_converter.nodeOutputMap.emplace(inputs[i], getConstant(block_builder, cst, loc));
+ } else {
+ auto funcInputVal = func.getArgument(r++);
+ // transition from memref enclosure to tensor interior
+ auto ranked = mlir::dyn_cast<mlir::MemRefType>(funcInputVal.getType());
+ auto tensorTy = mlir::RankedTensorType::get(ranked.getShape(), ranked.getElementType());
+ auto tensor = bufferization::ToTensorOp::create(block_builder, loc, tensorTy, funcInputVal, /*restrict = */ true, /*writable=*/true);
+ graph_converter.nodeOutputMap.emplace(inputs[i], tensor);
+
+ // FIXME: Avoid pre-population of dimension_map, take dimension values only if needed
+ auto input_shape = inputs[i].get_partial_shape();
+ auto input_rank = input_shape.rank();
+ if (input_rank.is_static()) {
+ for (int64_t j = 0; j < input_rank.get_length(); ++j) {
+ auto dim = input_shape[j];
+ if (dim.is_dynamic()) {
+ auto symbol = dim.get_symbol();
+ assert(symbol);
+ symbol = ov::symbol::ancestor_of(symbol);
+ if (dim.is_dynamic() && !graph_converter.dimension_map.count(symbol)) {
+ auto dimSize = tensor::DimOp::create(block_builder, loc, tensor, j);
+ graph_converter.dimension_map[symbol] = dimSize;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ for (const auto& node : nodes) {
+ graph_converter.convert(node);
+ }
+
+ SmallVector<mlir::Value> funcOutputs;
+ funcOutputs.reserve(outputs.size());
+
+ for (size_t i = 0; i < outputs.size(); ++i) {
+ auto tensor = graph_converter.nodeOutputMap.at(outputs[i]);
+ auto memref = func.getArgument(i + runtime_inputs.size());
+ auto loc = createLocation(context, outputs[i].get_node_shared_ptr());
+ // Ensure the result is stored in the provided function argument.
+ // Mark as restrict to avoid temporary buffer and copy.
+ // Mark as writable to ensure the output can be written to the buffer.
+ bufferization::MaterializeInDestinationOp::create(block_builder,
+ loc,
+ TypeRange{},
+ tensor,
+ memref,
+ /*restrict=*/true,
+ /*writable=*/true);
+ }
+
+ const auto retLoc = createLayerLocation(context, "output", "Output");
+ mlir::func::ReturnOp::create(block_builder, retLoc, ArrayRef(SmallVector<Value>()));
+ SmallVector<size_t> keptRuntimeIndices;
+ dropUnusedInputArgs(func, runtime_inputs.size(), keptRuntimeIndices);
+ auto runtime_to_original = llvm::map_to_vector(llvm::make_filter_range(llvm::enumerate(is_constant),
+ [](const auto& p) {
+ return !p.value();
+ }),
+ [](const auto& p) {
+ return p.index();
+ });
+ llvm::transform(keptRuntimeIndices, std::back_inserter(keptInputIndices), [&](size_t i) {
+ return runtime_to_original[i];
+ });
+ return module;
+}
+
+// This pass converts a group of nodes into a single MLIROp
+NodePtr ngraph_to_mlir_op(MLIRContext* context, const SubgraphPtr& subgraph, const std::shared_ptr<ov::EvaluationContext>& loweringContext) {
+ SmallVector<size_t> keptInputIndices;
+ mlir::OwningOpRef<mlir::ModuleOp> module =
+ ngraph_to_mlir(context, subgraph->inputs, subgraph->nodes, subgraph->outputs, keptInputIndices, subgraph->function_name);
+
+ ov::OutputVector inputs;
+ inputs.reserve(keptInputIndices.size());
+ for (size_t idx : keptInputIndices) {
+ inputs.push_back(subgraph->inputs[idx]);
+ }
+ using Index = ov::intel_gpu::op::DimensionsMap::value_type::value_type;
+ std::map<SymbolPtr, Index> input_map;
+ for (size_t i = 0; i < inputs.size(); ++i) {
+ auto input = inputs[i];
+ auto shape = input.get_partial_shape();
+ for (size_t j = 0; j < shape.size(); ++j) {
+ auto dim = shape[j];
+ if (shape[j].is_dynamic()) {
+ auto symbol = ov::symbol::ancestor_of(dim.get_symbol());
+ if (0 == input_map.count(symbol)) {
+ input_map[symbol] = Index(i, j);
+ } else {
+ OPENVINO_MLIR_DEBUG_PRINT("Lost equality constraint for dimensions in output " << input << ".");
+ OPENVINO_MLIR_DEBUG_PRINT("If the constraint is violated in runtime it will result in the undefined behaviour.");
+ }
+ }
+ }
+ }
+
+ std::tuple<size_t, size_t> empty(-1, -1);
+ const auto& outputs = subgraph->outputs;
+ ov::intel_gpu::op::OVOutputTypes output_types;
+ ov::intel_gpu::op::DimensionsMap output_map;
+ output_map.reserve(outputs.size());
+ for (const auto& output : outputs) {
+ auto shape = output.get_partial_shape();
+ output_types.emplace_back(output.get_element_type(), shape);
+ ov::intel_gpu::op::DimensionsMap::value_type dm;
+ dm.reserve(shape.size());
+ for (const auto& dim : shape) {
+ if (dim.is_dynamic()) {
+ assert(input_map.count(ov::symbol::ancestor_of(dim.get_symbol())) && "Input map is missing a symbol for dynamic dim");
+ }
+ dm.push_back(dim.is_dynamic() ? input_map.at(ov::symbol::ancestor_of(dim.get_symbol())) : empty);
+ }
+ output_map.emplace_back(dm);
+ }
+ return std::make_shared<ov::intel_gpu::op::MLIROp>(inputs,
+ std::make_shared<MLIREvaluateGcGPU>(std::move(module), loweringContext),
+ output_types,
+ output_map);
+};
+
+void replace_subgraph(const SubgraphPtr& subgraph, const NodePtr& node) {
+ const auto& output_consumers = subgraph->output_consumers;
+ assert(output_consumers.size() == node->get_output_size());
+ for (size_t i = 0; i < node->get_output_size(); ++i) {
+ auto replacement = node->output(i);
+ for (auto consumer : output_consumers[i]) {
+ consumer.replace_source_output(replacement);
+ }
+ }
+}
+
+} // namespace
+
+namespace ov::intel_gpu::mlir {
+
+// Marks matched subgraphs with a custom function name so the
+// Partitioner groups them into a dedicated MLIR function.
+// The patterns come from ov::intel_gpu::mlir_patterns (OV_GPU_MLIR_PATTERNS env var), format is
+// "name1=Type1,Type2;name2=Type3,Type4,...".
+// Behavior depending on its value:
+// empty -> fall back to the default patterns (PatternMatcher::default_patterns);
+// "*" -> match every op already marked by the pattern passes;
+// "spec" -> match only the specified chains.
+class PatternMatcher : public ov::pass::ModelPass {
+ struct NamedPattern {
+ std::string name;
+ std::vector<std::string> types;
+ };
+
+ // Out-of-the-box patterns used when mlir_patterns is not set
+ static constexpr const char* default_patterns = "sdpa=ScaledDotProductAttention";
+ // Special value of mlir_patterns: match everything already marked by the pattern passes
+ static constexpr const char* match_all = "*";
+
+ static std::vector<NamedPattern> parse(const std::string& requested) {
+ std::vector<NamedPattern> patterns;
+ // An empty pattern list turns run_on_model() into a no-op, so nothing gets narrowed down
+ // and every op marked by the pattern passes stays matched.
+ if (requested == match_all) {
+ return patterns;
+ }
+ const std::string spec = requested.empty() ? std::string(default_patterns) : requested;
+ size_t pos = 0;
+ while (pos < spec.size()) {
+ auto sep = spec.find(';', pos);
+ auto entry = spec.substr(pos, sep == std::string::npos ? std::string::npos : sep - pos);
+ pos = sep == std::string::npos ? spec.size() : sep + 1;
+
+ auto eq = entry.find('=');
+ if (eq == std::string::npos) {
+ continue;
+ }
+ NamedPattern p{entry.substr(0, eq), {}};
+ for (size_t tp = eq + 1; tp < entry.size();) {
+ auto comma = entry.find(',', tp);
+ auto type = entry.substr(tp, comma == std::string::npos ? std::string::npos : comma - tp);
+ if (!type.empty()) {
+ p.types.push_back(type);
+ }
+ tp = comma == std::string::npos ? entry.size() : comma + 1;
+ }
+ if (!p.name.empty() && !p.types.empty()) {
+ patterns.push_back(std::move(p));
+ }
+ }
+ return patterns;
+ }
+
+ const std::vector<NamedPattern> patterns;
+
+public:
+ OPENVINO_MODEL_PASS_RTTI("PatternMatcher");
+
+ explicit PatternMatcher(const std::string& requested) : patterns(parse(requested)) {}
+
+ bool run_on_model(const std::shared_ptr<ov::Model>& model) override {
+ if (patterns.empty()) {
+ return false;
+ }
+
+ auto ordered_ops = model->get_ordered_ops();
+ auto filter = std::remove_if(ordered_ops.begin(), ordered_ops.end(), [](const auto& n) {
+ static const std::array<std::string, 3> skip = {"Constant", "Parameter", "Result"};
+ return std::any_of(skip.begin(), skip.end(), [&n](const std::string& s) {
+ return s == n->get_type_info().name;
+ });
+ });
+ ordered_ops.erase(filter, ordered_ops.end());
+
+ auto print_chain = [&](const char* msg, size_t offset, size_t count) {
+ std::string chain;
+ for (size_t i = offset; i < offset + count; ++i) {
+ chain += ordered_ops[i]->get_type_info().name;
+ chain += ",";
+ }
+ if (!chain.empty()) {
+ chain.pop_back();
+ OPENVINO_MLIR_DEBUG_PRINT(msg << chain);
+ }
+ };
+
+ if (::ov::intel_gpu::mlir::is_debug()) {
+ print_chain("Matching model: ", 0, ordered_ops.size());
+ }
+
+ bool changed = false;
+ std::unordered_set<ov::Node*> matched;
+ // Per-pattern match counter: each match gets a unique name (name, name1, name2, ...) so
+ // repeated matches stay separate single-output subgraphs instead of being force-joined by name.
+ std::unordered_map<std::string, int> match_count;
+ for (size_t i = 0, count = ordered_ops.size(); i < count; ++i) {
+ auto node = ordered_ops[i];
+ for (const auto& p : patterns) {
+ if (p.types.size() > count - i || p.types.front() != node->get_type_info().name || !has_subgraph_mark(node)) {
+ continue;
+ }
+ bool all_matches = true;
+ size_t len = p.types.size();
+ for (size_t n = i + 1, t = 1; t < len; ++n, ++t) {
+ if (p.types[t] != ordered_ops[n]->get_type_info().name || !has_subgraph_mark(ordered_ops[n])) {
+ all_matches = false;
+ break;
+ }
+ }
+ // Connectivity check
+ if (all_matches && len > 1) {
+ std::unordered_set<ov::Node*> nodes;
+ for (size_t t = 0; t < len; ++t) {
+ nodes.insert(ordered_ops[i + t].get());
+ }
+ std::unordered_set<ov::Node*> seen{ordered_ops[i].get()};
+ std::vector<ov::Node*> stack{ordered_ops[i].get()};
+ auto visit = [&](ov::Node* nb) {
+ if ((nodes.count(nb) != 0U) && seen.insert(nb).second) {
+ stack.push_back(nb);
+ }
+ };
+ while (!stack.empty()) {
+ auto* cur = stack.back();
+ stack.pop_back();
+ for (auto& in : cur->input_values()) {
+ visit(in.get_node());
+ }
+ for (auto& out : cur->outputs()) {
+ for (const auto& ti : out.get_target_inputs()) {
+ visit(ti.get_node());
+ }
+ }
+ }
+ all_matches = seen.size() == len;
+ }
+ if (all_matches) {
+ int n = match_count[p.name]++;
+ std::string name = n ? p.name + "#" + std::to_string(n) : p.name;
+ if (::ov::intel_gpu::mlir::is_debug()) {
+ std::string msg = "Matched pattern " + name + "=";
+ print_chain(msg.c_str(), i, len);
+ }
+ for (size_t t = 0; t < len; ++t, ++i) {
+ set_subgraph_mark(ordered_ops[i], name);
+ matched.insert(ordered_ops[i].get());
+ }
+ changed = true;
+ --i;
+ break;
+ }
+ }
+ }
+
+ // Clear marks on nodes not matched by any pattern - they will not be converted to MLIR.
+ for (const auto& node : ordered_ops) {
+ if (matched.count(node.get()) == 0) {
+ set_subgraph_mark(node, "");
+ changed = true;
+ }
+ }
+
+ return changed;
+ }
+};
+
+class Partitioner : public ov::pass::ModelPass {
+ MLIRContext* context;
+ std::shared_ptr<ov::EvaluationContext> loweringContext;
+
+public:
+ OPENVINO_MODEL_PASS_RTTI("Partitioner");
+
+ Partitioner(MLIRContext* context, std::shared_ptr<ov::EvaluationContext> loweringContext)
+ : context(context),
+ loweringContext(std::move(std::move(loweringContext))) {}
+
+ bool run_on_model(const std::shared_ptr<ov::Model>& model) override {
+ SubgraphTracker tracker([this](const SubgraphPtr& subgraph) {
+ auto mlir_op = ngraph_to_mlir_op(context, subgraph, loweringContext);
+ replace_subgraph(subgraph, mlir_op);
+ OPENVINO_MLIR_DEBUG_PRINT("Created MLIR op: " << mlir_op);
+ });
+ for (const auto& node : model->get_ordered_ops()) {
+ tracker.add_node(node, get_subgraph_mark(node));
+ }
+ tracker.finalize();
+ return true;
+ }
+};
+
+} // namespace ov::intel_gpu::mlir
+
+namespace {
+
+using namespace mlir;
+using namespace ov::intel_gpu::mlir;
+
+void injectMLIR(const std::shared_ptr<ov::Model>& model,
+ MLIRContext* context,
+ const ov::intel_gpu::ExecutionConfig& config,
+ const std::shared_ptr<ov::EvaluationContext>& loweringContext) {
+ ov::pass::Manager manager;
+ using namespace ov::op;
+ manager.set_per_pass_validation(false);
+ manager.register_pass<ov::pass::SymbolicPropagation>();
+ manager.register_pass<SDPAPattern>();
+ manager.register_pass<BinaryEltwisePattern<v1::Add, linalg::AddOp>>();
+ manager.register_pass<BinaryEltwisePattern<v1::Subtract, linalg::SubOp>>();
+ manager.register_pass<BinaryEltwisePattern<v1::Multiply, linalg::MulOp>>();
+ manager.register_pass<BinaryEltwisePattern<v1::Divide, linalg::DivOp>>();
+ manager.register_pass<BinaryEltwisePattern<v1::Power, linalg::PowFOp>>();
+ manager.register_pass<ReducePattern<v1::ReduceMax>>();
+ manager.register_pass<ReducePattern<v1::ReduceMean>>();
+ manager.register_pass<ReducePattern<v1::ReduceMin>>();
+ manager.register_pass<ReducePattern<v1::ReduceProd>>();
+ manager.register_pass<ReducePattern<v1::ReduceSum>>();
+ manager.register_pass<RMSPattern>();
+ manager.register_pass<ReshapePattern>();
+ manager.register_pass<ConcatPattern>();
+ manager.register_pass<ReluPattern>();
+ manager.register_pass<FloorPattern>();
+ manager.register_pass<UnaryEltwisePattern<v0::Abs, linalg::AbsOp>>();
+ manager.register_pass<UnaryEltwisePattern<v0::Ceiling, linalg::CeilOp>>();
+ manager.register_pass<UnaryEltwisePattern<v0::Exp, linalg::ExpOp>>();
+ manager.register_pass<UnaryEltwisePattern<v0::Log, linalg::LogOp>>();
+ manager.register_pass<UnaryEltwisePattern<v0::Negative, linalg::NegFOp>>();
+ manager.register_pass<UnaryEltwisePattern<v0::Sqrt, linalg::SqrtOp>>();
+ manager.register_pass<UnaryEltwisePattern<v0::Tanh, linalg::TanhOp>>();
+ manager.register_pass<GatherPattern>();
+ manager.register_pass<ShapeOfPattern>();
+ manager.register_pass<SlicePattern>();
+ manager.register_pass<SqueezePattern>();
+ manager.register_pass<TransposePattern>();
+ manager.register_pass<UnsqueezePattern>();
+ manager.register_pass<MatMulPattern>();
+ manager.register_pass<PatternMatcher>(config.get_mlir_patterns());
+ manager.register_pass<Partitioner>(context, loweringContext);
+ manager.run_passes(model);
+ model->validate_nodes_and_infer_types();
+}
+
+MLIRContext* get_shared_mlir_context() {
+ static auto context = [] {
+ auto ctx = std::make_unique<MLIRContext>(gc::getDialectRegistry());
+ ctx->loadAllAvailableDialects();
+ return ctx;
+ }();
+ return context.get();
+}
+
+} // namespace
+
+void ov::intel_gpu::mlir::transformMLIR(const std::shared_ptr<ov::Model>& model,
+ const ov::intel_gpu::ExecutionConfig& config,
+ const std::shared_ptr<ov::EvaluationContext>& loweringContext) {
+ injectMLIR(model, get_shared_mlir_context(), config, loweringContext);
+}
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/graph_converter.cpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/graph_converter.cpp
new file mode 100644
index 00000000000..b168bbe904b
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/graph_converter.cpp
@@ -0,0 +1,116 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+// #include "mlir/IR/BuiltinAttributes.h"
+// #include "mlir/IR/BuiltinTypes.h"
+
+#include "graph_converter.hpp"
+
+#include <utility>
+
+#include "common/conversion_context.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+using namespace ::mlir;
+
+std::string GraphConverter::rt_info_convertor() {
+ return "__mlir_convertor";
+}
+
+GraphConverter::GraphConverter(mlir::MLIRContext* context, mlir::OpBuilder* block_builder)
+ : _ctx(
+ context,
+ block_builder,
+ [this](const NodePtr& node) {
+ return getInputs(node);
+ },
+ [this](const Dimension& dim) {
+ return get_dimension_value(dim);
+ }) {}
+
+SmallVector<mlir::Value> GraphConverter::getInputs(const NodePtr& node) {
+ SmallVector<mlir::Value> out;
+ out.reserve(node->get_input_size());
+ for (const auto& input : node->inputs()) {
+ out.push_back(nodeOutputMap.at(input.get_source_output()));
+ }
+ return out;
+}
+
+void GraphConverter::addOutputs(const NodePtr& node, mlir::Operation* op) {
+ const auto results = op->getOpResults();
+
+ OPENVINO_ASSERT(results.size() == node->get_output_size(),
+ "Mismatch between original Node '{0}' number of outputs '{1}' and created number of outputs '{2}'",
+ node->get_friendly_name(),
+ node->get_output_size(),
+ results.size());
+
+ for (const auto& res : results) {
+ nodeOutputMap.emplace(node->output(res.getResultNumber()), res);
+ }
+}
+
+void GraphConverter::convert(const NodePtr& node) {
+ const auto& rt_info = node->get_rt_info();
+ auto it = rt_info.find(rt_info_convertor());
+ OPENVINO_ASSERT(it != rt_info.end(), "No MLIR converter registered for node ", node->get_type_name());
+ auto convertor = it->second.as<Convertor>();
+ auto* mlirOp = convertor(_ctx, node);
+ addOutputs(node, mlirOp);
+}
+
+void GraphConverter::set_convertor(const NodePtr& node, const Convertor& convertor) {
+ Convertor local_copy = convertor;
+ auto as_any = ov::Any(local_copy);
+ node->get_rt_info()[rt_info_convertor()] = as_any;
+}
+
+Value GraphConverter::get_dimension_value(const Dimension& d) {
+ auto symbol = d.get_symbol();
+ assert(symbol);
+ symbol = ov::symbol::ancestor_of(symbol);
+ // Suppose all dimensions are known and the map is populated
+ // FIXME: Add dimensions on demand to avoid unnecessary operations in the produced MLIR
+ assert(dimension_map.count(symbol));
+ return dimension_map.at(symbol);
+}
+
+const std::string& subgraph_mark() {
+ static const std::string mark = "__subgraph_mlir_mark";
+ return mark;
+}
+
+void set_subgraph_mark(const NodePtr& node, const std::string& name) {
+ node->get_rt_info()[subgraph_mark()] = name;
+}
+
+bool has_subgraph_mark(const NodePtr& node) {
+ return node->get_rt_info().count(subgraph_mark()) != 0U;
+}
+
+std::string get_subgraph_mark(const NodePtr& node) {
+ const auto& rti = node->get_rt_info();
+ auto it = rti.find(subgraph_mark());
+ return it == rti.end() ? "" : it->second.as<std::string>();
+}
+
+MarkPattern::MarkPattern(const NodePtr& pattern, const GraphConverter::Convertor& convertor) {
+ auto callback = [convertor](ov::pass::pattern::Matcher& m) {
+ auto node = m.get_match_root();
+ set_subgraph_mark(node);
+ GraphConverter::set_convertor(node, convertor);
+ return true;
+ };
+ auto m = std::make_shared<ov::pass::pattern::Matcher>(pattern, "MarkPattern");
+ register_matcher(m, callback);
+}
+
+MarkPattern::MarkPattern(const NodePtr& pattern, const MarkPattern::Callback& callback) {
+ auto m = std::make_shared<ov::pass::pattern::Matcher>(pattern, "MarkPattern");
+ register_matcher(m, callback);
+}
+
+} // namespace ov::intel_gpu::mlir
\ No newline at end of file
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/graph_converter.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/graph_converter.hpp
new file mode 100644
index 00000000000..5c11dae078a
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/graph_converter.hpp
@@ -0,0 +1,67 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <openvino/pass/graph_rewrite.hpp>
+
+#include "common/conversion_context.hpp"
+#include "common/convert_common.hpp"
+#include "common/typedefs.hpp"
+#include "mlir/IR/Builders.h"
+#include "mlir/IR/MLIRContext.h"
+#include "mlir/IR/Value.h"
+
+namespace ov::intel_gpu::mlir {
+
+using ::mlir::MLIRContext;
+using ::mlir::OpBuilder;
+using ::mlir::Operation;
+using ::mlir::SmallVector;
+using ::mlir::ValueRange;
+
+class GraphConverter {
+ static std::string rt_info_convertor();
+ ConversionContext _ctx;
+
+public:
+ using Convertor = std::function<Operation*(ConversionContext&, const NodePtr&)>;
+ using NodeOutputMap = std::map<ov::Output<ov::Node>, mlir::Value>;
+
+ static const std::map<ov::DiscreteTypeInfo, Convertor> convertors;
+ NodeOutputMap nodeOutputMap;
+ std::map<SymbolPtr, Value> dimension_map;
+
+ GraphConverter(mlir::MLIRContext* context, mlir::OpBuilder* block_builder);
+
+ SmallVector<mlir::Value> getInputs(const NodePtr& node);
+ void addOutputs(const NodePtr& node, mlir::Operation* op);
+
+ static void set_convertor(const NodePtr& node, const Convertor& convertor);
+
+ void convert(const NodePtr& node);
+
+ Value get_dimension_value(const Dimension& d);
+};
+
+const std::string& subgraph_mark();
+
+// name is the function name, that will contain the subgraph after conversion. The nodes are grouped by this name and
+// could be splitted into multiple subgraphs by marking with different names.
+void set_subgraph_mark(const NodePtr& node, const std::string& name = "entry");
+
+bool has_subgraph_mark(const NodePtr& node);
+
+// Returns "" if node is not marked
+std::string get_subgraph_mark(const NodePtr& node);
+
+class MarkPattern : public ov::pass::MatcherPass {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("MarkPattern");
+ MarkPattern(const NodePtr& pattern, const GraphConverter::Convertor& convertor);
+ using Callback = std::function<bool(ov::pass::pattern::Matcher&)>;
+ MarkPattern(const NodePtr& pattern, const Callback& callback);
+};
+
+} // namespace ov::intel_gpu::mlir
\ No newline at end of file
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/interface/convert.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/interface/convert.hpp
new file mode 100644
index 00000000000..9a587af3b22
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/interface/convert.hpp
@@ -0,0 +1,20 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <memory>
+
+#include "intel_gpu/runtime/execution_config.hpp"
+#include "openvino/core/any.hpp"
+#include "openvino/core/model.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+// 'config' is needed for the per-model ov::intel_gpu::mlir_patterns option
+void transformMLIR(const std::shared_ptr<ov::Model>& model,
+ const ExecutionConfig& config,
+ const std::shared_ptr<ov::EvaluationContext>& loweringContext);
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/interface/mlir_evaluate_base.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/interface/mlir_evaluate_base.hpp
new file mode 100644
index 00000000000..faa81d4d9e3
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/interface/mlir_evaluate_base.hpp
@@ -0,0 +1,22 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <vector>
+
+#include "openvino/core/node.hpp"
+#include "openvino/runtime/tensor.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+class MLIREvaluateBase {
+public:
+ [[nodiscard]] virtual bool requires_packed_args() const = 0;
+ virtual bool invoke(const ov::TensorVector& inputs, ov::TensorVector& outputs, const ov::EvaluationContext& evaluationContext) = 0;
+ virtual bool invoke_packed(std::vector<void*>& args, const ov::EvaluationContext& evaluationContext) = 0;
+ virtual ~MLIREvaluateBase() = default;
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/interface/properties.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/interface/properties.hpp
new file mode 100644
index 00000000000..a9a273a2191
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/interface/properties.hpp
@@ -0,0 +1,29 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <vector>
+
+#include "openvino/runtime/properties.hpp"
+
+namespace ov::internal::mlir_meta {
+
+/**
+ * @brief This key identifies a list of cl_event to wait for a kernel execution.
+ */
+static constexpr Property<std::vector<void*>> wait_list{"EVENTS_WAIT_LIST"};
+
+/**
+ * @brief This key identifies a pointer to a list that should be filled with
+ * result cl_events of a kernel execution.
+ */
+static constexpr Property<std::vector<void*>*> result_events{"RESULT_EVENTS"};
+
+/**
+ * @brief This key identifies whether the kernel argument at [i] position is USM pointer
+ */
+static constexpr Property<std::vector<bool>> is_kernel_arg_usm{"IS_KERNEL_ARG_USM"};
+
+} // namespace ov::internal::mlir_meta
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/mlir_evaluate.cpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/mlir_evaluate.cpp
new file mode 100644
index 00000000000..185bb1ad98c
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/mlir_evaluate.cpp
@@ -0,0 +1,165 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "mlir_evaluate.hpp"
+
+#include <memory>
+#include <vector>
+
+#include "common/convert_common.hpp"
+#include "gc/ExecutionEngine/GPURuntime/GpuOclRuntime.h"
+#include "gc/Transforms/Passes.h"
+#include "interface/properties.hpp"
+#include "mlir/Dialect/Bufferization/Transforms/Passes.h"
+#include "openvino/runtime/intel_gpu/remote_properties.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+using namespace ::mlir;
+
+static cl_device_id extract_device_from_context(cl_context context) {
+ size_t devices_size = 0;
+ cl_int err = clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, nullptr, &devices_size);
+ if (err != CL_SUCCESS) {
+ OPENVINO_THROW("Error getting context info: ", err);
+ }
+ if (devices_size / sizeof(cl_device_id) != 1) {
+ OPENVINO_THROW("Expected exactly one device in the context, got ", devices_size);
+ }
+
+ cl_device_id devices = nullptr;
+ // cl_device_id is itself a pointer type and clGetContextInfo takes its output buffer as 'void*',
+ // so the extra level of indirection is dictated by the OpenCL API and cannot be avoided here.
+ // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)
+ err = clGetContextInfo(context, CL_CONTEXT_DEVICES, devices_size, &devices, nullptr);
+ if (err != CL_SUCCESS) {
+ OPENVINO_THROW("Error getting device IDs: ", err);
+ }
+
+ return devices;
+}
+
+MLIREvaluateGcGPU::MLIREvaluateGcGPU(OwningOpRef<::mlir::ModuleOp> _module, const std::shared_ptr<ov::EvaluationContext>& loweringContext) {
+ if (::ov::intel_gpu::mlir::is_debug()) {
+ OPENVINO_MLIR_DEBUG_PRINT("-------------- Source MLIR --------------");
+ _module->dump();
+ OPENVINO_MLIR_DEBUG_PRINT("-----------------------------------------");
+ }
+
+ gc::gpu::OclModuleBuilderOpts opts;
+ gc::gpu::OclModuleBuilder builder(std::move(_module), opts);
+
+ auto it = loweringContext->find(ov::intel_gpu::ocl_context.name());
+ if (it == loweringContext->end()) {
+ OPENVINO_THROW("No cl_context provided for OpenCL execution");
+ }
+ auto* context = reinterpret_cast<cl_context>(it->second.as<ov::intel_gpu::gpu_handle_param>());
+ // assuming there's always one device per context
+ auto* device = extract_device_from_context(context);
+
+ if (auto mod = builder.build(device, context)) {
+ module = std::make_unique<const gc::gpu::OclModule>(*mod);
+ } else {
+ OPENVINO_THROW("Failed to build gc::gpuOclModule module");
+ }
+}
+
+bool MLIREvaluateGcGPU::invoke(const ov::TensorVector& inputs, ov::TensorVector& outputs, const ov::EvaluationContext& evaluationContext) {
+ gc::gpu::OclContext ctx = build_ocl_context(evaluationContext);
+ gc::gpu::StaticExecutor<> exec(*module);
+
+ auto it = evaluationContext.find(ov::internal::mlir_meta::is_kernel_arg_usm.name());
+ if (it == evaluationContext.end()) {
+ OPENVINO_THROW("No is_kernel_arg_usm provided for OpenCL execution");
+ }
+ std::vector<bool> arg_types = it->second.as<std::vector<bool>>();
+
+ for (size_t i = 0; i < inputs.size(); ++i) {
+ exec.arg(inputs[i].data(), arg_types[i]);
+ }
+ for (size_t i = 0, j = inputs.size(); i < outputs.size(); ++i, ++j) {
+ exec.arg(outputs[i].data(), arg_types[j]);
+ }
+
+ exec(ctx);
+
+ // Hands the completion events over via the mlir_meta::result_events vector, from which
+ // cldnn::mlir_primitive builds the event returned by the primitive
+ maybe_set_result_events(evaluationContext, ctx);
+ return true;
+}
+
+bool MLIREvaluateGcGPU::invoke_packed(std::vector<void*>& args, const ov::EvaluationContext& evaluationContext) {
+ gc::gpu::OclContext ctx = build_ocl_context(evaluationContext);
+ gc::gpu::DynamicExecutor<> exec(*module);
+
+ // Layout (5 pointers per memref, see MemRefDescriptor::append_to_packed_args
+ // in transformations/op/mlir_op.cpp):
+ // [aligned, rank, shape*, strides*, is_usm]
+ constexpr size_t kStride = 5;
+ OPENVINO_ASSERT(args.size() % kStride == 0, "[GPU] MLIREvaluateGcGPU::invoke_packed: malformed args vector");
+ for (size_t i = 0; i < args.size(); i += kStride) {
+ exec.arg(
+ /*alignedPtr=*/args[i],
+ /*rank=*/static_cast<size_t>(reinterpret_cast<uintptr_t>(args[i + 1])),
+ /*shape=*/reinterpret_cast<int64_t*>(args[i + 2]),
+ /*strides=*/reinterpret_cast<int64_t*>(args[i + 3]),
+ /*isUsm=*/reinterpret_cast<uintptr_t>(args[i + 4]) != 0);
+ }
+ exec(ctx);
+ // Hands the completion events over via the mlir_meta::result_events vector, from which
+ // cldnn::mlir_primitive builds the event returned by the primitive
+ maybe_set_result_events(evaluationContext, ctx);
+ return true;
+}
+
+void MLIREvaluateGcGPU::maybe_set_result_events(const ov::EvaluationContext& evaluationContext, gc::gpu::OclContext& ctx) {
+ auto events_it = evaluationContext.find(ov::internal::mlir_meta::result_events.name());
+ if (events_it == evaluationContext.end()) {
+ return;
+ }
+
+ auto retain_event = [](cl_event event) {
+ const auto err = clRetainEvent(event);
+ if (err != CL_SUCCESS) {
+ OPENVINO_THROW("Failed to retain MLIR result event, error: ", err);
+ }
+ };
+
+ auto* events = events_it->second.as<std::vector<void*>*>();
+ events->reserve(events->size() + ctx.events.size());
+ for (auto* event : ctx.events) {
+ retain_event(event);
+ events->push_back(event);
+ }
+}
+
+// Builds the gc::gpu::OclContext describing a single execution: the queue to enqueue to, the events
+// to wait for and whether Graph Compiler has to produce completion events.
+//
+// The wait-list is stored in the EvaluationContext as a std::vector<void*> owned by an
+// ov::Any, while OclContext takes a plain cl_event* + length, so they are copied into a local vector
+// first. The OclContext constructor clRetainEvent()s them and copies them into its own storage, so
+// that vector is no longer needed once the context is built.
+gc::gpu::OclContext MLIREvaluateGcGPU::build_ocl_context(const ov::EvaluationContext& evaluationContext) {
+ auto it = evaluationContext.find(ov::intel_gpu::ocl_queue.name());
+ if (it == evaluationContext.end()) {
+ OPENVINO_THROW("No queue provided for OpenCL execution");
+ }
+ auto* queue = reinterpret_cast<cl_command_queue>(it->second.as<void*>());
+
+ std::vector<void*> waitList;
+ uint32_t waitListLen = 0;
+
+ it = evaluationContext.find(ov::internal::mlir_meta::wait_list.name());
+ if (it != evaluationContext.end()) {
+ waitList = it->second.as<std::vector<void*>>();
+ waitListLen = waitList.size();
+ }
+
+ const bool createEvents = evaluationContext.count(ov::internal::mlir_meta::result_events.name()) != 0;
+ return gc::gpu::OclContext(module->runtime, queue, createEvents, waitListLen, reinterpret_cast<cl_event*>(waitList.data()));
+}
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/mlir_evaluate.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/mlir_evaluate.hpp
new file mode 100644
index 00000000000..3de14c5c63f
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/mlir_evaluate.hpp
@@ -0,0 +1,41 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <memory>
+#include <vector>
+
+#include "gc/ExecutionEngine/GPURuntime/GpuOclRuntime.h"
+#include "interface/mlir_evaluate_base.hpp"
+#include "mlir/ExecutionEngine/ExecutionEngine.h"
+#include "mlir/IR/BuiltinOps.h"
+#include "openvino/core/any.hpp"
+#include "openvino/core/node.hpp"
+#include "openvino/runtime/tensor.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+using ::mlir::ExecutionEngine;
+using ::mlir::ModuleOp;
+using ::mlir::OwningOpRef;
+
+class MLIREvaluateGcGPU : public MLIREvaluateBase {
+ std::unique_ptr<const ::mlir::gc::gpu::OclModule> module;
+
+public:
+ MLIREvaluateGcGPU(OwningOpRef<ModuleOp> _module, const std::shared_ptr<ov::EvaluationContext>& loweringContext);
+
+ [[nodiscard]] bool requires_packed_args() const override {
+ return !module->isStatic();
+ }
+ bool invoke(const ov::TensorVector& inputs, ov::TensorVector& outputs, const ov::EvaluationContext& evaluationContext) override;
+ bool invoke_packed(std::vector<void*>& args, const ov::EvaluationContext& evaluationContext) override;
+
+private:
+ ::mlir::gc::gpu::OclContext build_ocl_context(const ov::EvaluationContext& evaluationContext);
+ static void maybe_set_result_events(const ov::EvaluationContext& evaluationContext, ::mlir::gc::gpu::OclContext& ctx);
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/subgraph_tracker.cpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/subgraph_tracker.cpp
new file mode 100644
index 00000000000..0091148abfc
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/subgraph_tracker.cpp
@@ -0,0 +1,196 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "subgraph_tracker.hpp"
+
+#include <algorithm>
+#include <functional>
+#include <unordered_map>
+#include <utility>
+
+namespace ov::intel_gpu::mlir {
+
+void Subgraph::merge(Subgraph& other) {
+ nodes.insert(nodes.end(), other.nodes.begin(), other.nodes.end());
+}
+
+SubgraphTracker::SubgraphTracker(Finalizer finalizer) : m_finalizer(std::move(finalizer)) {}
+
+void SubgraphTracker::add_node(const NodePtr& node, const std::string& name) {
+ const bool belongs = !name.empty();
+ // collect all subgraph ids that input nodes belong to and all dependencies
+ Dependencies input_subgraphs;
+ Dependencies input_dependencies;
+ for (const auto& input_value : node->input_values()) {
+ auto node = input_value.get_node_shared_ptr();
+ if (auto id = get_subgraph_id(node)) {
+ id = ov::symbol::ancestor_of(id);
+ // Only merge with input subgraphs of the same name; a differently named input subgraph
+ // becomes a boundary (its output feeds this node's subgraph as an external input).
+ if (belongs && get_subgraph(id)->function_name == name) {
+ input_subgraphs.insert(id);
+ } else {
+ input_dependencies.insert(id);
+ }
+ }
+ const auto& deps = get_dependencies(node);
+ for (const auto& dep : deps) {
+ input_dependencies.insert(ov::symbol::ancestor_of(dep));
+ }
+ }
+
+ if (belongs) {
+ // Remove input_subgraphs from input_dependencies: a subgraph depending on itself
+ // is not a cycle — it just means multiple paths converge inside the same subgraph.
+ for (const auto& id : input_subgraphs) {
+ input_dependencies.erase(ov::symbol::ancestor_of(id));
+ }
+
+ // Below we refuse to merge subgraphs if all of them cannot merge to a single subgraph, this is rough because
+ // there are cases when a part of the input subgraphs can be merged together and consume the new node and other
+ // (conflicting) subgraphs will come as inputs
+ // TODO: leave only those input subgraphs that are not conflicting with other subgraphs nor with any
+ // dependencies
+ if (input_subgraphs.empty() || intersected(input_subgraphs, input_dependencies)) { // no input subgraphs || cannot merge all due to cycles
+ try_terminate_subgraphs(input_subgraphs, node);
+
+ // start a new subgraph
+ auto subgraph_id = new_subgraph();
+ get_subgraph(subgraph_id)->function_name = name;
+ add_node_to_subgraph(node, subgraph_id);
+ set_subgraph_id(node, subgraph_id);
+ input_dependencies.insert(input_subgraphs.begin(), input_subgraphs.end());
+ } else {
+ auto merged_subgraph_id =
+ std::accumulate(input_subgraphs.begin(), input_subgraphs.end(), *input_subgraphs.begin(), [this](SubgraphID a, SubgraphID b) {
+ merge_subgraphs(a, std::move(b));
+ return a;
+ });
+ set_subgraph_id(node, merged_subgraph_id);
+ add_node_to_subgraph(node, merged_subgraph_id);
+ }
+
+ } else {
+ try_terminate_subgraphs(input_subgraphs, node);
+ set_subgraph_id(node, nullptr);
+ input_dependencies.insert(input_subgraphs.begin(), input_subgraphs.end());
+ }
+ set_dependencies(node, input_dependencies);
+}
+
+SubgraphPtr SubgraphTracker::get_current_subgraph(const NodePtr& node) {
+ auto id = get_subgraph_id(node);
+ return id ? get_subgraph(id) : nullptr;
+}
+
+void SubgraphTracker::finalize() {
+ for (const auto& subgraph_record : m_subgraphs) {
+ terminate_subgraph(subgraph_record.first);
+ }
+}
+
+SubgraphID SubgraphTracker::new_subgraph() {
+ SubgraphID id = std::make_shared<ov::Symbol>();
+ m_subgraphs[id] = std::make_shared<Subgraph>();
+ return id;
+}
+
+void SubgraphTracker::add_node_to_subgraph(const NodePtr& node, const SubgraphID& id) {
+ get_subgraph(id)->nodes.push_back(node);
+}
+
+void SubgraphTracker::merge_subgraphs(SubgraphID id1, SubgraphID id2) {
+ id1 = ov::symbol::ancestor_of(id1);
+ id2 = ov::symbol::ancestor_of(id2);
+ if (id1 == id2) {
+ return;
+ }
+
+ auto subgraph1 = get_subgraph(id1);
+ auto subgraph2 = get_subgraph(id2);
+ subgraph1->merge(*subgraph2);
+ m_subgraphs.erase(id1);
+ m_subgraphs.erase(id2);
+ ov::symbol::set_equal(id1, id2);
+ id1 = ov::symbol::ancestor_of(id1);
+ m_subgraphs[id1] = subgraph1;
+}
+
+SubgraphPtr SubgraphTracker::get_subgraph(const SubgraphID& id) {
+ return m_subgraphs.at(ov::symbol::ancestor_of(id));
+}
+
+// set/get all subgraph ids that contribute to a given node
+
+const SubgraphTracker::Dependencies& SubgraphTracker::get_dependencies(const NodePtr& node) {
+ return node->get_rt_info().at("__subgraph_dependencies").as<Dependencies>();
+}
+void SubgraphTracker::set_dependencies(const NodePtr& node, const Dependencies& dependencies) {
+ node->get_rt_info()["__subgraph_dependencies"] = dependencies;
+}
+
+// set/get subgraph id that a give node belongs to
+
+SubgraphID SubgraphTracker::get_subgraph_id(const NodePtr& node) {
+ const auto& rti = node->get_rt_info();
+ if (rti.count("__subgraph_id") == 0U) {
+ return nullptr;
+ }
+ auto id = rti.at("__subgraph_id").as<SubgraphID>();
+ if (id) {
+ id = ov::symbol::ancestor_of(id);
+ }
+ return id;
+}
+
+void SubgraphTracker::set_subgraph_id(const NodePtr& node, const SubgraphID& id) {
+ node->get_rt_info()["__subgraph_id"] = id;
+}
+
+bool SubgraphTracker::intersected(const Dependencies& a, const Dependencies& b) {
+ return std::any_of(a.begin(), a.end(), [&b](const SubgraphID& id) {
+ return b.count(id) != 0;
+ });
+}
+
+void SubgraphTracker::terminate_subgraph(SubgraphID id) {
+ id = ov::symbol::ancestor_of(id);
+ auto subgraph = get_subgraph(id);
+ // Build subgraph inputs and outputs
+ std::set<ov::Output<ov::Node>> inputs;
+ auto& outputs = subgraph->outputs;
+ auto& output_consumers = subgraph->output_consumers;
+ for (const auto& node : subgraph->nodes) {
+ for (const auto& input : node->input_values()) {
+ auto input_id = get_subgraph_id(input.get_node_shared_ptr());
+ if (!ov::symbol::are_equal(id, input_id)) {
+ inputs.insert(input);
+ }
+ }
+ for (const auto& output : node->outputs()) {
+ const auto& consumers = output.get_target_inputs();
+ InputVector external_consumers;
+ for (auto consumer : consumers) {
+ auto consumer_id = get_subgraph_id(consumer.get_node()->shared_from_this());
+ if (!ov::symbol::are_equal(id, consumer_id)) {
+ external_consumers.push_back(consumer);
+ }
+ }
+ bool used_outside = !external_consumers.empty();
+ if (used_outside) {
+ outputs.push_back(output);
+ output_consumers.push_back(external_consumers);
+ }
+ }
+ }
+ subgraph->inputs.assign(inputs.begin(), inputs.end());
+ m_finalizer(subgraph);
+}
+
+void SubgraphTracker::try_terminate_subgraphs(const Dependencies& subgraphs, const NodePtr& terminator) {
+ // TODO: Terminate subgraphs earlier when all terminating nodes are known
+ // TODO: try to merge subgraphs if they are being terminated simultaniously
+}
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/mlir/subgraph_tracker.hpp b/src/plugins/intel_gpu/src/plugin/transformations/mlir/subgraph_tracker.hpp
new file mode 100644
index 00000000000..e053daf8366
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/mlir/subgraph_tracker.hpp
@@ -0,0 +1,62 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <functional>
+
+#include "common/typedefs.hpp"
+
+namespace ov::intel_gpu::mlir {
+
+struct Subgraph {
+ ov::NodeVector nodes;
+ ov::OutputVector inputs;
+ ov::OutputVector outputs;
+ std::vector<InputVector> output_consumers;
+ std::string function_name;
+
+ // Consumes other subgraph
+ void merge(Subgraph& other);
+};
+
+using SubgraphPtr = std::shared_ptr<Subgraph>;
+using SubgraphID = SymbolPtr;
+
+class SubgraphTracker {
+public:
+ // callback to finalize the subgraph when it is terminated
+ using Finalizer = std::function<void(SubgraphPtr)>;
+
+ SubgraphTracker(Finalizer finalizer);
+ // name == "" means the node does not belong to any subgraph. Nodes that belong are merged only with
+ // connected input subgraphs sharing the same name; a different name starts a separate (named) subgraph.
+ void add_node(const NodePtr& node, const std::string& name);
+ void finalize();
+ SubgraphPtr get_current_subgraph(const NodePtr& node);
+
+private:
+ std::unordered_map<SubgraphID, SubgraphPtr> m_subgraphs;
+ using Dependencies = std::unordered_set<SubgraphID>;
+ Finalizer m_finalizer;
+
+ SubgraphID new_subgraph();
+ void add_node_to_subgraph(const NodePtr& node, const SubgraphID& id);
+ void merge_subgraphs(SubgraphID id1, SubgraphID id2);
+ SubgraphPtr get_subgraph(const SubgraphID& id);
+
+ // set/get all subgraph ids that contribute to a given node
+ static const Dependencies& get_dependencies(const NodePtr& node);
+ static void set_dependencies(const NodePtr& node, const Dependencies& dependencies);
+
+ // set/get subgraph id that a give node belongs to
+ static SubgraphID get_subgraph_id(const NodePtr& node);
+ static void set_subgraph_id(const NodePtr& node, const SubgraphID& id);
+
+ static bool intersected(const Dependencies& a, const Dependencies& b);
+ void terminate_subgraph(SubgraphID id);
+ void try_terminate_subgraphs(const Dependencies& subgraphs, const NodePtr& terminator);
+};
+
+} // namespace ov::intel_gpu::mlir
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/op/mlir_op.cpp b/src/plugins/intel_gpu/src/plugin/transformations/op/mlir_op.cpp
new file mode 100644
index 00000000000..0712f95bd0c
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/op/mlir_op.cpp
@@ -0,0 +1,223 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#ifdef ENABLE_MLIR_FOR_GPU
+
+# include "intel_gpu/op/mlir_op.hpp"
+
+# include <algorithm>
+# include <cassert>
+# include <iterator>
+# include <memory>
+# include <utility>
+# include <vector>
+
+# include "../mlir/interface/mlir_evaluate_base.hpp"
+# include "../mlir/interface/properties.hpp"
+# include "openvino/core/shape.hpp"
+
+namespace ov::intel_gpu::op {
+
+namespace {
+
+// Descriptor packed into the 5-slot layout expected by
+// MLIREvaluateGcGPU::invoke_packed:
+// [aligned, rank, shape*, strides*, is_usm]
+// TODO: u4/i4 types are not supported
+struct MemRefDescriptor {
+ MemRefDescriptor() = default;
+
+ MemRefDescriptor(ov::Tensor tensor, const ov::PartialShape& module_input_shape) : allocated(tensor.data()), aligned(tensor.data()) {
+ OPENVINO_ASSERT(module_input_shape.rank().is_static(), "MLIROp: module_input_shape rank must be static");
+ const auto module_rank = static_cast<size_t>(module_input_shape.rank().get_length());
+ OPENVINO_ASSERT(module_rank <= tensor.get_shape().size(),
+ "MLIROp: tensor rank (",
+ tensor.get_shape().size(),
+ ") is smaller than expected module rank (",
+ module_rank,
+ ")");
+
+ // Keep only the leading `module_rank` dims; the trailing ones must all be 1
+ auto it = std::next(tensor.get_shape().begin(), module_rank);
+ shape.assign(tensor.get_shape().begin(), it);
+ if (std::any_of(it, tensor.get_shape().end(), [](size_t dim) {
+ return dim != 1;
+ })) {
+ OPENVINO_THROW("Mismatch in shape sizes");
+ }
+
+ strides.resize(shape.size());
+ const auto& byte_strides = tensor.get_strides();
+ auto element_size = tensor.get_element_type().size();
+ for (size_t i = 0; i < strides.size(); ++i) {
+ assert(byte_strides[i] % element_size == 0);
+ // TODO: handle case when stride is not aligned (restrict at OV API level)
+ strides[i] = byte_strides[i] / element_size;
+ }
+ }
+
+ explicit MemRefDescriptor(const ov::Tensor& tensor) : MemRefDescriptor(tensor, tensor.get_shape()) {}
+
+ void* allocated = nullptr;
+ void* aligned = nullptr;
+ int64_t offset = 0L;
+ std::vector<int64_t> shape;
+ std::vector<int64_t> strides;
+
+ void append_to_packed_args(std::vector<void*>& args, bool is_usm) {
+ args.push_back(aligned);
+ // The kernel ABI passes scalars in the same 'void*' slots as pointers, so integer-to-pointer
+ // casts are required here; there is no pointer-typed alternative.
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
+ args.push_back(reinterpret_cast<void*>(static_cast<uintptr_t>(shape.size())));
+ args.push_back(shape.data());
+ args.push_back(strides.data());
+ // NOLINTNEXTLINE(performance-no-int-to-ptr)
+ args.push_back(reinterpret_cast<void*>(static_cast<uintptr_t>(is_usm)));
+ }
+};
+
+} // namespace
+
+MLIROp::MLIROp(const ov::OutputVector& args, std::shared_ptr<mlir::MLIREvaluateBase> engine, OVOutputTypes output_types, DimensionsMap dimensions_map)
+ : Op(args),
+ engine(std::move(engine)),
+ output_types(std::move(output_types)),
+ dimensions_map(std::move(dimensions_map)) {
+ constructor_validate_and_infer_types();
+}
+
+std::vector<ov::PartialShape> MLIROp::shape_infer(const std::vector<ov::PartialShape>& input_shapes) const {
+ OPENVINO_ASSERT(dimensions_map.size() == output_types.size(),
+ "MLIROp::shape_infer: dimensions_map size (",
+ dimensions_map.size(),
+ ") does not match output_types size (",
+ output_types.size(),
+ ")");
+
+ std::vector<ov::PartialShape> output_shapes;
+ output_shapes.reserve(output_types.size());
+ for (size_t i = 0; i < output_types.size(); ++i) {
+ ov::PartialShape resolved = std::get<1>(output_types[i]);
+ OPENVINO_ASSERT(dimensions_map[i].size() == resolved.size(),
+ "MLIROp::shape_infer: dimensions_map[",
+ i,
+ "] size (",
+ dimensions_map[i].size(),
+ ") does not match output ",
+ i,
+ " rank (",
+ resolved.size(),
+ ")");
+
+ for (size_t j = 0; j < resolved.size(); ++j) {
+ if (!resolved[j].is_dynamic()) {
+ continue;
+ }
+ size_t input_index = 0, dim_index = 0;
+ std::tie(input_index, dim_index) = dimensions_map[i][j];
+ OPENVINO_ASSERT(input_index < input_shapes.size(),
+ "MLIROp::shape_infer: dimensions_map[",
+ i,
+ "][",
+ j,
+ "] refers to input ",
+ input_index,
+ " but only ",
+ input_shapes.size(),
+ " input shapes provided");
+ OPENVINO_ASSERT(dim_index < input_shapes[input_index].size(),
+ "MLIROp::shape_infer: dimensions_map[",
+ i,
+ "][",
+ j,
+ "] refers to dim ",
+ dim_index,
+ " of input ",
+ input_index,
+ " (rank ",
+ input_shapes[input_index].size(),
+ ")");
+ resolved[j] = input_shapes[input_index][dim_index];
+ }
+ output_shapes.push_back(resolved);
+ }
+ return output_shapes;
+}
+
+void MLIROp::validate_and_infer_types() {
+ std::vector<ov::PartialShape> input_shapes;
+ input_shapes.reserve(get_input_size());
+ for (size_t i = 0; i < get_input_size(); ++i) {
+ input_shapes.push_back(get_input_partial_shape(i));
+ }
+ auto output_shapes = shape_infer(input_shapes);
+
+ set_output_size(output_types.size());
+ for (size_t i = 0; i < output_types.size(); ++i) {
+ set_output_type(i, std::get<0>(output_types[i]), output_shapes[i]);
+ }
+}
+
+std::shared_ptr<ov::Node> MLIROp::clone_with_new_inputs(const ov::OutputVector& new_args) const {
+ return std::make_shared<MLIROp>(new_args, engine, output_types, dimensions_map);
+}
+
+bool MLIROp::evaluate(ov::TensorVector& outputs, const ov::TensorVector& inputs, const ov::EvaluationContext& evaluationContext) const {
+ if (!engine->requires_packed_args()) {
+ return engine->invoke(inputs, outputs, evaluationContext);
+ }
+
+ std::vector<MemRefDescriptor> memref_args;
+ memref_args.reserve(inputs.size() + outputs.size());
+ for (size_t i = 0; i < inputs.size(); ++i) {
+ const auto& initial_shape = get_input_partial_shape(i);
+ memref_args.emplace_back(inputs[i], initial_shape);
+ }
+ for (size_t i = 0; i < outputs.size(); ++i) {
+ // TODO: Optimize by adding all dimensions to dimensions_map, not only dynamic
+ ov::Shape target;
+ ov::PartialShape expected = get_output_partial_shape(i);
+ for (size_t j = 0; j < expected.size(); ++j) {
+ auto dim = expected[j];
+ if (dim.is_dynamic()) {
+ size_t input_index = 0, dim_index = 0;
+ std::tie(input_index, dim_index) = dimensions_map[i][j];
+ target.push_back(inputs[input_index].get_shape()[dim_index]);
+ } else {
+ target.push_back(dim.get_length());
+ }
+ }
+ outputs[i].set_shape(target);
+ memref_args.emplace_back(outputs[i]);
+ }
+
+ std::vector<bool> is_usm;
+ auto it = evaluationContext.find(ov::internal::mlir_meta::is_kernel_arg_usm.name());
+ if (it != evaluationContext.end()) {
+ is_usm = it->second.as<std::vector<bool>>();
+ } else {
+ is_usm.assign(memref_args.size(), false);
+ }
+ OPENVINO_ASSERT(is_usm.size() == memref_args.size(), "[GPU] MLIROp::evaluate: is_usm and memref count mismatch");
+
+ std::vector<void*> args;
+ for (size_t k = 0; k < memref_args.size(); ++k) {
+ memref_args[k].append_to_packed_args(args, is_usm[k]);
+ }
+
+ return engine->invoke_packed(args, evaluationContext);
+}
+
+bool MLIROp::evaluate(ov::TensorVector& outputs, const ov::TensorVector& inputs) const {
+ return evaluate(outputs, inputs, ov::EvaluationContext());
+}
+
+bool MLIROp::has_evaluate() const {
+ return true;
+}
+
+} // namespace ov::intel_gpu::op
+
+#endif // ENABLE_MLIR_FOR_GPU
diff --git a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
index b6d01397f97..6d5bbc517f1 100644
--- a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
+++ b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
@@ -169,6 +169,9 @@
#include "transformations/init_node_info.hpp"
#include "transformations/normalize_l2_decomposition.hpp"
#include "transformations/low_precision/mark_dequantization_subgraph.hpp"
+#ifdef OV_GPU_MLIR_BACKEND_LINKED
+# include "transformations/mlir/interface/convert.hpp"
+#endif // OV_GPU_MLIR_BACKEND_LINKED
#include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp"
#include "transformations/op_conversions/convert_batch_to_space.hpp"
#include "transformations/op_conversions/convert_broadcast3.hpp"
@@ -975,6 +978,11 @@ void TransformationsPipeline::apply(std::shared_ptr<ov::Model> func) {
}
pass_config->set_callback<ov::pass::ScaledDotProductAttentionDecomposition>([&](const std::shared_ptr<const ov::Node> node){
+ // Never decompose if mlir-path is enabled
+ if (GPU_DEBUG_VALUE_OR(ExecutionConfig::get_enable_mlir(), false)) {
+ return true;
+ }
+
if (!config.get_enable_sdpa_optimization())
return false;
@@ -1697,6 +1705,25 @@ void TransformationsPipeline::apply(std::shared_ptr<ov::Model> func) {
manager.run_passes(func);
}
+ if (GPU_DEBUG_VALUE_OR(ExecutionConfig::get_enable_mlir(), false)) {
+ // Guarded by OV_GPU_MLIR_BACKEND_LINKED rather than ENABLE_MLIR_FOR_GPU: this file is also
+ // compiled into ov_gpu_unit_tests, which does not link the MLIR objects providing transformMLIR().
+#ifdef OV_GPU_MLIR_BACKEND_LINKED
+ auto loweringContext = std::make_shared<ov::EvaluationContext>();
+ auto it = m_context->get_property().find(ov::intel_gpu::ocl_context.name());
+ if (it != m_context->get_property().end()) {
+ // We assume here that there's only one device per context and that an
+ // actual device will be extracted later by the 'mlir_op'.
+ loweringContext->insert(ov::intel_gpu::ocl_context(it->second.as<ov::intel_gpu::gpu_handle_param>()));
+ }
+ ov::intel_gpu::mlir::transformMLIR(func, config, loweringContext);
+#else
+ OPENVINO_THROW("[GPU] Property 'GPU_ENABLE_MLIR' (or OV_GPU_ENABLE_MLIR env var) is enabled, "
+ "but this binary was built without Graph Compiler support. "
+ "Rebuild OpenVINO with -DENABLE_MLIR_FOR_GPU=ON to enable MLIR execution.");
+#endif // OV_GPU_MLIR_BACKEND_LINKED
+ }
+
{
ov::pass::Manager manager("GPU:PostLPT");
manager.set_per_pass_validation(false);
diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_base_event.hpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_base_event.hpp
index c2b56e1ef43..5ce1ec27985 100644
--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_base_event.hpp
+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_base_event.hpp
@@ -26,6 +26,9 @@ public:
explicit ocl_base_event(uint64_t queue_stamp = 0) : _queue_stamp(queue_stamp) { }
uint64_t get_queue_stamp() const { return _queue_stamp; }
virtual cl::Event& get() = 0;
+#ifdef ENABLE_MLIR_FOR_GPU
+ void* get_native_handle() override { return static_cast<void*>(get().get()); }
+#endif
protected:
uint64_t _queue_stamp = 0;
diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_memory.hpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_memory.hpp
index 8151344421c..8adc37ccfd4 100644
--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_memory.hpp
+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_memory.hpp
@@ -47,6 +47,9 @@ struct gpu_buffer : public lockable_gpu_mem, public memory {
void* buffer_ptr() const override {
return get_buffer().get();
}
+#ifdef ENABLE_MLIR_FOR_GPU
+ void* get_native_handle() const override { return static_cast<void*>(get_buffer().get()); }
+#endif
event::ptr copy_from(stream& stream, const void* data_ptr, size_t src_offset, size_t dst_offset, size_t size, bool blocking) override;
event::ptr copy_from(stream& stream, const memory& src_mem, size_t src_offset, size_t dst_offset, size_t size, bool blocking) override;
diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_stream.cpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_stream.cpp
index 9c9e65adc7d..eb634b8b6fb 100644
--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_stream.cpp
+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_stream.cpp
@@ -377,6 +377,14 @@ event::ptr ocl_stream::create_base_event() {
return std::make_shared<ocl_event>(ret_ev, ++_queue_counter);
}
+#ifdef ENABLE_MLIR_FOR_GPU
+event::ptr ocl_stream::create_base_event(void* handle) {
+ cl::Event ret_ev;
+ ret_ev = reinterpret_cast<cl_event>(handle);
+ return std::make_shared<ocl_event>(ret_ev, ++_queue_counter);
+}
+#endif
+
std::unique_ptr<surfaces_lock> ocl_stream::create_surfaces_lock(const std::vector<memory::ptr>& mem) const {
return std::unique_ptr<ocl::ocl_surfaces_lock>(new ocl::ocl_surfaces_lock(mem, *this));
}
diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_stream.hpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_stream.hpp
index 052db583fa9..d3ff8f9423f 100644
--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_stream.hpp
+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_stream.hpp
@@ -19,6 +19,9 @@ namespace ocl {
class ocl_stream : public stream {
public:
const ocl_queue_type& get_cl_queue() const { return _command_queue; }
+#ifdef ENABLE_MLIR_FOR_GPU
+ void* get_native_handle() const override { return static_cast<void*>(get_cl_queue().get()); }
+#endif
ocl_stream(const ocl_engine& engine, const ExecutionConfig& config);
ocl_stream(const ocl_engine &engine, const ExecutionConfig& config, void *handle);
@@ -49,6 +52,9 @@ public:
void enqueue_barrier() override;
event::ptr create_user_event(bool set) override;
event::ptr create_base_event() override;
+#ifdef ENABLE_MLIR_FOR_GPU
+ event::ptr create_base_event(void* handle) override;
+#endif
std::unique_ptr<surfaces_lock> create_surfaces_lock(const std::vector<memory::ptr> &mem) const override;
const cl::UsmHelper& get_usm_helper() const { return _engine.get_usm_helper(); }
diff --git a/src/plugins/intel_gpu/tests/functional/CMakeLists.txt b/src/plugins/intel_gpu/tests/functional/CMakeLists.txt
index c9cb54d3439..041699ffe97 100644
--- a/src/plugins/intel_gpu/tests/functional/CMakeLists.txt
+++ b/src/plugins/intel_gpu/tests/functional/CMakeLists.txt
@@ -13,6 +13,12 @@ endif()
list(APPEND DEFINES TEST_CUSTOM_OP_CONFIG_PATH="${CMAKE_CURRENT_SOURCE_DIR}/custom_op/custom_op.xml")
+# Exclude MLIR tests if MLIR support is disabled
+set(EXCLUDED_TEST_PATHS)
+if(NOT ENABLE_MLIR_FOR_GPU)
+ list(APPEND EXCLUDED_TEST_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/mlir_op")
+endif()
+
ov_add_test_target(
NAME
${TARGET_NAME}
@@ -20,6 +26,8 @@ ov_add_test_target(
${CMAKE_CURRENT_SOURCE_DIR}
ADDITIONAL_SOURCE_DIRS
${TEST_COMMON_SOURCE_DIR}
+ EXCLUDED_SOURCE_PATHS
+ ${EXCLUDED_TEST_PATHS}
INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}
$<TARGET_PROPERTY:openvino_intel_gpu_plugin,SOURCE_DIR>/include/
diff --git a/src/plugins/intel_gpu/tests/functional/mlir_op/binary_eltwise.cpp b/src/plugins/intel_gpu/tests/functional/mlir_op/binary_eltwise.cpp
new file mode 100644
index 00000000000..c1a4c5e51dd
--- /dev/null
+++ b/src/plugins/intel_gpu/tests/functional/mlir_op/binary_eltwise.cpp
@@ -0,0 +1,178 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "common_test_utils/ov_tensor_utils.hpp"
+#include "mlir_test_env.hpp"
+#include "openvino/op/add.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/divide.hpp"
+#include "openvino/op/floor_mod.hpp"
+#include "openvino/op/maximum.hpp"
+#include "openvino/op/minimum.hpp"
+#include "openvino/op/mod.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/power.hpp"
+#include "openvino/op/result.hpp"
+#include "openvino/op/subtract.hpp"
+
+namespace {
+
+// Params: lhs shape, rhs shape, precision
+using BinaryElementwiseParams = std::tuple<ov::Shape, ov::Shape, ov::element::Type>;
+
+template <typename Op>
+class BinaryElementwiseTest : public testing::WithParamInterface<BinaryElementwiseParams>, virtual public ov::test::MlirSubgraphStaticTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<BinaryElementwiseParams>& obj) {
+ const auto& [lhs_shape, rhs_shape, precision] = obj.param;
+ std::ostringstream result;
+ result << "LHS=" << ov::test::utils::vec2str(lhs_shape) << "_";
+ result << "RHS=" << ov::test::utils::vec2str(rhs_shape) << "_";
+ result << "precision=" << precision;
+ return result.str();
+ }
+
+protected:
+ void SetUp() override {
+ targetDevice = ov::test::utils::DEVICE_GPU;
+ const auto& [lhs_shape, rhs_shape, precision] = GetParam();
+ auto lhs = std::make_shared<ov::op::v0::Parameter>(precision, lhs_shape);
+ auto rhs = std::make_shared<ov::op::v0::Parameter>(precision, rhs_shape);
+ auto op = std::make_shared<Op>(lhs, rhs);
+ auto result = std::make_shared<ov::op::v0::Result>(op);
+ function = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{lhs, rhs});
+ }
+};
+
+using AddTest = BinaryElementwiseTest<ov::op::v1::Add>;
+using SubtractTest = BinaryElementwiseTest<ov::op::v1::Subtract>;
+using MultiplyTest = BinaryElementwiseTest<ov::op::v1::Multiply>;
+using DivideTest = BinaryElementwiseTest<ov::op::v1::Divide>;
+using PowerTest = BinaryElementwiseTest<ov::op::v1::Power>;
+using MaximumTest = BinaryElementwiseTest<ov::op::v1::Maximum>;
+using MinimumTest = BinaryElementwiseTest<ov::op::v1::Minimum>;
+using FloorModTest = BinaryElementwiseTest<ov::op::v1::FloorMod>;
+using ModTest = BinaryElementwiseTest<ov::op::v1::Mod>;
+
+TEST_P(AddTest, Inference) {
+ run();
+}
+TEST_P(SubtractTest, Inference) {
+ run();
+}
+TEST_P(MultiplyTest, Inference) {
+ run();
+}
+TEST_P(DivideTest, Inference) {
+ run();
+}
+TEST_P(PowerTest, Inference) {
+ run();
+}
+TEST_P(MaximumTest, Inference) {
+ GTEST_SKIP() << "Maximum is not offloaded to MLIR yet (no BinaryEltwisePattern registered).";
+ run();
+}
+TEST_P(MinimumTest, Inference) {
+ GTEST_SKIP() << "Minimum is not offloaded to MLIR yet (no BinaryEltwisePattern registered).";
+ run();
+}
+TEST_P(FloorModTest, Inference) {
+ GTEST_SKIP() << "FloorMod is not offloaded to MLIR yet (no BinaryEltwisePattern registered).";
+ run();
+}
+TEST_P(ModTest, Inference) {
+ GTEST_SKIP() << "Mod is not offloaded to MLIR yet (no BinaryEltwisePattern registered).";
+ run();
+}
+
+// Same-shape
+const auto same_shape_params =
+ ::testing::Combine(::testing::Values(ov::Shape{1, 1024, 1536}), ::testing::Values(ov::Shape{1, 1024, 1536}), ::testing::Values(ov::element::f16));
+// Broadcast: arg0=[1, 1024, 1536], arg1=[1536]
+const auto broadcast_params =
+ ::testing::Combine(::testing::Values(ov::Shape{1, 1024, 1536}), ::testing::Values(ov::Shape{1536}), ::testing::Values(ov::element::f16));
+
+#define INSTANTIATE_TS(Name) \
+ INSTANTIATE_TEST_SUITE_P(mlir_BinaryElementwise##Name##_same_shape, Name, same_shape_params, Name::getTestCaseName); \
+ INSTANTIATE_TEST_SUITE_P(mlir_BinaryElementwise##Name##_broadcast, Name, broadcast_params, Name::getTestCaseName)
+
+INSTANTIATE_TS(AddTest);
+INSTANTIATE_TS(SubtractTest);
+INSTANTIATE_TS(MultiplyTest);
+INSTANTIATE_TS(DivideTest);
+INSTANTIATE_TS(PowerTest);
+INSTANTIATE_TS(MaximumTest);
+INSTANTIATE_TS(MinimumTest);
+INSTANTIATE_TS(FloorModTest);
+INSTANTIATE_TS(ModTest);
+
+// Params: input shape, constant shape, precision
+using BinaryElementwiseConstParams = std::tuple<ov::Shape, ov::Shape, ov::element::Type>;
+
+template <typename Op>
+class BinaryElementwiseConstTest : public testing::WithParamInterface<BinaryElementwiseConstParams>, virtual public ov::test::MlirSubgraphStaticTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<BinaryElementwiseConstParams>& obj) {
+ const auto& [input_shape, const_shape, precision] = obj.param;
+ std::ostringstream result;
+ result << "Input=" << ov::test::utils::vec2str(input_shape) << "_";
+ result << "Const=" << ov::test::utils::vec2str(const_shape) << "_";
+ result << "precision=" << precision;
+ return result.str();
+ }
+
+protected:
+ void SetUp() override {
+ targetDevice = ov::test::utils::DEVICE_GPU;
+ const auto& [input_shape, const_shape, precision] = GetParam();
+ ov::test::utils::InputGenerateData gen;
+ gen.start_from = 3;
+ gen.range = 1;
+ auto const_tensor = ov::test::utils::create_and_fill_tensor(precision, const_shape, gen);
+ auto input = std::make_shared<ov::op::v0::Parameter>(precision, input_shape);
+ auto constant = std::make_shared<ov::op::v0::Constant>(const_tensor);
+ auto op = std::make_shared<Op>(input, constant);
+ auto result = std::make_shared<ov::op::v0::Result>(op);
+ function = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{input});
+ }
+};
+
+using AddConstTest = BinaryElementwiseConstTest<ov::op::v1::Add>;
+using SubtractConstTest = BinaryElementwiseConstTest<ov::op::v1::Subtract>;
+using MultiplyConstTest = BinaryElementwiseConstTest<ov::op::v1::Multiply>;
+using DivideConstTest = BinaryElementwiseConstTest<ov::op::v1::Divide>;
+
+TEST_P(AddConstTest, Inference) {
+ run();
+}
+TEST_P(SubtractConstTest, Inference) {
+ run();
+}
+TEST_P(MultiplyConstTest, Inference) {
+ run();
+}
+TEST_P(DivideConstTest, Inference) {
+ run();
+}
+
+// Scalar constant broadcast
+const auto const_scalar_params =
+ ::testing::Combine(::testing::Values(ov::Shape{1, 1024, 1536}), ::testing::Values(ov::Shape{}), ::testing::Values(ov::element::f16));
+// 1D constant broadcast
+const auto const_broadcast_params =
+ ::testing::Combine(::testing::Values(ov::Shape{1, 1024, 1536}), ::testing::Values(ov::Shape{1536}), ::testing::Values(ov::element::f16));
+
+#undef INSTANTIATE_TS
+#define INSTANTIATE_TS(Name) \
+ INSTANTIATE_TEST_SUITE_P(mlir_BinaryElementwise##Name##_scalar, Name, const_scalar_params, Name::getTestCaseName); \
+ INSTANTIATE_TEST_SUITE_P(mlir_BinaryElementwise##Name##_broadcast, Name, const_broadcast_params, Name::getTestCaseName)
+
+INSTANTIATE_TS(AddConstTest);
+INSTANTIATE_TS(SubtractConstTest);
+INSTANTIATE_TS(MultiplyConstTest);
+INSTANTIATE_TS(DivideConstTest);
+
+} // namespace
diff --git a/src/plugins/intel_gpu/tests/functional/mlir_op/concat.cpp b/src/plugins/intel_gpu/tests/functional/mlir_op/concat.cpp
new file mode 100644
index 00000000000..65be470bd29
--- /dev/null
+++ b/src/plugins/intel_gpu/tests/functional/mlir_op/concat.cpp
@@ -0,0 +1,81 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "openvino/op/concat.hpp"
+
+#include "mlir_test_env.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/result.hpp"
+#include "openvino/op/transpose.hpp"
+
+namespace {
+
+// Params: precision
+using ConcatParams = ov::element::Type;
+
+class ConcatTest : public testing::WithParamInterface<ConcatParams>, virtual public ov::test::MlirSubgraphStaticTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<ConcatParams>& obj) {
+ std::ostringstream result;
+ result << "precision=" << obj.param;
+ return result.str();
+ }
+
+protected:
+ void SetUp() override {
+ targetDevice = ov::test::utils::DEVICE_GPU;
+ const auto precision = GetParam();
+
+ auto input0 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1, 24, 1024, 64});
+ auto input1 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1, 24, 128, 64});
+ auto concat = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{input0, input1}, 2);
+
+ auto result = std::make_shared<ov::op::v0::Result>(concat);
+ function = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{input0, input1});
+ }
+};
+
+TEST_P(ConcatTest, Inference) {
+ run();
+}
+
+INSTANTIATE_TEST_SUITE_P(mlir_Concat, ConcatTest, ::testing::Values(ov::element::f16), ConcatTest::getTestCaseName);
+
+// Params: precision
+using TransposeConcatParams = ov::element::Type;
+
+class TransposeConcatTest : public testing::WithParamInterface<TransposeConcatParams>, virtual public ov::test::MlirSubgraphStaticTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<TransposeConcatParams>& obj) {
+ std::ostringstream result;
+ result << "precision=" << obj.param;
+ return result.str();
+ }
+
+protected:
+ void SetUp() override {
+ targetDevice = ov::test::utils::DEVICE_GPU;
+ const auto precision = GetParam();
+ const std::vector<int64_t> order{0, 2, 1, 3};
+ auto order_const = ov::op::v0::Constant::create(ov::element::i64, {order.size()}, order);
+
+ auto input0 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1, 1024, 24, 64});
+ auto transpose0 = std::make_shared<ov::op::v1::Transpose>(input0, order_const);
+
+ auto input1 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1, 128, 24, 64});
+ auto transpose1 = std::make_shared<ov::op::v1::Transpose>(input1, order_const);
+
+ auto concat = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{transpose0, transpose1}, 2);
+ auto result = std::make_shared<ov::op::v0::Result>(concat);
+ function = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{input0, input1});
+ }
+};
+
+TEST_P(TransposeConcatTest, Inference) {
+ run();
+}
+
+INSTANTIATE_TEST_SUITE_P(mlir_TransposeConcat, TransposeConcatTest, ::testing::Values(ov::element::f16), TransposeConcatTest::getTestCaseName);
+
+} // namespace
diff --git a/src/plugins/intel_gpu/tests/functional/mlir_op/matmul.cpp b/src/plugins/intel_gpu/tests/functional/mlir_op/matmul.cpp
new file mode 100644
index 00000000000..4fdd5d40a06
--- /dev/null
+++ b/src/plugins/intel_gpu/tests/functional/mlir_op/matmul.cpp
@@ -0,0 +1,129 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "openvino/op/matmul.hpp"
+
+#include "common_test_utils/ov_tensor_utils.hpp"
+#include "mlir_test_env.hpp"
+#include "openvino/op/parameter.hpp"
+#include "shared_test_classes/base/ov_subgraph.hpp"
+
+namespace {
+
+using BatchMatMulParams = std::tuple<ov::Shape, // A shape
+ ov::Shape, // B shape
+ bool, // transpose A
+ bool, // transpose B
+ ov::element::Type>;
+
+class BatchMatMulTest : public testing::WithParamInterface<BatchMatMulParams>, virtual public ov::test::MlirSubgraphStaticTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<BatchMatMulParams>& obj) {
+ const auto& [a_shape, b_shape, tr_a, tr_b, prec] = obj.param;
+ std::ostringstream result;
+ result << "A=" << ov::test::utils::vec2str(a_shape) << "_";
+ result << "B=" << ov::test::utils::vec2str(b_shape) << "_";
+ result << "trA=" << tr_a << "_trB=" << tr_b << "_";
+ result << "precision=" << prec;
+ return result.str();
+ }
+
+protected:
+ void SetUp() override {
+ targetDevice = ov::test::utils::DEVICE_GPU;
+ const auto& [a_shape, b_shape, tr_a, tr_b, prec] = GetParam();
+ auto param_a = std::make_shared<ov::op::v0::Parameter>(prec, a_shape);
+ auto param_b = std::make_shared<ov::op::v0::Parameter>(prec, b_shape);
+ auto matmul = std::make_shared<ov::op::v0::MatMul>(param_a, param_b, tr_a, tr_b);
+ auto result = std::make_shared<ov::op::v0::Result>(matmul);
+ function = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param_a, param_b}, "BatchMatMul");
+ abs_threshold = 100.F;
+ }
+};
+
+TEST_P(BatchMatMulTest, Inference) {
+ run();
+}
+
+INSTANTIATE_TEST_SUITE_P(mlir_BatchMatMul,
+ BatchMatMulTest,
+ ::testing::Combine(::testing::Values(ov::Shape{1, 1024, 1536}),
+ ::testing::Values(ov::Shape{1536, 1536}),
+ ::testing::Values(false),
+ ::testing::Values(true),
+ ::testing::Values(ov::element::f16)),
+ BatchMatMulTest::getTestCaseName);
+
+// -------- Dynamic-shape MatMul (non-batched, dynamic K) --------
+
+using DynamicMatMulParams = std::tuple<ov::test::InputShape, // A shape (M, K)
+ ov::test::InputShape, // B shape (K, N)
+ ov::element::Type>;
+
+class DynamicMatMulTest : public testing::WithParamInterface<DynamicMatMulParams>, virtual public ov::test::MlirSubgraphTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<DynamicMatMulParams>& obj) {
+ const auto& [a_shape, b_shape, prec] = obj.param;
+ std::ostringstream result;
+ result << "A_IS=" << ov::test::utils::partialShape2str({a_shape.first}) << "_";
+ result << "A_TS=";
+ for (const auto& s : a_shape.second) {
+ result << ov::test::utils::vec2str(s) << "_";
+ }
+ result << "B_IS=" << ov::test::utils::partialShape2str({b_shape.first}) << "_";
+ result << "B_TS=";
+ for (const auto& s : b_shape.second) {
+ result << ov::test::utils::vec2str(s) << "_";
+ }
+ result << "precision=" << prec;
+ return result.str();
+ }
+
+protected:
+ void SetUp() override {
+ targetDevice = ov::test::utils::DEVICE_GPU;
+ const auto& [a_shape, b_shape, prec] = GetParam();
+ init_input_shapes({a_shape, b_shape});
+ auto param_a = std::make_shared<ov::op::v0::Parameter>(prec, inputDynamicShapes[0]);
+ auto param_b = std::make_shared<ov::op::v0::Parameter>(prec, inputDynamicShapes[1]);
+ auto matmul = std::make_shared<ov::op::v0::MatMul>(param_a, param_b, false, false);
+ auto result = std::make_shared<ov::op::v0::Result>(matmul);
+ function = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param_a, param_b}, "DynamicMatMul");
+ abs_threshold = 0.05F;
+ rel_threshold = 0.05F;
+ }
+
+ void generate_inputs(const std::vector<ov::Shape>& target_input_shapes) override {
+ const auto& model_inputs = function->inputs();
+ inputs.clear();
+ ov::test::utils::InputGenerateData gen(-0.5, 1, 4);
+ for (size_t i = 0; i < model_inputs.size(); ++i) {
+ auto tensor = ov::test::utils::create_and_fill_tensor(model_inputs[i].get_element_type(), target_input_shapes[i], gen);
+ inputs.insert({model_inputs[i].get_node_shared_ptr(), tensor});
+ }
+ }
+};
+
+TEST_P(DynamicMatMulTest, Inference) {
+ run();
+}
+
+// A: (M=1024, K=?) x B: (K=?, N=1536), K varies between iterations.
+INSTANTIATE_TEST_SUITE_P(mlir_DynamicMatMul_dynamicK,
+ DynamicMatMulTest,
+ ::testing::Combine(::testing::Values(ov::test::InputShape{ov::PartialShape{1024, -1}, {ov::Shape{1024, 768}, ov::Shape{1024, 1536}}}),
+ ::testing::Values(ov::test::InputShape{ov::PartialShape{-1, 1536}, {ov::Shape{768, 1536}, ov::Shape{1536, 1536}}}),
+ ::testing::Values(ov::element::f16)),
+ DynamicMatMulTest::getTestCaseName);
+
+// A: (M=?, K=?) x B: (K=?, N=?), all dims dynamic, all vary between iterations.
+INSTANTIATE_TEST_SUITE_P(
+ mlir_DynamicMatMul_allDynamic,
+ DynamicMatMulTest,
+ ::testing::Combine(::testing::Values(ov::test::InputShape{ov::PartialShape{-1, -1}, {ov::Shape{512, 768}, ov::Shape{1024, 1536}, ov::Shape{128, 256}}}),
+ ::testing::Values(ov::test::InputShape{ov::PartialShape{-1, -1}, {ov::Shape{768, 384}, ov::Shape{1536, 1024}, ov::Shape{256, 512}}}),
+ ::testing::Values(ov::element::f16)),
+ DynamicMatMulTest::getTestCaseName);
+
+} // namespace
diff --git a/src/plugins/intel_gpu/tests/functional/mlir_op/matmul_rms_norm_concat.cpp b/src/plugins/intel_gpu/tests/functional/mlir_op/matmul_rms_norm_concat.cpp
new file mode 100644
index 00000000000..1a7cca9ef66
--- /dev/null
+++ b/src/plugins/intel_gpu/tests/functional/mlir_op/matmul_rms_norm_concat.cpp
@@ -0,0 +1,189 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "mlir_test_env.hpp"
+#include "openvino/op/add.hpp"
+#include "openvino/op/concat.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/divide.hpp"
+#include "openvino/op/matmul.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/power.hpp"
+#include "openvino/op/reduce_mean.hpp"
+#include "openvino/op/reshape.hpp"
+#include "openvino/op/result.hpp"
+#include "openvino/op/sqrt.hpp"
+#include "openvino/op/transpose.hpp"
+#include "shared_test_classes/base/benchmark.hpp"
+
+namespace {
+
+// A(1xSEQx1536xf16)
+// ▼
+// MatMul(transpose B) → Add(const) → Reshape(1xSEQx24x64) → Transpose(1x24xSEQx64)
+// ▲ ▼ ▼
+// B(1536x1536xf16) Power(B=const) │
+// ▼ │
+// ReduceMean(axis=3) │
+// ▼ │
+// Add(B=const) │
+// ▼ │
+// Sqrt │
+// ▼ │
+// Divide(B=const) │
+// ▼ ▼
+// Multiply(Divide × Transpose)
+// ▼
+// Multiply(× const)
+
+// Builds the MatMul+RmsNorm subgraph for a given A shape and shared B parameter.
+// Returns the output node (Multiply × scale).
+std::shared_ptr<ov::Node> build_matmul_rmsnorm(ov::element::Type prec,
+ const std::shared_ptr<ov::op::v0::Parameter>& param_a,
+ const std::shared_ptr<ov::op::v0::Parameter>& param_b) {
+ const auto& a_shape = param_a->get_shape();
+ const auto hidden = static_cast<int64_t>(a_shape.back());
+ const auto seq = static_cast<int64_t>(a_shape[1]);
+ const int64_t heads = 24;
+ const int64_t head_size = hidden / heads;
+
+ auto matmul = std::make_shared<ov::op::v0::MatMul>(param_a, param_b, false, true);
+
+ auto bias = ov::op::v0::Constant::create(prec, {static_cast<size_t>(hidden)}, std::vector<float>(hidden, 0.1F));
+ auto add1 = std::make_shared<ov::op::v1::Add>(matmul, bias);
+
+ auto shape_val = ov::op::v0::Constant::create(ov::element::i64, {4}, std::vector<int64_t>{1, seq, heads, head_size});
+ auto reshape = std::make_shared<ov::op::v1::Reshape>(add1, shape_val, false);
+
+ auto order = ov::op::v0::Constant::create(ov::element::i64, {4}, std::vector<int64_t>{0, 2, 1, 3});
+ auto transpose = std::make_shared<ov::op::v1::Transpose>(reshape, order);
+
+ auto exp2 = ov::op::v0::Constant::create(prec, {1}, std::vector<float>{2.F});
+ auto power = std::make_shared<ov::op::v1::Power>(transpose, exp2);
+
+ auto axes = ov::op::v0::Constant::create(ov::element::i64, {1}, std::vector<int64_t>{3});
+ auto reduce_mean = std::make_shared<ov::op::v1::ReduceMean>(power, axes, true);
+
+ auto eps = ov::op::v0::Constant::create(prec, {1}, std::vector<float>{1e-5F});
+ auto add2 = std::make_shared<ov::op::v1::Add>(reduce_mean, eps);
+
+ auto sqrt_node = std::make_shared<ov::op::v0::Sqrt>(add2);
+
+ auto one = ov::op::v0::Constant::create(prec, {1}, std::vector<float>{1.F});
+ auto divide = std::make_shared<ov::op::v1::Divide>(one, sqrt_node);
+
+ auto mul1 = std::make_shared<ov::op::v1::Multiply>(divide, transpose);
+
+ auto scale = ov::op::v0::Constant::create(prec, {1}, std::vector<float>{2.F});
+ return std::make_shared<ov::op::v1::Multiply>(mul1, scale);
+}
+
+// ── MatMulRmsnormTest ─────────────────────────────────────────────────────────
+
+using MatMulRmsnormParams = std::tuple<ov::Shape, // A shape
+ ov::Shape>; // B shape
+
+class MatMulRmsnormTest : public testing::WithParamInterface<MatMulRmsnormParams>, virtual public ov::test::MlirSubgraphStaticTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<MatMulRmsnormParams>& obj) {
+ const auto& [a_shape, b_shape] = obj.param;
+ std::ostringstream result;
+ result << "A=" << ov::test::utils::vec2str(a_shape) << "_";
+ result << "B=" << ov::test::utils::vec2str(b_shape);
+ return result.str();
+ }
+
+protected:
+ void SetUp() override {
+ targetDevice = ov::test::utils::DEVICE_GPU;
+ const auto prec = ov::element::f16;
+ const auto& [a_shape, b_shape] = GetParam();
+
+ auto param_a = std::make_shared<ov::op::v0::Parameter>(prec, a_shape);
+ auto param_b = std::make_shared<ov::op::v0::Parameter>(prec, b_shape);
+ auto out = build_matmul_rmsnorm(prec, param_a, param_b);
+ auto result = std::make_shared<ov::op::v0::Result>(out);
+ function = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param_a, param_b}, "MatMulRmsnorm");
+ }
+};
+
+class MatMulRmsnormBenchmark : public ov::test::BenchmarkLayerTest<MatMulRmsnormTest> {};
+
+TEST_P(MatMulRmsnormTest, Inference) {
+ run();
+}
+TEST_P(MatMulRmsnormBenchmark, Inference) {
+ if (ov::test::is_mlir_enabled()) {
+ run_benchmark("MLIROp");
+ } else {
+ run_benchmark({"FullyConnected", "Add", "Reshape", "Transpose", "RMS"});
+ }
+}
+
+const auto rmsnormParams = ::testing::Combine(::testing::Values(ov::Shape{1, 1024, 1536}), ::testing::Values(ov::Shape{1536, 1536}));
+INSTANTIATE_TEST_SUITE_P(mlir_MatMulRmsnormTest, MatMulRmsnormTest, rmsnormParams, MatMulRmsnormTest::getTestCaseName);
+INSTANTIATE_TEST_SUITE_P(bench_MatMulRmsnormBenchmark, MatMulRmsnormBenchmark, rmsnormParams, MatMulRmsnormTest::getTestCaseName);
+
+// ── MatMulRmsnormConcatTest ───────────────────────────────────────────────────
+//
+// Runs two MatMul+RmsNorm graphs (different A sequence lengths) sharing B,
+// then concatenates their outputs along the sequence axis (axis=2).
+//
+// branch0: A0(1xSEQ0x1536) ─┐
+// branch1: A1(1xSEQ1x1536) ─┤ → Concat(axis=2)
+// └─ shared B(1536x1536)
+
+using MatMulRmsnormConcatParams = std::tuple<ov::Shape, // A0 shape
+ ov::Shape, // A1 shape
+ ov::Shape>; // B shape
+
+class MatMulRmsnormConcatTest : public testing::WithParamInterface<MatMulRmsnormConcatParams>, virtual public ov::test::MlirSubgraphStaticTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<MatMulRmsnormConcatParams>& obj) {
+ const auto& [a0_shape, a1_shape, b_shape] = obj.param;
+ std::ostringstream result;
+ result << "A0=" << ov::test::utils::vec2str(a0_shape) << "_";
+ result << "A1=" << ov::test::utils::vec2str(a1_shape) << "_";
+ result << "B=" << ov::test::utils::vec2str(b_shape);
+ return result.str();
+ }
+
+protected:
+ void SetUp() override {
+ targetDevice = ov::test::utils::DEVICE_GPU;
+ const auto prec = ov::element::f16;
+ const auto& [a0_shape, a1_shape, b_shape] = GetParam();
+
+ auto param_a0 = std::make_shared<ov::op::v0::Parameter>(prec, a0_shape);
+ auto param_a1 = std::make_shared<ov::op::v0::Parameter>(prec, a1_shape);
+ auto param_b = std::make_shared<ov::op::v0::Parameter>(prec, b_shape);
+
+ auto out0 = build_matmul_rmsnorm(prec, param_a0, param_b);
+ auto out1 = build_matmul_rmsnorm(prec, param_a1, param_b);
+
+ auto concat = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{out0, out1}, 2);
+ auto result = std::make_shared<ov::op::v0::Result>(concat);
+ function = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param_a0, param_a1, param_b}, "MatMulRmsnormConcat");
+ }
+};
+
+class MatMulRmsnormConcatBenchmark : public ov::test::BenchmarkLayerTest<MatMulRmsnormConcatTest> {};
+
+TEST_P(MatMulRmsnormConcatTest, Inference) {
+ run();
+}
+TEST_P(MatMulRmsnormConcatBenchmark, Inference) {
+ if (ov::test::is_mlir_enabled()) {
+ run_benchmark("MLIROp");
+ } else {
+ run_benchmark({"FullyConnected", "Add", "Reshape", "Transpose", "RMS", "Concat"});
+ }
+}
+
+const auto concatParams =
+ ::testing::Combine(::testing::Values(ov::Shape{1, 128, 1536}), ::testing::Values(ov::Shape{1, 1024, 1536}), ::testing::Values(ov::Shape{1536, 1536}));
+INSTANTIATE_TEST_SUITE_P(mlir_MatMulRmsnormConcatTest, MatMulRmsnormConcatTest, concatParams, MatMulRmsnormConcatTest::getTestCaseName);
+INSTANTIATE_TEST_SUITE_P(bench_MatMulRmsnormConcatBenchmark, MatMulRmsnormConcatBenchmark, concatParams, MatMulRmsnormConcatTest::getTestCaseName);
+} // namespace
diff --git a/src/plugins/intel_gpu/tests/functional/mlir_op/mlir_test_env.hpp b/src/plugins/intel_gpu/tests/functional/mlir_op/mlir_test_env.hpp
new file mode 100644
index 00000000000..47533df6554
--- /dev/null
+++ b/src/plugins/intel_gpu/tests/functional/mlir_op/mlir_test_env.hpp
@@ -0,0 +1,102 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <gtest/gtest.h>
+
+#include <cstdlib>
+
+#include "openvino/core/model.hpp"
+#include "openvino/runtime/compiled_model.hpp"
+#include "openvino/runtime/exec_model_info.hpp"
+#include "openvino/util/env_util.hpp"
+#include "shared_test_classes/base/ov_subgraph.hpp"
+
+namespace ov::test {
+
+// RAII helper for MLIR op tests. Sets 'OV_GPU_MLIR_PATTERNS' to "*" (match-all to mlir) for the
+// lifetime of the test-class object. This is the env form of ov::intel_gpu::mlir_patterns; the
+// environment is the only way to set it, DEBUG_GLOBAL options are not accepted from a config map.
+struct MlirMatchAllEnv {
+ MlirMatchAllEnv() {
+ // Respect an explicitly provided value: only inject "match all" when the
+ // variable is not already set, and only then restore (unset) it later.
+ if (std::getenv("OV_GPU_MLIR_PATTERNS") == nullptr) {
+ m_owned = true;
+ setenv("OV_GPU_MLIR_PATTERNS", "*", /*overwrite=*/1);
+ }
+ }
+
+ ~MlirMatchAllEnv() {
+ if (m_owned) {
+ unsetenv("OV_GPU_MLIR_PATTERNS");
+ }
+ }
+
+ MlirMatchAllEnv(const MlirMatchAllEnv&) = delete;
+ MlirMatchAllEnv& operator=(const MlirMatchAllEnv&) = delete;
+
+private:
+ bool m_owned = false;
+};
+
+inline bool is_mlir_enabled() {
+ return ov::util::getenv_bool("OV_GPU_ENABLE_MLIR");
+}
+
+// Returns true if the compiled model's runtime graph contains at least one MLIROp.
+inline bool has_mlir_op(const ov::CompiledModel& compiled) {
+ const auto exec_model = compiled.get_runtime_model();
+ if (!exec_model) {
+ return false;
+ }
+ for (const auto& node : exec_model->get_ordered_ops()) {
+ const auto& rt_info = node->get_rt_info();
+ const auto it = rt_info.find(ov::exec_model_info::LAYER_TYPE);
+ if (it == rt_info.end()) {
+ continue;
+ }
+ const auto layer_type = it->second.as<std::string>();
+ if (layer_type == "mlir_primitive" || layer_type == "MLIROp") {
+ return true;
+ }
+ }
+ return false;
+}
+
+// Common base for all MLIR op tests.
+//
+// - Sets OV_GPU_MLIR_PATTERNS="*" for the test lifetime (match-all), see MlirMatchAllEnv.
+// - After run(), verifies that the MLIR path was actually involved: when OV_GPU_ENABLE_MLIR is on,
+// at least one MLIROp must appear in the runtime graph.
+template <typename Base>
+class MlirTestFixture : public Base {
+protected:
+ void run() override {
+ Base::run();
+ if (m_check_mlir_execution) {
+ check_mlir_execution();
+ }
+ }
+
+ virtual void check_mlir_execution() {
+ if (!is_mlir_enabled()) {
+ GTEST_LOG_(WARNING) << "Skipping MLIROp presence check: 'OV_GPU_ENABLE_MLIR' is not set. "
+ << "The model was compiled without the MLIR path.";
+ return;
+ }
+ EXPECT_TRUE(ov::test::has_mlir_op(this->compiledModel)) << "Expected at least one MLIROp in the execution graph, but none was found.";
+ }
+
+ bool m_check_mlir_execution = true;
+
+private:
+ MlirMatchAllEnv m_match_all_env;
+};
+
+using MlirSubgraphTest = MlirTestFixture<ov::test::SubgraphBaseTest>;
+using MlirSubgraphStaticTest = MlirTestFixture<ov::test::SubgraphBaseStaticTest>;
+
+} // namespace ov::test
diff --git a/src/plugins/intel_gpu/tests/functional/mlir_op/reduction.cpp b/src/plugins/intel_gpu/tests/functional/mlir_op/reduction.cpp
new file mode 100644
index 00000000000..74fbda1ea3b
--- /dev/null
+++ b/src/plugins/intel_gpu/tests/functional/mlir_op/reduction.cpp
@@ -0,0 +1,80 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "mlir_test_env.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/reduce_max.hpp"
+#include "openvino/op/reduce_mean.hpp"
+#include "openvino/op/reduce_min.hpp"
+#include "openvino/op/reduce_prod.hpp"
+#include "openvino/op/reduce_sum.hpp"
+
+namespace {
+using ReduceParams = std::tuple<ov::Shape, // Input shape
+ ov::element::Type, // Input precision
+ std::vector<int64_t>, // Reduce axes
+ bool>; // Keep dims
+
+template <typename ReduceOp>
+class ReduceTest : public testing::WithParamInterface<ReduceParams>, virtual public ov::test::MlirSubgraphStaticTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<ReduceParams>& obj) {
+ const auto& [input_shape, precision, axes, keep_dims] = obj.param;
+ std::ostringstream result;
+ result << "IS=" << ov::test::utils::vec2str(input_shape) << "_";
+ result << "axes=" << ov::test::utils::vec2str(axes) << "_";
+ result << "keep_dims=" << keep_dims << "_";
+ result << "precision=" << precision;
+ return result.str();
+ }
+
+protected:
+ void SetUp() override {
+ targetDevice = ov::test::utils::DEVICE_GPU;
+ const auto& [input_shape, precision, axes, keep_dims] = GetParam();
+ auto input = std::make_shared<ov::op::v0::Parameter>(precision, input_shape);
+ auto axes_node = ov::op::v0::Constant::create(ov::element::i64, {axes.size()}, axes);
+ auto reduce = std::make_shared<ReduceOp>(input, axes_node, keep_dims);
+ auto result = std::make_shared<ov::op::v0::Result>(reduce);
+ function = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{input}, "Reduce");
+ }
+};
+
+using ReduceMeanTest = ReduceTest<ov::op::v1::ReduceMean>;
+using ReduceMaxTest = ReduceTest<ov::op::v1::ReduceMax>;
+using ReduceMinTest = ReduceTest<ov::op::v1::ReduceMin>;
+using ReduceProdTest = ReduceTest<ov::op::v1::ReduceProd>;
+using ReduceSumTest = ReduceTest<ov::op::v1::ReduceSum>;
+
+TEST_P(ReduceMeanTest, Inference) {
+ run();
+}
+TEST_P(ReduceMaxTest, Inference) {
+ run();
+}
+TEST_P(ReduceMinTest, Inference) {
+ run();
+}
+TEST_P(ReduceProdTest, Inference) {
+ run();
+}
+TEST_P(ReduceSumTest, Inference) {
+ run();
+}
+
+const auto reduce_test_params = ::testing::Combine(::testing::Values(ov::Shape{1, 24, 1024, 64}),
+ ::testing::Values(ov::element::f32),
+ ::testing::Values(std::vector<int64_t>{3}),
+ ::testing::Values(true));
+// ::testing::Values(true, false));
+
+#define INSTANTIATE_TS(Name) INSTANTIATE_TEST_SUITE_P(mlir_Reduce##Name##Test, Reduce##Name##Test, reduce_test_params, Reduce##Name##Test::getTestCaseName)
+INSTANTIATE_TS(Mean);
+INSTANTIATE_TS(Max);
+INSTANTIATE_TS(Min);
+INSTANTIATE_TS(Prod);
+INSTANTIATE_TS(Sum);
+
+} // namespace
diff --git a/src/plugins/intel_gpu/tests/functional/mlir_op/rms.cpp b/src/plugins/intel_gpu/tests/functional/mlir_op/rms.cpp
new file mode 100644
index 00000000000..f2a785f64eb
--- /dev/null
+++ b/src/plugins/intel_gpu/tests/functional/mlir_op/rms.cpp
@@ -0,0 +1,64 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "ov_ops/rms.hpp"
+
+#include "mlir_test_env.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/result.hpp"
+
+namespace {
+
+using RMSParams = std::tuple<ov::Shape, // input shape
+ ov::element::Type, // precision
+ bool>; // with gamma
+
+class RMSTest : public testing::WithParamInterface<RMSParams>, virtual public ov::test::MlirSubgraphStaticTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<RMSParams>& obj) {
+ const auto& [shape, precision, with_gamma] = obj.param;
+ std::ostringstream result;
+ result << "Input=" << ov::test::utils::vec2str(shape) << "_";
+ result << "precision=" << precision << "_";
+ result << "gamma=" << with_gamma;
+ return result.str();
+ }
+
+protected:
+ void SetUp() override {
+ targetDevice = ov::test::utils::DEVICE_GPU;
+ const auto& [shape, precision, with_gamma] = GetParam();
+ abs_threshold = 0.01;
+
+ auto input = std::make_shared<ov::op::v0::Parameter>(precision, shape);
+ std::shared_ptr<ov::Node> rms;
+ if (with_gamma) {
+ const size_t last = shape.back();
+ std::vector<float> gamma_val(last);
+ for (size_t i = 0; i < last; ++i) {
+ gamma_val[i] = 0.5F + 0.01F * static_cast<float>(i % 10);
+ }
+ auto gamma = ov::op::v0::Constant::create(precision, {last}, gamma_val);
+ rms = std::make_shared<ov::op::internal::RMS>(input, gamma, 1e-5, precision);
+ } else {
+ rms = std::make_shared<ov::op::internal::RMS>(input, 1e-5, precision);
+ }
+ auto result = std::make_shared<ov::op::v0::Result>(rms);
+ function = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{input}, "RMS");
+ }
+};
+
+TEST_P(RMSTest, Inference) {
+ run();
+}
+
+INSTANTIATE_TEST_SUITE_P(mlir_RMS,
+ RMSTest,
+ ::testing::Combine(::testing::Values(ov::Shape{1, 128, 64}, ov::Shape{1, 24, 128, 64}),
+ ::testing::Values(ov::element::f16, ov::element::f32),
+ ::testing::Bool()),
+ RMSTest::getTestCaseName);
+
+} // namespace
diff --git a/src/plugins/intel_gpu/tests/functional/mlir_op/sdpa.cpp b/src/plugins/intel_gpu/tests/functional/mlir_op/sdpa.cpp
new file mode 100644
index 00000000000..665d1c66ab0
--- /dev/null
+++ b/src/plugins/intel_gpu/tests/functional/mlir_op/sdpa.cpp
@@ -0,0 +1,412 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "common_test_utils/ov_tensor_utils.hpp"
+#include "mlir_test_env.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/result.hpp"
+#include "openvino/op/transpose.hpp"
+#include "openvino/opsets/opset13_decl.hpp"
+#include "openvino/pass/manager.hpp"
+#include "openvino/runtime/exec_model_info.hpp"
+#include "openvino/runtime/intel_gpu/properties.hpp"
+#include "shared_test_classes/base/ov_subgraph.hpp"
+#include "transformations/op_conversions/scaled_dot_product_attention_decomposition.hpp"
+
+namespace {
+using ov::test::InputShape;
+
+using ScaledAttnGPUTestParams = std::tuple<ov::element::Type, std::vector<InputShape>, bool, bool, bool, bool, bool, std::vector<std::vector<int64_t>>, bool>;
+
+class ScaledAttnLayerGPUMlirTest : public testing::WithParamInterface<ScaledAttnGPUTestParams>, virtual public ov::test::MlirSubgraphTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<ScaledAttnGPUTestParams>& obj);
+
+protected:
+ void SetUp() override;
+ void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override;
+ static void transpose_prepare(std::vector<InputShape>& shapes, const std::vector<std::vector<int64_t>>& input_transpose);
+ void check_mlir_execution() override;
+ bool is_causal = false;
+ bool has_attn = false;
+ bool is_attn_const = false;
+ bool has_scale = false;
+ bool is_scale_const = false;
+ bool has_sink = false;
+};
+
+std::string ScaledAttnLayerGPUMlirTest::getTestCaseName(const testing::TestParamInfo<ScaledAttnGPUTestParams>& obj) {
+ bool transpose_enable = false;
+ const auto& [inType, inputShapes, is_causal, has_attn, is_attn_const, has_scale, is_scale_const, input_transpose, has_sink] = obj.param;
+
+ transpose_enable = (!input_transpose.empty());
+ std::ostringstream result;
+ result << "netPRC=" << inType << "_";
+ result << "IS=";
+ for (const auto& inputShape : inputShapes) {
+ result << ov::test::utils::partialShape2str({inputShape.first}) << "_";
+ }
+ result << "TS=";
+ for (const auto& shapes : inputShapes) {
+ for (const auto& shape : shapes.second) {
+ result << ov::test::utils::vec2str(shape);
+ result << "_";
+ }
+ }
+ result << "is_causal=" << is_causal << "_";
+ result << "has_attn=" << has_attn << "_";
+ result << "is_attn_const=" << is_attn_const << "_";
+ result << "has_scale=" << has_scale << "_";
+ result << "is_scale_const=" << is_scale_const << "_";
+ result << "with_transpose" << transpose_enable << "_";
+ result << "has_sink=" << has_sink << "_";
+
+ return result.str();
+}
+
+void ScaledAttnLayerGPUMlirTest::SetUp() {
+ targetDevice = ov::test::utils::DEVICE_GPU;
+ configuration[ov::intel_gpu::hint::enable_sdpa_optimization.name()] = false;
+
+ const auto& [inType, _inputShapes, _is_causal, _has_attn, _is_attn_const, _has_scale, _is_scale_const, input_transpose, _has_sink] =
+ ScaledAttnLayerGPUMlirTest::GetParam();
+ is_causal = _is_causal;
+ has_attn = _has_attn;
+ is_attn_const = _is_attn_const;
+ has_scale = _has_scale;
+ is_scale_const = _is_scale_const;
+ auto inputShapes = _inputShapes;
+ has_sink = _has_sink;
+
+ transpose_prepare(inputShapes, input_transpose);
+ init_input_shapes(inputShapes);
+
+ ov::ParameterVector inputParams;
+ // q, k, v
+ inputParams.push_back(std::make_shared<ov::op::v0::Parameter>(inType, inputDynamicShapes[0]));
+ inputParams.push_back(std::make_shared<ov::op::v0::Parameter>(inType, inputDynamicShapes[1]));
+ inputParams.push_back(std::make_shared<ov::op::v0::Parameter>(inType, inputDynamicShapes[2]));
+ inputParams[0]->set_friendly_name("q");
+ inputParams[1]->set_friendly_name("k");
+ inputParams[2]->set_friendly_name("v");
+ if (!has_attn && has_scale) {
+ inputParams.push_back(std::make_shared<ov::op::v0::Parameter>(inType, ov::PartialShape{}));
+ inputParams.back()->set_friendly_name("attention_mask");
+ if (!is_scale_const) {
+ inputParams.push_back(std::make_shared<ov::op::v0::Parameter>(inType, ov::PartialShape{1}));
+ inputParams.back()->set_friendly_name("scale");
+ }
+ } else {
+ if (has_attn && !is_attn_const) {
+ inputParams.push_back(std::make_shared<ov::op::v0::Parameter>(inType, inputDynamicShapes[3]));
+ inputParams.back()->set_friendly_name("attention_mask");
+ if (has_scale && !is_scale_const) {
+ inputParams.push_back(std::make_shared<ov::op::v0::Parameter>(inType, ov::PartialShape{1}));
+ inputParams.back()->set_friendly_name("scale");
+ }
+ }
+ }
+
+ ov::OutputVector inputParams_transpose;
+ for (const auto& inputParam : inputParams) {
+ inputParams_transpose.emplace_back(inputParam);
+ }
+ if (has_attn && is_attn_const) {
+ auto attn_const = std::make_shared<ov::op::v0::Constant>(inType, ov::Shape{}, 0.0F);
+ attn_const->set_friendly_name("attention_mask");
+ inputParams_transpose.emplace_back(attn_const);
+ if (has_scale && !is_scale_const) {
+ auto scale_param = std::make_shared<ov::op::v0::Parameter>(inType, ov::PartialShape{1});
+ scale_param->set_friendly_name("scale");
+ inputParams.push_back(scale_param);
+ inputParams_transpose.emplace_back(scale_param);
+ }
+ } else if (has_sink && !has_attn) {
+ // Add default mask when sink token exists and attention mask is not present
+ auto attn_const = std::make_shared<ov::op::v0::Constant>(inType, ov::Shape{}, 0.0F);
+ attn_const->set_friendly_name("attention_mask");
+ inputParams_transpose.emplace_back(attn_const);
+ }
+ if (has_scale && is_scale_const) {
+ auto scale_const = std::make_shared<ov::op::v0::Constant>(inType, ov::Shape({1}), 0.35F);
+ scale_const->set_friendly_name("scale");
+ inputParams_transpose.emplace_back(scale_const);
+ } else if (has_sink && !has_scale) {
+ // Add default scale when sink token exists and scale is not present
+ auto scale_const = std::make_shared<ov::op::v0::Constant>(inType, ov::Shape({1}), 0.35F);
+ scale_const->set_friendly_name("scale");
+ inputParams_transpose.emplace_back(scale_const);
+ }
+
+ if (!input_transpose.empty()) {
+ auto rank = input_transpose[0].size();
+ // deal with transpose.
+ auto tranpose_a_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{rank}, input_transpose[0]);
+ auto tranpose_a = std::make_shared<ov::op::v1::Transpose>(inputParams[0], tranpose_a_const);
+ tranpose_a->set_friendly_name("tranpose_a");
+ inputParams_transpose[0] = tranpose_a;
+
+ auto tranpose_b_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{rank}, input_transpose[1]);
+ auto tranpose_b = std::make_shared<ov::op::v1::Transpose>(inputParams[1], tranpose_b_const);
+ tranpose_b->set_friendly_name("tranpose_b");
+ inputParams_transpose[1] = tranpose_b;
+
+ auto tranpose_c_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{rank}, input_transpose[2]);
+ auto tranpose_c = std::make_shared<ov::op::v1::Transpose>(inputParams[2], tranpose_c_const);
+ tranpose_c->set_friendly_name("tranpose_c");
+ inputParams_transpose[2] = tranpose_c;
+ }
+
+ ov::OutputVector inputs;
+ for (const auto& i : inputParams_transpose) {
+ inputs.push_back(i);
+ }
+ if (has_sink) {
+ size_t num_heads = inputDynamicShapes[0][1].get_length();
+ ov::test::utils::InputGenerateData data(0, 5, 100);
+ auto sink_tensor = ov::test::utils::create_and_fill_tensor(ov::element::f16, ov::Shape{1, num_heads, 1, 1}, data);
+ auto sink_const = std::make_shared<ov::op::v0::Constant>(sink_tensor);
+ sink_const->set_friendly_name("sink");
+ inputs.emplace_back(sink_const);
+ }
+ auto sdp = std::make_shared<ov::opset13::ScaledDotProductAttention>(inputs, is_causal);
+ sdp->set_friendly_name("sdpa");
+
+ auto output = std::make_shared<ov::op::v0::Result>(sdp->output(0));
+
+ function = std::make_shared<ov::Model>(ov::OutputVector{output}, inputParams, "sdpa_model");
+
+ functionRefs = function->clone();
+
+ // Set friendly name on the SDPA node in the reference model
+ for (const auto& node : functionRefs->get_ops()) {
+ if (ov::as_type_ptr<ov::opset13::ScaledDotProductAttention>(node)) {
+ node->set_friendly_name("decompose_me_sdpa");
+ break;
+ }
+ }
+
+ ov::pass::Manager manager;
+
+ // Decompose ScaledDotProductAttention
+ manager.register_pass<ov::pass::ScaledDotProductAttentionDecomposition>();
+ manager.run_passes(functionRefs);
+
+ auto it = std::find_if(inputShapes[1].second.begin(), inputShapes[1].second.end(), [&](const ov::Shape& shape) {
+ return shape[0] >= 128 || shape[2] >= 384 || shape[3] >= 128;
+ });
+
+ bool has_diff_head_size = inputShapes[1].first.begin()[3] != inputShapes[2].first.begin()[3];
+
+ bool has_long_seq = it != inputShapes[1].second.end();
+
+ if (inType == ov::element::f16) {
+ if (has_sink || (has_diff_head_size && !has_scale)) {
+ abs_threshold = 0.1;
+ rel_threshold = 0.1;
+ } else if (has_long_seq) {
+ abs_threshold = 0.025;
+ rel_threshold = 0.025;
+ } else {
+ abs_threshold = 0.005;
+ rel_threshold = 0.005;
+ }
+ }
+}
+
+void ScaledAttnLayerGPUMlirTest::transpose_prepare(std::vector<InputShape>& shapes, const std::vector<std::vector<int64_t>>& input_transpose) {
+ auto transpose_pshape = [](InputShape& pshapes, const std::vector<int64_t>& order) {
+ auto transposed_pshape = ov::PartialShape::dynamic(pshapes.first.rank());
+ std::vector<ov::Shape> transposed_cshapes(pshapes.second);
+ auto& pshape = pshapes.first;
+ auto& cshape = pshapes.second;
+ for (size_t i = 0; i < order.size(); i++) {
+ transposed_pshape[i] = pshape[order[i]];
+ for (size_t j = 0; j < cshape.size(); j++) {
+ transposed_cshapes[j][i] = cshape[j][order[i]];
+ }
+ }
+
+ for (size_t i = 0; i < order.size(); i++) {
+ pshape[i] = transposed_pshape[i];
+ for (size_t j = 0; j < cshape.size(); j++) {
+ cshape[j][i] = transposed_cshapes[j][i];
+ }
+ }
+ };
+
+ if (shapes.empty()) {
+ return;
+ }
+
+ if (input_transpose.empty()) {
+ return;
+ }
+
+ for (size_t i = 0; i < input_transpose.size(); i++) {
+ transpose_pshape(shapes[i], input_transpose[i]);
+ }
+}
+
+void ScaledAttnLayerGPUMlirTest::generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) {
+ const auto& model_inputs = function->inputs();
+ inputs.clear();
+ std::vector<ov::Shape> shapes(3);
+ {
+ for (int i = 0; i < 3; ++i) {
+ shapes[i] = targetInputStaticShapes[i];
+ ov::test::utils::InputGenerateData data(-0.5, 1, 4);
+ ov::Tensor data_tensor = ov::test::utils::create_and_fill_tensor(ov::element::f16, shapes[i], data);
+ inputs.insert({model_inputs[i].get_node_shared_ptr(), data_tensor});
+ }
+ }
+ ov::test::utils::InputGenerateData attn_data(-1.0F, 2, 1);
+ ov::test::utils::InputGenerateData scale_data(0.1F, 1, 10);
+ if (!has_attn && has_scale) {
+ shapes.emplace_back();
+ ov::Tensor attn_tensor = ov::test::utils::create_and_fill_tensor(ov::element::f16, shapes[3], attn_data);
+ inputs.insert({model_inputs[3].get_node_shared_ptr(), attn_tensor});
+ if (!is_scale_const) {
+ shapes.emplace_back(1);
+ ov::Tensor scale_tensor = ov::test::utils::create_and_fill_tensor(ov::element::f16, shapes[4], scale_data);
+ inputs.insert({model_inputs[4].get_node_shared_ptr(), scale_tensor});
+ }
+ } else {
+ int idx = 3;
+ if (has_attn && !is_attn_const) {
+ shapes.push_back(targetInputStaticShapes[3]);
+ ov::Tensor attn_tensor = ov::test::utils::create_and_fill_tensor(ov::element::f16, shapes[idx], attn_data);
+ inputs.insert({model_inputs[idx++].get_node_shared_ptr(), attn_tensor});
+ }
+ if (has_scale && !is_scale_const) {
+ shapes.emplace_back(1);
+ ov::Tensor scale_tensor = ov::test::utils::create_and_fill_tensor(ov::element::f16, shapes[idx], scale_data);
+ inputs.insert({model_inputs[idx].get_node_shared_ptr(), scale_tensor});
+ }
+ }
+}
+
+void ScaledAttnLayerGPUMlirTest::check_mlir_execution() {
+ if (!ov::test::is_mlir_enabled()) {
+ return;
+ }
+
+ auto exec_model = compiledModel.get_runtime_model();
+ ASSERT_NE(exec_model, nullptr);
+
+ bool has_mlir_op = false;
+ bool has_sdpa = false;
+ for (const auto& node : exec_model->get_ordered_ops()) {
+ const auto& rt_info = node->get_rt_info();
+ auto it = rt_info.find(ov::exec_model_info::LAYER_TYPE);
+ if (it == rt_info.end()) {
+ continue;
+ }
+ const auto layer_type = it->second.as<std::string>();
+ if (layer_type == "mlir_primitive" || layer_type == "MLIROp") {
+ has_mlir_op = true;
+ } else if (layer_type == "ScaledDotProductAttention" || layer_type == "scaled_dot_product_attention") {
+ has_sdpa = true;
+ }
+ }
+
+ // The SDPA pattern must have matched: execution goes through MLIROp and no
+ // ScaledDotProductAttention primitive is left in the execution graph.
+ EXPECT_TRUE(has_mlir_op) << "Expected an MLIROp in the execution graph, but none was found. "
+ << "Is 'OV_GPU_ENABLE_MLIR=1' ?";
+ EXPECT_FALSE(has_sdpa) << "Unexpected ScaledDotProductAttention in the execution graph";
+}
+
+TEST_P(ScaledAttnLayerGPUMlirTest, CompareWithRefs) {
+ run();
+}
+
+const std::vector<std::vector<int64_t>> disable_transpose{};
+const std::vector<std::vector<InputShape>> static_shapes_3D{
+ // static shapes
+ {
+ // q shape
+ {ov::test::InputShape{ov::PartialShape{16, 128, 80}, {ov::Shape{16, 128, 80}}}},
+ // k shape
+ {ov::test::InputShape{ov::PartialShape{16, 128, 80}, {ov::Shape{16, 128, 80}}}},
+ // v shape
+ {ov::test::InputShape{ov::PartialShape{16, 128, 80}, {ov::Shape{16, 128, 80}}}},
+ // attn shape: [B, 128, -128, L0+L1]
+ {ov::test::InputShape{ov::PartialShape{128, 128}, {ov::Shape{128, 128}}}},
+ },
+};
+
+const auto static_shape_params_3D = testing::Combine(testing::Values(ov::element::f16),
+ testing::ValuesIn(static_shapes_3D),
+ testing::Values(false), // is_causal
+ testing::Values(false, true), // has_attn
+ testing::Values(false, true), // is_attn_const
+ testing::Values(false, true), // has_scale
+ testing::Values(/*false,*/ true), // is_scale_const
+ testing::ValuesIn({disable_transpose}),
+ testing::Values(false)); // has_sink
+
+INSTANTIATE_TEST_SUITE_P(mlir_ScaledAttnStatic3D_GPU, ScaledAttnLayerGPUMlirTest, static_shape_params_3D, ScaledAttnLayerGPUMlirTest::getTestCaseName);
+
+const std::vector<std::vector<InputShape>> static_shapes_4D{
+ // static shapes
+ {
+ // q shape
+ {ov::test::InputShape{ov::PartialShape{1, 16, 128, 80}, {ov::Shape{1, 16, 128, 80}}}},
+ // k shape
+ {ov::test::InputShape{ov::PartialShape{1, 16, 128, 80}, {ov::Shape{1, 16, 128, 80}}}},
+ // v shape
+ {ov::test::InputShape{ov::PartialShape{1, 16, 128, 80}, {ov::Shape{1, 16, 128, 80}}}},
+ // attn shape: [B, 128, -128, L0+L1]
+ {ov::test::InputShape{ov::PartialShape{128, 128}, {ov::Shape{128, 128}}}},
+ },
+ {
+ // q shape
+ {ov::test::InputShape{ov::PartialShape{1, 8, 128, 128}, {ov::Shape{1, 8, 128, 128}}}},
+ // k shape
+ {ov::test::InputShape{ov::PartialShape{1, 8, 128, 128}, {ov::Shape{1, 8, 128, 128}}}},
+ // v shape
+ {ov::test::InputShape{ov::PartialShape{1, 8, 128, 128}, {ov::Shape{1, 8, 128, 128}}}},
+ // attn shape: [B, 1, -1, L0+L1]
+ {ov::test::InputShape{ov::PartialShape{1, 1, 128, 128}, {ov::Shape{1, 1, 128, 128}}}},
+ },
+};
+
+const auto static_shape_params_4D = testing::Combine(testing::Values(ov::element::f16),
+ testing::ValuesIn(static_shapes_4D),
+ testing::Values(false), // is_causal
+ testing::Values(false, true), // has_attn
+ testing::Values(false, true), // is_attn_const
+ testing::Values(false, true), // has_scale
+ testing::Values(/*false,*/ true), // is_scale_const
+ testing::ValuesIn({disable_transpose}),
+ testing::Values(false)); // has_sink
+
+INSTANTIATE_TEST_SUITE_P(mlir_ScaledAttnStatic4D_GPU, ScaledAttnLayerGPUMlirTest, static_shape_params_4D, ScaledAttnLayerGPUMlirTest::getTestCaseName);
+
+const std::vector<std::vector<InputShape>> dynamic_shapes_4D{
+ {
+ // q shape: ?x24x?x64
+ {ov::test::InputShape{ov::PartialShape{-1, 24, -1, 64}, {ov::Shape{1, 24, 128, 64}}}},
+ // k shape: ?x24x?x64
+ {ov::test::InputShape{ov::PartialShape{-1, 24, -1, 64}, {ov::Shape{1, 24, 128, 64}}}},
+ // v shape: ?x24x?x64
+ {ov::test::InputShape{ov::PartialShape{-1, 24, -1, 64}, {ov::Shape{1, 24, 128, 64}}}},
+ },
+};
+
+const auto dynamic_shape_params_4D = testing::Combine(testing::Values(ov::element::f16),
+ testing::ValuesIn(dynamic_shapes_4D),
+ testing::Values(false), // is_causal
+ testing::Values(false), // has_attn
+ testing::Values(false), // is_attn_const
+ testing::Values(false), // has_scale
+ testing::Values(false), // is_scale_const
+ testing::ValuesIn({disable_transpose}),
+ testing::Values(false)); // has_sink
+
+INSTANTIATE_TEST_SUITE_P(mlir_ScaledAttnDynamic4D_GPU, ScaledAttnLayerGPUMlirTest, dynamic_shape_params_4D, ScaledAttnLayerGPUMlirTest::getTestCaseName);
+
+} // namespace
diff --git a/src/plugins/intel_gpu/tests/functional/mlir_op/transpose.cpp b/src/plugins/intel_gpu/tests/functional/mlir_op/transpose.cpp
new file mode 100644
index 00000000000..088f856b1fc
--- /dev/null
+++ b/src/plugins/intel_gpu/tests/functional/mlir_op/transpose.cpp
@@ -0,0 +1,89 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "openvino/op/transpose.hpp"
+
+#include "mlir_test_env.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/reshape.hpp"
+#include "openvino/op/result.hpp"
+
+namespace {
+
+// Params: input shape, order, precision
+using TransposeParams = std::tuple<ov::Shape, std::vector<int64_t>, ov::element::Type>;
+
+class TransposeTest : public testing::WithParamInterface<TransposeParams>, virtual public ov::test::MlirSubgraphStaticTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<TransposeParams>& obj) {
+ const auto& [shape, order, precision] = obj.param;
+ std::ostringstream result;
+ result << "Input=" << ov::test::utils::vec2str(shape) << "_";
+ result << "Order=" << ov::test::utils::vec2str(order) << "_";
+ result << "precision=" << precision;
+ return result.str();
+ }
+
+protected:
+ void SetUp() override {
+ targetDevice = ov::test::utils::DEVICE_GPU;
+ const auto& [shape, order, precision] = GetParam();
+ auto input = std::make_shared<ov::op::v0::Parameter>(precision, shape);
+ auto order_const = ov::op::v0::Constant::create(ov::element::i64, {order.size()}, order);
+ auto op = std::make_shared<ov::op::v1::Transpose>(input, order_const);
+ auto result = std::make_shared<ov::op::v0::Result>(op);
+ function = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{input});
+ }
+};
+
+TEST_P(TransposeTest, Inference) {
+ run();
+}
+
+const auto transpose_params = ::testing::Combine(::testing::Values(ov::Shape{1, 1024, 24, 64}, ov::Shape{1, 128, 24, 64}),
+ ::testing::Values(std::vector<int64_t>{0, 2, 1, 3}),
+ ::testing::Values(ov::element::f16));
+INSTANTIATE_TEST_SUITE_P(mlir_Transpose, TransposeTest, transpose_params, TransposeTest::getTestCaseName);
+
+// Params: input shape, output shape, order, precision
+using ReshapeAndTransposeParams = std::tuple<ov::Shape, ov::Shape, std::vector<int64_t>, ov::element::Type>;
+
+class ReshapeAndTransposeTest : public testing::WithParamInterface<ReshapeAndTransposeParams>, virtual public ov::test::MlirSubgraphStaticTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<ReshapeAndTransposeParams>& obj) {
+ const auto& [input_shape, output_shape, order, precision] = obj.param;
+ std::ostringstream result;
+ result << "Input=" << ov::test::utils::vec2str(input_shape) << "_";
+ result << "Output=" << ov::test::utils::vec2str(output_shape) << "_";
+ result << "Order=" << ov::test::utils::vec2str(order) << "_";
+ result << "precision=" << precision;
+ return result.str();
+ }
+
+protected:
+ void SetUp() override {
+ targetDevice = ov::test::utils::DEVICE_GPU;
+ const auto& [input_shape, output_shape, order, precision] = GetParam();
+ auto input = std::make_shared<ov::op::v0::Parameter>(precision, input_shape);
+ std::vector<int64_t> shape_data(output_shape.begin(), output_shape.end());
+ auto shape_const = ov::op::v0::Constant::create(ov::element::i64, {output_shape.size()}, shape_data);
+ auto reshape = std::make_shared<ov::op::v1::Reshape>(input, shape_const, false);
+ auto order_const = ov::op::v0::Constant::create(ov::element::i64, {order.size()}, order);
+ auto op = std::make_shared<ov::op::v1::Transpose>(reshape, order_const);
+ auto result = std::make_shared<ov::op::v0::Result>(op);
+ function = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{input});
+ }
+};
+
+TEST_P(ReshapeAndTransposeTest, Inference) {
+ run();
+}
+
+const auto reshape_and_transpose_params =
+ ::testing::Values(ReshapeAndTransposeParams{ov::Shape{1, 1024, 1536}, ov::Shape{1, 1024, 24, 64}, std::vector<int64_t>{0, 2, 1, 3}, ov::element::f16},
+ ReshapeAndTransposeParams{ov::Shape{1, 128, 1536}, ov::Shape{1, 128, 24, 64}, std::vector<int64_t>{0, 2, 1, 3}, ov::element::f16});
+INSTANTIATE_TEST_SUITE_P(mlir_ReshapeAndTranspose, ReshapeAndTransposeTest, reshape_and_transpose_params, ReshapeAndTransposeTest::getTestCaseName);
+
+} // namespace
diff --git a/src/plugins/intel_gpu/tests/functional/mlir_op/unary_eltwise.cpp b/src/plugins/intel_gpu/tests/functional/mlir_op/unary_eltwise.cpp
new file mode 100644
index 00000000000..761d2773ae4
--- /dev/null
+++ b/src/plugins/intel_gpu/tests/functional/mlir_op/unary_eltwise.cpp
@@ -0,0 +1,88 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <type_traits>
+
+#include "mlir_test_env.hpp"
+#include "openvino/op/abs.hpp"
+#include "openvino/op/ceiling.hpp"
+#include "openvino/op/exp.hpp"
+#include "openvino/op/floor.hpp"
+#include "openvino/op/log.hpp"
+#include "openvino/op/negative.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/relu.hpp"
+#include "openvino/op/result.hpp"
+#include "openvino/op/sqrt.hpp"
+#include "openvino/op/tanh.hpp"
+
+namespace {
+
+using UnaryElementwiseParams = std::tuple<ov::Shape, ov::element::Type>;
+
+template <typename Op>
+class UnaryElementwiseTest : public testing::WithParamInterface<UnaryElementwiseParams>, virtual public ov::test::MlirSubgraphStaticTest {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<UnaryElementwiseParams>& obj) {
+ const auto& [shape, precision] = obj.param;
+ std::ostringstream result;
+ result << "Input=" << ov::test::utils::vec2str(shape) << "_";
+ result << "precision=" << precision;
+ return result.str();
+ }
+
+protected:
+ void SetUp() override {
+ targetDevice = ov::test::utils::DEVICE_GPU;
+ if constexpr (std::is_same_v<Op, ov::op::v0::Exp>) {
+ rel_threshold = 0.011F;
+ }
+ const auto& [shape, precision] = GetParam();
+ auto input = std::make_shared<ov::op::v0::Parameter>(precision, shape);
+ auto op = std::make_shared<Op>(input);
+ auto result = std::make_shared<ov::op::v0::Result>(op);
+ function = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{input});
+ }
+};
+
+using AbsTest = UnaryElementwiseTest<ov::op::v0::Abs>;
+using CeilingTest = UnaryElementwiseTest<ov::op::v0::Ceiling>;
+using ExpTest = UnaryElementwiseTest<ov::op::v0::Exp>;
+using FloorTest = UnaryElementwiseTest<ov::op::v0::Floor>;
+using LogTest = UnaryElementwiseTest<ov::op::v0::Log>;
+using NegativeTest = UnaryElementwiseTest<ov::op::v0::Negative>;
+using ReluTest = UnaryElementwiseTest<ov::op::v0::Relu>;
+using SqrtTest = UnaryElementwiseTest<ov::op::v0::Sqrt>;
+using TanhTest = UnaryElementwiseTest<ov::op::v0::Tanh>;
+
+#define DEFINE_TEST(Name) \
+ TEST_P(Name, Inference) { \
+ run(); \
+ }
+
+DEFINE_TEST(AbsTest)
+DEFINE_TEST(CeilingTest)
+DEFINE_TEST(ExpTest)
+DEFINE_TEST(FloorTest)
+DEFINE_TEST(LogTest)
+DEFINE_TEST(NegativeTest)
+DEFINE_TEST(ReluTest)
+DEFINE_TEST(SqrtTest)
+DEFINE_TEST(TanhTest)
+
+const auto test_params = ::testing::Combine(::testing::Values(ov::Shape{1, 24, 1024, 1}, ov::Shape{1, 24, 128, 1}), ::testing::Values(ov::element::f16));
+
+#define INSTANTIATE_TS(Name) INSTANTIATE_TEST_SUITE_P(mlir_UnaryElementwise##Name, Name, test_params, Name::getTestCaseName)
+
+INSTANTIATE_TS(AbsTest);
+INSTANTIATE_TS(CeilingTest);
+INSTANTIATE_TS(ExpTest);
+INSTANTIATE_TS(FloorTest);
+INSTANTIATE_TS(LogTest);
+INSTANTIATE_TS(NegativeTest);
+INSTANTIATE_TS(ReluTest);
+INSTANTIATE_TS(SqrtTest);
+INSTANTIATE_TS(TanhTest);
+
+} // namespace
diff --git a/src/plugins/intel_gpu/thirdparty/cmake/graph-compiler.cmake b/src/plugins/intel_gpu/thirdparty/cmake/graph-compiler.cmake
new file mode 100644
index 00000000000..e9e56ceaf7c
--- /dev/null
+++ b/src/plugins/intel_gpu/thirdparty/cmake/graph-compiler.cmake
@@ -0,0 +1,30 @@
+# Copyright (C) 2018-2026 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+#
+
+include_guard()
+include("${CMAKE_CURRENT_LIST_DIR}/llvm.cmake")
+
+find_package(GraphCompiler QUIET CONFIG)
+
+if (NOT GraphCompiler_FOUND)
+ option(GRAPH_COMPILER_DYLINK "Use dynamic linking with GraphCompiler" OFF)
+ set(GRAPH_COMPILER_REPO "https://github.com/dchigarev/graph-compiler" CACHE STRING "GraphCompiler repository URL")
+ set(GRAPH_COMPILER_TAG "ov_pin/0.1.1" CACHE STRING "GraphCompiler git tag/branch")
+ message(STATUS "GraphCompiler not found, fetching from: ${GRAPH_COMPILER_REPO}")
+ include(FetchContent)
+ FetchContent_Declare(
+ GraphCompiler
+ GIT_REPOSITORY ${GRAPH_COMPILER_REPO}
+ GIT_TAG ${GRAPH_COMPILER_TAG}
+ GIT_SHALLOW TRUE
+ )
+ set(GC_ENABLE_TEST OFF CACHE BOOL "" FORCE)
+ set(GC_ENABLE_TOOLS OFF CACHE BOOL "" FORCE)
+ set(GC_ENABLE_PYTHON_BINDINGS OFF CACHE BOOL "" FORCE)
+ set(GC_DYLINK ${GRAPH_COMPILER_DYLINK} CACHE BOOL "" FORCE)
+ set(_ov_build_shared_libs ${BUILD_SHARED_LIBS})
+ set(BUILD_SHARED_LIBS ${GRAPH_COMPILER_DYLINK})
+ FetchContent_MakeAvailable(GraphCompiler)
+ set(BUILD_SHARED_LIBS ${_ov_build_shared_libs})
+endif()
diff --git a/src/plugins/intel_gpu/thirdparty/cmake/llvm.cmake b/src/plugins/intel_gpu/thirdparty/cmake/llvm.cmake
new file mode 100644
index 00000000000..45e8b7b5f73
--- /dev/null
+++ b/src/plugins/intel_gpu/thirdparty/cmake/llvm.cmake
@@ -0,0 +1,24 @@
+# Copyright (C) 2018-2026 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+#
+
+include_guard()
+
+set(SUPPORTED_LLVM_VERSION "24" CACHE STRING "")
+
+find_package(LLVM CONFIG QUIET)
+if (NOT LLVM_FOUND)
+ set(LLVM_DIR "/usr/lib/llvm-${SUPPORTED_LLVM_VERSION}/lib/cmake/llvm" CACHE PATH "" FORCE)
+ find_package(LLVM REQUIRED CONFIG)
+endif()
+
+find_package(MLIR CONFIG QUIET)
+if (NOT MLIR_FOUND)
+ get_filename_component(llvm_cmake_path "${LLVM_DIR}" REALPATH)
+ get_filename_component(llvm_cmake_dir "${llvm_cmake_path}" DIRECTORY)
+ set(MLIR_DIR "${llvm_cmake_dir}/mlir" CACHE PATH "" FORCE)
+ find_package(MLIR REQUIRED CONFIG)
+endif()
+
+message(STATUS "LLVM_DIR: ${LLVM_DIR}")
+message(STATUS "MLIR_DIR: ${MLIR_DIR}")