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
12 changes: 8 additions & 4 deletions .ci/scripts/test_llava.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
set -exu
# shellcheck source=/dev/null

BUILD_TYPE=${1:-Debug}

echo "Building with BUILD_TYPE: $BUILD_TYPE"

if [[ -z "${PYTHON_EXECUTABLE:-}" ]]; then
PYTHON_EXECUTABLE=python3
fi

cmake_install_executorch_libraries() {
cmake \
-DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
Expand All @@ -27,7 +31,7 @@ cmake_install_executorch_libraries() {
-Bcmake-out .


cmake --build cmake-out -j9 --target install --config Debug
cmake --build cmake-out -j9 --target install --config ${BUILD_TYPE}
}

cmake_build_llava_runner() {
Expand All @@ -36,7 +40,7 @@ cmake_build_llava_runner() {

cmake \
-DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
-DEXECUTORCH_BUILD_XNNPACK=ON \
Expand All @@ -45,7 +49,7 @@ cmake_build_llava_runner() {
${dir}


cmake --build cmake-out/${dir} -j9 --config Debug
cmake --build cmake-out/${dir} -j9 --config ${BUILD_TYPE}
}

# only export the one without custom op for now since it's
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,34 @@ jobs:
# Test llama2
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_llama.sh stories110M "${BUILD_TOOL}" "${DTYPE}" "${MODE}"

test-llava-runner-macos:
name: test-llava-runner-macos
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
strategy:
fail-fast: false
with:
runner: macos-m1-stable
python-version: '3.11'
submodules: 'true'
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
timeout: 900
script: |
# The generic Linux job chooses to use base env, not the one setup by the image
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
conda activate "${CONDA_ENV}"

PYTHON_EXECUTABLE=python bash .ci/scripts/setup-macos.sh "cmake"

# install Llava requirements
bash examples/models/llama2/install_requirements.sh
bash examples/models/llava/install_requirements.sh

# run python unittest
python -m unittest examples.models.llava.test.test_llava

# run e2e (export, tokenizer and runner)
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llava.sh Release

test-qnn-model:
name: test-qnn-model
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
Expand Down
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -786,8 +786,12 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
endif()

add_executable(executor_runner ${_executor_runner__srcs})
if(CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT APPLE)
target_link_options(executor_runner PRIVATE "LINKER:--gc-sections")
if(CMAKE_BUILD_TYPE STREQUAL "Release")
if(APPLE)
target_link_options(executor_runner PRIVATE "LINKER:-dead_strip")
else()
target_link_options(executor_runner PRIVATE "LINKER:--gc-sections")
endif()
endif()
target_link_libraries(executor_runner ${_executor_runner_libs})
target_compile_options(executor_runner PUBLIC ${_common_compile_options})
Expand Down
6 changes: 5 additions & 1 deletion examples/models/llava/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ endif()

add_executable(llava_main ${_srcs})
if(CMAKE_BUILD_TYPE STREQUAL "Release")
target_link_options(llava_main PRIVATE "LINKER:--gc-sections,-s")
if(APPLE)
target_link_options(llava_main PRIVATE "LINKER:-dead_strip,-s")
else()
target_link_options(llava_main PRIVATE "LINKER:--gc-sections,-s")
endif()
endif()

target_include_directories(llava_main PUBLIC ${_common_include_directories})
Expand Down