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

Function _restore_sparse_tensors

tensorflow/python/training/input.py:600–627  ·  view source on GitHub ↗

Restore SparseTensors after dequeue in batch, batch_join, etc.

(stored_list, sparse_info_list)

Source from the content-addressed store, hash-verified

598
599
600def _restore_sparse_tensors(stored_list, sparse_info_list):
601 """Restore SparseTensors after dequeue in batch, batch_join, etc."""
602 received_sequence = isinstance(stored_list, collections_abc.Sequence)
603 if not received_sequence:
604 stored_list = (stored_list,)
605 tensors = [
606 _restore_sparse(sparse_map_op=info.map_op,
607 sparse_handles=array_ops.squeeze(s, [1]),
608 rank=tensor_shape.dimension_value(info.rank + 1))
609 if info.sparse else s
610 for (s, info) in zip(stored_list, sparse_info_list)]
611 has_st = any(isinstance(x, sparse_tensor.SparseTensor) for x in tensors)
612 if has_st:
613 t_values = [
614 x.values if isinstance(x, sparse_tensor.SparseTensor)
615 else x
616 for x in tensors]
617 with_deps = lambda x: control_flow_ops.with_dependencies(t_values, x)
618 ensure_restore_tensors = [
619 sparse_tensor.SparseTensor(indices=with_deps(x.indices),
620 values=with_deps(x.values),
621 dense_shape=with_deps(x.dense_shape))
622 if isinstance(x, sparse_tensor.SparseTensor)
623 else with_deps(x)
624 for x in tensors]
625 else:
626 ensure_restore_tensors = tensors
627 return ensure_restore_tensors if received_sequence else tensors[0]
628
629
630def _validate(tensor_list):

Callers 5

bucketFunction · 0.85
_batchFunction · 0.85
_batch_joinFunction · 0.85
_shuffle_batchFunction · 0.85
_shuffle_batch_joinFunction · 0.85

Calls 1

anyFunction · 0.85

Tested by

no test coverage detected