File size: 298 Bytes
c1af2fa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#pragma once
#include <algorithm>
namespace at::native {
// returns 2**floor(log2(n))
static int lastPow2(unsigned int n) {
n |= (n >> 1);
n |= (n >> 2);
n |= (n >> 4);
n |= (n >> 8);
n |= (n >> 16);
return std::max<int>(1, n - (n >> 1));
}
} // namespace at::native
|