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

Method reduce_concat

tensorflow/python/ops/parallel_for/pfor.py:994–1018  ·  view source on GitHub ↗

Performs a concat reduction on `x` across pfor iterations. Note that this currently may not work inside a control flow construct. Args: x: an unvectorized Tensor. Returns: A Tensor that has rank one higher than `x`. The value is the vectorized version of `x`, i.e. sta

(self, x)

Source from the content-addressed store, hash-verified

992
993 # TODO(agarwal): handle reductions inside control flow constructs.
994 def reduce_concat(self, x):
995 """Performs a concat reduction on `x` across pfor iterations.
996
997 Note that this currently may not work inside a control flow construct.
998 Args:
999 x: an unvectorized Tensor.
1000
1001 Returns:
1002 A Tensor that has rank one higher than `x`. The value is the vectorized
1003 version of `x`, i.e. stacking the value of `x` across different pfor
1004 iterations.
1005 """
1006 assert not context.executing_eagerly()
1007 assert isinstance(x, ops.Tensor)
1008 if x not in self._reduce_concat_map:
1009 out_shape = tensor_shape.TensorShape([self._maybe_iters]).concatenate(
1010 x.shape)
1011 with ops.control_dependencies([x]):
1012 # Control dependency to make sure out is converted after x.
1013 out = array_ops.placeholder(x.dtype, out_shape)
1014 self._reduce_concat_map[out] = x
1015 self._reverse_reduce_concat_map[x] = out
1016 return out
1017 else:
1018 return self._reverse_reduce_concat_map[x]
1019
1020 def reduce_mean(self, x):
1021 """Performs a mean reduction on `x` across pfor iterations.

Callers 4

reduce_meanMethod · 0.95
reduce_sumMethod · 0.95
loop_fnMethod · 0.80
loop_fnMethod · 0.80

Calls 4

executing_eagerlyMethod · 0.80
concatenateMethod · 0.45
control_dependenciesMethod · 0.45
placeholderMethod · 0.45

Tested by 2

loop_fnMethod · 0.64
loop_fnMethod · 0.64