CV-CUDA icon indicating copy to clipboard operation
CV-CUDA copied to clipboard

[QUESTION] how to use cvcudaCopyMakeBorderVarShapeSubmit

Open LianJunjian opened this issue 2 months ago • 2 comments

how to use cvcudaCopyMakeBorderVarShapeSubmit interface . how to create nvcv::Tensor &left and nvcv::Tensor &top.

I had try: nvcv::TensorShape::DimType dims[1] = {static_castnvcv::TensorShape::DimType(curN)}; nvcv::TensorShape::ShapeType s(dims, 1); nvcv::Tensor tTop (nvcv::TensorShape(s, nvcv::TENSOR_W), nvcv::DataType(NVCV_DATA_TYPE_S32));

opBorderBatch(cu_stream_, /in/ ibResized, /out/ ibCanvas, /top/ tTop, /left/tLeft, /mode/NVCVBorderType::NVCV_BORDER_CONSTANT, /val/ float4({br, bg, bb, 0.f}));

but got error: terminate called after throwing an instance of 'nvcv::Exception' what(): NVCV_ERROR_INVALID_ARGUMENT: Tensor layout not supported

LianJunjian avatar Oct 27 '25 08:10 LianJunjian

Problem solved — I checked the source file copy_make_border_var_shape.cu and found that the layouts of left and top must be NHWC or HWC:

if (!(left_format == kNHWC || left_format == kHWC)) { LOG_ERROR("Invalid Left DataFormat " << left_format); return ErrorCode::INVALID_DATA_FORMAT; }

Moreover, inside the kernel, left and top are read as 3D tensors:

const int left = *left_.ptr(0, 0, batch_idx); const int top = *top_.ptr(0, 0, batch_idx);

I think this should be documented in more detail in the official documentation.

LianJunjian avatar Oct 27 '25 09:10 LianJunjian

Hi @LianJunjian , glad you got the problem figured out!

Currently in the documentation we have some constraints listed for the top/left tensors, but we can certainty look into fixing any errors or improving the clarity. Do you have a specific error or missing constraint in the documentation that you found?

justincdavis avatar Nov 14 '25 17:11 justincdavis