| 1023 | } |
| 1024 | |
| 1025 | port::StatusOr<Stream *> StreamExecutorMemoryAllocator::GetStream( |
| 1026 | int device_ordinal) { |
| 1027 | CHECK(!AllowsAsynchronousDeallocation()) |
| 1028 | << "The logic below only works for synchronous allocators"; |
| 1029 | TF_ASSIGN_OR_RETURN(StreamExecutor * executor, |
| 1030 | GetStreamExecutor(device_ordinal)); |
| 1031 | Stream *out = [&] { |
| 1032 | absl::MutexLock lock(&mutex_); |
| 1033 | if (!streams_.count(device_ordinal)) { |
| 1034 | auto p = streams_.emplace(std::piecewise_construct, |
| 1035 | std::forward_as_tuple(device_ordinal), |
| 1036 | std::forward_as_tuple(executor)); |
| 1037 | p.first->second.Init(); |
| 1038 | return &p.first->second; |
| 1039 | } |
| 1040 | return &streams_.at(device_ordinal); |
| 1041 | }(); |
| 1042 | return out; |
| 1043 | } |
| 1044 | |
| 1045 | } // namespace stream_executor |
nothing calls this directly
no test coverage detected