| 9 | #include "vm.h" |
| 10 | |
| 11 | static inline TinyNNStatus alloc_tensor_opt(Tensor* tensor, const RuntimeOpt* opt) { |
| 12 | if (tensor->is_dynamic) { |
| 13 | size_t length_in_byte = tensor_length_in_byte(tensor); |
| 14 | if (!tensor->ptr || tensor->size < length_in_byte) { |
| 15 | if (tensor->ptr) |
| 16 | opt->device->free(tensor->ptr); |
| 17 | tensor->ptr = opt->device->malloc(length_in_byte); |
| 18 | tensor->size = length_in_byte; |
| 19 | tensor->offset = 0; |
| 20 | } |
| 21 | } else { |
| 22 | LOG_DEBUG("tensor is static, no memory allocated.\n"); |
| 23 | } |
| 24 | return TinyNN_SUCCESS; |
| 25 | } |
| 26 | |
| 27 | static inline DeviceModel* get_active_device_model(VM* vm) { |
| 28 | return vm->model->device_models[vm->model->active_device_model_idx]; |
no test coverage detected