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

Function checkTensorList

python/mod_cvcuda/operators/OpStack.cpp:31–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29namespace {
30
31void checkTensorList(std::vector<Tensor> &tensorList, int64_t (&outputShape)[4], nvcv::TensorLayout &layout,
32 nvcv::DataType &dtype)
33{
34 int32_t totalTensors = 0;
35
36 if (tensorList.size() == 0)
37 {
38 throw std::runtime_error("Invalid input tensor list");
39 }
40
41 for (auto &tensor : tensorList)
42 {
43 if (tensor.shape().rank() < 3 || tensor.shape().rank() > 4)
44 {
45 throw std::runtime_error("Invalid input tensor shape");
46 }
47 if (tensor.shape().rank() == 4)
48 {
49 totalTensors += tensor.shape()[0];
50 outputShape[1] = tensor.shape()[1];
51 outputShape[2] = tensor.shape()[2];
52 outputShape[3] = tensor.shape()[3];
53 }
54 else
55 {
56 totalTensors++;
57 outputShape[1] = tensor.shape()[0];
58 outputShape[2] = tensor.shape()[1];
59 outputShape[3] = tensor.shape()[2];
60 }
61
62 if (tensor.shape().layout() == nvcv::TENSOR_CHW || tensor.shape().layout() == nvcv::TENSOR_NCHW)
63 layout = nvcv::TENSOR_NCHW;
64 else
65 layout = nvcv::TENSOR_NHWC;
66 }
67 outputShape[0] = totalTensors; // set N to total number of tensors
68 dtype = tensorList[0].dtype();
69}
70
71Tensor StackIntoInternal(Tensor &output, std::vector<Tensor> &tensorList, std::optional<Stream> pstream,
72 int32_t numberOfTensors)

Callers 2

StackIntoFunction · 0.85
StackFunction · 0.85

Calls 5

sizeMethod · 0.45
rankMethod · 0.45
shapeMethod · 0.45
layoutMethod · 0.45
dtypeMethod · 0.45

Tested by

no test coverage detected