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

Method readDigits

samples/sampleIOFormats/sampleIOFormats.cpp:465–490  ·  view source on GitHub ↗

\brief Reads the digit map from file

Source from the content-addressed store, hash-verified

463//! \brief Reads the digit map from file
464//!
465bool SampleIOFormats::readDigits(SampleBuffer& buffer, int32_t groundTruthDigit)
466{
467 int32_t const inputH = buffer.dims.d[2];
468 int32_t const inputW = buffer.dims.d[3];
469
470 // Read a random digit file
471 std::vector<uint8_t> fileData(inputH * inputW);
472 readPGMFile(
473 locateFile(std::to_string(groundTruthDigit) + ".pgm", mParams.dataDirs), fileData.data(), inputH, inputW);
474
475 // Print ASCII representation of digit
476 for (int32_t i = 0; i < inputH * inputW; i++)
477 {
478 sample::gLogInfo << (" .:-=+*#%@"[fileData[i] / 26]) << (((i + 1) % inputW) ? "" : "\n");
479 }
480 sample::gLogInfo << std::endl;
481
482 float* inputBuf = reinterpret_cast<float*>(buffer.buffer);
483
484 for (int32_t i = 0; i < inputH * inputW; i++)
485 {
486 inputBuf[i] = 1.0F - static_cast<float>(fileData[i] / 255.0F);
487 }
488
489 return true;
490}
491
492//!
493//! \brief Verifies that the output is correct and prints it

Callers 1

runFP32ReferenceFunction · 0.80

Calls 3

readPGMFileFunction · 0.85
locateFileFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected