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

Function MakeParallelConf

oneflow/core/framework/parallel_conf_util.cpp:34–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34Maybe<ParallelConf> MakeParallelConf(const std::string& device_tag,
35 const std::vector<std::string>& machine_device_ids,
36 const std::shared_ptr<Shape>& hierarchy) {
37 std::shared_ptr<ParallelConf> parallel_conf = std::make_shared<ParallelConf>();
38 parallel_conf->set_device_tag(device_tag);
39 for (const std::string& machine_device_id : machine_device_ids) {
40 size_t pos = machine_device_id.find(':');
41 CHECK_NE_OR_RETURN(pos, std::string::npos) << "device_name: " << machine_device_id;
42 std::string machine_id = machine_device_id.substr(0, pos);
43 CHECK_OR_RETURN(
44 (IsStrInt(machine_id) || (machine_id[0] == '@' && IsStrInt(machine_id.substr(1)))))
45 << " machine_id: " << machine_id;
46 std::string device_id = machine_device_id.substr(pos + 1);
47 size_t minus_pos = device_id.rfind('-');
48 if (minus_pos == std::string::npos) {
49 CHECK_OR_RETURN(IsStrInt(device_id));
50 } else {
51 std::string min_id = device_id.substr(0, minus_pos);
52 CHECK_OR_RETURN(IsStrInt(min_id));
53 std::string max_id = device_id.substr(minus_pos + 1);
54 CHECK_OR_RETURN(IsStrInt(max_id));
55 }
56 parallel_conf->add_device_name(machine_device_id);
57 if (hierarchy) {
58 ShapeProto proto;
59 hierarchy->ToProto(&proto);
60 parallel_conf->mutable_hierarchy()->CopyFrom(proto);
61 }
62 }
63 return parallel_conf;
64}
65
66} // namespace oneflow

Callers 5

BuildInitialScopeMethod · 0.85
TESTFunction · 0.85
NewMethod · 0.85
CreateParallelDescMethod · 0.85

Calls 4

IsStrIntFunction · 0.85
findMethod · 0.80
ToProtoMethod · 0.45
CopyFromMethod · 0.45

Tested by 1

TESTFunction · 0.68