forked from NVIDIA/MinkowskiEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dispatcher.hpp
39 lines (33 loc) · 1.87 KB
/
dispatcher.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once
#include <ATen/core/DeprecatedTypeProperties.h>
#include <ATen/core/Tensor.h>
#include <ATen/record_function.h>
#include <c10/macros/Macros.h>
#include <c10/util/Exception.h>
#include <c10/util/Half.h>
#include <c10/util/Metaprogramming.h>
#include <c10/util/complex.h>
#include <c10/util/string_view.h>
namespace minkowski {
#define MINK_PRIVATE_CASE_TYPE_USING_HINT(NAME, enum_type, type, HINT, ...) \
case enum_type: { \
using HINT = type; \
return __VA_ARGS__(); \
}
#define MINK_PRIVATE_CASE_TYPE(NAME, enum_type, type, HINT, ...) \
MINK_PRIVATE_CASE_TYPE_USING_HINT(NAME, enum_type, type, HINT, __VA_ARGS__)
#define MINK_DISPATCH_INTEGER_TYPES(TYPE, HINT, NAME, ...) \
[&] { \
const auto &the_type = TYPE; \
/* don't use TYPE again in case it is an expensive or side-effect op */ \
at::ScalarType _it = ::detail::scalar_type(the_type); \
switch (_it) { \
MINK_PRIVATE_CASE_TYPE(NAME, at::ScalarType::Int, int32_t, HINT, \
__VA_ARGS__) \
MINK_PRIVATE_CASE_TYPE(NAME, at::ScalarType::Long, int64_t, HINT, \
__VA_ARGS__) \
default: \
AT_ERROR(#NAME, " not implemented for '", toString(_it), "'"); \
} \
}()
} // namespace minkowski