diff options
Diffstat (limited to 'tensorflow/core/lib/core/bits.h')
-rw-r--r-- | tensorflow/core/lib/core/bits.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tensorflow/core/lib/core/bits.h b/tensorflow/core/lib/core/bits.h index 30ad0c2bea..1110ef5c2a 100644 --- a/tensorflow/core/lib/core/bits.h +++ b/tensorflow/core/lib/core/bits.h @@ -16,6 +16,7 @@ limitations under the License. #ifndef TENSORFLOW_LIB_CORE_BITS_H_ #define TENSORFLOW_LIB_CORE_BITS_H_ +#include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/types.h" namespace tensorflow { @@ -91,6 +92,18 @@ inline int Log2Ceiling64(uint64 n) { return floor + 1; } +inline uint32 NextPowerOfTwo(uint32 value) { + int exponent = Log2Ceiling(value); + DCHECK_LT(exponent, std::numeric_limits<uint32>::digits); + return 1 << exponent; +} + +inline uint64 NextPowerOfTwo64(uint64 value) { + int exponent = Log2Ceiling(value); + DCHECK_LT(exponent, std::numeric_limits<uint64>::digits); + return 1LL << exponent; +} + } // namespace tensorflow #endif // TENSORFLOW_LIB_CORE_BITS_H_ |