Skip to content
Open
Show file tree
Hide file tree
Changes from 111 commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
fbd17fb
Initial integration of MLIR into OpenVINO core.
slyalin Jun 15, 2024
f6555b9
Eliminate temporary buffer in binary op conversion (#130)
adam-smnk Jun 28, 2024
2d1955b
Assert doesn't get compiled in Release mode (#131)
rengolin Jul 4, 2024
6f554c9
Reduce warnings (#133)
rengolin Jul 8, 2024
560a659
Multi-node patterns with Add, Sub, Mul, Div (#135)
slyalin Jul 9, 2024
08e601d
Reorg: split monolithic convert.cpp into multiple files (#137)
slyalin Jul 10, 2024
e30e919
Pre-bufferization cleanup (#138)
adam-smnk Jul 12, 2024
754e385
ov::MatMul -> linalg::MatmulTransposeBOp (#139)
slyalin Jul 16, 2024
b5370bd
Allow static input (#141)
adam-smnk Jul 17, 2024
1e1d807
Match and lower ov::Relu (#143)
adam-smnk Jul 19, 2024
a4dbd98
[GPU] Draft of MLIR and Generic ops (#140)
Jul 19, 2024
6f038fc
TPP-MLIR as out-of-tree dependency (#142)
slyalin Jul 22, 2024
ff4d018
Fixed double free due to missing return statement in Partitioner::run…
slyalin Jul 22, 2024
863f139
Fixing xsmm runner dynamic load (#146)
slyalin Jul 23, 2024
d44f7c9
Pass XSMM runner lib to MLIR execution engine (#147)
adam-smnk Jul 25, 2024
c72dc8a
Revert "Pass XSMM runner lib to MLIR execution engine (#147)" (#149)
adam-smnk Jul 25, 2024
3707523
Broadcast support for elementwise ops (#148)
slyalin Jul 25, 2024
3e1871b
Disable MatMul conversion for not supported cases to avoid crashing (…
slyalin Jul 26, 2024
f8bbb6a
More matmul variants (#153)
adam-smnk Jul 26, 2024
e6241fd
Environment variables to control MLIR execution (#154)
slyalin Jul 26, 2024
ea8e4a3
Match all element types (#156)
adam-smnk Jul 29, 2024
acbd925
Fix graph partitioner when two MLIROp instances go side-by-side. Fix …
slyalin Jul 30, 2024
df9b3e0
MLP benchmarks (#152)
adam-smnk Jul 30, 2024
1f9a555
Align MLP sizes with TPP-MLIR benchmarks (#158)
adam-smnk Jul 30, 2024
80dd502
Lower number of benchmark iterations (#159)
adam-smnk Jul 30, 2024
77f5ea3
MLP bench - control OV infer precision (#160)
adam-smnk Jul 31, 2024
e93f1a6
TPP const weights and benchmark runners (#161)
adam-smnk Jul 31, 2024
aa86cfb
Integration with GraphCompiler (#155)
AndreyPavlenko Aug 1, 2024
ee1d2b4
[GraphCompiler] Use find_package() for CMake < 3.24 (#162)
AndreyPavlenko Aug 5, 2024
21c61af
Fixed build failure caused by #155 (#163)
AndreyPavlenko Aug 5, 2024
966634e
multi-layer support in benchmark scripts (#164)
rengolin Aug 5, 2024
acedae2
[MLIR][DLTI] Add DLTI attr to MLIR-generated modules
Aug 8, 2024
0988860
Unify bench configs (#166)
adam-smnk Aug 9, 2024
da56c3c
Add simple script to benchmark LoRA fragment
Sep 3, 2024
34b7817
Control LoRA bench inference precision (#170)
adam-smnk Sep 6, 2024
a48c9f1
LoRA manual MLIR model (#171)
adam-smnk Sep 10, 2024
fc319c4
[MLIR][TPP] Enable --lower-pack-unpack-without-transpose on LoRA benc…
Sep 25, 2024
0b3feca
GC-GPU integration (#169)
dchigarev Oct 15, 2024
932ed83
Fix python execution in GC_GPU mode (#174)
kurapov-peter Nov 26, 2024
a7fe844
Add floor, shape_of and squeeze patterns (#175)
kurapov-peter Dec 17, 2024
cc4d614
Add gather, slice and concat patterns (#177)
kurapov-peter Dec 17, 2024
af561ef
Add unsqueeze and transpose patterns (#178)
kurapov-peter Dec 18, 2024
b05ab45
Fix python e2e buld (#179)
zhiczhong Dec 18, 2024
27ae57d
Make it work with new llvm & ov
dchigarev Jan 29, 2026
0f05a42
Fix GC build
dchigarev Feb 4, 2026
1f39cba
Add gc-build instructions
dchigarev Feb 4, 2026
01f7f22
Add basic ov::SDPA -> linalgx converter
dchigarev Feb 9, 2026
cafa32d
Fix sanity tests
dchigarev Feb 26, 2026
8d3267d
Remove add
dchigarev Feb 26, 2026
5b3b9b1
Enable GPU executor
dchigarev Feb 26, 2026
38e0a79
Fixes
AndreyPavlenko Feb 27, 2026
d983076
Support scale & mask & 4d cases in SDPA conversion
dchigarev Mar 10, 2026
6b8e115
Matmul + add
AndreyPavlenko Mar 12, 2026
89f6242
Added option for dynamic linking with LLVM and GC
AndreyPavlenko Mar 13, 2026
d1ebc65
Update GC_BUILD.MD
AndreyPavlenko Mar 17, 2026
92e9bbb
Enable SDPA e2e (#62)
dchigarev Mar 25, 2026
27f8b35
Optimize SDPA tests
dchigarev Mar 25, 2026
57845f3
Merge remote-tracking branch 'origin/master' into HEAD
dchigarev Mar 26, 2026
98ae86d
Merge pull request #64 from intel-sandbox/dchigarev/merge-upstream
dchigarev Mar 27, 2026
058ee2a
Update build instructions
dchigarev Mar 27, 2026
992694e
Implemented reduction converter
AndreyPavlenko Apr 2, 2026
cb252b1
Separate mlir-converters from ov-patterns (#95)
dchigarev Apr 13, 2026
d305154
Drop unused input args
AndreyPavlenko Apr 24, 2026
79935c3
Added ReduceMeanTest
AndreyPavlenko Apr 24, 2026
51ede59
Added tests for all supported Reduce* ops
AndreyPavlenko Apr 29, 2026
c457001
Added binary elementwise tests (#116)
AndreyPavlenko May 12, 2026
9b1a407
Implemented converters and tests for unary elementwise ops (#119)
AndreyPavlenko May 12, 2026
7addf0f
Added tests for the Transpose operation (#123)
AndreyPavlenko May 13, 2026
c83e1b5
Moved reduction tests to mlir_op (#128)
AndreyPavlenko May 13, 2026
7f9c511
Implemented converter and tests for the Reshape operation (#127)
AndreyPavlenko May 13, 2026
747c5df
Adapt OV to new llvm (#143)
dchigarev May 20, 2026
d15d7b9
Added ConcatTest and TransposeConcatTest (#133)
AndreyPavlenko May 28, 2026
e94b479
[MLIR Convertors] Added support for batch matmul (#150)
AndreyPavlenko Jun 10, 2026
8cd1c89
Use empty tensor as the div output
AndreyPavlenko Jun 18, 2026
050230c
Match matmul-rms-norm-concat subgraph (#151)
AndreyPavlenko Jun 29, 2026
e1c4464
Merge commit '611b5300d238bf7456975f6201fb1d47b5e296c6' into HEAD
dchigarev Jun 29, 2026
d7ee462
Fix paged-attention link for BUILD_SHARED_LIBS=OFF
dchigarev Jun 26, 2026
0ccc31d
Fix missing includes
dchigarev Jun 26, 2026
a7069d0
Merge pull request #165 from intel-sandbox/dchigarev/merge_ov
dchigarev Jun 29, 2026
1fa75d8
[MemrefDescriptor] Fix arguments packing for dynamic executor
dchigarev Jul 1, 2026
e7de9c5
[MLIROp] Fix shape_infer for dynamic shapes
dchigarev Jul 1, 2026
6980e12
Merge pull request #180 from intel-sandbox/dchigarev/dyn_packing
dchigarev Jul 1, 2026
5c03ce5
Merge pull request #181 from intel-sandbox/dchigarev/shape_infer
dchigarev Jul 1, 2026
3ffdd72
Fix submodules versions (#1)
dchigarev Jul 6, 2026
eec19f7
Static build + cleanup (#2)
AndreyPavlenko Jul 8, 2026
c2de20b
Moved converters to GPU plugin (#3)
AndreyPavlenko Jul 14, 2026
f322e7c
Graph Compiler CI (#4)
AndreyPavlenko Jul 14, 2026
32c9ee5
Replace 'generic_primitive' with 'mlir_primitive' (#6)
dchigarev Jul 19, 2026
a338296
Fixed profiling info for MLIROp
AndreyPavlenko Jul 16, 2026
cede3e3
Merge pull request #5 from dchigarev/ap/time
AndreyPavlenko Jul 22, 2026
94903a4
[CI] Changed GC_TAG and OV_GPU_QUEUE_TYPE
AndreyPavlenko Jul 22, 2026
93fa790
Move mlir-properties to GPU plugin (#7)
dchigarev Jul 22, 2026
0685a31
Restructure MLIR integration in GPU plugin (#8)
dchigarev Jul 23, 2026
51b598a
General clean-up (#12)
dchigarev Jul 24, 2026
5ad5590
Merge remote-tracking branch 'origin/master' into HEAD
dchigarev Jul 24, 2026
f70d938
revert pvc support in ci
dchigarev Jul 24, 2026
03c0a8a
use git revert
dchigarev Jul 24, 2026
802f390
Revert "use git revert"
dchigarev Jul 24, 2026
d93ef3d
Merge pull request #14 from dchigarev/dchigarev/bump_ov
dchigarev Jul 24, 2026
5e7ba78
Fix copyrights
dchigarev Jul 24, 2026
6f8aceb
Merge pull request #15 from dchigarev/dchigarev/copyright
dchigarev Jul 24, 2026
3b48113
Bump docker tag (#16)
dchigarev Jul 24, 2026
723fc65
Fix ov-ci (#17)
dchigarev Jul 24, 2026
8d27aa4
Implemented graph matcher
AndreyPavlenko Jul 24, 2026
172569b
Implemented graph matcher #11
AndreyPavlenko Jul 24, 2026
4235cd4
Fix compile warnings (#18)
dchigarev Jul 27, 2026
cb11e23
Merge remote-tracking branch 'origin/master' into HEAD
dchigarev Jul 27, 2026
a296719
Merge pull request #20 from dchigarev/dchigarev/bump_ov_now
dchigarev Jul 27, 2026
a87821c
Align SDPA-mlir matcher with converter restrictions (#19)
dchigarev Jul 27, 2026
151ac18
Remove 'revert-pvc-support' patch from CI (#21)
dchigarev Jul 27, 2026
091b97b
Isolate MLIR tests (#22)
dchigarev Jul 28, 2026
33cc8e9
Test ov-ci (#25)
dchigarev Jul 31, 2026
3d7e337
Merge remote-tracking branch 'origin/master' into HEAD
dchigarev Jul 31, 2026
108c3ae
Merge pull request #26 from dchigarev/dchigarev/bump
dchigarev Aug 3, 2026
cd9c2ae
Implemented RMS converter
AndreyPavlenko Jul 29, 2026
e90607f
Do not disable 'convertSubstract'
dchigarev Aug 3, 2026
462dad2
Only match 'SDPA' out of the box
dchigarev Jul 31, 2026
35032f1
Skip broken tests
dchigarev Jul 31, 2026
9f93c4f
revert back virtual inheritance
dchigarev Jul 31, 2026
d7c52a1
Adapt test to mlir
dchigarev Aug 3, 2026
f0ef4c6
Pin proper GC version
dchigarev Aug 3, 2026
cb19ebd
Merge pull request #29 from dchigarev/tmp222
dchigarev Aug 3, 2026
5a49854
Do cleanup
dchigarev Aug 3, 2026
2336f5e
Disable 'MLIR_Disabled_Unit' in ci
dchigarev Aug 4, 2026
d8b9b32
Merge remote-tracking branch 'origin/master' into HEAD
dchigarev Aug 4, 2026
585ff3d
Fix mlir workflow file
dchigarev Aug 4, 2026
c27479d
Merge remote-tracking branch 'origin/master' into HEAD
dchigarev Aug 5, 2026
cb92724
Do not print generated values in SDPA test
dchigarev Aug 5, 2026
d4ec2b3
Gate unsupported slice patterns
dchigarev Aug 5, 2026
e4b3cc5
Fix 'rank' packing into 'void*' vector
dchigarev Aug 5, 2026
b94dc3f
Fix MemrefDescriptor constructor
dchigarev Aug 6, 2026
c565fff
Gate unsupported cases for Transpose/Unsqueeze converters
dchigarev Aug 7, 2026
f55a50d
Guard out-of-bounds access in ConvertReshape
dchigarev Aug 7, 2026
a53e9e5
Increased rel_threshold for UnaryElementwiseExpTest
AndreyPavlenko Aug 10, 2026
07761bb
Restrict mlir_primitive serialization
dchigarev Aug 11, 2026
1dc5942
fix clang-tidy
dchigarev Aug 11, 2026
1c9c6eb
add notes regarding integer support
dchigarev Aug 11, 2026
e03250c
Fixed errors afetr changes in GC interfaces (#24)
AndreyPavlenko Aug 12, 2026
cbf4429
Update gc-pin to 'ov_pin/0.1.1'
dchigarev Aug 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dockerfiles/docker_tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pr-36049
pr-35336
79 changes: 79 additions & 0 deletions .github/workflows/graph-compiler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Graph Compiler GPU Backend

@dchigarev dchigarev Aug 3, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is for internal CI in our fork. We'll remove this just before the merge.


on:
push:
pull_request:

permissions:
contents: read

env:
GC_REPO: https://x-access-token:${{ secrets.GC_TOKEN }}@github.com/intel-sandbox/graph-compiler
GC_TAG: main
BUILD_DIR: ${{ github.workspace }}-gc-build
OUTPUT_DIR: ${{ github.workspace }}-gc-bin

jobs:
ci:
runs-on: ${{ vars.RUNNER }}

Comment on lines +3 to +19

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow is only used in our internal OV-fork's CI. It's not launched in the main ov-repo and will be removed just before the merge

steps:
- uses: actions/checkout@v7
with:
submodules: recursive

- name: Build
run: |
mkdir -p $BUILD_DIR
run_build() {
[ "$1" = '-c' ] && rm -rf $BUILD_DIR
mkdir -p $BUILD_DIR
cmake -G Ninja -S "$GITHUB_WORKSPACE" -B "$BUILD_DIR" \
-DOUTPUT_ROOT="$OUTPUT_DIR" \
-DGRAPH_COMPILER_REPO="$GC_REPO" \
-DGRAPH_COMPILER_TAG="$GC_TAG" \
-DENABLE_INTEL_GPU=ON \
-DENABLE_GRAPH_COMPILER=ON \
-DENABLE_TESTS=ON \
-DENABLE_ONEDNN_FOR_GPU=OFF \
-DENABLE_INTEL_CPU=OFF \
-DENABLE_INTEL_NPU=OFF \
-DCMAKE_CXX_FLAGS="-DOV_GPU_OPENCL_HPP_HAS_UUID -DOV_GPU_OPENCL_HPP_HAS_BUS_INFO" \
-DOpenCL_HPP_INCLUDE_DIR="$GITHUB_WORKSPACE/thirdparty/ocl/clhpp_headers/include" \
-DOpenCL_HPP="$GITHUB_WORKSPACE/thirdparty/ocl/clhpp_headers/include/CL/opencl.hpp"
cmake --build "$BUILD_DIR" --parallel
}

if [ -d "$BUILD_DIR" ]; then
# Reuse build artifacts from previous build. If the build fails, clean and rebuild.
run_build || run_build -c
else
run_build
fi

- name: Test
run: |
# These tests require MLIR patches:
# https://github.com/llvm/llvm-project/pull/208932
# https://github.com/llvm/llvm-project/pull/197281
exclude='.*ScaledAttnLayerGPUMlirTest.CompareWithRefs.*|mlir_Transpose.*|mlir_ReshapeAndTranspose.*'

export OV_GPU_ENABLE_MLIR=1
export OV_GPU_QUEUE_TYPE=out-of-order
func_tests="$OUTPUT_DIR/bin/intel64/Release/ov_gpu_func_tests"
filter=$(printf '%s:' \
'MLIRExecution.SimpleMatmulf16' \
'MLIRExecution.SDPABasic' \
'*ScaledAttnLayerGPUMlirTest*' \
'mlir_*' \
)
tests=$("$func_tests" --gtest_list_tests --gtest_filter="${filter%:}" \
| awk -v exclude="$exclude" '/^ /{print suite $1} /^[^ ]/{suite=$1}' \
| grep -v -E "$exclude")
start=$SECONDS
echo "$tests" | xargs -P 32 -I{} "$func_tests" --gtest_filter='{}'
echo "Run $(echo "$tests" | wc -l) tests in $((SECONDS - start))s"

OV_MLIR_PATTERNS='mart=MatMul,Add,Reshape,Transpose;rms=Power,ReduceMean,Add,Sqrt,Divide' \
OV_MLIR_DEBUG=1 "$func_tests" --gtest_filter=mlir_MatMulRmsnormConcatTest* 2>&1 \
| grep -E 'func.func @(mart|rms)' | wc -l | xargs test 4 -eq || { echo "MLIR patterns test failed" && exit 1; }
9 changes: 7 additions & 2 deletions cmake/developer_package/plugins/plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ 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]
# [ADD_CLANG_TIDY]
# )
#
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})
Expand All @@ -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)

@AndreyPavlenko AndreyPavlenko Jul 28, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MLIR GPU unit tests require LLVM/MLIR runtime and link the plugin directly.

else()
set(library_type MODULE)
endif()
else()
set(library_type STATIC)
endif()
Expand Down
2 changes: 2 additions & 0 deletions cmake/features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ ov_dependent_option (ENABLE_CM_FOR_GPU "Enable C for Metal (CM) kernels at GPU r

ov_dependent_option (ENABLE_INTEL_NPU "NPU plugin for OpenVINO runtime" ON "X86_64;WIN32 OR LINUX OR ANDROID" OFF)
ov_dependent_option (ENABLE_INTEL_NPU_INTERNAL "NPU plugin internal components for OpenVINO runtime" ON "ENABLE_INTEL_NPU" OFF)
ov_option (ENABLE_GRAPH_COMPILER "Enable Graph Compiler" OFF)


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)
Expand Down
26 changes: 26 additions & 0 deletions cmake/graph-compiler.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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/intel-sandbox/graph-compiler" CACHE STRING "GraphCompiler repository URL")
set(GRAPH_COMPILER_TAG "main" 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()
17 changes: 17 additions & 0 deletions cmake/llvm.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
include_guard()

set(SUPPORTED_LLVM_VERSION "23" CACHE STRING "")

find_package(LLVM CONFIG QUIET)
if (NOT LLVM_FOUND OR NOT LLVM_VERSION_MAJOR EQUAL ${SUPPORTED_LLVM_VERSION})
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()
16 changes: 16 additions & 0 deletions install_build_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if [ -f /etc/lsb-release ] || [ -f /etc/debian_version ] ; then

apt update
apt-get install -y --no-install-recommends \
software-properties-common \
Comment thread
dchigarev marked this conversation as resolved.
Outdated
`# for python3-pip` \
ca-certificates \
file \
Expand Down Expand Up @@ -89,6 +90,21 @@ if [ -f /etc/lsb-release ] || [ -f /etc/debian_version ] ; then
else
apt-get install -y --no-install-recommends nlohmann-json-dev
fi

# LLVM/MLIR nightly from apt.llvm.org
for arg in "$@"; do
if [ "$arg" = "-llvm" ]; then
: "${LLVM_VERSION:=$(grep -Po '(?<=set\(SUPPORTED_LLVM_VERSION ")[^"]*' "$(dirname "$0")/cmake/llvm.cmake")}"
if ! dpkg -l "libmlir-${LLVM_VERSION}-dev" &>/dev/null; then
wget -qO- https://apt.llvm.org/llvm.sh | bash -s -- "${LLVM_VERSION}" all
apt-get install -y --no-install-recommends \
"libmlir-${LLVM_VERSION}-dev" "mlir-${LLVM_VERSION}-tools" \
`# LLVMExports.cmake requires zstd::libzstd_shared` \
libzstd-dev
fi
break
fi
done
elif [ -f /etc/redhat-release ] || grep -q "rhel\|tencentos\|opencloudos" /etc/os-release ; then
yum update
# RHEL 8 / CentOS 7 / Fedora 29
Expand Down
12 changes: 12 additions & 0 deletions src/inference/include/openvino/runtime/intel_gpu/properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ static constexpr Property<bool> enable_loop_unrolling{"GPU_ENABLE_LOOP_UNROLLING
*/
static constexpr Property<bool> disable_winograd_convolution{"GPU_DISABLE_WINOGRAD_CONVOLUTION"};

/**
* @brief 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_GRAPH_COMPILER=ON; setting
* this to true on a plugin built without Graph Compiler support raises an
* exception at compile_model() time.
* @ingroup ov_runtime_ocl_gpu_prop_cpp_api
*/
static constexpr Property<bool> enable_mlir{"GPU_ENABLE_MLIR"};

namespace hint {
/**
* @brief This enum represents the possible value of ov::intel_gpu::hint::queue_throttle property:
Expand Down
31 changes: 31 additions & 0 deletions src/plugins/intel_gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,35 @@ 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_GRAPH_COMPILER=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_GRAPH_COMPILER)
include(${CMAKE_SOURCE_DIR}/cmake/graph-compiler.cmake)

set(mlir_lib openvino_intel_gpu_mlir_obj)
add_library(${mlir_lib} OBJECT ${GPU_MLIR_SOURCES})
target_compile_options(${mlir_lib} PRIVATE -Wno-error)
target_compile_definitions(${mlir_lib} PRIVATE GRAPH_COMPILER IMPLEMENT_OPENVINO_API)
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})

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.
Expand All @@ -151,6 +177,11 @@ target_link_libraries(${TARGET_NAME} PRIVATE openvino_intel_gpu_graph openvino::
target_include_directories(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include/)

if(ENABLE_GRAPH_COMPILER)
target_link_libraries(${TARGET_NAME} PRIVATE GraphCompiler)
target_compile_definitions(${TARGET_NAME} PRIVATE GRAPH_COMPILER)
endif()

ov_set_threading_interface_for(${TARGET_NAME})
ov_gpu_set_runtime_interface_for(${TARGET_NAME})

Expand Down
55 changes: 55 additions & 0 deletions src/plugins/intel_gpu/include/intel_gpu/op/mlir_op.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 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,
const OVOutputTypes& output_types,
const 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
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,6 @@ REGISTER_FACTORY(internal, GatherMatmul);
REGISTER_FACTORY(internal, GatherMatmulCompressed);
REGISTER_FACTORY(internal, GroupedMatMulCompressed);
REGISTER_FACTORY(internal, Atan2);
#ifdef GRAPH_COMPILER
REGISTER_FACTORY(internal, MLIR);
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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;
Comment thread
dchigarev marked this conversation as resolved.
};

} // namespace cldnn
2 changes: 2 additions & 0 deletions src/plugins/intel_gpu/include/intel_gpu/runtime/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ struct event {

// returns true if handler has been successfully added
bool add_event_handler(event_handler handler, void* data);
// return a handle to an underlying event implementation (i.e. cl_event for OpenCL)
virtual void* get_native_handle() { return nullptr; }

std::vector<instrumentation::profiling_interval> get_profiling_info();

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ struct memory {
}
// only supports gpu_usm
virtual void* buffer_ptr() const { return nullptr; }
// Returns the handle to the underlying memory object (e.g. cl_mem for OpenCL)
virtual void* get_native_handle() const { return nullptr; }

size_t size() const { return _bytes_count; }
size_t count() const { return _layout.count(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ OV_CONFIG_RELEASE_OPTION(ov::intel_gpu::hint, queue_throttle, ov::intel_gpu::hin
OV_CONFIG_RELEASE_OPTION(ov::intel_gpu::hint, queue_priority, ov::hint::Priority::MEDIUM, "Low-level hint that controls queue priority property")
OV_CONFIG_RELEASE_OPTION(ov::intel_gpu::hint, enable_sdpa_optimization, true, "Enable/Disable fused SDPA primitive execution")
OV_CONFIG_RELEASE_OPTION(ov::intel_gpu::hint, enable_lora_operation, true, "Enable/Disable LoRA operation. The separate operation is less versatile, but has better performance")
OV_CONFIG_RELEASE_OPTION(ov::intel_gpu, enable_mlir, false, "Enable/Disable MLIR/Graph-Compiler execution for supported subgraphs. Requires ENABLE_GRAPH_COMPILER=ON at build time")
OV_CONFIG_RELEASE_OPTION(ov::intel_gpu::hint, enable_large_allocations, false, "Allow buffer allocations that exceed the device max allocation size. Enabling this option may lead to performance degradation")
OV_CONFIG_RELEASE_OPTION(ov::intel_gpu, enable_loop_unrolling, true, "Enable/Disable Loop/TensorIterator operation unrolling")
OV_CONFIG_RELEASE_OPTION(ov::intel_gpu, disable_winograd_convolution, false, "Enable/Disable winograd convolution implementation if available")
Expand Down
Loading
Loading