1 | #pragma once |
---|---|
2 | #include <c10/macros/Macros.h> |
3 | |
4 | namespace at { |
5 | |
6 | /** |
7 | Computes ceil(a / b) |
8 | */ |
9 | template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>> |
10 | C10_ALWAYS_INLINE C10_HOST_DEVICE T ceil_div(T a, T b) { |
11 | return (a + b - 1) / b; |
12 | } |
13 | |
14 | /** |
15 | Computes ceil(a / b) * b; i.e., rounds up `a` to the next highest |
16 | multiple of b |
17 | */ |
18 | template <typename T> |
19 | C10_ALWAYS_INLINE C10_HOST_DEVICE T round_up(T a, T b) { |
20 | return ceil_div(a, b) * b; |
21 | } |
22 | |
23 | } // namespace at |
24 |