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

Method alloc

dnn/src/cambricon/handle.cpp:60–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58HandleImpl::~HandleImpl() noexcept = default;
59
60void* HandleImpl::alloc(size_t size) {
61 auto mem_mgr = megcore_context().mem_mgr;
62 if (size <= 0) {
63 return nullptr;
64 }
65 if (mem_mgr) {
66 return mem_mgr->alloc(size);
67 } else {
68 void* ptr = nullptr;
69 cnrt_check(cnrtSetDevice(device_id()));
70 cnrt_check(cnrtMalloc(&ptr, size));
71 return ptr;
72 }
73}
74
75void HandleImpl::free(void* ptr) {
76 auto mem_mgr = megcore_context().mem_mgr;

Callers 4

execMethod · 0.45
execMethod · 0.45
exec_index_putFunction · 0.45
make_bundleFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected