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

Function _convert_biasadd

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

Source from the content-addressed store, hash-verified

2221
2222@RegisterPFor("BiasAdd")
2223def _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")

Callers

nothing calls this directly

Calls 11

stacked_inputMethod · 0.80
reshapeMethod · 0.80
wrapFunction · 0.70
inputMethod · 0.45
decodeMethod · 0.45
get_attrMethod · 0.45
castMethod · 0.45
shapeMethod · 0.45
concatMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected