MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / volume

Function volume

samples/common/sampleUtils.cpp:41–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41int64_t volume(nvinfer1::Dims const& dims, nvinfer1::Dims const& strides, int32_t vecDim, int32_t comps, int32_t batch)
42{
43 int32_t maxNbElems = 1;
44 for (int32_t i = 0; i < dims.nbDims; ++i)
45 {
46 // Get effective length of axis.
47 int32_t d = dims.d[i];
48 // Any dimension is 0, it is an empty tensor.
49 if (d == 0)
50 {
51 return 0;
52 }
53 if (i == vecDim)
54 {
55 d = samplesCommon::divUp(d, comps);
56 }
57 maxNbElems = std::max(maxNbElems, d * strides.d[i]);
58 }
59 return static_cast<int64_t>(maxNbElems) * batch * (vecDim < 0 ? 1 : comps);
60}
61
62nvinfer1::Dims toDims(std::vector<int32_t> const& vec)
63{

Callers 1

dumpBufferFunction · 0.70

Calls 2

maxFunction · 0.85
divUpFunction · 0.70

Tested by

no test coverage detected