| 39 | } |
| 40 | |
| 41 | int64_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 | |
| 62 | nvinfer1::Dims toDims(std::vector<int32_t> const& vec) |
| 63 | { |
no test coverage detected