From dc2fdaa7c0f18156d50608a53d5822ea1ab17061 Mon Sep 17 00:00:00 2001 From: zenghongtai <1518445275@qq.com> Date: Mon, 5 Dec 2022 13:27:27 +0800 Subject: [PATCH 1/9] static constexpr should be used in cuda/reducer.cuh, otherwise compilation fails in VS --- csrc/cuda/reducer.cuh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/csrc/cuda/reducer.cuh b/csrc/cuda/reducer.cuh index 8c851d20..577f4286 100644 --- a/csrc/cuda/reducer.cuh +++ b/csrc/cuda/reducer.cuh @@ -16,27 +16,27 @@ const std::map reduce2REDUCE = { [&] { \ switch (reduce2REDUCE.at(reduce)) { \ case SUM: { \ - const ReductionType REDUCE = SUM; \ + static constexpr ReductionType REDUCE = SUM; \ return __VA_ARGS__(); \ } \ case MEAN: { \ - const ReductionType REDUCE = MEAN; \ + static constexpr ReductionType REDUCE = MEAN; \ return __VA_ARGS__(); \ } \ case MUL: { \ - const ReductionType REDUCE = MUL; \ + static constexpr ReductionType REDUCE = MUL; \ return __VA_ARGS__(); \ } \ case DIV: { \ - const ReductionType REDUCE = DIV; \ + static constexpr ReductionType REDUCE = DIV; \ return __VA_ARGS__(); \ } \ case MIN: { \ - const ReductionType REDUCE = MIN; \ + static constexpr ReductionType REDUCE = MIN; \ return __VA_ARGS__(); \ } \ case MAX: { \ - const ReductionType REDUCE = MAX; \ + static constexpr ReductionType REDUCE = MAX; \ return __VA_ARGS__(); \ } \ } \ From 1dcfdccc072961762d27bad0a6a219ca8b010107 Mon Sep 17 00:00:00 2001 From: zenghongtai <1518445275@qq.com> Date: Mon, 5 Dec 2022 15:25:26 +0800 Subject: [PATCH 2/9] modify torch/include/ATen/Parallel.h in testing.yml --- .github/workflows/testing.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index a5dfdcf3..ce26fe18 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -28,7 +28,9 @@ jobs: - name: Install PyTorch ${{ matrix.torch-version }} run: | pip install torch==${{ matrix.torch-version }} --extra-index-url https://download.pytorch.org/whl/cpu - + sed -i '32,38c\ +TORCH_API void lazy_init_num_threads();' "$(python -c "import os, torch; print(os.path.join(os.path.dirname(torch.__file__), 'include/ATen/Parallel.h'))")" + - name: Install main package run: | pip install -e .[test] From a7252713c1f743e5906aa3e270dc5d255bf81ca1 Mon Sep 17 00:00:00 2001 From: rusty1s Date: Mon, 5 Dec 2022 07:48:55 +0000 Subject: [PATCH 3/9] update --- .github/workflows/building.yml | 8 ++++++++ .github/workflows/testing.yml | 10 ++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/building.yml b/.github/workflows/building.yml index 71fa83d6..0cda26cb 100644 --- a/.github/workflows/building.yml +++ b/.github/workflows/building.yml @@ -59,6 +59,14 @@ jobs: python -c "import torch; print('PyTorch:', torch.__version__)" python -c "import torch; print('CUDA:', torch.version.cuda)" + - name: Patch PyTorch static constexpr on Windows + if: ${{ runner.os == 'Windows' }} + run: | + Torch_DIR=`python -c 'import os; import torch;print(os.path.dirname(torch.__file__))'` + sed -i '32,38c\ +TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h + shell: bash + - name: Set version if: ${{ runner.os != 'macOS' }} run: | diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index ce26fe18..c186a5db 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -28,9 +28,15 @@ jobs: - name: Install PyTorch ${{ matrix.torch-version }} run: | pip install torch==${{ matrix.torch-version }} --extra-index-url https://download.pytorch.org/whl/cpu + + - name: Patch PyTorch static constexpr on Windows + if: ${{ runner.os == 'Windows' }} + run: | + Torch_DIR=`python -c 'import os; import torch;print(os.path.dirname(torch.__file__))'` sed -i '32,38c\ -TORCH_API void lazy_init_num_threads();' "$(python -c "import os, torch; print(os.path.join(os.path.dirname(torch.__file__), 'include/ATen/Parallel.h'))")" - +TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h + shell: bash + - name: Install main package run: | pip install -e .[test] From 5a2a5772d1965f3368d06f1247e22d9f2eb4ef01 Mon Sep 17 00:00:00 2001 From: rusty1s Date: Mon, 5 Dec 2022 07:51:46 +0000 Subject: [PATCH 4/9] update --- .github/workflows/building.yml | 4 ++-- .github/workflows/testing.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/building.yml b/.github/workflows/building.yml index 0cda26cb..e9e8f58b 100644 --- a/.github/workflows/building.yml +++ b/.github/workflows/building.yml @@ -62,9 +62,9 @@ jobs: - name: Patch PyTorch static constexpr on Windows if: ${{ runner.os == 'Windows' }} run: | - Torch_DIR=`python -c 'import os; import torch;print(os.path.dirname(torch.__file__))'` + Torch_DIR=`python -c 'import os; import torch; print(os.path.dirname(torch.__file__))'` sed -i '32,38c\ -TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h + TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h shell: bash - name: Set version diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index c186a5db..f793122e 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -32,9 +32,9 @@ jobs: - name: Patch PyTorch static constexpr on Windows if: ${{ runner.os == 'Windows' }} run: | - Torch_DIR=`python -c 'import os; import torch;print(os.path.dirname(torch.__file__))'` + Torch_DIR=`python -c 'import os; import torch; print(os.path.dirname(torch.__file__))'` sed -i '32,38c\ -TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h + TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h shell: bash - name: Install main package From 182177d8e7c7950ac7914c23d39c188833d2b106 Mon Sep 17 00:00:00 2001 From: rusty1s Date: Mon, 5 Dec 2022 07:57:14 +0000 Subject: [PATCH 5/9] update --- .github/workflows/testing.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index f793122e..e229f242 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -33,8 +33,11 @@ jobs: if: ${{ runner.os == 'Windows' }} run: | Torch_DIR=`python -c 'import os; import torch; print(os.path.dirname(torch.__file__))'` + cat ${Torch_DIR}/include/ATen/Paralle.h + echo "================" sed -i '32,38c\ TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h + cat ${Torch_DIR}/include/ATen/Paralle.h shell: bash - name: Install main package From 2d297cdcf7d90d7af6c812914c7142e8b3b9efd9 Mon Sep 17 00:00:00 2001 From: rusty1s Date: Mon, 5 Dec 2022 08:01:38 +0000 Subject: [PATCH 6/9] typo --- .github/workflows/testing.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index e229f242..4d31e446 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -33,11 +33,11 @@ jobs: if: ${{ runner.os == 'Windows' }} run: | Torch_DIR=`python -c 'import os; import torch; print(os.path.dirname(torch.__file__))'` - cat ${Torch_DIR}/include/ATen/Paralle.h + cat ${Torch_DIR}/include/ATen/Parallel.h echo "================" sed -i '32,38c\ TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h - cat ${Torch_DIR}/include/ATen/Paralle.h + cat ${Torch_DIR}/include/ATen/Parallel.h shell: bash - name: Install main package From 9546aad68cb0e2af56e4202a95890b4f639f979d Mon Sep 17 00:00:00 2001 From: rusty1s Date: Mon, 5 Dec 2022 08:14:57 +0000 Subject: [PATCH 7/9] typo --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 4d31e446..d8d150bd 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -35,7 +35,7 @@ jobs: Torch_DIR=`python -c 'import os; import torch; print(os.path.dirname(torch.__file__))'` cat ${Torch_DIR}/include/ATen/Parallel.h echo "================" - sed -i '32,38c\ + sed -i '31,38c\ TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h cat ${Torch_DIR}/include/ATen/Parallel.h shell: bash From b349ad5a78c6279babc0af60924d0e336c1dc250 Mon Sep 17 00:00:00 2001 From: rusty1s Date: Mon, 5 Dec 2022 08:16:42 +0000 Subject: [PATCH 8/9] typo --- .github/workflows/building.yml | 4 ++-- .github/workflows/testing.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/building.yml b/.github/workflows/building.yml index e9e8f58b..23459440 100644 --- a/.github/workflows/building.yml +++ b/.github/workflows/building.yml @@ -63,8 +63,8 @@ jobs: if: ${{ runner.os == 'Windows' }} run: | Torch_DIR=`python -c 'import os; import torch; print(os.path.dirname(torch.__file__))'` - sed -i '32,38c\ - TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h + sed -i '31,38c\ + TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h shell: bash - name: Set version diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index d8d150bd..48c103df 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -36,7 +36,7 @@ jobs: cat ${Torch_DIR}/include/ATen/Parallel.h echo "================" sed -i '31,38c\ - TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h + TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h cat ${Torch_DIR}/include/ATen/Parallel.h shell: bash From 1fb7e03c0b365a469caf7a9a65fa14fb8dcf37ae Mon Sep 17 00:00:00 2001 From: rusty1s Date: Mon, 5 Dec 2022 08:19:17 +0000 Subject: [PATCH 9/9] remove prints --- .github/workflows/testing.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 48c103df..e50a0fd6 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -33,11 +33,8 @@ jobs: if: ${{ runner.os == 'Windows' }} run: | Torch_DIR=`python -c 'import os; import torch; print(os.path.dirname(torch.__file__))'` - cat ${Torch_DIR}/include/ATen/Parallel.h - echo "================" sed -i '31,38c\ TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h - cat ${Torch_DIR}/include/ATen/Parallel.h shell: bash - name: Install main package