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

Function CreateTensor

bench/BenchCvtColor.cpp:82–100  ·  view source on GitHub ↗

Adapted from src/util/TensorDataUtils.hpp

Source from the content-addressed store, hash-verified

80
81// Adapted from src/util/TensorDataUtils.hpp
82inline static nvcv::Tensor CreateTensor(int numImages, int imgWidth, int imgHeight, const nvcv::ImageFormat &imgFormat)
83{
84 if (imgFormat == NVCV_IMAGE_FORMAT_NV12 || imgFormat == NVCV_IMAGE_FORMAT_NV12_ER
85 || imgFormat == NVCV_IMAGE_FORMAT_NV21 || imgFormat == NVCV_IMAGE_FORMAT_NV21_ER)
86 {
87 if (imgHeight % 2 != 0 || imgWidth % 2 != 0)
88 {
89 throw std::invalid_argument("Invalid height");
90 }
91
92 int height420 = (imgHeight * 3) / 2;
93
94 return nvcv::Tensor(numImages, {imgWidth, height420}, nvcv::ImageFormat(NVCV_IMAGE_FORMAT_Y8));
95 }
96 else
97 {
98 return nvcv::Tensor(numImages, {imgWidth, imgHeight}, imgFormat);
99 }
100}
101
102template<typename BT>
103inline void CvtColor(nvbench::state &state, nvbench::type_list<BT>)

Callers 1

CvtColorFunction · 0.70

Calls 2

TensorClass · 0.50
ImageFormatClass · 0.50

Tested by

no test coverage detected