@@ -166,7 +166,7 @@ class BatchingSession : public ServingSession {
166
166
// signatures, and for each one supplies a lambda to construct a batch
167
167
// scheduler given a process-batch callback. See batching_session.h for
168
168
// example usage.
169
- static Status Create (
169
+ static absl:: Status Create (
170
170
const BatchingSessionOptions& options, std::unique_ptr<Session> wrapped,
171
171
const std::vector<SignatureWithBatchingSessionSchedulerCreator>&
172
172
signatures_with_scheduler_creators,
@@ -176,7 +176,7 @@ class BatchingSession : public ServingSession {
176
176
// Same as above but allows for specification of a default scheduler creator
177
177
// which enables requests that don't match an exact signature to also
178
178
// have batching.
179
- static Status Create (
179
+ static absl:: Status Create (
180
180
const BatchingSessionOptions& options, std::unique_ptr<Session> wrapped,
181
181
const std::vector<SignatureWithBatchingSessionSchedulerCreator>&
182
182
signatures_with_scheduler_creators,
@@ -186,10 +186,10 @@ class BatchingSession : public ServingSession {
186
186
187
187
~BatchingSession () override = default ;
188
188
189
- Status Run (const std::vector<std::pair<string, Tensor>>& inputs,
190
- const std::vector<string>& output_tensor_names,
191
- const std::vector<string>& target_node_names,
192
- std::vector<Tensor>* outputs) override ;
189
+ absl:: Status Run (const std::vector<std::pair<string, Tensor>>& inputs,
190
+ const std::vector<string>& output_tensor_names,
191
+ const std::vector<string>& target_node_names,
192
+ std::vector<Tensor>* outputs) override ;
193
193
194
194
// RunOptions handling:
195
195
// Since multiple of these Run() calls get backed into a single call to the
@@ -206,31 +206,33 @@ class BatchingSession : public ServingSession {
206
206
// assuming all individual tasks in a batch have equal cost, which is the
207
207
// assumption before splitting is introduced), the rest of fields in
208
208
// `RunMetadata` are copied from the processing result of first split.
209
- Status Run (const RunOptions& run_options,
210
- const std::vector<std::pair<string, Tensor>>& inputs,
211
- const std::vector<string>& output_tensor_names,
212
- const std::vector<string>& target_node_names,
213
- std::vector<Tensor>* outputs, RunMetadata* run_metadata) override ;
209
+ absl::Status Run (const RunOptions& run_options,
210
+ const std::vector<std::pair<string, Tensor>>& inputs,
211
+ const std::vector<string>& output_tensor_names,
212
+ const std::vector<string>& target_node_names,
213
+ std::vector<Tensor>* outputs,
214
+ RunMetadata* run_metadata) override ;
214
215
215
216
// Similar to the function above, but takes an additional
216
217
// 'thread_pool_options' to pass to the underlying Session's Run(). We select
217
218
// an arbitrary 'thread_pool_options' (typically they are the same across
218
219
// calls).
219
- Status Run (const RunOptions& run_options,
220
- const std::vector<std::pair<string, Tensor>>& inputs,
221
- const std::vector<string>& output_tensor_names,
222
- const std::vector<string>& target_node_names,
223
- std::vector<Tensor>* outputs, RunMetadata* run_metadata,
224
- const thread::ThreadPoolOptions& thread_pool_options) override ;
220
+ absl::Status Run (
221
+ const RunOptions& run_options,
222
+ const std::vector<std::pair<string, Tensor>>& inputs,
223
+ const std::vector<string>& output_tensor_names,
224
+ const std::vector<string>& target_node_names,
225
+ std::vector<Tensor>* outputs, RunMetadata* run_metadata,
226
+ const thread::ThreadPoolOptions& thread_pool_options) override ;
225
227
226
- Status ListDevices (std::vector<DeviceAttributes>* response) override ;
228
+ absl:: Status ListDevices (std::vector<DeviceAttributes>* response) override ;
227
229
228
230
private:
229
231
explicit BatchingSession (const BatchingSessionOptions& options,
230
232
const std::string& thread_pool_name);
231
233
232
234
// Helper fucntion to run the session.
233
- Status InternalRun (
235
+ absl:: Status InternalRun (
234
236
const RunOptions& run_options,
235
237
const std::vector<std::pair<string, Tensor>>& inputs,
236
238
const std::vector<string>& output_tensor_names,
@@ -242,28 +244,28 @@ class BatchingSession : public ServingSession {
242
244
// analyzing the 0th dimension size of each of the tensors. All tensors in the
243
245
// list must have the same 0th dimension size to be batchable. If the sizes
244
246
// are not all identical, returns an error.
245
- Status ComputeInputSize (const std::vector<std::pair<string, Tensor>>& inputs,
246
- size_t * size) const ;
247
+ absl:: Status ComputeInputSize (
248
+ const std::vector<std::pair<string, Tensor>>& inputs, size_t * size) const ;
247
249
248
250
// Merges the input tensors in a batch, via concatenation of correspondingly-
249
251
// named tensors. Puts the merged inputs in the order they are in in the
250
252
// signature. Assumes 'batch' is non-empty. Returns an error if there are any
251
253
// mismatches among the tasks in the batch that violate the constraints for
252
254
// batchability.
253
- Status MergeInputTensors (
255
+ absl:: Status MergeInputTensors (
254
256
const TensorSignature& signature, const Batch<BatchingSessionTask>& batch,
255
257
std::vector<std::pair<string, Tensor>>* merged_inputs);
256
258
257
259
// Splits the output of a batched call to 'wrapped_->Run()' into individual
258
260
// task outputs. Assumes the output tensor order matches the signature.
259
- Status SplitOutputTensors (const TensorSignature& signature,
260
- const std::vector<Tensor>& combined_outputs,
261
- Batch<BatchingSessionTask>* batch);
261
+ absl:: Status SplitOutputTensors (const TensorSignature& signature,
262
+ const std::vector<Tensor>& combined_outputs,
263
+ Batch<BatchingSessionTask>* batch);
262
264
263
265
// Splits RunMetadata parts (e.g. costgraph attribution) into individual task
264
266
// outputs.
265
- Status SplitRunMetadata (RunMetadata* batch_metadata,
266
- Batch<BatchingSessionTask>* batch);
267
+ absl:: Status SplitRunMetadata (RunMetadata* batch_metadata,
268
+ Batch<BatchingSessionTask>* batch);
267
269
268
270
// Processes one batch of Run() calls with 'signature'. Called by
269
271
// 'batch_scheduler_' in a batch thread.
@@ -295,7 +297,7 @@ class BatchingSession : public ServingSession {
295
297
TF_DISALLOW_COPY_AND_ASSIGN (BatchingSession);
296
298
};
297
299
298
- Status BatchingSession::Create (
300
+ absl:: Status BatchingSession::Create (
299
301
const BatchingSessionOptions& options, std::unique_ptr<Session> wrapped,
300
302
const std::vector<SignatureWithBatchingSessionSchedulerCreator>&
301
303
signatures_with_scheduler_creators,
@@ -309,7 +311,7 @@ Status BatchingSession::Create(
309
311
return status;
310
312
}
311
313
312
- Status BatchingSession::Create (
314
+ absl:: Status BatchingSession::Create (
313
315
const BatchingSessionOptions& options, std::unique_ptr<Session> wrapped,
314
316
const std::vector<SignatureWithBatchingSessionSchedulerCreator>&
315
317
signatures_with_scheduler_creators,
@@ -339,7 +341,7 @@ Status BatchingSession::Create(
339
341
return absl::OkStatus ();
340
342
}
341
343
342
- Status BatchingSession::Run (
344
+ absl:: Status BatchingSession::Run (
343
345
const std::vector<std::pair<string, Tensor>>& inputs,
344
346
const std::vector<string>& output_tensor_names,
345
347
const std::vector<string>& target_node_names,
@@ -349,7 +351,7 @@ Status BatchingSession::Run(
349
351
outputs, &run_metadata);
350
352
}
351
353
352
- Status BatchingSession::Run (
354
+ absl:: Status BatchingSession::Run (
353
355
const RunOptions& run_options,
354
356
const std::vector<std::pair<string, Tensor>>& inputs,
355
357
const std::vector<string>& output_tensor_names,
@@ -359,7 +361,7 @@ Status BatchingSession::Run(
359
361
target_node_names, outputs, run_metadata, absl::nullopt);
360
362
}
361
363
362
- Status BatchingSession::Run (
364
+ absl:: Status BatchingSession::Run (
363
365
const RunOptions& run_options,
364
366
const std::vector<std::pair<string, Tensor>>& inputs,
365
367
const std::vector<string>& output_tensor_names,
@@ -371,7 +373,7 @@ Status BatchingSession::Run(
371
373
thread_pool_options);
372
374
}
373
375
374
- Status BatchingSession::InternalRun (
376
+ absl:: Status BatchingSession::InternalRun (
375
377
const RunOptions& run_options,
376
378
const std::vector<std::pair<string, Tensor>>& inputs,
377
379
const std::vector<string>& output_tensor_names,
@@ -434,7 +436,7 @@ Status BatchingSession::InternalRun(
434
436
outputs->clear ();
435
437
436
438
Notification done;
437
- Status status;
439
+ absl:: Status status;
438
440
auto task = std::unique_ptr<BatchingSessionTask>(new BatchingSessionTask);
439
441
task->enqueue_time_micros = EnvTime::NowMicros ();
440
442
task->run_options = run_options;
@@ -455,15 +457,16 @@ Status BatchingSession::InternalRun(
455
457
return status;
456
458
}
457
459
458
- Status BatchingSession::ListDevices (std::vector<DeviceAttributes>* response) {
460
+ absl::Status BatchingSession::ListDevices (
461
+ std::vector<DeviceAttributes>* response) {
459
462
return wrapped_->ListDevices (response);
460
463
}
461
464
462
465
BatchingSession::BatchingSession (const BatchingSessionOptions& options,
463
466
const std::string& thread_pool_name)
464
467
: options_(options), thread_pool_name_(thread_pool_name) {}
465
468
466
- Status BatchingSession::ComputeInputSize (
469
+ absl:: Status BatchingSession::ComputeInputSize (
467
470
const std::vector<std::pair<string, Tensor>>& inputs, size_t * size) const {
468
471
TF_RETURN_IF_ERROR (::tensorflow::serving::ComputeTensorBatchSize (
469
472
inputs, size,
@@ -480,7 +483,7 @@ Status BatchingSession::ComputeInputSize(
480
483
return absl::OkStatus ();
481
484
}
482
485
483
- Status BatchingSession::MergeInputTensors (
486
+ absl:: Status BatchingSession::MergeInputTensors (
484
487
const TensorSignature& signature, const Batch<BatchingSessionTask>& batch,
485
488
std::vector<std::pair<string, Tensor>>* merged_inputs) {
486
489
DCHECK_GE (batch.num_tasks (), 1 );
@@ -574,7 +577,8 @@ Status BatchingSession::MergeInputTensors(
574
577
" One or more tasks does not conform to batch signature" );
575
578
}
576
579
Tensor concated;
577
- const Status concat_status = tensor::Concat (tensors->second , &concated);
580
+ const absl::Status concat_status =
581
+ tensor::Concat (tensors->second , &concated);
578
582
DCHECK (concat_status.ok ()) << concat_status.ToString ();
579
583
if (!concat_status.ok ()) {
580
584
return errors::Internal (" Tensor concat operation failed: " ,
@@ -586,7 +590,7 @@ Status BatchingSession::MergeInputTensors(
586
590
return absl::OkStatus ();
587
591
}
588
592
589
- Status BatchingSession::SplitOutputTensors (
593
+ absl:: Status BatchingSession::SplitOutputTensors (
590
594
const TensorSignature& signature,
591
595
const std::vector<Tensor>& combined_outputs,
592
596
Batch<BatchingSessionTask>* batch) {
@@ -633,7 +637,7 @@ Status BatchingSession::SplitOutputTensors(
633
637
}
634
638
635
639
std::vector<Tensor> split_tensor;
636
- const Status split_status =
640
+ const absl:: Status split_status =
637
641
tensor::Split (tensor, task_sizes_plus_optional_padding, &split_tensor);
638
642
DCHECK (split_status.ok ()) << split_status.ToString ();
639
643
if (!split_status.ok ()) {
@@ -673,8 +677,8 @@ Status BatchingSession::SplitOutputTensors(
673
677
return absl::OkStatus ();
674
678
}
675
679
676
- Status BatchingSession::SplitRunMetadata (RunMetadata* batch_metadata,
677
- Batch<BatchingSessionTask>* batch) {
680
+ absl:: Status BatchingSession::SplitRunMetadata (
681
+ RunMetadata* batch_metadata, Batch<BatchingSessionTask>* batch) {
678
682
if (batch->num_tasks () > 0 ) {
679
683
if (batch_metadata->has_cost_graph ()) {
680
684
// Scale the batch aggregated to reflect the cost of an individual request
@@ -725,7 +729,7 @@ void BatchingSession::ProcessBatch(
725
729
// Regardless of the outcome, we need to propagate the status to the
726
730
// individual tasks and signal that they are done. We use MakeCleanup() to
727
731
// ensure that this happens no matter how we exit the method below.
728
- Status status;
732
+ absl:: Status status;
729
733
auto finally = gtl::MakeCleanup ([&status, &batch] {
730
734
for (int i = 0 ; i < batch->num_tasks (); ++i) {
731
735
BatchingSessionTask* task = batch->mutable_task (i);
@@ -764,9 +768,9 @@ void BatchingSession::ProcessBatch(
764
768
->Add (dequeue_time_micros - task.enqueue_time_micros );
765
769
}
766
770
if (all_tasks_timeout_exceeded) {
767
- status = Status ( static_cast <tensorflow::errors::Code> (
768
- absl::StatusCode::kResourceExhausted ),
769
- " Run() timeout exceeded while waiting in batching queue" );
771
+ status = absl::Status (
772
+ static_cast <absl::StatusCode>( absl::StatusCode::kResourceExhausted ),
773
+ " Run() timeout exceeded while waiting in batching queue" );
770
774
return ;
771
775
}
772
776
@@ -817,7 +821,7 @@ void BatchingSession::ProcessBatch(
817
821
// Share implementation between `SplitInputTask` here and
818
822
// `BatchResource::SplitInputTask` by refactoring and unifying the naming or
819
823
// type differences of data members.
820
- Status SplitInputTask (
824
+ absl:: Status SplitInputTask (
821
825
std::unique_ptr<BatchingSessionTask>* input_task_ptr,
822
826
int open_batch_remaining_slot, int max_batch_size,
823
827
std::vector<std::unique_ptr<BatchingSessionTask>>* output_tasks) {
@@ -947,7 +951,7 @@ Status SplitInputTask(
947
951
// TODO(b/158393551):
948
952
// Figure out the optimal implementation of Split, by using
949
953
// 'Tensor::Slice' and eliminating unnecessary memcpy as much as possible.
950
- const Status split_status =
954
+ const absl:: Status split_status =
951
955
tensor::Split (input_tensor, output_task_sizes, &split_tensors);
952
956
if (!split_status.ok ()) {
953
957
return errors::Internal (
@@ -969,7 +973,7 @@ Status SplitInputTask(
969
973
return absl::OkStatus ();
970
974
}
971
975
972
- Status CreateBatchingSession (
976
+ absl:: Status CreateBatchingSession (
973
977
const BatchingSessionOptions& options,
974
978
const std::vector<SignatureWithBatchingSessionSchedulerCreator>&
975
979
signatures_with_scheduler_creators,
@@ -984,7 +988,7 @@ Status CreateBatchingSession(
984
988
return absl::OkStatus ();
985
989
}
986
990
987
- Status CreateBatchingSession (
991
+ absl:: Status CreateBatchingSession (
988
992
const BatchingSessionOptions& options,
989
993
const std::vector<SignatureWithBatchingSessionSchedulerCreator>&
990
994
signatures_with_scheduler_creators,
@@ -998,7 +1002,7 @@ Status CreateBatchingSession(
998
1002
return absl::OkStatus ();
999
1003
}
1000
1004
1001
- Status CreateBasicBatchingSession (
1005
+ absl:: Status CreateBasicBatchingSession (
1002
1006
const BasicBatchScheduler<BatchingSessionTask>::Options& schedule_options,
1003
1007
const BatchingSessionOptions& batching_session_options,
1004
1008
const TensorSignature& signature, std::unique_ptr<Session> session,
0 commit comments