From 8107a008edf3ed88806b18288b0b1ff66004bd8b Mon Sep 17 00:00:00 2001 From: xintian-514 Date: Thu, 6 Jul 2023 12:03:40 +0800 Subject: [PATCH 1/2] update folder name of DIOPI --- SOP.md | 12 ++++++------ scripts/ci/ascend/ci_ascend_script.sh | 4 ++-- scripts/ci/camb/ci_camb_env.sh | 4 ++-- scripts/ci/camb/ci_camb_script.sh | 4 ++-- scripts/ci/nv/ci_nv_env.sh | 4 ++-- scripts/ci/nv/ci_nv_script.sh | 4 ++-- scripts/ci/topsrider/ci_topsrider_env.sh | 2 +- scripts/ci/topsrider/ci_topsrider_script.sh | 2 +- template_build_sh | 4 ++-- third_party/DIOPI | 2 +- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/SOP.md b/SOP.md index cf2c97575..8cbb8750e 100644 --- a/SOP.md +++ b/SOP.md @@ -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 @@ -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 @@ -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) { @@ -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 diff --git a/scripts/ci/ascend/ci_ascend_script.sh b/scripts/ci/ascend/ci_ascend_script.sh index 746063f00..95d76afec 100644 --- a/scripts/ci/ascend/ci_ascend_script.sh +++ b/scripts/ci/ascend/ci_ascend_script.sh @@ -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 - @@ -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 diff --git a/scripts/ci/camb/ci_camb_env.sh b/scripts/ci/camb/ci_camb_env.sh index 2ba29ac0c..3cefa2a59 100644 --- a/scripts/ci/camb/ci_camb_env.sh +++ b/scripts/ci/camb/ci_camb_env.sh @@ -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} @@ -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 diff --git a/scripts/ci/camb/ci_camb_script.sh b/scripts/ci/camb/ci_camb_script.sh index 98bac8ca5..3c18f2893 100644 --- a/scripts/ci/camb/ci_camb_script.sh +++ b/scripts/ci/camb/ci_camb_script.sh @@ -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 \ @@ -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 - diff --git a/scripts/ci/nv/ci_nv_env.sh b/scripts/ci/nv/ci_nv_env.sh index e68f99355..0801b8749 100644 --- a/scripts/ci/nv/ci_nv_env.sh +++ b/scripts/ci/nv/ci_nv_env.sh @@ -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 diff --git a/scripts/ci/nv/ci_nv_script.sh b/scripts/ci/nv/ci_nv_script.sh index 1af58054b..1d0810cfe 100644 --- a/scripts/ci/nv/ci_nv_script.sh +++ b/scripts/ci/nv/ci_nv_script.sh @@ -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 @@ -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 diff --git a/scripts/ci/topsrider/ci_topsrider_env.sh b/scripts/ci/topsrider/ci_topsrider_env.sh index 8f58d0e92..df3ab0e57 100644 --- a/scripts/ci/topsrider/ci_topsrider_env.sh +++ b/scripts/ci/topsrider/ci_topsrider_env.sh @@ -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}: diff --git a/scripts/ci/topsrider/ci_topsrider_script.sh b/scripts/ci/topsrider/ci_topsrider_script.sh index 038108690..0b48807be 100644 --- a/scripts/ci/topsrider/ci_topsrider_script.sh +++ b/scripts/ci/topsrider/ci_topsrider_script.sh @@ -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"}' diff --git a/template_build_sh b/template_build_sh index 2dedc81df..d49a845b8 100755 --- a/template_build_sh +++ b/template_build_sh @@ -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 diff --git a/third_party/DIOPI b/third_party/DIOPI index 907afb20d..b315bc291 160000 --- a/third_party/DIOPI +++ b/third_party/DIOPI @@ -1 +1 @@ -Subproject commit 907afb20d9c3bc55770224519ee807d437d53e10 +Subproject commit b315bc29179ad55a5605acfdc4ddac7499ba23f6 From e726f6db7d711ff312caf9d0ee8b03586c9c41cc Mon Sep 17 00:00:00 2001 From: xintian-514 Date: Thu, 6 Jul 2023 12:29:15 +0800 Subject: [PATCH 2/2] update folder name of DIOPI --- CMakeLists.txt | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0159975ed..08cb3bb38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/README.md b/README.md index dd5c03d41..7a3bca98b 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ DIPU 的这一部分主要就是对 PyTorch 的``c10`` 和``c10d``相关接口 DIPU CPP层适配的 ATen 算子对应的是分派过程中最底层(*backend*层) 的算子或者 *composite* 层里等效为 *backend* 的算子。 - 这里面有一定的灵活性,以``Linear``算子为例,在 PyTorch 的 ``cpu/cuda`` 设备上,它被实现为一个 ``composite`` 算子,实际的 *backend* 层算子是组合算子内部调用的 ``addmm`` 或者更底层的 ``mm``。 而在 DIPU (``privateuse1``) 设备中,目前是注册了 一个 ``Linear`` 算子 ( DIOPI 有这个算子 ) 来替代组合算子,所以分派会直接走到新的 *backend* 层算子 ``Linear`` ,而不会在调用原来的 ``addmm/mm``。但是如果对应设备的 DIOPI-Impl 算子库 没有实现 ``diopiLinear`` 而是实现了 ``mm`` 算子,也是可以正常走通 ``Linear`` 的调用流程的。 + 这里面有一定的灵活性,以``Linear``算子为例,在 PyTorch 的 ``cpu/cuda`` 设备上,它被实现为一个 ``composite`` 算子,实际的 *backend* 层算子是组合算子内部调用的 ``addmm`` 或者更底层的 ``mm``。 而在 DIPU (``privateuse1``) 设备中,目前是注册了 一个 ``Linear`` 算子 ( DIOPI 有这个算子 ) 来替代组合算子,所以分派会直接走到新的 *backend* 层算子 ``Linear`` ,而不会在调用原来的 ``addmm/mm``。但是如果对应设备的 DIOPI/impl 算子库 没有实现 ``diopiLinear`` 而是实现了 ``mm`` 算子,也是可以正常走通 ``Linear`` 的调用流程的。 ### 无侵入式的 PyTorch 扩展包: DIPU 没有直接修改 PyTorch 的代码,而是使用 out-of-tree 的方式接入新设备,详见[参考文档](https://pytorch.org/tutorials/advanced/extend_dispatcher.html)。