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

Method alloc_dynamic

src/opr/test/cond.cpp:455–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

453
454public:
455 void alloc_dynamic(VarNode* var, DeviceTensorStorage& dest, size_t size) override {
456 ASSERT_LT(dest.size(), size);
457 ++m_nr_alive;
458 auto ptr = dest.comp_node().alloc_device(size);
459 auto del = [this, cn = dest.comp_node()](void* ptr) {
460 cn.free_device(ptr);
461 auto nr = m_nr_alive.fetch_sub(1);
462 ASSERT_GT(nr, 0u);
463 };
464 dest.reset(dest.comp_node(), size, {static_cast<dt_byte*>(ptr), del});
465 }
466
467 size_t nr_alive() const { return m_nr_alive; }
468

Callers

nothing calls this directly

Calls 5

sizeMethod · 0.45
alloc_deviceMethod · 0.45
comp_nodeMethod · 0.45
free_deviceMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected