@@ -745,11 +745,10 @@ Status BundleReader::GetSliceValue(StringPiece full_tensor_key,
745745 // allocate_temp()? Note that without major refactorings to Saver, it's
746746 // hard for the caller of the tensor bundle module to allocate these
747747 // precisely-shaped scratch storage.
748- // TODO(zongheng): implement an important optimization: if the stored slice
749- // is a subset of the to-restore slice, directly read the stored slice into
750- // the latter's already-allocated backing buffer.
751748
752749 // Optimization for the common case: stored slice == to-restore slice.
750+ // TODO(zongheng): also include the case where "slice_spec" is full ("-"),
751+ // and "stored_slice" is logically full but contains actual extents.
753752 if (stored_slice == slice_spec) {
754753 VLOG (1 ) << " Optimized for common case: directly copying into "
755754 " pre-allocated buffer; spec: "
@@ -800,14 +799,20 @@ bool BundleReader::Contains(StringPiece key) {
800799 return Valid () && (this ->key () == key);
801800}
802801
803- Status BundleReader::LookupTensorShape (StringPiece key, TensorShape* shape) {
802+ Status BundleReader::LookupDtypeAndShape (StringPiece key, DataType* dtype,
803+ TensorShape* shape) {
804804 BundleEntryProto entry;
805805 TF_RETURN_IF_ERROR (GetBundleEntryProto (key, &entry));
806-
806+ *dtype = entry. dtype ();
807807 *shape = TensorShape (entry.shape ());
808808 return Status::OK ();
809809}
810810
811+ Status BundleReader::LookupTensorShape (StringPiece key, TensorShape* shape) {
812+ DataType ignored;
813+ return LookupDtypeAndShape (key, &ignored, shape);
814+ }
815+
811816string BundleReader::DebugString () {
812817 // Format used below emulates that of TensorSliceReader::DebugString().
813818 string shape_str;
0 commit comments