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

Method dump_var

src/plugin/impl/opr_io_dump.cpp:260–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260void TextOprIODump::dump_var(VarNode* var, bool lazy_sync) {
261 MGB_LOCK_GUARD(m_mtx);
262 auto fout = m_fout.get();
263 auto opr = var->owner_opr();
264 bool valid = var->dev_tensor_valid();
265
266 bool print_var_produce = true;
267 if (lazy_sync) {
268 if (!m_lazy_value) {
269 m_lazy_value = std::make_unique<LazyValueRecorder>();
270 fprintf(fout, "==== begin lazy value recording\n");
271 }
272 if (valid) {
273 print_var_produce = m_lazy_value->record_var(var);
274 } else {
275 print_var_produce = false;
276 }
277 }
278
279 if (print_var_produce) {
280 fprintf(fout, "var%zd produced: name=%s layout=%s owner_opr=%s{%s} opr%zd\n",
281 var->id(), var->cname(),
282 valid ? var->layout().to_string().c_str() : "<invalid>", opr->cname(),
283 opr->dyn_typeinfo()->name, opr->id());
284 }
285
286 if (!valid || !print_var_produce)
287 return;
288
289 auto print_var_val = [&](VarNode* var, bool print_stat = false) {
290 if (lazy_sync) {
291 fprintf(fout, "<see lazy value below>");
292 return;
293 }
294 if (!var->dev_tensor_valid()) {
295 fprintf(fout, "<invalid>");
296 return;
297 }
298
299 HostTensorND hv;
300 hv.copy_from(var->dev_tensor()).sync();
301 print_host_val(fout, m_max_size, hv.as_megdnn(), print_stat);
302 if (m_print_addr) {
303 fprintf(fout, " <%p>", var->dev_tensor().raw_ptr());
304 }
305 };
306
307 fprintf(fout, " deps:\n");
308
309 ThinHashMap<VarNode*, int> var2iid;
310 for (size_t i = 0; i < opr->input().size(); ++i)
311 var2iid[opr->input(i)] = i;
312
313 using DT = cg::OperatorNodeBase::NodeProp::DepType;
314 // [(input_id, var_id, var, dep_type)]
315 SmallVector<std::tuple<int, size_t, VarNode*, DT>> dep_vars;
316 for (auto&& dep_entry : opr->node_prop().dep_map()) {
317 int inp_id = -1;

Callers

nothing calls this directly

Calls 15

print_host_valFunction · 0.85
small_sortFunction · 0.85
is_static_var_shapeFunction · 0.85
is_static_var_valueFunction · 0.85
is_static_var_storageFunction · 0.85
dump_tensorFunction · 0.85
dev_tensor_validMethod · 0.80
as_megdnnMethod · 0.80
emplace_backMethod · 0.80
infer_valueMethod · 0.80
getMethod · 0.45
owner_oprMethod · 0.45

Tested by

no test coverage detected