@@ -210,25 +210,28 @@ class StagingMap : public ResourceBase {
210210 const OptionalTuple& tuple)
211211 TF_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
212212 if (tuple[index].has_value ()) {
213- return Status ( errors::InvalidArgument (
213+ return errors::InvalidArgument (
214214 " The tensor for index '" , index, " ' for key '" , key.scalar <int64>()(),
215- " ' was already initialized '" , dtypes_.size (), " '." )) ;
215+ " ' was already initialized '" , dtypes_.size (), " '." );
216216 }
217217
218218 return Status::OK ();
219219 }
220220
221221 // Check that the indices are strictly ordered
222222 Status check_index_ordering (const Tensor& indices) {
223+ if (indices.NumElements () == 0 ) {
224+ return errors::InvalidArgument (" Indices are empty" );
225+ }
226+
223227 auto findices = indices.flat <int >();
224228
225229 for (std::size_t i = 0 ; i < findices.dimension (0 ) - 1 ; ++i) {
226230 if (findices (i) < findices (i + 1 )) {
227231 continue ;
228232 }
229233
230- return Status (
231- errors::InvalidArgument (" Indices are not strictly ordered" ));
234+ return errors::InvalidArgument (" Indices are not strictly ordered" );
232235 }
233236
234237 return Status::OK ();
@@ -238,10 +241,10 @@ class StagingMap : public ResourceBase {
238241 Status check_memory_limit (std::size_t bytes)
239242 TF_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
240243 if (has_memory_limit () && bytes > memory_limit_) {
241- return Status ( errors::ResourceExhausted (
244+ return errors::ResourceExhausted (
242245 " Attempted to insert tensors with combined size of '" , bytes,
243246 " ' bytes into Staging Area with a memory limit of '" , memory_limit_,
244- " '." )) ;
247+ " '." );
245248 }
246249
247250 return Status::OK ();
0 commit comments