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

Method add_input

src/core/impl/graph/operator_node.cpp:216–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214}
215
216void OperatorNodeBase::add_input(
217 std::initializer_list<VarNode*> list, AddInputSortType sort_type) {
218 mgb_assert(
219 !m_inserted_in_graph && !m_node_prop.valid(),
220 "add input on an opr that has been inserted into graph");
221 auto start_size = m_input.size();
222 for (auto ptr : list) {
223 mgb_assert(
224 ptr && ptr->owner_graph() == owner_graph(),
225 "input(%s) does not belong to same graph", ptr->cname());
226 mgb_assert(
227 !ptr->contain_flag(VarNode::Flag::VOLATILE_CONTENT),
228 "use input of volatile content: %s", cg::dump_var_info({ptr}).c_str());
229 m_input.push_back(ptr);
230 }
231 if (sort_type != AddInputSortType::NONE) {
232 auto begin = m_input.begin(), end = m_input.end();
233 if (sort_type == AddInputSortType::CUR_ADDED)
234 begin += start_size;
235 auto cmp = [](VarNode* a, VarNode* b) { return a->id() < b->id(); };
236 small_sort(begin, end, cmp);
237 }
238}
239
240VarNode* OperatorNodeBase::add_output(const Maybe<std::string>& name) {
241 mgb_assert(

Callers 2

TESTFunction · 0.45
TESTFunction · 0.45

Calls 10

small_sortFunction · 0.85
validMethod · 0.45
sizeMethod · 0.45
owner_graphMethod · 0.45
cnameMethod · 0.45
contain_flagMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
idMethod · 0.45

Tested by 2

TESTFunction · 0.36
TESTFunction · 0.36