Skip to content

Commit ae1fce5

Browse files
authored
cmake fixes (#278)
1 parent e60840d commit ae1fce5

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

csrc/scatter.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@
22

33
#include <torch/extension.h>
44

5-
int64_t cuda_version();
5+
#if (defined __cpp_inline_variables) || __cplusplus >= 201703L
6+
#define SCATTER_INLINE_VARIABLE inline
7+
#else
8+
#ifdef _MSC_VER
9+
#define SCATTER_INLINE_VARIABLE __declspec(selectany)
10+
#else
11+
#define SCATTER_INLINE_VARIABLE __attribute__((weak))
12+
#endif
13+
#endif
14+
15+
namespace scatter {
16+
int64_t cuda_version() noexcept;
17+
18+
namespace detail {
19+
SCATTER_INLINE_VARIABLE int64_t _cuda_version = cuda_version();
20+
} // namespace detail
21+
} // namespace scatter
622

723
torch::Tensor scatter_sum(torch::Tensor src, torch::Tensor index, int64_t dim,
824
torch::optional<torch::Tensor> optional_out,

csrc/version.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ PyMODINIT_FUNC PyInit__version_cpu(void) { return NULL; }
1313
#endif
1414
#endif
1515

16-
int64_t cuda_version() {
16+
namespace scatter {
17+
int64_t cuda_version() noexcept {
1718
#ifdef WITH_CUDA
1819
return CUDA_VERSION;
1920
#else
2021
return -1;
2122
#endif
2223
}
24+
} // namespace scatter
2325

24-
static auto registry =
25-
torch::RegisterOperators().op("torch_scatter::cuda_version", &cuda_version);
26+
static auto registry = torch::RegisterOperators().op(
27+
"torch_scatter::cuda_version", &scatter::cuda_version);

0 commit comments

Comments
 (0)