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

Method alloc_with_defrag

src/core/impl/graph/var_node_mem_mgr/defrag.cpp:36–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36void VarDevMemDefragmenter::alloc_with_defrag(
37 VarNode* var, DeviceTensorStorage& storage, size_t size) {
38 CompNodeInfo* cninfo_ptr;
39 {
40 MGB_LOCK_GUARD(m_mtx);
41 cninfo_ptr = &m_cninfo_map[var->comp_node()];
42 }
43 MGB_LOCK_GUARD(cninfo_ptr->mtx);
44
45 if (!storage.comp_node_valid()) {
46 storage.comp_node(var->comp_node());
47 cninfo_ptr->vars.insert(var);
48 }
49
50 MGB_TRY { alloc_direct(var, storage, size); }
51 MGB_CATCH(MemAllocError&, {
52 mgb_log_warn(
53 "memory allocation failed for var %s; try defragmenting", var->cname());

Callers

nothing calls this directly

Calls 3

comp_node_validMethod · 0.80
comp_nodeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected