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

Function dumpBuffer

samples/common/sampleUtils.cpp:392–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390
391template <typename T>
392void dumpBuffer(void const* buffer, std::string const& separator, std::ostream& os, Dims const& dims,
393 Dims const& strides, int32_t vectorDim, int32_t spv)
394{
395 auto const vol = volume(dims);
396 T const* typedBuffer = static_cast<T const*>(buffer);
397 std::string sep;
398 for (int64_t v = 0; v < vol; ++v)
399 {
400 int64_t curV = v;
401 int32_t dataOffset = 0;
402 for (int32_t dimIndex = dims.nbDims - 1; dimIndex >= 0; --dimIndex)
403 {
404 int32_t dimVal = curV % dims.d[dimIndex];
405 if (dimIndex == vectorDim)
406 {
407 dataOffset += (dimVal / spv) * strides.d[dimIndex] * spv + dimVal % spv;
408 }
409 else
410 {
411 dataOffset += dimVal * strides.d[dimIndex] * (vectorDim == -1 ? 1 : spv);
412 }
413 curV /= dims.d[dimIndex];
414 ASSERT(curV >= 0);
415 }
416
417 os << sep;
418 sep = separator;
419 print(os, typedBuffer[dataOffset]);
420 }
421}
422
423// Explicit instantiation
424template void dumpBuffer<bool>(void const* buffer, std::string const& separator, std::ostream& os, Dims const& dims,

Callers

nothing calls this directly

Calls 2

printFunction · 0.85
volumeFunction · 0.70

Tested by

no test coverage detected