Skip to content

Commit d778555

Browse files
authored
build: build_wheel tools update (#82)
1 parent 50847ae commit d778555

File tree

10 files changed

+53
-17
lines changed

10 files changed

+53
-17
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
run: |
5252
set -ex
5353
source /usr/local/Ascend/ascend-toolkit/set_env.sh
54+
source /usr/local/Ascend/nnal/atb/set_env.sh
5455
cd ${{ env.CI_PATH }}
5556
pip uninstall -y dlinfer-ascend
5657
pip install -r requirements/ascend/full.txt

CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,4 @@ elseif(NOT DEVICE IN_LIST SUPPORTED_DEVICE)
2525
endif()
2626

2727
add_subdirectory(dlinfer/vendor/${DEVICE})
28-
29-
if("$ENV{DICP}" STREQUAL "true")
30-
add_subdirectory(dlinfer/graph/dicp/vendor/AtbGraph/codegen/runtime)
31-
endif()
32-
28+
add_subdirectory(dlinfer/graph/dicp/vendor)

dlinfer/graph/dicp/vendor/AtbGraph/codegen/runtime/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,14 @@ set(COMPILE_OPTIONS
6767
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
6868

6969
add_library(dicp_model SHARED ${SOURCES})
70-
set_target_properties(dicp_model PROPERTIES
71-
OUTPUT_NAME "dicp_model"
72-
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../
73-
)
7470

7571
target_compile_options(dicp_model PRIVATE ${COMPILE_OPTIONS})
7672

7773
target_link_libraries(dicp_model PRIVATE
7874
atb torch c10 torch_cpu torch_python torch_npu opapi)
75+
76+
file(RELATIVE_PATH OUTPUT_LIB_RELATIVE_PATH "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../")
77+
install(
78+
TARGETS dicp_model
79+
DESTINATION ${OUTPUT_LIB_RELATIVE_PATH}
80+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if (DEVICE STREQUAL "ascend")
2+
add_subdirectory(AtbGraph/codegen/runtime)
3+
endif()

dlinfer/vendor/ascend/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ execute_process(
88
)
99

1010
execute_process(
11-
COMMAND bash -c "pip show torch-npu | awk '/^Location:/{ORS=\"\"; print \$2\"/torch_npu\"}'"
11+
COMMAND python -c "from importlib.metadata import distribution; \
12+
print(str(distribution('torch_npu').locate_file('torch_npu')), end='')"
1213
OUTPUT_VARIABLE Torch_npu_ROOT
1314
)
1415

@@ -62,7 +63,8 @@ target_link_libraries(
6263
PUBLIC ${HCCL_LIBRARY}
6364
)
6465

66+
file(RELATIVE_PATH OUTPUT_LIB_RELATIVE_PATH "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
6567
install(
6668
TARGETS ${PROJECT_NAME}
67-
DESTINATION ./dlinfer/vendor/ascend
69+
DESTINATION ${OUTPUT_LIB_RELATIVE_PATH}
6870
)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
requires = [
33
"pyyaml",
44
"scikit-build",
5+
"setuptools==69.5.1",
56
]
67
build-backend = "setuptools.build_meta"

requirements/ascend/torch.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
torch==2.1.0
2-
torchvision==0.16.0
3-
torch-npu==2.1.0.post6
1+
torch==2.3.1
2+
torchvision==0.18.1
3+
torch-npu==2.3.1
44
numpy<2.0.0
55
pyyaml

scripts/build_wheel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -e
33

44
REPO_ROOT=$(cd $(dirname $(dirname $0)); pwd)
55
pip install -U build
6-
rm -rf ${REPO_ROOT}/_skbuild ${REPO_ROOT}/dlinfer.egg*
6+
rm -rf ${REPO_ROOT}/_skbuild ${REPO_ROOT}/dlinfer*.egg*
77
export DEVICE=${DEVICE:-ascend}
88
python -m build \
99
-C="--build-option=--plat-name" \

scripts/build_wheel_allpy.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
eval "$(conda shell.bash hook)"
5+
6+
REPO_ROOT=$(cd $(dirname $(dirname $0)); pwd)
7+
cd ${REPO_ROOT}
8+
9+
# PY_VERSION_LIST=("3.8" "3.9" "3.10")
10+
PY_VERSION_LIST=("3.10")
11+
for PY_VERSION in ${PY_VERSION_LIST[@]}; do
12+
echo start building wheels for python${PY_VERSION}
13+
PY_VERSION_NAME=${PY_VERSION/./}
14+
ENV_NAME=dlinfer_build_py${PY_VERSION_NAME}
15+
conda env remove -n ${ENV_NAME} -y
16+
conda create -n ${ENV_NAME} python=${PY_VERSION} -y
17+
conda activate ${ENV_NAME}
18+
pip install -U build
19+
bash ${REPO_ROOT}/scripts/build_wheel.sh
20+
conda deactivate
21+
conda env remove -n ${ENV_NAME} -y
22+
echo end building wheels for python${PY_VERSION}
23+
done

setup.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from skbuild import setup
66

77

8-
VERSION = "0.1.0post1"
8+
VERSION = "0.1.1"
99

1010
vendor_dispatch_key_map = {
1111
"ascend": "PrivateUse1",
@@ -71,6 +71,14 @@ def get_requirements(file_name):
7171
return requirements
7272

7373

74+
def get_vendor_excludes():
75+
device = get_device()
76+
exclude_vendors = [
77+
name for name in vendor_dispatch_key_map.keys() if name != device
78+
]
79+
return [f"dlinfer.vendor.{name}" for name in exclude_vendors]
80+
81+
7482
def get_entry_points():
7583
device = get_device()
7684
if device == "ascend":
@@ -91,7 +99,7 @@ def main():
9199
long_description=get_readme(),
92100
long_description_content_type="text/markdown",
93101
url="https://github.com/DeepLink-org/dlinfer",
94-
packages=find_packages(),
102+
packages=find_packages(exclude=get_vendor_excludes()),
95103
package_data=get_package_data(),
96104
exclude_package_data={"": ["tests/*"]},
97105
cmake_args=get_cmake_args(),

0 commit comments

Comments
 (0)