def aggregate_tensors_or_indexed_slices(values, accumulation_fn=math_ops.add_n):
"""Aggregate tensors using `accumulation_fn` and IndexedSlices via concat."""
- if isinstance(values[0], ops.IndexedSlices):
+ if any(isinstance(v, ops.IndexedSlices) for v in values):
return gradients_impl._AggregateIndexedSlicesGradients(values) # pylint: disable=protected-access
else:
return accumulation_fn(values)
elif len(grads) == 1:
return grads[0]
else:
- assert isinstance(grads[0], ops.IndexedSlices)
grads = math_ops._as_indexed_slices_list( # pylint: disable=protected-access
[g for g in grads if g is not None])
grads = [_HandleNestedIndexedSlices(x) for x in grads] # pylint: disable=protected-access