Defined in generated file: python/ops/gen_data_flow_ops.py
Partitions data
into num_partitions
tensors using indices from partitions
.
Aliases:
tf.compat.v1.dynamic_partition
tf.compat.v2.dynamic_partition
tf.dynamic_partition(
data,
partitions,
num_partitions,
name=None
)
For each i
ndex tuple js
of si
ze partitions.ndim
, the sli
ce data[js, ...]
becomes part of outputs[partitions[js]]
. The sli
ces wi
th partitions[js] = i
are placed i
n outputs[i]
i
n lexi
cographi
c order of js
, and the fi
rst di
mensi
on of outputs[i]
i
s the number of entri
es i
n partitions
equal to i
. In detai
l,
outputs[i].shape = [sum(partitions == i)] + data.shape[partitions.ndim:]
outputs[i] = pack([data[js, ...] for js if partitions[js] == i])
data.shape
must start with partitions.shape
.
For example:
# Scalar partitions.
partitions = 1
num_partitions = 2
data = [10, 20]
outputs[0] = [] # Empty with shape [0, 2]
outputs[1] = [[10, 20]]
# Vector partitions.
partitions = [0, 0, 1, 1, 0]
num_partitions = 2
data = [10, 20, 30, 40, 50]
outputs[0] = [10, 20, 50]
outputs[1] = [30, 40]
See dynamic_stitch
for an example on how to merge partitions back.
Args:
data
: ATensor
.
Returns:
A list of num_partitions
Tensor
objects with the same type as data
.