"docs/vscode:/vscode.git/clone" did not exist on "c3516f1a8e68504d4dd0bec32887f8af079965d7"
Unverified Commit 111ffc42 authored by HunterTracer's avatar HunterTracer Committed by GitHub
Browse files

Use `static constexpr` for VS compilation (#342)



* static constexpr should be used in cuda/reducer.cuh, otherwise compilation fails in VS

* modify torch/include/ATen/Parallel.h in testing.yml

* update

* update

* update

* typo

* typo

* typo

* remove prints
Co-authored-by: Hunter_Tracer's avatarzenghongtai <1518445275@qq.com>
Co-authored-by: default avatarrusty1s <matthias.fey@tu-dortmund.de>
parent 8e6635b3
......@@ -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 '31,38c\
TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h
shell: bash
- name: Set version
if: ${{ runner.os != 'macOS' }}
run: |
......
......@@ -29,6 +29,14 @@ jobs:
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 '31,38c\
TORCH_API void lazy_init_num_threads();' ${Torch_DIR}/include/ATen/Parallel.h
shell: bash
- name: Install main package
run: |
pip install -e .[test]
......
......@@ -16,27 +16,27 @@ const std::map<std::string, ReductionType> 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__(); \
} \
} \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment