|
请问,我用Npu 模型推理时发生内存泄漏,内存泄露的的函数发生在rknn_run上,请问这是这个函数接口内部实现的问题么,还是我的代码问题,内存增加速度挺快的,一分钟差不多能加个1m
inputs[0].buf = rgbbuf;
ret = rknn_inputs_set(ctx, 1, inputs);
if(ret < 0)
{
printf("rknn_input_set fail! ret=%d\n", ret);
}
ret = rknn_run(ctx, nullptr);
if(ret < 0)
{
printf("rknn_run fail! ret=%d\n", ret);
}
outputs[0].want_float = true;
outputs[0].is_prealloc = false;
ret = rknn_outputs_get(ctx, 1, outputs, nullptr);
if(ret < 0)
{
printf("rknn_outputs_get fail! ret=%d\n", ret);
}
// Process output
if(outputs[0].size == output0_attr.n_elems * sizeof(float))
{
const size_t num_results = 1;
const float threshold = 0.001f;
std::vector<std::pair<float, int>> top_results;
get_top_n<float>((float*)outputs[0].buf, output_elems, num_results, threshold, &top_results, true);
std::vector<string> labels;
size_t label_count;
if (!ReadLabelsFile(lable_path, &labels, &label_count))
{
for (const auto& result : top_results)
{
const float confidence = result.first;
const int index = result.second;
centralStatus = result.second;
//printf("%d\n", centralStatus);
//std::cout << confidence << ": " << index << " " << labels[index] << "\n";
}
}
}
else
{
printf("rknn_outputs_get fail! get output_size = [%d], but expect %u!\n",
outputs[0].size, (uint32_t)(output0_attr.n_elems * sizeof(float)));
}
rknn_outputs_release(ctx, 1, outputs);
|
|