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

Function broadcast_to

tensorflow/python/ops/ragged/ragged_tensor_shape.py:476–503  ·  view source on GitHub ↗

Broadcasts a potentially ragged tensor to a ragged shape. Tiles `rt_input` as necessary to match the given shape. Behavior is undefined if `rt_input` is not broadcast-compatible with `shape`. Args: rt_input: The potentially ragged tensor to broadcast. shape: A `RaggedTensorDynamicSh

(rt_input, shape, broadcast_inner_dimensions=True)

Source from the content-addressed store, hash-verified

474
475
476def broadcast_to(rt_input, shape, broadcast_inner_dimensions=True):
477 """Broadcasts a potentially ragged tensor to a ragged shape.
478
479 Tiles `rt_input` as necessary to match the given shape.
480
481 Behavior is undefined if `rt_input` is not broadcast-compatible with `shape`.
482
483 Args:
484 rt_input: The potentially ragged tensor to broadcast.
485 shape: A `RaggedTensorDynamicShape`
486 broadcast_inner_dimensions: If false, then inner dimensions will not be
487 tiled.
488
489 Returns:
490 A potentially ragged tensor whose values are taken from
491 `rt_input`, and whose shape matches `shape`.
492 """
493 if not isinstance(shape, RaggedTensorDynamicShape):
494 raise TypeError('shape must be a RaggedTensorDynamicShape')
495 rt_input = ragged_tensor.convert_to_tensor_or_ragged_tensor(rt_input)
496
497 # Broadcasting to a uniform shape.
498 if shape.num_partitioned_dimensions == 0:
499 return _broadcast_to_uniform_shape(rt_input, shape,
500 broadcast_inner_dimensions)
501 else:
502 return _broadcast_to_ragged_shape(rt_input, shape,
503 broadcast_inner_dimensions)
504
505
506def _broadcast_to_uniform_shape(rt_input, shape, broadcast_inner_dimensions):

Callers 1

repeat_with_axisFunction · 0.85

Calls 2

Tested by

no test coverage detected