Return 2**N for integer N such that 2**N >= value.
(value)
| 276 | |
| 277 | |
| 278 | def _enclosing_power_of_two(value): |
| 279 | """Return 2**N for integer N such that 2**N >= value.""" |
| 280 | value_static = tensor_util.constant_value(value) |
| 281 | if value_static is not None: |
| 282 | return constant_op.constant( |
| 283 | int(2**np.ceil(np.log(value_static) / np.log(2.0))), value.dtype) |
| 284 | return math_ops.cast( |
| 285 | math_ops.pow( |
| 286 | 2.0, |
| 287 | math_ops.ceil( |
| 288 | math_ops.log(math_ops.cast(value, dtypes.float32)) / |
| 289 | math_ops.log(2.0))), value.dtype) |
no test coverage detected