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

Function _convert_broadcast_to

tensorflow/python/ops/parallel_for/pfor.py:1758–1773  ·  view source on GitHub ↗
(pfor_input)

Source from the content-addressed store, hash-verified

1756
1757@RegisterPFor("BroadcastTo")
1758def _convert_broadcast_to(pfor_input):
1759 t = pfor_input.stacked_input(0)
1760 shape = pfor_input.unstacked_input(1)
1761 new_shape = array_ops.concat([pfor_input.pfor.loop_len_vector, shape], axis=0)
1762
1763 # Expand dims of stacked t to broadcast against the new shape.
1764 # TODO(davmre): consider factoring out common code with
1765 # `expanddim_inputs_for_broadcast`, which has similar logic but with
1766 # implicit shapes (of input Tensors) rather than explicit shapes.
1767 rank_diff = array_ops.shape(new_shape)[0] - array_ops.rank(t)
1768 ones = array_ops.tile([1], array_ops.reshape(rank_diff, [1]))
1769 t_shape = array_ops.shape(t)
1770 t_expanded_shape = array_ops.concat([t_shape[:1], ones, t_shape[1:]], axis=0)
1771
1772 return wrap(array_ops.broadcast_to(array_ops.reshape(t, t_expanded_shape),
1773 new_shape), True)
1774
1775
1776@RegisterPFor("ExpandDims")

Callers

nothing calls this directly

Calls 9

stacked_inputMethod · 0.80
unstacked_inputMethod · 0.80
tileMethod · 0.80
reshapeMethod · 0.80
broadcast_toMethod · 0.80
wrapFunction · 0.70
concatMethod · 0.45
shapeMethod · 0.45
rankMethod · 0.45

Tested by

no test coverage detected