Skip to content

Commit

Permalink
Add range assert in autograd engine queue lookup (#50372)
Browse files Browse the repository at this point in the history
Summary:
Follow up to  #49652

Pull Request resolved: #50372

Reviewed By: zhangguanheng66

Differential Revision: D25872203

Pulled By: albanD

fbshipit-source-id: 8d6f30f17fba856c5c34c08372767349a250983d
  • Loading branch information
albanD authored and facebook-github-bot committed Jan 11, 2021
1 parent 7efc212 commit e160362
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions torch/csrc/autograd/engine.cpp
Expand Up @@ -1051,6 +1051,8 @@ auto Engine::ready_queue_by_index(std::shared_ptr<ReadyQueue> cpu_ready_queue, i
TORCH_INTERNAL_ASSERT(cpu_ready_queue);
return cpu_ready_queue;
} else {
// Static cast is ok here as the number of device should never overflow an int.
TORCH_INTERNAL_ASSERT(0 <= device_index && device_index < static_cast<int>(device_ready_queues_.size()));
// See Note [Allocating GPUs to autograd threads]
// NB: This function would become obsolete if we truly allocated a CPU thread
// per device, rather than colocate.
Expand Down

0 comments on commit e160362

Please sign in to comment.