(pfor_input)
| 2221 | |
| 2222 | @RegisterPFor("BiasAdd") |
| 2223 | def _convert_biasadd(pfor_input): |
| 2224 | t, t_stacked, _ = pfor_input.input(0) |
| 2225 | bias, bias_stacked, _ = pfor_input.input(1) |
| 2226 | data_format = pfor_input.get_attr("data_format").decode() |
| 2227 | if bias_stacked: |
| 2228 | # BiasAdd only supports 1-D biases, so cast bias to match value and use Add. |
| 2229 | pfor_input.expanddim_inputs_for_broadcast() |
| 2230 | t, _, _ = pfor_input.input(0) |
| 2231 | bias = math_ops.cast(pfor_input.stacked_input(1), t.dtype) |
| 2232 | if compat.as_bytes(data_format) == b"NCHW": |
| 2233 | b_shape = array_ops.shape(bias) |
| 2234 | new_b_shape = array_ops.concat( |
| 2235 | [b_shape[:-3], b_shape[-1:], b_shape[-3:-1]], axis=0) |
| 2236 | bias = array_ops.reshape(bias, new_b_shape) |
| 2237 | return wrap(math_ops.add(t, bias), True) |
| 2238 | else: |
| 2239 | assert t_stacked, "At least one input to BiasAdd should be loop variant." |
| 2240 | if compat.as_bytes(data_format) == b"NCHW": |
| 2241 | shape = array_ops.shape(t) |
| 2242 | flattened_shape = array_ops.concat([[-1], shape[2:]], axis=0) |
| 2243 | t = array_ops.reshape(t, flattened_shape) |
| 2244 | t = nn_ops.bias_add(t, bias, data_format="NCHW") |
| 2245 | t = array_ops.reshape(t, shape) |
| 2246 | return wrap(t, True) |
| 2247 | return wrap(nn_ops.bias_add(t, bias, data_format=data_format), True) |
| 2248 | |
| 2249 | |
| 2250 | @RegisterPFor("UnsortedSegmentSum") |
nothing calls this directly
no test coverage detected