MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / collect_groups

Method collect_groups

src/gopt/impl/misc.cpp:844–865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

842}
843
844uint64_t PackAllReduceReplacePass::collect_groups(
845 OperatorNodeBase* opr,
846 ThinHashMap<uint64_t, std::shared_ptr<GroupInfo>>& group_info,
847 ThinHashMap<uint64_t, cg::OprNodeArray>& groups) {
848 // check CollectiveComm oprs that have been marked in PackAllReduceScanPass
849 if (!opr->same_type<opr::CollectiveComm>())
850 return 0;
851 opr::CollectiveComm& comm = opr->cast_final_safe<opr::CollectiveComm>();
852 if (comm.pack_hash() == 0)
853 return 0; // pack_hash not set
854
855 VarNode* var = comm.input(0);
856 auto info = std::make_shared<GroupInfo>(
857 var->comp_node().locator().device, var->dtype(), comm.nr_devices(),
858 comm.is_root(), comm.rank(), comm.group_client(), comm.backend());
859 uint64_t hash = info->hash(comm.pack_hash());
860 if (group_info.find(hash) == group_info.end()) {
861 group_info.emplace(hash, info);
862 }
863 groups[hash].push_back(opr);
864 return hash;
865}
866
867void PackAllReduceReplacePass::divide_packs(
868 const ThinHashMap<uint64_t, cg::OprNodeArray>& groups,

Callers

nothing calls this directly

Calls 13

backendMethod · 0.80
inputMethod · 0.45
locatorMethod · 0.45
comp_nodeMethod · 0.45
dtypeMethod · 0.45
nr_devicesMethod · 0.45
is_rootMethod · 0.45
rankMethod · 0.45
hashMethod · 0.45
findMethod · 0.45
endMethod · 0.45
emplaceMethod · 0.45

Tested by

no test coverage detected