Calculate the next size for reallocating a dynamic array. Args: required_size: number or tf.Tensor specifying required array capacity. growth_factor: optional number or tf.Tensor specifying the growth factor between subsequent allocations. Returns: tf.Tensor with dtype=int32
(required_size, growth_factor=1.5)
| 3539 | |
| 3540 | |
| 3541 | def _next_array_size(required_size, growth_factor=1.5): |
| 3542 | """Calculate the next size for reallocating a dynamic array. |
| 3543 | |
| 3544 | Args: |
| 3545 | required_size: number or tf.Tensor specifying required array capacity. |
| 3546 | growth_factor: optional number or tf.Tensor specifying the growth factor |
| 3547 | between subsequent allocations. |
| 3548 | |
| 3549 | Returns: |
| 3550 | tf.Tensor with dtype=int32 giving the next array size. |
| 3551 | """ |
| 3552 | exponent = math_ops.ceil( |
| 3553 | math_ops.log(math_ops.cast(required_size, dtypes.float32)) / |
| 3554 | math_ops.log(math_ops.cast(growth_factor, dtypes.float32))) |
| 3555 | return math_ops.cast(math_ops.ceil(growth_factor**exponent), dtypes.int32) |
| 3556 | |
| 3557 | |
| 3558 | def streaming_concat(values, |
no test coverage detected