UMMJ's picture
Upload 5875 files
9dd3461
raw
history blame contribute delete
306 Bytes
#pragma once
#include<algorithm>
namespace at {
namespace 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 native
} // namespace at