Skip to content

Commit

Permalink
Merge branch 'main' into kvaishnavi/whisper-separate-export
Browse files Browse the repository at this point in the history
  • Loading branch information
kunal-vaishnavi committed Jan 24, 2025
2 parents 9640736 + 06fc73b commit 75a342a
Show file tree
Hide file tree
Showing 1,240 changed files with 39,085 additions and 12,541 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
--use_xnnpack \
--use_binskim_compliant_compile_flags \
--ios \
--apple_deploy_target=13.0 \
--apple_deploy_target=15.1 \
--apple_sysroot=iphonesimulator \
--osx_arch=${{ matrix.target_arch }}
Expand All @@ -117,17 +117,21 @@ jobs:
with:
python-version: ${{ env.python_version }}

- name: "Run Homebrew"
run: brew install autoconf automake autoconf-archive

- name: "Run vcpkg(x64-osx)"
uses: lukka/run-vcpkg@v11
with:
vcpkgDirectory: "${{ runner.temp }}/vcpkg"
vcpkgGitCommitId: "1de2026f28ead93ff1773e6e680387643e914ea1" # 2024.07.12
runVcpkgInstall: true
vcpkgGitCommitId: "b322364f06308bdd24823f9d8f03fe0cc86fd46f" # 2024.12.16
runVcpkgInstall: true # vcpkg install --x-manifest-root cmake --x-install-root .build --overlay-triplets cmake/vcpkg-triplets/default
vcpkgJsonGlob: "cmake/vcpkg.json"
vcpkgConfigurationJsonGlob: "cmake/vcpkg-configuration.json"
env:
VCPKG_INSTALLED_DIR: "${{ github.workspace }}/.build"
VCPKG_DEFAULT_TRIPLET: "x64-osx"
VCPKG_OVERLAY_TRIPLETS: "${{ github.workspace }}/cmake/vcpkg-triplets/default"
# VCPKG_BINARY_SOURCES: "default" # https://learn.microsoft.com/en-us/vcpkg/reference/binarycaching

- name: "Run compile_schema.py"
Expand Down Expand Up @@ -163,19 +167,22 @@ jobs:
--cmake_extra_defines "VCPKG_TARGET_TRIPLET=x64-osx" \
--cmake_extra_defines "VCPKG_INSTALLED_DIR:PATH=${{ github.workspace }}/.build" \
--cmake_extra_defines "VCPKG_INSTALL_OPTIONS=--x-feature=tests"
env:
VCPKG_OVERLAY_TRIPLETS: "${{ github.workspace }}/cmake/vcpkg-triplets/default"
shell: bash

- name: "Run vcpkg(arm64-osx)"
uses: lukka/run-vcpkg@v11
with:
vcpkgDirectory: "${{ runner.temp }}/vcpkg"
vcpkgGitCommitId: "1de2026f28ead93ff1773e6e680387643e914ea1" # 2024.07.12
runVcpkgInstall: true
doNotUpdateVcpkg: true
runVcpkgInstall: true # vcpkg install --x-manifest-root cmake --x-install-root .build --overlay-triplets cmake/vcpkg-triplets/default
vcpkgJsonGlob: "cmake/vcpkg.json"
vcpkgConfigurationJsonGlob: "cmake/vcpkg-configuration.json"
env:
VCPKG_INSTALLED_DIR: "${{ github.workspace }}/.build"
VCPKG_DEFAULT_TRIPLET: "arm64-osx"
VCPKG_OVERLAY_TRIPLETS: "${{ github.workspace }}/cmake/vcpkg-triplets/default"
# VCPKG_BINARY_SOURCES: "default" # https://learn.microsoft.com/en-us/vcpkg/reference/binarycaching

- name: "Run build.py(arm64-osx)"
Expand All @@ -193,6 +200,8 @@ jobs:
--cmake_extra_defines "VCPKG_TARGET_TRIPLET=arm64-osx" \
--cmake_extra_defines "VCPKG_INSTALLED_DIR:PATH=${{ github.workspace }}/.build" \
--cmake_extra_defines "VCPKG_INSTALL_OPTIONS=--x-feature=tests"
env:
VCPKG_OVERLAY_TRIPLETS: "${{ github.workspace }}/cmake/vcpkg-triplets/default"
shell: bash

Objective-C-StaticAnalysis:
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ jobs:
uses: lukka/run-vcpkg@v11
with:
vcpkgDirectory: "C:/vcpkg" # use VCPKG_INSTALLATION_ROOT of the image
runVcpkgInstall: true
vcpkgGitCommitId: "b322364f06308bdd24823f9d8f03fe0cc86fd46f" # 2024.12.16
runVcpkgInstall: true # vcpkg install --x-manifest-root cmake --x-install-root .build --overlay-triplets cmake/vcpkg-triplets/default
vcpkgJsonGlob: "cmake/vcpkg.json"
vcpkgConfigurationJsonGlob: "cmake/vcpkg-configuration.json"
env:
VCPKG_INSTALLED_DIR: "${{ github.workspace }}/.build"
VCPKG_DEFAULT_TRIPLET: "x64-windows"
VCPKG_OVERLAY_TRIPLETS: "${{ github.workspace }}/cmake/vcpkg-triplets/default"
# VCPKG_BINARY_SOURCES: "default" # https://learn.microsoft.com/en-us/vcpkg/reference/binarycaching

- name: "Run compile_schema.py"
Expand Down Expand Up @@ -99,19 +101,22 @@ jobs:
--cmake_extra_defines "VCPKG_TARGET_TRIPLET=x64-windows" `
--cmake_extra_defines "VCPKG_INSTALLED_DIR:PATH=${{ github.workspace }}/.build" `
--cmake_extra_defines "VCPKG_INSTALL_OPTIONS=--x-feature=tests"
env:
VCPKG_OVERLAY_TRIPLETS: "${{ github.workspace }}/cmake/vcpkg-triplets/default"
shell: pwsh

- name: "Run vcpkg(arm64-windows)"
uses: lukka/run-vcpkg@v11
with:
vcpkgDirectory: "C:/vcpkg" # use VCPKG_INSTALLATION_ROOT of the image
doNotUpdateVcpkg: true
runVcpkgInstall: true
runVcpkgInstall: true # vcpkg install --x-manifest-root cmake --x-install-root .build --overlay-triplets cmake/vcpkg-triplets/default
vcpkgJsonGlob: "cmake/vcpkg.json"
vcpkgConfigurationJsonGlob: "cmake/vcpkg-configuration.json"
env:
VCPKG_INSTALLED_DIR: "${{ github.workspace }}/.build"
VCPKG_DEFAULT_TRIPLET: "arm64-windows"
VCPKG_OVERLAY_TRIPLETS: "${{ github.workspace }}/cmake/vcpkg-triplets/default"
# VCPKG_BINARY_SOURCES: "default" # https://learn.microsoft.com/en-us/vcpkg/reference/binarycaching

- name: "Run build.py(arm64-windows)"
Expand All @@ -128,4 +133,6 @@ jobs:
--cmake_extra_defines "VCPKG_TARGET_TRIPLET=arm64-windows" `
--cmake_extra_defines "VCPKG_INSTALLED_DIR:PATH=${{ github.workspace }}/.build" `
--cmake_extra_defines "VCPKG_INSTALL_OPTIONS=--x-feature=tests"
env:
VCPKG_OVERLAY_TRIPLETS: "${{ github.workspace }}/cmake/vcpkg-triplets/default"
shell: pwsh
4 changes: 2 additions & 2 deletions .lintrunner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ is_formatter = true


[[linter]]
code = 'BLACK-ISORT'
code = 'RUFF-FORMAT'
include_patterns = [
'**/*.py',
]
Expand All @@ -76,7 +76,7 @@ command = [
'-m',
'lintrunner_adapters',
'run',
'black_isort_linter',
'ruff_format_linter',
'--',
'@{{PATHSFILE}}'
]
Expand Down
12 changes: 6 additions & 6 deletions cgmanifests/generated/cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "595228d99e3977ac27cb79d5963adda262af99ad",
"commitHash": "b8baa8446686496da4cc8fda09f2b6fe65c2a02c",
"repositoryUrl": "https://github.com/onnx/onnx.git"
},
"comments": "git submodule at cmake/external/onnx"
Expand Down Expand Up @@ -136,7 +136,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "309b75c9e56e0a674bf78d59872ce131f814dfb6",
"commitHash": "fe98e0b93565382648129271381c14d6205255e3",
"repositoryUrl": "https://github.com/google/XNNPACK.git"
},
"comments": "googlexnnpack"
Expand Down Expand Up @@ -226,8 +226,8 @@
"component": {
"type": "git",
"git": {
"commitHash": "4fe0e1e183925bf8cfa6aae24237e724a96479b8",
"repositoryUrl": "https://github.com/Maratyszcza/pthreadpool.git"
"commitHash": "4e80ca24521aa0fb3a746f9ea9c3eaa20e9afbb0",
"repositoryUrl": "https://github.com/google/pthreadpool.git"
},
"comments": "pthreadpool"
}
Expand All @@ -246,7 +246,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "ca678952a9a8eaa6de112d154e8e104b22f9ab3f",
"commitHash": "8a1772a0c5c447df2d18edf33ec4603a8c9c04a6",
"repositoryUrl": "https://github.com/pytorch/cpuinfo.git"
},
"comments": "pytorch_cpuinfo"
Expand Down Expand Up @@ -306,7 +306,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "94142d8391c9791ec71c38336436319a2d4ac7a0",
"commitHash": "f3f6caa6e8adb420e005ec41c6fefc8d75affb6e",
"repositoryUrl": "https://github.com/microsoft/onnxruntime-extensions.git"
},
"comments": "extensions"
Expand Down
80 changes: 76 additions & 4 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ option(onnxruntime_USE_OPENVINO "Build with OpenVINO support" OFF)
option(onnxruntime_USE_COREML "Build with CoreML support" OFF)
option(onnxruntime_USE_NNAPI_BUILTIN "Build with builtin NNAPI lib for Android NNAPI support" OFF)
option(onnxruntime_USE_QNN "Build with QNN support" OFF)
option(onnxruntime_BUILD_QNN_EP_STATIC_LIB "Build with QNN EP as a static library" OFF)
option(onnxruntime_USE_SNPE "Build with SNPE support" OFF)
option(onnxruntime_USE_RKNPU "Build with RKNPU support" OFF)
option(onnxruntime_USE_DNNL "Build with DNNL support" OFF)
Expand Down Expand Up @@ -371,6 +372,70 @@ if (onnxruntime_USE_ROCM)
set(onnxruntime_HIPIFY_PERL ${HIPIFY_PERL_PATH}/hipify-perl)
endif()

# replicate strategy used by pytorch to get ROCM_VERSION
# https://github.com/pytorch/pytorch/blob/1a10751731784942dcbb9c0524c1369a29d45244/cmake/public/LoadHIP.cmake#L45-L109
# with modification
set(ROCM_INCLUDE_DIRS "${onnxruntime_ROCM_HOME}/include")
set(PROJECT_RANDOM_BINARY_DIR "${CMAKE_BINARY_DIR}")
set(file "${CMAKE_BINARY_DIR}/detect_rocm_version.cc")

# Find ROCM version for checks
# ROCM 5.0 and later will have header api for version management
if(EXISTS ${ROCM_INCLUDE_DIRS}/rocm_version.h)
file(WRITE ${file} ""
"#include <rocm_version.h>\n"
)
elseif(EXISTS ${ROCM_INCLUDE_DIRS}/rocm-core/rocm_version.h)
file(WRITE ${file} ""
"#include <rocm-core/rocm_version.h>\n"
)
else()
message(FATAL_ERROR "********************* rocm_version.h couldnt be found ******************\n")
endif()

file(APPEND ${file} ""
"#include <cstdio>\n"

"#ifndef ROCM_VERSION_PATCH\n"
"#define ROCM_VERSION_PATCH 0\n"
"#endif\n"
"#define STRINGIFYHELPER(x) #x\n"
"#define STRINGIFY(x) STRINGIFYHELPER(x)\n"
"int main() {\n"
" printf(\"%d.%d.%s\", ROCM_VERSION_MAJOR, ROCM_VERSION_MINOR, STRINGIFY(ROCM_VERSION_PATCH));\n"
" return 0;\n"
"}\n"
)

try_run(run_result compile_result ${PROJECT_RANDOM_BINARY_DIR} ${file}
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${ROCM_INCLUDE_DIRS}"
RUN_OUTPUT_VARIABLE rocm_version_from_header
COMPILE_OUTPUT_VARIABLE output_var
)
# We expect the compile to be successful if the include directory exists.
if(NOT compile_result)
message(FATAL_ERROR "ROCM: Couldn't determine version from header: " ${output_var})
endif()
message(STATUS "ROCM: Header version is: " ${rocm_version_from_header})
set(ROCM_VERSION_DEV_RAW ${rocm_version_from_header})

string(REGEX MATCH "^([0-9]+)\.([0-9]+)\.([0-9]+).*$" ROCM_VERSION_DEV_MATCH ${ROCM_VERSION_DEV_RAW})

if (ROCM_VERSION_DEV_MATCH)
set(ROCM_VERSION_DEV_MAJOR ${CMAKE_MATCH_1})
set(ROCM_VERSION_DEV_MINOR ${CMAKE_MATCH_2})
set(ROCM_VERSION_DEV_PATCH ${CMAKE_MATCH_3})
set(ROCM_VERSION_DEV "${ROCM_VERSION_DEV_MAJOR}.${ROCM_VERSION_DEV_MINOR}.${ROCM_VERSION_DEV_PATCH}")
math(EXPR ROCM_VERSION_DEV_INT "(${ROCM_VERSION_DEV_MAJOR}*10000) + (${ROCM_VERSION_DEV_MINOR}*100) + ${ROCM_VERSION_DEV_PATCH}")
else()
message(FATAL_ERROR "Cannot determine ROCm version string")
endif()
message("\n***** ROCm version from rocm_version.h ****\n")
message("ROCM_VERSION_DEV: ${ROCM_VERSION_DEV}")
message("ROCM_VERSION_DEV_MAJOR: ${ROCM_VERSION_DEV_MAJOR}")
message("ROCM_VERSION_DEV_MINOR: ${ROCM_VERSION_DEV_MINOR}")
message("ROCM_VERSION_DEV_PATCH: ${ROCM_VERSION_DEV_PATCH}")
message("ROCM_VERSION_DEV_INT: ${ROCM_VERSION_DEV_INT}")
message("\n***** HIP LANGUAGE CONFIG INFO ****\n")
message("CMAKE_HIP_COMPILER: ${CMAKE_HIP_COMPILER}")
message("CMAKE_HIP_ARCHITECTURES: ${CMAKE_HIP_ARCHITECTURES}")
Expand Down Expand Up @@ -534,6 +599,11 @@ if (onnxruntime_EXTENDED_MINIMAL_BUILD AND NOT onnxruntime_MINIMAL_BUILD)
set(onnxruntime_MINIMAL_BUILD ON)
endif()

set(REPO_ROOT ${PROJECT_SOURCE_DIR}/..)
set(ONNXRUNTIME_ROOT ${PROJECT_SOURCE_DIR}/../onnxruntime)
set(ORTTRAINING_ROOT ${PROJECT_SOURCE_DIR}/../orttraining)
set(ORTTRAINING_SOURCE_DIR ${ORTTRAINING_ROOT}/orttraining)

include(adjust_global_compile_flags.cmake)

if (APPLE)
Expand Down Expand Up @@ -565,10 +635,6 @@ if (NOT MSVC AND NOT (CMAKE_SYSTEM_NAME STREQUAL "iOS"))
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endif()

set(REPO_ROOT ${PROJECT_SOURCE_DIR}/..)
set(ONNXRUNTIME_ROOT ${PROJECT_SOURCE_DIR}/../onnxruntime)
set(ORTTRAINING_ROOT ${PROJECT_SOURCE_DIR}/../orttraining)
set(ORTTRAINING_SOURCE_DIR ${ORTTRAINING_ROOT}/orttraining)

file (STRINGS "${REPO_ROOT}/VERSION_NUMBER" ORT_VERSION)

Expand Down Expand Up @@ -679,6 +745,7 @@ else()
check_cxx_compiler_flag(-Wdeprecated-builtins HAS_DEPRECATED_BUILTINS)
check_cxx_compiler_flag(-Wdeprecated-copy HAS_DEPRECATED_COPY)
check_cxx_compiler_flag(-Wdeprecated-declarations HAS_DEPRECATED_DECLARATIONS)
check_cxx_compiler_flag(-Wdeprecated-literal-operator HAS_DEPRECATED_LITERAL_OPERATOR)
check_cxx_compiler_flag(-Wdeprecated-this-capture HAS_DEPRECATED_THIS_CAPTURE)
check_cxx_compiler_flag(-Wenum-constexpr-conversion HAS_ENUM_CONSTEXPR_CONVERSION)
check_cxx_compiler_flag(-Wformat-truncation HAS_FORMAT_TRUNCATION)
Expand Down Expand Up @@ -735,6 +802,9 @@ else()
if (HAS_DEPRECATED_BUILTINS)
list(APPEND ORT_WARNING_FLAGS -Wno-deprecated-builtins)
endif()
if (HAS_DEPRECATED_LITERAL_OPERATOR)
list(APPEND ORT_WARNING_FLAGS -Wno-deprecated-literal-operator)
endif()
#see:https://reviews.llvm.org/D131307
#It was intended that the 'enum-constexpr-conversion' type warnings can not be silenced by -w
if(HAS_ENUM_CONSTEXPR_CONVERSION AND NOT Protobuf_FOUND)
Expand Down Expand Up @@ -1138,6 +1208,8 @@ function(onnxruntime_set_compile_flags target_name)
# because we may mix gcc and hipclang
set(ORT_HIP_WARNING_FLAGS ${ORT_WARNING_FLAGS})
list(REMOVE_ITEM ORT_HIP_WARNING_FLAGS -Wno-nonnull-compare)
# Unsupported by Clang 18 yet.
list(REMOVE_ITEM ORT_HIP_WARNING_FLAGS -Wno-dangling-reference)

# float16.h:90:12: error: ‘tmp’ is used uninitialized
list(APPEND ORT_HIP_WARNING_FLAGS -Wno-uninitialized)
Expand Down
1 change: 1 addition & 0 deletions cmake/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"VCPKG_INSTALLED_DIR": "${sourceParentDir}/.build"
},
"environment": {
"VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/vcpkg-triplets",
"VCPKG_FEATURE_FLGAS": "manifests,versions"
}
},
Expand Down
17 changes: 8 additions & 9 deletions cmake/adjust_global_compile_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ if (ANDROID)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,max-page-size=16384")
endif()

# Suggested by https://gitlab.kitware.com/cmake/cmake/-/issues/20132
# MacCatalyst is not well supported in CMake
# The error that can emerge without this flag can look like:
# "clang : error : overriding '-mmacosx-version-min=11.0' option with '-target x86_64-apple-ios14.0-macabi' [-Werror,-Woverriding-t-option]"
if (PLATFORM_NAME STREQUAL "macabi")
add_compile_options(-Wno-overriding-t-option)
add_link_options(-Wno-overriding-t-option)
endif()

# Enable space optimization for gcc/clang
# Cannot use "-ffunction-sections -fdata-sections" if we enable bitcode (iOS)
if (NOT MSVC AND NOT onnxruntime_ENABLE_BITCODE)
Expand Down Expand Up @@ -338,6 +329,10 @@ else()
# suppress warnings from flatbuffers
string(APPEND CMAKE_CXX_FLAGS " -Wno-restrict ")
string(APPEND CMAKE_C_FLAGS " -Wno-restrict ")
if(onnxruntime_USE_XNNPACK)
# https://github.com/google/XNNPACK/issues/7650
string(APPEND CMAKE_C_FLAGS " -Wno-incompatible-pointer-types ")
endif()
endif()
# Check support for AVX and f16c.
include(CheckCXXCompilerFlag)
Expand Down Expand Up @@ -374,3 +369,7 @@ if (WIN32)
elseif(LINUX)
add_compile_definitions("_GNU_SOURCE")
endif()

if (onnxruntime_USE_EXTENSIONS)
include_directories(${REPO_ROOT}/include/onnxruntime/core/session)
endif()
Loading

0 comments on commit 75a342a

Please sign in to comment.