(pfor_input)
| 1756 | |
| 1757 | @RegisterPFor("BroadcastTo") |
| 1758 | def _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") |
nothing calls this directly
no test coverage detected