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

Function split_by_sparsity

tensorflow/python/distribute/cross_device_utils.py:725–747  ·  view source on GitHub ↗

Split values into dense and sparse values. Args: values: a list of tensors or `PerReplica`s. Returns: Four lists: a list of dense values, a list of their indices in `values` and a list of sparse values, a list of their indices in `values`.

(values)

Source from the content-addressed store, hash-verified

723
724
725def split_by_sparsity(values):
726 """Split values into dense and sparse values.
727
728 Args:
729 values: a list of tensors or `PerReplica`s.
730
731 Returns:
732 Four lists:
733 a list of dense values, a list of their indices in `values` and
734 a list of sparse values, a list of their indices in `values`.
735 """
736 dense_values = []
737 dense_indices = []
738 sparse_values = []
739 sparse_indices = []
740 for i, v in enumerate(values):
741 if is_indexed_slices(v):
742 sparse_values.append(v)
743 sparse_indices.append(i)
744 else:
745 dense_values.append(v)
746 dense_indices.append(i)
747 return dense_values, dense_indices, sparse_values, sparse_indices
748
749
750def stitch_values(values_and_indices_list):

Callers

nothing calls this directly

Calls 2

is_indexed_slicesFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected