Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
62 changes: 46 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ jobs:
tag_name: ${{ steps.tag.outputs.name }}
version: ${{ steps.tag.outputs.version }}
should_release: ${{ steps.tag.outputs.should_release }}
is_full_build: ${{ steps.tag.outputs.is_full_build }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -85,39 +86,64 @@ jobs:
SHORT_HASH=$(git rev-parse --short=7 HEAD)
CUSTOM_TAG="${{ github.event.inputs.pre_release_tag }}"
SHOULD_RELEASE="false"
IS_FULL_BUILD="false"
IS_PR="${{ github.event_name == 'pull_request' }}"
HAS_FULL_CI_LABEL="false"
# Check for 'full-ci' label on PRs
if [[ "$IS_PR" == "true" ]]; then
LABELS='${{ toJson(github.event.pull_request.labels.*.name) }}'
if echo "$LABELS" | grep -q '"full-ci"'; then
HAS_FULL_CI_LABEL="true"
fi
fi

if [[ "${{ github.ref_type }}" == "tag" ]]; then
# Triggered by sync.yml pushing a vX.Y.Z tag — this is the primary release path
TAG_NAME="${{ github.ref_name }}"
SHOULD_RELEASE="true"
IS_FULL_BUILD="true"
elif [[ -n "$CUSTOM_TAG" ]]; then
TAG_NAME="$CUSTOM_TAG"
SHOULD_RELEASE="true"
IS_FULL_BUILD="true"
elif [[ "${{ github.event.inputs.create_release }}" == "true" ]]; then
TAG_NAME="b${BUILD_NUMBER}"
SHOULD_RELEASE="true"
IS_FULL_BUILD="true"
elif [[ "$IS_PR" == "true" && "$HAS_FULL_CI_LABEL" == "true" ]]; then
SAFE=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
TAG_NAME="${SAFE}-b${BUILD_NUMBER}-${SHORT_HASH}"
IS_FULL_BUILD="true"
elif [[ "$IS_PR" == "true" ]]; then
# PR without full-ci label — lightweight path only
SAFE=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
TAG_NAME="${SAFE}-b${BUILD_NUMBER}-${SHORT_HASH}"
IS_FULL_BUILD="false"
elif [[ "${{ github.event_name }}" == "schedule" ]]; then
TAG_NAME="b${BUILD_NUMBER}"
IS_FULL_BUILD="true"
elif [[ "${{ env.BRANCH_NAME }}" == "main" || "${{ env.BRANCH_NAME }}" == "master" ]]; then
TAG_NAME="b${BUILD_NUMBER}"
SHOULD_RELEASE="false"
IS_FULL_BUILD="true"
else
SAFE=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
TAG_NAME="${SAFE}-b${BUILD_NUMBER}-${SHORT_HASH}"
SHOULD_RELEASE="false"
IS_FULL_BUILD="true"
fi

# Version used in artifact filenames — keep leading 'v' to match lemonade expectations
# e.g. v1.8.4 → v1.8.4, b1234 → b1234
VERSION="${TAG_NAME}"

echo "name=$TAG_NAME" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "should_release=$SHOULD_RELEASE" >> $GITHUB_OUTPUT
echo "is_full_build=$IS_FULL_BUILD" >> $GITHUB_OUTPUT

# ════════════════════════════════════════════════════════════════════════════════
# 1. ROCm matrix (Linux + Windows per GFX target)
# ════════════════════════════════════════════════════════════════════════════════
prepare-rocm-matrix:
runs-on: ubuntu-latest
if: needs.determine-tag.outputs.is_full_build == 'true'
needs: determine-tag
outputs:
ubuntu_matrix: ${{ steps.m.outputs.ubuntu_matrix }}
windows_matrix: ${{ steps.m.outputs.windows_matrix }}
Expand All @@ -142,6 +168,7 @@ jobs:
# ════════════════════════════════════════════════════════════════════════════════
linux-rocm:
runs-on: ubuntu-22.04
if: needs.determine-tag.outputs.is_full_build == 'true'
needs: [determine-tag, prepare-rocm-matrix]
strategy:
matrix: ${{ fromJson(needs.prepare-rocm-matrix.outputs.ubuntu_matrix) }}
Expand Down Expand Up @@ -1223,6 +1250,12 @@ jobs:
if: |
always() &&
needs.determine-tag.outputs.should_release == 'true' &&
(needs.linux-rocm.result == 'success' || needs.linux-rocm.result == 'skipped') &&
(needs.windows-rocm.result == 'success' || needs.windows-rocm.result == 'skipped') &&
(needs.linux-vulkan.result == 'success' || needs.linux-vulkan.result == 'skipped') &&
(needs.windows-vulkan.result == 'success' || needs.windows-vulkan.result == 'skipped') &&
(needs.linux-cpu.result == 'success' || needs.linux-cpu.result == 'skipped') &&
(needs.windows-cpu.result == 'success' || needs.windows-cpu.result == 'skipped') &&
(needs.test-cpu-windows.result == 'success' || needs.test-cpu-windows.result == 'skipped') &&
(needs.test-cpu-linux.result == 'success' || needs.test-cpu-linux.result == 'skipped') &&
(needs.test-vulkan-windows.result == 'success' || needs.test-vulkan-windows.result == 'skipped') &&
Expand Down Expand Up @@ -1272,12 +1305,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${{ needs.determine-tag.outputs.tag_name }}"
RELEASE_ID=$(gh api repos/${{ github.repository }}/releases/tags/"$TAG" --jq '.id' 2>/dev/null || true)
if [ -n "$RELEASE_ID" ]; then
echo "Deleting existing release $RELEASE_ID for tag $TAG"
gh api -X DELETE repos/${{ github.repository }}/releases/"$RELEASE_ID"
fi
git push --delete origin "refs/tags/$TAG" 2>/dev/null || true
gh release delete "$TAG" --yes --cleanup-tag --repo ${{ github.repository }} 2>/dev/null || true

- name: Create release
id: create_release
Expand Down Expand Up @@ -1313,28 +1341,30 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const path = require('path');
const id = '${{ steps.create_release.outputs.id }}';
const fs = require('fs');
const id = '${{ steps.create_release.outputs.id }}';
if (!id) throw new Error('create_release did not produce a release ID');
for (const file of fs.readdirSync('./release')) {
if (!file.endsWith('.zip') && !file.endsWith('.tar.gz')) continue;
console.log('Uploading:', file);
const stat = fs.statSync(`./release/${file}`);
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: id,
name: file,
data: fs.readFileSync(`./release/${file}`),
data: fs.createReadStream(`./release/${file}`),
headers: { 'content-length': stat.size, 'content-type': 'application/octet-stream' },
});
}

- name: Update README download links
run: |
TAG="${{ needs.determine-tag.outputs.tag_name }}"
# Replace the placeholder tag in all download URLs with the actual release tag
sed -i "s|/releases/download/[^/]*/whisper-[^-]*-|/releases/download/${TAG}/whisper-${TAG}-|g" README.md
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md
git diff --cached --quiet || git commit -m "docs: update download links to ${TAG}"
git pull --rebase origin master 2>/dev/null || git pull --rebase origin main
git push
59 changes: 58 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,57 @@ 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()

#
Expand Down Expand Up @@ -111,6 +162,8 @@ if (WHISPER_VITISAI)
add_library(${TARGET} OBJECT
vitisai/whisper-vitisai-encoder.h
vitisai/whisper-vitisai-encoder.cpp
vitisai/whisper-vitisai-helpers.h
vitisai/whisper-vitisai-helpers.cpp
)

target_include_directories(${TARGET} PUBLIC
Expand All @@ -120,11 +173,15 @@ if (WHISPER_VITISAI)
set_property(TARGET ${TARGET} PROPERTY POSITION_INDEPENDENT_CODE ON)
set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DWHISPER_USE_VITISAI)

# C++17 required for MSVC (FlexML headers use structured bindings etc.)
# Add C++17 standard for MSVC
if (MSVC)
target_compile_options(${TARGET} PRIVATE /std:c++17)
endif()

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()
Expand Down
Loading
Loading