vitisai : add VitisAI Plugin for AMD Ryzen AI NPU encoder offload (#3608)

* Add VitisAI Plugin

* Added VitisAI encoder module placeholder files

* VitisAI build integration

* VitisAI encoder offload functional

* Clean up vitisai integration

* Add c++17 requirement for Windows

* Enabled preemption for windows runs

* Add model cache override option

* Remove vitisai premature log message

* Add rai support through file mapping

* Fixed flatbuffer loading

* Fixed Windows file mapping issue

* Update FlexmlRT resolution

* Use Flexmlrt wheel pkg to build VitisAI plugin

* Clean up

* Remove prints

* Change flexmlrt target from Shared to Interface

* Add c++17 requirement for Windows

* Enabled preemption for windows runs

* Add rai support through file mapping

* Fixed flatbuffer loading

* Fixed Windows file mapping issue

* Update FlexmlRT resolution

* Use Flexmlrt wheel pkg to build VitisAI plugin

* Clean up

* Remove prints

* Change flexmlrt target from Shared to Interface

* Cleanup FlexmlRT integration

* format fix

* Adding AMD Licenses

* Update CMakeLists.txt

Co-authored-by: Kumawat, Sachin <sachin.kumawat@amd.com>

* Update src/CMakeLists.txt

Co-authored-by: Kumawat, Sachin <sachin.kumawat@amd.com>

* Update whisper.cpp

* Added VitisAI encoder readme section

* Remove license headers from common files to whisper.cpp

---------

Co-authored-by: Sachin Kumawat <sachink@amd.com>
Co-authored-by: Jeff Lin <jeffylin@xilinx.com>
Co-authored-by: Lin <jefflin@amd.com>
Co-authored-by: Lin, Jeff (DCG-ENG) <jeff.lin@amd.com>
Co-authored-by: Iswarya Alex <iswaryaalex96@gmail.com>
Co-authored-by: Alex, Iswarya <Iswarya.Alex@amd.com>

* Update README.md

- RAI EULA Links
- Updated for RAI Whisper instructions

* Cleanup and add runtime print debug guard

* turn off profiling

* Add VitisAI Plugin

* Added VitisAI encoder module placeholder files

* VitisAI build integration

* VitisAI encoder offload functional

* Clean up vitisai integration

* Add c++17 requirement for Windows

* Enabled preemption for windows runs

* Add model cache override option

* Remove vitisai premature log message

* Add rai support through file mapping

* Fixed flatbuffer loading

* Fixed Windows file mapping issue

* Update FlexmlRT resolution

* Use Flexmlrt wheel pkg to build VitisAI plugin

* Clean up

* Remove prints

* Change flexmlrt target from Shared to Interface

* Add c++17 requirement for Windows

* Enabled preemption for windows runs

* Add rai support through file mapping

* Fixed flatbuffer loading

* Fixed Windows file mapping issue

* Update FlexmlRT resolution

* Use Flexmlrt wheel pkg to build VitisAI plugin

* Clean up

* Remove prints

* Change flexmlrt target from Shared to Interface

* Cleanup FlexmlRT integration

* format fix

* Adding AMD Licenses

* Update CMakeLists.txt

Co-authored-by: Kumawat, Sachin <sachin.kumawat@amd.com>

* Update src/CMakeLists.txt

Co-authored-by: Kumawat, Sachin <sachin.kumawat@amd.com>

* Update whisper.cpp

* Added VitisAI encoder readme section

* Remove license headers from common files to whisper.cpp

---------

Co-authored-by: Sachin Kumawat <sachink@amd.com>
Co-authored-by: Jeff Lin <jeffylin@xilinx.com>
Co-authored-by: Lin <jefflin@amd.com>
Co-authored-by: Lin, Jeff (DCG-ENG) <jeff.lin@amd.com>
Co-authored-by: Iswarya Alex <iswaryaalex96@gmail.com>
Co-authored-by: Alex, Iswarya <Iswarya.Alex@amd.com>

* Cleanup and add runtime print debug guard

* Update README.md

- RAI EULA Links
- Updated for RAI Whisper instructions

* turn off profiling

* Let flexmlrt detect device type

* Add VitisAI model download scripts

* Add encoder + cross projection layer offload

* Add self hosted runner for amd npu

* Update runner

* Update workflow for linux

* Update workflow for linux

* Update flexmlrt packages for linux

* Update flexmlrt packages for linux

* Updated README

* readme: clarify xrt

* readme: clarify xrt

* ci: update test config

* Added supported plarform details with python 3.12 requirement for Linux

* Use refactored helpers

* Deprecate cross_proj .rai naming and cleanup

* Remove stale function code

* Fix: formatting

---------

Co-authored-by: Jeff Lin <jeffylin@xilinx.com>
Co-authored-by: Lin <jefflin@amd.com>
Co-authored-by: Lin, Jeff (DCG-ENG) <jeff.lin@amd.com>
Co-authored-by: Iswarya Alex <iswaryaalex96@gmail.com>
Co-authored-by: Alex, Iswarya <Iswarya.Alex@amd.com>
Co-authored-by: Iswarya Alex <47045679+iswaryaalex@users.noreply.github.com>
This commit is contained in:
Sachin Kumawat
2026-08-24 08:02:30 +02:00
committed by GitHub
co-authored by Jeff Lin Lin Lin, Jeff (DCG-ENG) Iswarya Alex Alex, Iswarya Iswarya Alex
parent 233fe1fc9b
commit 52dec9d889
12 changed files with 2072 additions and 3 deletions
+86
View File
@@ -48,6 +48,61 @@ if (WHISPER_OPENVINO)
find_package(OpenVINO REQUIRED COMPONENTS Runtime)
endif()
if (WHISPER_VITISAI)
find_package(FlexmlRT REQUIRED)
# Legacy RAI overrides are required by FlexMLRT older than 1.8.0
set(WHISPER_FLEXMLRT_LEGACY_RAI_OVERRIDES_MODE "AUTO" CACHE STRING
"Legacy RAI override mode for FlexMLRT (AUTO|ON|OFF)")
set_property(CACHE WHISPER_FLEXMLRT_LEGACY_RAI_OVERRIDES_MODE PROPERTY STRINGS AUTO ON OFF)
string(TOUPPER "${WHISPER_FLEXMLRT_LEGACY_RAI_OVERRIDES_MODE}" _flexmlrt_legacy_mode)
set(_flexmlrt_legacy_hint "Set -DWHISPER_FLEXMLRT_LEGACY_RAI_OVERRIDES_MODE=ON or OFF explicitly.")
if (NOT _flexmlrt_legacy_mode MATCHES "^(AUTO|ON|OFF)$")
message(FATAL_ERROR
"Invalid WHISPER_FLEXMLRT_LEGACY_RAI_OVERRIDES_MODE='${WHISPER_FLEXMLRT_LEGACY_RAI_OVERRIDES_MODE}'. "
"Expected AUTO, ON, or OFF.")
endif()
if (_flexmlrt_legacy_mode STREQUAL "AUTO")
if (NOT FlexmlRT_DIR)
message(FATAL_ERROR
"FlexmlRT_DIR is unset after find_package(FlexmlRT). ${_flexmlrt_legacy_hint}")
endif()
# FlexmlRT_DIR points to <pkg_root>/share/cmake/FlexmlRT.
get_filename_component(_flexmlrt_init_py "${FlexmlRT_DIR}/../../../__init__.py" ABSOLUTE)
if (NOT EXISTS "${_flexmlrt_init_py}")
message(FATAL_ERROR
"flexmlrt __init__.py not found at ${_flexmlrt_init_py}. ${_flexmlrt_legacy_hint}")
endif()
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${_flexmlrt_init_py}")
file(STRINGS "${_flexmlrt_init_py}" _flexmlrt_version_lines
REGEX "^VERSION[ \t]*=[ \t]*\"[0-9]+\\.[0-9]+\\.[0-9]+")
if (NOT _flexmlrt_version_lines MATCHES "\"([0-9]+\\.[0-9]+\\.[0-9]+)")
message(FATAL_ERROR
"Could not parse flexmlrt VERSION from ${_flexmlrt_init_py}. ${_flexmlrt_legacy_hint}")
endif()
set(_flexmlrt_version "${CMAKE_MATCH_1}")
if (_flexmlrt_version VERSION_LESS "1.8.0")
set(WHISPER_FLEXMLRT_LEGACY_RAI_OVERRIDES 1)
else()
set(WHISPER_FLEXMLRT_LEGACY_RAI_OVERRIDES 0)
endif()
message(STATUS "Detected flexmlrt VERSION=${_flexmlrt_version} from ${_flexmlrt_init_py} (legacy overrides=${WHISPER_FLEXMLRT_LEGACY_RAI_OVERRIDES})")
else()
if (_flexmlrt_legacy_mode STREQUAL "ON")
set(WHISPER_FLEXMLRT_LEGACY_RAI_OVERRIDES 1)
else()
set(WHISPER_FLEXMLRT_LEGACY_RAI_OVERRIDES 0)
endif()
message(STATUS "FlexMLRT legacy RAI overrides forced ${_flexmlrt_legacy_mode}")
endif()
endif()
#
# libraries
#
@@ -101,6 +156,33 @@ if (WHISPER_OPENVINO)
set_target_properties(${TARGET} PROPERTIES FOLDER "libs")
endif()
if (WHISPER_VITISAI)
set(TARGET whisper.vitisai)
add_library(${TARGET} OBJECT
vitisai/whisper-vitisai-helpers.h
vitisai/whisper-vitisai-helpers.cpp
vitisai/whisper-vitisai-encoder.h
vitisai/whisper-vitisai-encoder.cpp
)
target_include_directories(${TARGET} PUBLIC .)
set_property(TARGET ${TARGET} PROPERTY POSITION_INDEPENDENT_CODE ON)
set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DWHISPER_USE_VITISAI)
# FlexMLRT headers and this plugin require C++17. Keep it PRIVATE so the
# C++11 requirement of the whisper target is not bumped.
target_compile_features(${TARGET} PRIVATE cxx_std_17)
target_compile_definitions(${TARGET} PRIVATE
WHISPER_FLEXMLRT_LEGACY_RAI_OVERRIDES=${WHISPER_FLEXMLRT_LEGACY_RAI_OVERRIDES}
)
target_link_libraries(${TARGET} PRIVATE ggml flexmlrt::flexmlrt)
set_target_properties(${TARGET} PROPERTIES FOLDER "libs")
endif()
# whisper
add_library(whisper
@@ -159,6 +241,10 @@ if (WHISPER_OPENVINO)
target_link_libraries(whisper PRIVATE whisper.openvino)
endif()
if (WHISPER_VITISAI)
target_link_libraries(whisper PRIVATE whisper.vitisai)
endif()
if (WHISPER_MKL)
target_link_libraries(whisper PRIVATE MKL::MKL)
endif()