MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / GetOutputTensorShape

Function GetOutputTensorShape

python/mod_cvcuda/CvtColorUtil.cpp:299–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297}
298
299nvcv::TensorShape GetOutputTensorShape(const nvcv::TensorShape &inputShape, nvcv::ImageFormat outputFormat,
300 NVCVColorConversionCode code)
301{
302 if (inputShape.rank() < 3 || inputShape.rank() > 4)
303 {
304 throw std::runtime_error("Invalid input tensor shape, only NHWC or HWC are supported");
305 }
306
307 int64_t outputShape[4] = {};
308 bool heightIndex = inputShape.rank() == 4 ? 1 : 0;
309 for (int i = 0; i < inputShape.rank(); i++)
310 {
311 outputShape[i] = inputShape[i];
312 }
313 int channelIndex = inputShape.rank() == 4 ? 3 : 2;
314
315 outputShape[heightIndex] = GetOutputHeight(outputShape[heightIndex], code);
316 outputShape[channelIndex] = outputFormat.numChannels();
317
318 if (inputShape.rank() == 4)
319 {
320 return nvcv::TensorShape({outputShape[0], outputShape[1], outputShape[2], outputShape[3]}, "NHWC");
321 }
322 else
323 {
324 assert(inputShape.rank() == 3);
325
326 return nvcv::TensorShape({outputShape[0], outputShape[1], outputShape[2]}, "HWC");
327 }
328}

Callers 2

CvtColorFunction · 0.85
AdvCvtColorFunction · 0.85

Calls 4

GetOutputHeightFunction · 0.85
TensorShapeFunction · 0.50
rankMethod · 0.45
numChannelsMethod · 0.45

Tested by

no test coverage detected