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

Method Schedule

tensorflow/core/kernels/batching_util/shared_batch_scheduler.h:528–567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

526
527template <typename TaskType>
528Status Queue<TaskType>::Schedule(std::unique_ptr<TaskType>* task) {
529 if ((*task)->size() > options_.max_batch_size) {
530 return errors::InvalidArgument("Task size ", (*task)->size(),
531 " is larger than maximum batch size ",
532 options_.max_batch_size);
533 }
534
535 bool notify_of_schedulable_batch = false;
536 {
537 mutex_lock l(mu_);
538
539 DCHECK(!closed_);
540
541 if (batches_.back()->size() + (*task)->size() > options_.max_batch_size) {
542 if (batches_.size() >= options_.max_enqueued_batches) {
543 return errors::Unavailable(
544 "The batch scheduling queue to which this task was submitted is "
545 "full");
546 }
547 StartNewBatch();
548 }
549 if (batches_.back()->empty()) {
550 open_batch_start_time_micros_ = env_->NowMicros();
551 }
552 batches_.back()->AddTask(std::move(*task));
553
554 if (!schedulable_batch_) {
555 if (batches_.size() > 1 || IsOpenBatchSchedulable()) {
556 schedulable_batch_ = true;
557 notify_of_schedulable_batch = true;
558 }
559 }
560 }
561
562 if (notify_of_schedulable_batch) {
563 schedulable_batch_callback_();
564 }
565
566 return Status::OK();
567}
568
569template <typename TaskType>
570size_t Queue<TaskType>::NumEnqueuedTasks() const {

Callers

nothing calls this directly

Calls 7

InvalidArgumentFunction · 0.85
UnavailableFunction · 0.85
sizeMethod · 0.45
backMethod · 0.45
emptyMethod · 0.45
NowMicrosMethod · 0.45
AddTaskMethod · 0.45

Tested by

no test coverage detected