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

Method ReturnSubStream

tensorflow/stream_executor/stream.cc:2575–2608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2573}
2574
2575void Stream::ReturnSubStream(Stream *sub_stream) {
2576 absl::MutexLock lock(&mu_);
2577
2578 // Look for the sub-stream.
2579 for (int64 index = 0; index < sub_streams_.size(); ++index) {
2580 std::pair<std::unique_ptr<Stream>, bool> &pair = sub_streams_[index];
2581 if (pair.first.get() != sub_stream) {
2582 continue;
2583 }
2584
2585 // Found the sub_stream.
2586 if (sub_stream->ok()) {
2587 VLOG(1) << DebugStreamPointers() << " returned ok sub_stream "
2588 << sub_stream->DebugStreamPointers();
2589 pair.second = true;
2590 } else {
2591 // The returned stream is not ok. Streams have a monotonic state
2592 // machine; the stream will remain in !ok forever. Swap it with the last
2593 // stream and pop it off.
2594 VLOG(1) << DebugStreamPointers() << " returned !ok sub_stream "
2595 << sub_stream->DebugStreamPointers();
2596 const int64 last = sub_streams_.size() - 1;
2597 if (index != last) {
2598 std::swap(pair, sub_streams_[last]);
2599 }
2600 sub_streams_.pop_back();
2601 }
2602 return;
2603 }
2604
2605 LOG(FATAL) << DebugStreamPointers()
2606 << " did not create the returned sub-stream "
2607 << sub_stream->DebugStreamPointers();
2608}
2609
2610Stream &Stream::ThenStartTimer(Timer *t) {
2611 VLOG_CALL(PARAM(t));

Callers 5

TEST_FFunction · 0.80
TransferArrayToDeviceMethod · 0.80

Calls 5

DebugStreamPointersMethod · 0.80
pop_backMethod · 0.80
sizeMethod · 0.45
getMethod · 0.45
okMethod · 0.45

Tested by 1

TEST_FFunction · 0.64