Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
93 changes: 23 additions & 70 deletions .github/workflows/react_native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,11 @@ jobs:
cp tools/ci_build/github/js/react_native_e2e_full_aar_build_settings.json ${{ runner.temp }}/.build_settings/build_settings.json

python3 -m pip install --user -r ${{ github.workspace }}/tools/ci_build/requirements/pybind/requirements.txt
python3 ${{ github.workspace }}/tools/ci_build/github/android/build_aar_package.py --build_dir ${{ runner.temp }} --config Release --android_sdk_path $ANDROID_SDK_ROOT --android_ndk_path $ANDROID_NDK_ROOT ${{ runner.temp }}/.build_settings/build_settings.json

python3 ${{ github.workspace }}/tools/ci_build/github/android/build_aar_package.py --build_dir ${{ runner.temp }} --config Release --android_sdk_path $ANDROID_SDK_ROOT --android_ndk_path $ANDROID_NDK_ROOT ${{ runner.temp }}/.build_settings/build_settings.json

# Copy the built artifacts to give folder for publishing
BASE_PATH=${{ runner.temp }}/aar_out/Release/com/microsoft/onnxruntime/onnxruntime-android/${OnnxRuntimeVersion}
cp ${BASE_PATH}/*.jar ${{ runner.temp }}/artifacts
cp ${BASE_PATH}/*.aar ${{ runner.temp }}/artifacts
cp ${BASE_PATH}/*.pom ${{ runner.temp }}/artifacts
cp -r ${{ runner.temp }}/aar_out/Release/com ${{ runner.temp }}/artifacts

- name: Upload Android AAR Artifact
uses: actions/upload-artifact@v5
Expand Down Expand Up @@ -109,10 +106,8 @@ jobs:

- name: Copy AAR to React Native and E2E directories
run: |
mkdir -p ${{ github.workspace }}/js/react_native/android/libs
cp ${{ runner.temp }}/android-full-aar/*.aar ${{ github.workspace }}/js/react_native/android/libs
mkdir -p ${{ github.workspace }}/js/react_native/e2e/android/app/libs
cp ${{ runner.temp }}/android-full-aar/*.aar ${{ github.workspace }}/js/react_native/e2e/android/app/libs
cp -r ${{ runner.temp }}/android-full-aar/com ${{ github.workspace }}/js/react_native/e2e/android/app/libs

- name: Install dependencies and bootstrap
run: |
Expand Down Expand Up @@ -141,10 +136,6 @@ jobs:
with:
ndk-version: 28.0.13004108

- name: Run React Native Android Instrumented Tests
run: ./gradlew connectedDebugAndroidTest --stacktrace
working-directory: ${{ github.workspace }}/js/react_native/android

- name: Run React Native Detox Android e2e Tests
run: |
JEST_JUNIT_OUTPUT_FILE=${{ github.workspace }}/js/react_native/e2e/android-test-results.xml \
Expand All @@ -169,6 +160,15 @@ jobs:
echo "Emulator PID file was expected to exist but does not."
fi

- name: Upload Android Test Results
if: always()
uses: actions/upload-artifact@v5
with:
name: android-test-results
path: |
${{ github.workspace }}/js/react_native/e2e/android-test-results.xml
${{ github.workspace }}/js/react_native/e2e/artifacts

react_native_ci_ios_build:
name: React Native CI iOS Build
runs-on: macos-14
Expand Down Expand Up @@ -211,62 +211,6 @@ jobs:
name: ios_pod
path: ${{ runner.temp }}/ios_pod

react_native_ci_ios_unit_tests:
name: React Native CI iOS Unit Tests
needs: react_native_ci_ios_build
runs-on: macos-14
timeout-minutes: 90
steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Download iOS pod artifact
uses: actions/download-artifact@v6
with:
name: ios_pod
path: ${{ runner.temp }}/ios_pod

- name: Use Xcode 15.3.0
run: sudo xcode-select --switch /Applications/Xcode_15.3.0.app/Contents/Developer

- name: Use Node.js 22.x
uses: actions/setup-node@v6
with:
node-version: '22.x'

- uses: microsoft/onnxruntime-github-actions/setup-build-tools@v0.0.9
with:
vcpkg-version: '2025.06.13'
vcpkg-hash: 735923258c5187966698f98ce0f1393b8adc6f84d44fd8829dda7db52828639331764ecf41f50c8e881e497b569f463dbd02dcb027ee9d9ede0711102de256cc
cmake-version: '3.31.8'
cmake-hash: 99cc9c63ae49f21253efb5921de2ba84ce136018abf08632c92c060ba91d552e0f6acc214e9ba8123dee0cf6d1cf089ca389e321879fd9d719a60d975bcffcc8
add-cmake-to-path: 'true'
disable-terrapin: 'true'

- name: Install dependencies and bootstrap
run: |
npm ci
working-directory: ${{ github.workspace }}/js
- run: npm ci
working-directory: ${{ github.workspace }}/js/common
- run: |
set -e -x
npm ci
npm run bootstrap-no-pods
working-directory: ${{ github.workspace }}/js/react_native

- name: Pod install
run: |
set -e -x
ls ${{ runner.temp }}/ios_pod/onnxruntime-c
ORT_C_LOCAL_POD_PATH=${{ runner.temp }}/ios_pod/onnxruntime-c pod install --verbose
working-directory: ${{ github.workspace }}/js/react_native/ios

- name: Run React Native iOS Instrumented Tests
run: |
/usr/bin/xcodebuild -sdk iphonesimulator -configuration Debug -workspace ${{ github.workspace }}/js/react_native/ios/OnnxruntimeModule.xcworkspace -scheme OnnxruntimeModuleTest -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4' test CODE_SIGNING_ALLOWED=NO
working-directory: ${{ github.workspace }}/js/react_native/ios

react_native_ci_ios_e2e_tests:
name: React Native CI iOS E2E Tests
needs: react_native_ci_ios_build
Expand Down Expand Up @@ -314,7 +258,7 @@ jobs:
npm ci
npm run bootstrap-no-pods
working-directory: ${{ github.workspace }}/js/react_native

- name: Pod install for e2e tests
run: |
set -e -x
Expand All @@ -331,3 +275,12 @@ jobs:
--loglevel verbose \
--take-screenshots failing
working-directory: ${{ github.workspace }}/js/react_native/e2e

- name: Upload iOS Test Results
if: always()
uses: actions/upload-artifact@v5
with:
name: ios-test-results
path: |
${{ github.workspace }}/js/react_native/e2e/ios-test-results.xml
${{ github.workspace }}/js/react_native/e2e/artifacts
2 changes: 1 addition & 1 deletion .github/workflows/windows_x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
working-directory: ${{ github.workspace }}

- name: Use .NET 8.x
uses: actions/setup-dotnet@v5
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
env:
Expand Down
4 changes: 3 additions & 1 deletion cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,9 @@ if (onnxruntime_USE_QNN OR onnxruntime_USE_QNN_INTERFACE)
if (${QNN_ARCH_ABI} STREQUAL "aarch64-windows-msvc" OR ${QNN_ARCH_ABI} STREQUAL "arm64x-windows-msvc")
file(GLOB EXTRA_HTP_LIB LIST_DIRECTORIES false "${onnxruntime_QNN_HOME}/lib/hexagon-v68/unsigned/libQnnHtpV68Skel.so"
"${onnxruntime_QNN_HOME}/lib/hexagon-v73/unsigned/libQnnHtpV73Skel.so"
"${onnxruntime_QNN_HOME}/lib/hexagon-v73/unsigned/libqnnhtpv73.cat")
"${onnxruntime_QNN_HOME}/lib/hexagon-v73/unsigned/libqnnhtpv73.cat"
"${onnxruntime_QNN_HOME}/lib/hexagon-v81/unsigned/libQnnHtpV81Skel.so"
"${onnxruntime_QNN_HOME}/lib/hexagon-v81/unsigned/libqnnhtpv81.cat")
list(APPEND QNN_LIB_FILES ${EXTRA_HTP_LIB})
endif()
message(STATUS "QNN lib files: " ${QNN_LIB_FILES})
Expand Down
1 change: 1 addition & 0 deletions include/onnxruntime/core/session/onnxruntime_c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -3937,6 +3937,7 @@ struct OrtApi {
* -# "69"
* -# "73"
* -# "75"
* -# "81"
* "device_id": The ID of the device to use when setting 'htp_arch'. Defaults to "0" (for single device).
* "enable_htp_fp16_precision": Used for float32 model for HTP backend.
* Enable the float32 model to be inferenced with fp16 precision. Otherwise, it will be fp32 precision.
Expand Down
14 changes: 14 additions & 0 deletions js/common/lib/inference-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,20 @@ export declare namespace InferenceSession {
*/
forceCpuNodeNames?: readonly string[];

/**
* Specify the validation mode for WebGPU execution provider.
* - 'disabled': Disable all validation.
* When used in Node.js, disable validation may cause process crash if WebGPU errors occur. Be cautious when using
* this mode.
* When used in web, this mode is equivalent to 'wgpuOnly'.
* - 'wgpuOnly': Perform WebGPU internal validation only.
* - 'basic': Perform basic validation including WebGPU internal validation. This is the default mode.
* - 'full': Perform full validation. This mode may have performance impact. Use it for debugging purpose.
*
* @default 'basic'
*/
validationMode?: 'disabled' | 'wgpuOnly' | 'basic' | 'full';

/**
* Specify an optional WebGPU device to be used by the WebGPU execution provider.
*/
Expand Down
12 changes: 6 additions & 6 deletions js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 83 additions & 21 deletions js/react_native/android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,99 @@
project(OnnxruntimeJSIHelper)
project(OnnxruntimeJSI)
cmake_minimum_required(VERSION 3.9.0)

set (PACKAGE_NAME "onnxruntime-react-native")
set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
set(PACKAGE_NAME "onnxruntime-react-native")
set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)

file(TO_CMAKE_PATH "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/jsi.cpp" libPath)
option(ORT_EXTENSIONS_ENABLED "Enable Ort Extensions" NO)
option(USE_NNAPI "Use NNAPI" YES)
option(USE_QNN "Use QNN" NO)

file(GLOB libfbjni_link_DIRS "${BUILD_DIR}/fbjni-*.aar/jni/${ANDROID_ABI}")
file(GLOB libfbjni_include_DIRS "${BUILD_DIR}/fbjni-*-headers.jar/")

file(GLOB onnxruntime_include_DIRS
"${BUILD_DIR}/onnxruntime-android-*.aar/headers")
file(GLOB onnxruntime_link_DIRS
"${BUILD_DIR}/onnxruntime-android-*.aar/jni/${ANDROID_ABI}/")

if(ORT_EXTENSIONS_ENABLED)
add_definitions(-DORT_ENABLE_EXTENSIONS)
endif()

if(USE_QNN)
add_definitions(-DUSE_QNN)
endif()

if(USE_NNAPI)
add_definitions(-DUSE_NNAPI)
endif()

file(TO_CMAKE_PATH
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/jsi.cpp" libPath)

find_package(fbjni REQUIRED CONFIG)
find_package(ReactAndroid REQUIRED CONFIG)

find_library(
onnxruntime-lib onnxruntime
PATHS ${onnxruntime_link_DIRS}
NO_CMAKE_FIND_ROOT_PATH)

set(RN_INCLUDES
"${NODE_MODULES_DIR}/react-native/React"
"${NODE_MODULES_DIR}/react-native/React/Base"
"${NODE_MODULES_DIR}/react-native/ReactCommon"
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker")

if(${REACT_NATIVE_VERSION} VERSION_GREATER_EQUAL "0.76")
set(RN_LIBS
ReactAndroid::reactnative
ReactAndroid::jsi)
else()
list(
APPEND
RN_INCLUDES
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni"
)
set(RN_LIBS
ReactAndroid::jsi
ReactAndroid::react_nativemodule_core
ReactAndroid::turbomodulejsijni)
endif()

include_directories(
"${NODE_MODULES_DIR}/react-native/React"
"${NODE_MODULES_DIR}/react-native/React/Base"
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
)
../cpp
${RN_INCLUDES}
${onnxruntime_include_DIRS}
${libfbjni_include_DIRS})

add_library(onnxruntimejsihelper
SHARED
${libPath}
src/main/cpp/cpp-adapter.cpp
)
add_library(
onnxruntimejsi SHARED
${libPath}
src/main/cpp/cpp-adapter.cpp
../cpp/JsiMain.cpp
../cpp/InferenceSessionHostObject.cpp
../cpp/JsiUtils.cpp
../cpp/SessionUtils.cpp
../cpp/TensorUtils.cpp)

# Configure C++ 17
set_target_properties(
onnxruntimejsihelper PROPERTIES
CXX_STANDARD 17
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
)
onnxruntimejsi
PROPERTIES CXX_STANDARD 17
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON)

find_library(log-lib log)

target_link_libraries(
onnxruntimejsihelper
${log-lib} # <-- Logcat logger
android # <-- Android JNI core
onnxruntimejsi
${onnxruntime-lib}
fbjni::fbjni
${RN_LIBS}
${log-lib} # <-- Logcat logger
android # <-- Android JNI core
)
Loading
Loading