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

Method setup_input_checker

src/plugin/impl/var_sanity_check.cpp:285–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283}
284
285void VarSanityCheck::setup_input_checker(
286 bool add_debug_log, cg::OperatorNodeBase* opr,
287 cg::GraphExecutable::ExecEnv& env, input_checker_fn checker) {
288 for (auto&& dep_entry : opr->node_prop().dep_map()) {
289 if (!cg::OperatorNodeBase::NodeProp::is_device_value_dep(dep_entry.second)) {
290 continue;
291 }
292
293 auto var = dep_entry.first;
294 if (add_debug_log) {
295 m_debug_log.add_receiver(var);
296 }
297
298 // dispatch on output comp node, to check value before input var
299 // is reclaimed
300
301 CompNode cn;
302
303 // prefer var comp node if opr executes on it
304 for (auto i : opr->output()) {
305 if (i->comp_node() == var->comp_node()) {
306 cn = i->comp_node();
307 break;
308 }
309 }
310 if (!cn.valid()) {
311 // find a comp node that waits var
312 for (auto&& i : opr->input_waiting_spec()) {
313 for (auto j : i.dev_ready) {
314 if (j == var) {
315 cn = i.comp_node;
316 break;
317 }
318 }
319 if (cn.valid())
320 break;
321 }
322 if (!cn.valid()) {
323 // input waiting spec may be purged; now we just use any
324 // comp node of this opr
325 cn = opr->output(0)->comp_node();
326 }
327 }
328
329 auto callback = [this, opr, var, checker]() {
330#if MGB_ENABLE_COND_EXEC
331 if (auto mask = cg::ExecutionMask::get_from_opr(var->owner_opr())) {
332 if (!mask->enabled()) {
333 mgb_assert(
334 !m_var2chksum.count(var),
335 "disabled opr has computed output: %s",
336 cg::dump_var_info({var}).c_str());
337 return;
338 }
339 }
340#endif
341 (this->*checker)(opr, var);
342 };

Callers

nothing calls this directly

Calls 9

add_receiverMethod · 0.80
input_waiting_specMethod · 0.80
outputMethod · 0.45
comp_nodeMethod · 0.45
validMethod · 0.45
owner_oprMethod · 0.45
enabledMethod · 0.45
countMethod · 0.45
dispatch_on_comp_nodeMethod · 0.45

Tested by

no test coverage detected