AI2D重复调用死机问题

Viewed 93

问题描述


void Utils::crop_resize(Bbox &crop_info, std::unique_ptr<ai2d_builder> &builder, runtime_tensor &ai2d_in_tensor, runtime_tensor &ai2d_out_tensor)
{
    // run ai2d
    ai2d_datatype_t ai2d_dtype{ai2d_format::NCHW_FMT, ai2d_format::NCHW_FMT, ai2d_in_tensor.datatype(), ai2d_out_tensor.datatype()};
    ai2d_crop_param_t crop_param{true, crop_info.x, crop_info.y, crop_info.w, crop_info.h};
    ai2d_shift_param_t shift_param{false, 0};
    ai2d_pad_param_t pad_param{false, {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, ai2d_pad_mode::constant, {114, 114, 114}};
    ai2d_resize_param_t resize_param{true, ai2d_interp_method::tf_bilinear, ai2d_interp_mode::half_pixel};
    ai2d_affine_param_t affine_param{false, ai2d_interp_method::cv2_bilinear, 0, 0, 127, 1, {0.5, 0.1, 0.0, 0.1, 0.5, 0.0}};

    dims_t in_shape = ai2d_in_tensor.shape();
    dims_t out_shape = ai2d_out_tensor.shape();
    printf("dzs:crop_resize.1\n");
    //auto b = ;
    printf("dzs:crop_resize.1.1\n");
    builder.reset( new ai2d_builder(in_shape, out_shape, ai2d_dtype, crop_param, shift_param, pad_param, resize_param, affine_param) );
    printf("dzs:crop_resize.2\n");
    builder->build_schedule();
    printf("dzs:crop_resize.3\n");
    builder->invoke(ai2d_in_tensor,ai2d_out_tensor).expect("error occurred in ai2d running");
    printf("dzs:crop_resize.4\n");
    //delete b;
}
这个函数调用2-3次挂机,卡死在 builder.reset( new ai2d_builder(in_shape, out_shape, ai2d_dtype, crop_param, shift_param, pad_param, resize_param, affine_param) );
这行,跟踪了AI2D的驱动
static int ai_2d_device_open(struct dfs_fd *file)
{
    struct ai_2d_dev_handle *handle;
    rt_device_t device;
    rt_size_t size = sizeof (struct ai_2d_dev_handle);
    rt_kprintf("dzs:ai_2d open malloc size=%d\n", size);
    //g_memheap_log = 1;
    handle = rt_malloc( size );
    //g_memheap_log = 0;
    rt_kprintf("dzs:rt_malloc handle %p\n", handle);
    if(handle == RT_NULL) 
    {
        rt_kprintf("malloc failed\n");
        return -1;
    }
    device = (rt_device_t)file->fnode->data;
    handle->wait = &device->wait_queue;
    file->data = (void*)handle;
    rt_kprintf("dzs:ai_2d open end %p\n", file->data);
    return RT_EOK;
}

这个函数是可以成功返回

复现步骤


image.png

2 Answers

你好,这是使用的已有示例吗?还是自己写的?

在Utils类中修改的。 把剪裁+缩放一起true就不稳定,API手册中这两个是可以组合使用;单独用没问题