Skip to content

Commit

Permalink
Merge pull request #190 from DeepLink-org/xt/update_DIOPI_foldersname
Browse files Browse the repository at this point in the history
Xt/update diopi foldersname
  • Loading branch information
caikun-pjlab authored Jul 6, 2023
2 parents 62ca03f + 3dbbc1c commit c6af9cb
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ include_directories(${TORCH_INCLUDE_DIRS})
message(STATUS "Torch TORCH_INCLUDE_DIRS: ${TORCH_INCLUDE_DIRS}")

# diopi
set(DIOPI_PROTO_PATH "${PROJECT_SOURCE_DIR}/third_party/DIOPI/DIOPI-PROTO")
set(DIOPI_PROTO_PATH "${PROJECT_SOURCE_DIR}/third_party/DIOPI/proto")
include_directories(${DIOPI_PROTO_PATH}/include)
add_definitions(-DDIOPI_ATTR_WEAK)

Expand Down
12 changes: 6 additions & 6 deletions SOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ git submodule update --init --recursive
# PYTHON_INCLUDE_DIR="/home/$USER/env/py3.8/include/python3.8"

# DIPU_DEVICE设置成厂商在dipu的设备名,即 https://github.com/DeepLink-org/dipu/blob/main/CMakeLists.txt 中的DEVICE_CAMB、DEVICE_ASCEND对应的字符串
# DIOPI_IMPL设置成厂商在DIOPI_IMPL的实现代号,即 https://github.com/DeepLink-org/DIOPI/blob/main/DIOPI-IMPL/CMakeLists.txt 中的IMPL_CAMB、IMPL_ASCEND等对应的字符串
# DIOPI_IMPL设置成厂商在DIOPI/impl的实现代号,即 https://github.com/DeepLink-org/DIOPI/blob/main/impl/CMakeLists.txt 中的IMPL_CAMB、IMPL_ASCEND等对应的字符串
# 示例
# export DIPU_DEVICE=camb
# export DIOPI_IMPL=camb
Expand All @@ -76,7 +76,7 @@ sh template_build_sh builddp $DIPU_DEVICE $DIOPI_IMPL
```
### 2.1.4 验证DIPU
``` bash
export DIOPI_ROOT=/home/$USER/code/dipu/third_party/DIOPI/DIOPI-IMPL/lib
export DIOPI_ROOT=/home/$USER/code/dipu/third_party/DIOPI/impl/lib
export DIPU_ROOT=/home/$USER/code/dipu/torch_dipu
export LIBRARY_PATH=$DIPU_ROOT:$DIOPI_ROOT:$LIBRARY_PATH;
export LD_LIBRARY_PATH=$DIPU_ROOT:$DIOPI_ROOT:$LD_LIBRARY_PATH
Expand All @@ -89,10 +89,10 @@ python tests/test_ops/archived/test_tensor_add.py

### 3.1 算子库接入(请参考DIOPI第三方芯片算子库)

在接入DIPU之前,我们的硬件应该提供一个已经实现的算子库,并已经按照 DIOPI-PROTO 的声明进行了对应函数的实现,接入 DIOPI-IMPL。通过DIOPI-IMPL,我们可以编译出``libdiopi_impl.so``作为算子库文件
在接入DIPU之前,我们的硬件应该提供一个已经实现的算子库,并已经按照 DIOPI的PROTO 声明进行了对应函数的实现,接入 DIOPI的IMPL。通过DIOPI的IMPL,我们可以编译出``libdiopi_impl.so``作为算子库文件
- 细节可参考 [DIOPI仓库](https://github.com/DeepLink-org/DIOPI)
- 需要注意的是,在我们进行一致性测试(DIOPI-TEST)时,会在编译时开启``DTEST=ON``,在我们接入DIPU时,编译的算子库应该关闭测试选项,即在cmake阶段使用``DTEST=OFF``
- 下面是一个 DIOPI-IMPL 中的算子接入样例
- 需要注意的是,在我们进行一致性测试(diopi_test)时,会在编译时开启``DTEST=ON``,在我们接入DIPU时,编译的算子库应该关闭测试选项,即在cmake阶段使用``DTEST=OFF``
- 下面是一个 DIOPI的IMPL 中的算子接入样例
```c++
__global__ void softmaxKernel(const float* in, float* out, int64_t outer_dim, int64_t inner_dim, int64_t axis_dim) {
for (int64_t k = threadIdx.x; k < inner_dim; k += blockDim.x) {
Expand Down Expand Up @@ -182,7 +182,7 @@ $ python -c "import torch_dipu"
--config scripts/autogen_diopi_wrapper/diopi_functions.yaml \
--out torch_dipu/csrc_dipu/aten/ops/AutoGenedKernels.cpp \
--use_diopi_adapter True \
--diopi_adapter_header third_party/DIOPI/DIOPI-PROTO/include/diopi/diopi_adaptors.hpp \
--diopi_adapter_header third_party/DIOPI/proto/include/diopi/diopi_adaptors.hpp \
--autocompare True \
--print_func_call_info True \
--print_op_arg True
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci/ascend/ci_ascend_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e
echo "pwd: $(pwd)"

function build_diopi_lib() {
cd third_party/DIOPI/DIOPI-IMPL
cd third_party/DIOPI/impl
sh scripts/build_impl.sh clean
sh scripts/build_impl.sh ascend || exit -1
cd -
Expand Down Expand Up @@ -36,7 +36,7 @@ function autogen_diopi_wrapper() {

function build_dipu_lib() {
echo "building dipu_lib:$(pwd)"
export DIOPI_ROOT=$(pwd)/third_party/DIOPI/DIOPI-IMPL/lib
export DIOPI_ROOT=$(pwd)/third_party/DIOPI/impl/lib
echo "DIOPI_ROOT:${DIOPI_ROOT}"
export LIBRARY_PATH=$DIOPI_ROOT:$LIBRARY_PATH;
config_dipu_ascend_cmake 2>&1 | tee ./build1.log
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci/camb/ci_camb_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export CC=${GCC_ROOT}/bin/gcc
export CXX=${GCC_ROOT}/bin/g++


export DIOPI_ROOT=$(pwd)/third_party/DIOPI/DIOPI-IMPL/lib/
export DIOPI_ROOT=$(pwd)/third_party/DIOPI/impl/lib/
export DIPU_ROOT=$(pwd)/torch_dipu
export LIBRARY_PATH=$DIPU_ROOT:${DIOPI_ROOT}:${LIBRARY_PATH}; LD_LIBRARY_PATH=$DIPU_ROOT:$DIOPI_ROOT:$LD_LIBRARY_PATH
export PYTHONPATH=${PYTORCH_DIR}/install_path/lib/python3.8/site-packages:${PYTHONPATH}
Expand All @@ -21,7 +21,7 @@ export PYTHON_INCLUDE_DIR="/mnt/lustre/share/platform/env/miniconda3.8/envs/dipu

export NEUWARE_ROOT_DIR=${NEUWARE_HOME}
export VENDOR_INCLUDE_DIRS=${NEUWARE_HOME}/include
export DIOPI_PATH=$(pwd)/third_party/DIOPI/DIOPI-PROTO
export DIOPI_PATH=$(pwd)/third_party/DIOPI/proto
export DIPU_PATH=${DIPU_ROOT}

export MLU_INVOKE_BLOCKING=1 # TODO(caikun): remove this after copy issue fixed
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci/camb/ci_camb_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function autogen_diopi_wrapper() {
--config scripts/autogen_diopi_wrapper/diopi_functions.yaml \
--out torch_dipu/csrc_dipu/aten/ops/AutoGenedKernels.cpp \
--use_diopi_adapter True \
--diopi_adapter_header third_party/DIOPI/DIOPI-PROTO/include/diopi/diopi_adaptors.hpp \
--diopi_adapter_header third_party/DIOPI/proto/include/diopi/diopi_adaptors.hpp \
--autocompare False \
--print_func_call_info True \
--print_op_arg True \
Expand All @@ -40,7 +40,7 @@ function autogen_diopi_wrapper() {
}

function build_diopi_lib() {
cd third_party/DIOPI/DIOPI-IMPL
cd third_party/DIOPI/impl
sh scripts/build_impl.sh clean
sh scripts/build_impl.sh camb || exit -1
cd -
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci/nv/ci_nv_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export LD_LIBRARY_PATH=${PLATFORM}/dep/binutils-2.27/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=${NCCL_ROOT}/lib/:$LD_LIBRARY_PATH
export PIP_CONFIG_FILE=${CONDA_ROOT}/envs/${ENV_NAME}/.pip/pip.conf

export DIOPI_ROOT=$(pwd)/third_party/DIOPI/DIOPI-IMPL/lib/
export DIOPI_ROOT=$(pwd)/third_party/DIOPI/impl/lib/
export DIPU_ROOT=$(pwd)/torch_dipu
export DIOPI_PATH=$(pwd)/third_party/DIOPI/DIOPI-PROTO
export DIOPI_PATH=$(pwd)/third_party/DIOPI/proto
export DIPU_PATH=${DIPU_ROOT}
export PYTORCH_DIR=/nvme/share/share/platform/env/miniconda3.8/envs/pt2.0_diopi/lib/python3.8/site-packages
export LIBRARY_PATH=$DIPU_ROOT:${DIOPI_ROOT}:${LIBRARY_PATH}; LD_LIBRARY_PATH=$DIPU_ROOT:$DIOPI_ROOT:$LD_LIBRARY_PATH
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci/nv/ci_nv_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function autogen_diopi_wrapper() {
function build_diopi_lib() {
cd third_party/DIOPI/
git checkout .
cd DIOPI-IMPL
cd impl
RESTORE_PYTHONPATH=$PYTHONPATH
export PYTHONPATH=$PYTORCH_DIR_110:$PYTHONPATH
export Torch_DIR=${PYTORCH_DIR_110}/torch/share/cmake
Expand Down Expand Up @@ -90,7 +90,7 @@ function build_dipu_lib() {
cd build && make -j8 2>&1 | tee ./build.log && cd ..
cp ./build/torch_dipu/csrc_dipu/libtorch_dipu.so ./torch_dipu
cp ./build/torch_dipu/csrc_dipu/libtorch_dipu_python.so ./torch_dipu
patchelf --add-needed $(pwd)/torch_dipu/libtorch_dipu.so third_party/DIOPI/DIOPI-IMPL/lib/libtorch.so.1.10
patchelf --add-needed $(pwd)/torch_dipu/libtorch_dipu.so third_party/DIOPI/impl/lib/libtorch.so.1.10
}

case $1 in
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/topsrider/ci_topsrider_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export PYTORCH_DIR=/home/cse/src/pytorch
# export CC=${GCC_ROOT}/bin/gcc
# export CXX=${GCC_ROOT}/bin/g++

export DIOPI_ROOT=/home/cse/src/deeplink/dipu/third_party/DIOPI/DIOPI-IMPL/lib
export DIOPI_ROOT=/home/cse/src/deeplink/dipu/third_party/DIOPI/impl/lib
export DIPU_ROOT=$(pwd)/torch_dipu
export LIBRARY_PATH=$DIPU_ROOT:${DIOPI_ROOT}:${LIBRARY_PATH}; LD_LIBRARY_PATH=$DIPU_ROOT:$DIOPI_ROOT:$LD_LIBRARY_PATH
export PYTHONPATH=${CONDA_ROOT}/envs/dipu/lib/python3.8:${PYTHONPATH}:
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/topsrider/ci_topsrider_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function autogen_diopi_wrapper() {
python scripts/autogen_diopi_wrapper/autogen_diopi_wrapper.py \
--config scripts/autogen_diopi_wrapper/diopi_functions.yaml \
--use_diopi_adapter True \
--diopi_adapter_header third_party/DIOPI/DIOPI-ADAPTOR/diopi_adaptors.hpp \
--diopi_adapter_header third_party/DIOPI/adaptor/diopi_adaptors.hpp \
--autocompare False \
--out torch_dipu/csrc_dipu/aten/ops/AutoGenedKernels.cpp \
--fun_config_dict '{"current_device": "topsrider"}'
Expand Down
4 changes: 2 additions & 2 deletions template_build_sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ function autogen_diopi_wrapper() {
}

function build_diopi_lib() {
cd third_party/DIOPI/DIOPI-IMPL
cd third_party/DIOPI/impl
sh scripts/build_impl.sh clean
sh scripts/build_impl.sh ${DIOPI_IMPL}
cd -
}

function build_dipu_lib() {
export DIOPI_ROOT=$PWD/third_party/DIOPI/DIOPI-IMPL/lib/
export DIOPI_ROOT=$PWD/third_party/DIOPI/impl/lib/
export LIBRARY_PATH=$DIOPI_ROOT:$LIBRARY_PATH;

autogen_diopi_wrapper
Expand Down
2 changes: 1 addition & 1 deletion third_party/DIOPI
Submodule DIOPI updated 410 files

0 comments on commit c6af9cb

Please sign in to comment.