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

Method ThunkSchedule

tensorflow/compiler/xla/service/gpu/thunk_schedule.cc:50–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50ThunkSchedule::ThunkSchedule(
51 std::unique_ptr<ThunkSequence> thunks,
52 std::unique_ptr<StreamAssignment> stream_assignment,
53 const std::vector<HloInstruction*>& hlo_total_order)
54 : thunks_(std::move(thunks)),
55 stream_assignment_(std::move(stream_assignment)) {
56 absl::flat_hash_map<const HloInstruction*, Thunk*> hlo_to_thunk;
57 for (const auto& thunk : *thunks_) {
58 InsertOrDie(&hlo_to_thunk, thunk->hlo_instruction(), thunk.get());
59 }
60
61 for (HloInstruction* hlo : hlo_total_order) {
62 if (Thunk** thunk = tensorflow::gtl::FindOrNull(hlo_to_thunk, hlo)) {
63 thunk_total_order_.push_back(*thunk);
64 }
65 }
66
67 for (const Thunk* thunk : thunk_total_order_) {
68 const auto* dst = thunk->hlo_instruction();
69 CHECK(stream_assignment_->HasStreamAssigned(*dst));
70 for (const auto* src : dst->operands()) {
71 AddDependenciesOnTransitiveOperands(*thunk, *src, hlo_to_thunk);
72 }
73 }
74
75 RemoveRedundantDependencyEdges();
76
77 // Compute `depended_by_`, the inverse of `depends_on_`.
78 for (const auto& dependency : depends_on_) {
79 for (const auto* depended : dependency.second) {
80 depended_by_.insert(depended);
81 }
82 }
83}
84
85void ThunkSchedule::RemoveRedundantDependencyEdges() {
86 std::unordered_map<const Thunk*, int> thunk_to_total_order;

Callers

nothing calls this directly

Calls 8

InsertOrDieFunction · 0.85
FindOrNullFunction · 0.85
hlo_instructionMethod · 0.80
HasStreamAssignedMethod · 0.80
getMethod · 0.45
push_backMethod · 0.45
operandsMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected