MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / FindOrCreateNdSbpString

Function FindOrCreateNdSbpString

oneflow/core/framework/nd_sbp.cpp:24–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22namespace {
23
24Maybe<std::vector<std::string>> FindOrCreateNdSbpString(Symbol<NdSbp> nd_sbp) {
25 static thread_local auto* nd_sbp2nd_sbp_str =
26 new HashMap<Symbol<NdSbp>, std::shared_ptr<std::vector<std::string>>>();
27 auto iter = nd_sbp2nd_sbp_str->find(nd_sbp);
28 if (iter == nd_sbp2nd_sbp_str->end()) {
29 std::shared_ptr<std::vector<std::string>> nd_sbp_str =
30 std::make_shared<std::vector<std::string>>(nd_sbp->sbp_parallel_size());
31 for (int64_t i = 0; i < nd_sbp_str->size(); ++i) {
32 nd_sbp_str->at(i) = SbpParallelToString(nd_sbp->sbp_parallel(i));
33 }
34 iter = nd_sbp2nd_sbp_str->emplace(nd_sbp, nd_sbp_str).first;
35 }
36 return iter->second;
37}
38
39Maybe<void> GetDualSbpParallel(const SbpParallel& sbp_parallel, SbpParallel* dual_sbp_parallel) {
40 if (sbp_parallel.has_split_parallel()) {

Callers 1

GetNdSbpStrListFunction · 0.85

Calls 5

SbpParallelToStringFunction · 0.85
findMethod · 0.80
endMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected