MCPcopy Create free account
hub / github.com/MegEngine/MegCC / alloc_device_tensor

Function alloc_device_tensor

runtime/src/vm/memory.c:31–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31static TinyNNStatus alloc_device_tensor(Instruction* inst, VM* vm) {
32 Tensor* tensor = inst->workload.dev_mem_alloc.tensor;
33 DeviceModel* model = get_active_device_model(vm);
34 RuntimeOpt* opt = &model->opt;
35 if (!tensor || !opt)
36 return TinyNN_ERROR_NULL_PTR;
37 size_t length_in_bytes = tensor_length_in_byte(tensor);
38 tensor->ptr = opt->device->malloc(length_in_bytes);
39 return TinyNN_SUCCESS;
40}
41
42static TinyNNStatus free_device_tensor(Instruction* inst, VM* vm) {
43 Tensor* tensor = inst->workload.dev_mem_alloc.tensor;

Callers

nothing calls this directly

Calls 3

tensor_length_in_byteFunction · 0.85
mallocMethod · 0.80
get_active_device_modelFunction · 0.70

Tested by

no test coverage detected