MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _next_array_size

Function _next_array_size

tensorflow/contrib/metrics/python/ops/metric_ops.py:3541–3555  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

3539
3540
3541def _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
3558def streaming_concat(values,

Callers 1

reallocateFunction · 0.85

Calls 2

logMethod · 0.45
castMethod · 0.45

Tested by

no test coverage detected