Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
Build wheel from cached dnnl local (#303)
Browse files Browse the repository at this point in the history
Signed-off-by: Ding, Yi1 <[email protected]>
Signed-off-by: Wenxin Zhang <[email protected]>
Co-authored-by: Ding, Yi1 <[email protected]>
  • Loading branch information
VincyZhang and DDEle authored Sep 14, 2023
1 parent fb619e5 commit 7008ff7
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 24 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ jobs:
fi
docker run -dit --disable-content-trust --privileged --name=${{ env.CONTAINER_NAME }} -v /dev/shm:/dev/shm \
-v ${{ github.workspace }}:/intel-extension-for-transformers \
-v ~/.cache/oneAPI:/cache \
${{ env.REPO_NAME }}:${{ env.REPO_TAG }}
- name: Env build
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/optimize-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:
fi
docker run -dit --disable-content-trust --privileged --name=${{ env.CONTAINER_NAME }} -v /dev/shm:/dev/shm \
-v ${{ github.workspace }}:/intel-extension-for-transformers \
-v ~/.cache/oneAPI:/cache \
${{ env.REPO_NAME }}:${{ env.REPO_TAG }}
- name: Env build
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/script/install_binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
source /intel-extension-for-transformers/.github/workflows/script/change_color.sh

cd /intel-extension-for-transformers
export CMAKE_ARGS="-DNE_DNNL_CACHE_DIR=/cache"
$BOLD_YELLOW && echo "---------------- git submodule update --init --recursive -------------" && $RESET
git config --global --add safe.directory "*"
git submodule update --init --recursive
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/script/unitTest/run_unit_test_engine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function pytest() {

cd ${WORKING_DIR}/test/pytest
engine_path=$(python -c 'import intel_extension_for_transformers; import os; print(os.path.dirname(intel_extension_for_transformers.__file__))')
#engine_path="${engine_path}/llm/runtime"
engine_path="${engine_path}/llm/runtime"
echo "engine path is ${engine_path}"
find . -name "test*.py" | sed 's,\.\/,coverage run --source='"${engine_path}"' --append ,g' | sed 's/$/ --verbose/' >run.sh
coverage erase
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unit-test-engine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
fi
docker run -dit --disable-content-trust --privileged --name=${{ env.CONTAINER_NAME }} -v /dev/shm:/dev/shm \
-v ${{ github.workspace }}:/intel-extension-for-transformers \
-v ~/.cache/oneAPI:/cache \
-v /tf_dataset2:/tf_dataset2 \
${{ env.REPO_NAME }}:${{ env.REPO_TAG }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unit-test-kernel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
docker run -dit --disable-content-trust --privileged --name=${{ env.CONTAINER_NAME }} -v /dev/shm:/dev/shm \
-v ${{ github.workspace }}:/intel-extension-for-transformers \
-v /tf_dataset2:/tf_dataset2 \
-v ~/.cache/oneAPI:/cache \
${{ env.REPO_NAME }}:${{ env.REPO_TAG }}
- name: Env build
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unit-test-neuralchat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
fi
podman run -dit --disable-content-trust --privileged --name=${{ env.CONTAINER_NAME }} -v /dev/shm:/dev/shm \
-v ${{ github.workspace }}:/intel-extension-for-transformers \
-v ~/.cache/oneAPI:/cache \
${{ env.REPO_NAME }}:${{ env.REPO_TAG }}
- name: Env build
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unit-test-optimize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
docker run -dit --disable-content-trust --privileged --name=${{ env.CONTAINER_NAME }} -v /dev/shm:/dev/shm \
-v ${{ github.workspace }}:/intel-extension-for-transformers \
-v /tf_dataset2:/tf_dataset2 \
-v ~/.cache/oneAPI:/cache \
${{ env.REPO_NAME }}:${{ env.REPO_TAG }}
- name: Env build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ option(NE_WITH_ONEDNN_GRAPH "Build oneDNNGraph" ON)
option(NE_DYNAMIC_LINK "Whether third party libs dynamic link to neural engine" ON)
option(NE_WITH_AVX2 "Limit the compile time use of instruciton extensions to AVX2 rather than AVX512" OFF)
message(STATUS "NE_DYNAMIC_LINK: ${NE_DYNAMIC_LINK}")
set(NE_DNNL_CACHE_DIR "" CACHE STRING
"The abs directory of cached OneDNN builds, including a libdnnl.so file and a directory for configured header files
To create a cahce dir, first build without cache, then move `libdnnl.so*` to `YOUR_NEW_CACHE_DIR` and move
`build/neural_engine_py/third_party/oneDNN/include` to `YOUR_NEW_CACHE_DIR/include`")

# Disable extra OneDNN targets to speedup compilation
set(DNNL_BUILD_EXAMPLES OFF CACHE BOOL "builds examples" FORCE)
set(DNNL_BUILD_TESTS OFF CACHE BOOL "builds tests" FORCE)

# Disable extra OneDNN targets to speedup compilation
set(DNNL_BUILD_EXAMPLES OFF CACHE BOOL "builds examples" FORCE)
Expand Down Expand Up @@ -46,25 +55,40 @@ set(BUILD_SHARED_LIBS ON)
add_subdirectory(${NE_THIRD_PARTY_DIR}/glog)

if(NOT NE_WITH_SPARSELIB_ONLY)
if(NE_DYNAMIC_LINK)
set(DNNL_LIBRARY_TYPE "SHARED" CACHE STRING
"specifies whether oneDNN library should be SHARED, STATIC, or
SDL (single dynamic library).")
set(DNNL_GRAPH_LIBRARY_TYPE "SHARED" CACHE STRING
"specifies whether oneDNN Graph library should be SHARED, STATIC, or
SDL (single dynamic library).")
file(GLOB NE_DNNL_CACHE_B ${NE_DNNL_CACHE_DIR}/libdnnl.so*)
list(LENGTH NE_DNNL_CACHE_B NE_DNNL_CACHE_B_LEN)
set(NE_DNNL_CACHE_H ${NE_DNNL_CACHE_DIR}/include)
if (NE_DNNL_CACHE_DIR AND NE_DNNL_CACHE_B_LEN AND EXISTS ${NE_DNNL_CACHE_H})
message(STATUS "Using cached NE_DNNL: linking ${NE_DNNL_CACHE_B}")
message(STATUS "Using cached NE_DNNL: include ${NE_DNNL_CACHE_H}")
add_library(dnnl SHARED IMPORTED)
set_target_properties(dnnl PROPERTIES IMPORTED_LOCATION ${NE_DNNL_CACHE_B})
target_include_directories(dnnl INTERFACE ${NE_DNNL_CACHE_H})
target_include_directories(dnnl INTERFACE ${NE_THIRD_PARTY_DIR}/oneDNN/include)

file(COPY ${NE_DNNL_CACHE_B} DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
message(STATUS "dnnl library copied to: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
else()
set(DNNL_LIBRARY_TYPE "STATIC" CACHE STRING
"specifies whether oneDNN library should be SHARED, STATIC, or
SDL (single dynamic library).")
set(DNNL_GRAPH_LIBRARY_TYPE "STATIC" CACHE STRING
"specifies whether oneDNN Graph library should be SHARED, STATIC, or
SDL (single dynamic library).")
endif()
message(STATUS "DNNL_LIBRARY_TYPE: ${DNNL_LIBRARY_TYPE}")
message(STATUS "DNNL_GRAPH_LIBRARY_TYPE: ${DNNL_GRAPH_LIBRARY_TYPE}")
if(NE_DYNAMIC_LINK)
set(DNNL_LIBRARY_TYPE "SHARED" CACHE STRING
"specifies whether oneDNN library should be SHARED, STATIC, or
SDL (single dynamic library).")
set(DNNL_GRAPH_LIBRARY_TYPE "SHARED" CACHE STRING
"specifies whether oneDNN Graph library should be SHARED, STATIC, or
SDL (single dynamic library).")
else()
set(DNNL_LIBRARY_TYPE "STATIC" CACHE STRING
"specifies whether oneDNN library should be SHARED, STATIC, or
SDL (single dynamic library).")
set(DNNL_GRAPH_LIBRARY_TYPE "STATIC" CACHE STRING
"specifies whether oneDNN Graph library should be SHARED, STATIC, or
SDL (single dynamic library).")
endif()
message(STATUS "DNNL_LIBRARY_TYPE: ${DNNL_LIBRARY_TYPE}")
message(STATUS "DNNL_GRAPH_LIBRARY_TYPE: ${DNNL_GRAPH_LIBRARY_TYPE}")

add_subdirectory(${NE_THIRD_PARTY_DIR}/oneDNN)
add_subdirectory(${NE_THIRD_PARTY_DIR}/oneDNN)
endif()

add_subdirectory(${NE_THIRD_PARTY_DIR}/pybind11)
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ else()
string(APPEND CMAKE_CXX_FLAGS " -fPIC ")
string(APPEND CMAKE_C_FLAGS " -fPIC ")
endif()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" CACHE PATH "CMAKE_RUNTIME_OUTPUT_DIRECTORY")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH "CMAKE_LIBRARY_OUTPUT_DIRECTORY")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH "CMAKE_ARCHIVE_OUTPUT_DIRECTORY")
set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" CACHE PATH "CMAKE_PDB_OUTPUT_DIRECTORY")
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH "CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY")

0 comments on commit 7008ff7

Please sign in to comment.