CGroupInfo::CGroupInfo(shared_ptr<Graph> g){ m_groupSize.clear(); m_groupMembers.clear(); m_groupMembersSize.clear(); m_groupMembersInpSize.clear(); printf("CG0 \n"); for (auto it = g->begin(); it != g->end(); ++it) { printf("CG1 \n"); Node *n = *it; if(kConcat == n->kind()) { printf("CG2 \n"); string groupname = n->output()->uniqueName(); //Value's uniqueName is unique, so can be used as key printf("groupname = %s\n", groupname); m_groupSize[groupname] = getValueSize(n->output()); for(int i = 0; i < n->inputs().size(); i++) { printf("CG3 \n"); Node *inp = n->inputs()[i]->node(); if(n->inputs()[i]->node()->kind() == kParam) { printf("CG4 \n"); continue; } m_groupMembers[groupname].push_back(n->inputs()[i]->uniqueName()); m_groupMembersSize[groupname].push_back(getValueSize(n->inputs()[i])); m_groupMembersInpSize[inp->inputs()[0]->uniqueName()] = getValueSize(inp->inputs()[0]); } } else if(n->inputs().size() > 0 && isGraphInput(g,n)) { printf("CG5 \n"); m_groupSize["group_input"] += getValueSize(n->inputs()[0]); m_groupMembers["group_input"].push_back(n->inputs()[0]->uniqueName()); m_groupMembersSize["group_input"].push_back(getValueSize(n->inputs()[0])); } else if(kTransLayoutAfterSlice == n->kind()) { printf("CG6 \n"); string groupname = n->output()->uniqueName(); //Value's uniqueName is unique, so can be used as key m_groupSize[groupname] = getValueSize(n->output()); for(int i = 0; i < n->inputs().size(); i++) { printf("CG7 \n"); Node *inp = n->inputs()[i]->node(); m_groupMembers[groupname].push_back(n->inputs()[i]->uniqueName()); m_groupMembersSize[groupname].push_back(getValueSize(n->inputs()[i])); m_groupMembersInpSize[inp->inputs()[0]->uniqueName()] = getValueSize(inp->inputs()[0]); } } } }这段是什么意思
时间: 2024-03-19 08:39:54 浏览: 45
这段代码实现了一个名为CGroupInfo的类的构造函数,该类用于保存给定图中的节点分组信息。构造函数传入一个指向Graph对象的shared_ptr智能指针,然后遍历图中的每个节点,当遇到kConcat节点时,将其输出的唯一名称作为键,其输入节点的唯一名称和大小信息作为值存储在m_groupMembers、m_groupMembersSize、m_groupMembersInpSize等成员变量中,当遇到kTransLayoutAfterSlice节点时也是同样的处理方式,当遇到图的输入节点时,将其唯一名称和大小信息也存储在m_groupMembers、m_groupMembersSize、m_groupMembersInpSize等成员变量中。最终,CGroupInfo对象包含了图中每个节点的分组信息。
阅读全文