\brief Reads the input and mean data, preprocesses, and stores the result in a managed buffer.
| 524 | //! \brief Reads the input and mean data, preprocesses, and stores the result in a managed buffer. |
| 525 | //! |
| 526 | bool SampleAlgorithmSelector::processInput( |
| 527 | samplesCommon::BufferManager const& buffers, std::string const& inputTensorName, int32_t inputFileIdx) const |
| 528 | { |
| 529 | |
| 530 | int32_t const inputH = mInputDims.d[2]; |
| 531 | int32_t const inputW = mInputDims.d[3]; |
| 532 | |
| 533 | // Read a random digit file. |
| 534 | srand(unsigned(time(nullptr))); |
| 535 | std::vector<uint8_t> fileData(inputH * inputW); |
| 536 | readPGMFile(locateFile(std::to_string(inputFileIdx) + ".pgm", mParams.dataDirs), fileData.data(), inputH, inputW); |
| 537 | |
| 538 | // Print ASCII representation of digit. |
| 539 | sample::gLogInfo << "Input:\n"; |
| 540 | for (int32_t i = 0; i < inputH * inputW; i++) |
| 541 | { |
| 542 | sample::gLogInfo << (" .:-=+*#%@"[fileData[i] / 26]) << (((i + 1) % inputW) ? "" : "\n"); |
| 543 | } |
| 544 | sample::gLogInfo << std::endl; |
| 545 | |
| 546 | float* hostInputBuffer = static_cast<float*>(buffers.getHostBuffer(inputTensorName)); |
| 547 | |
| 548 | for (int32_t i = 0; i < inputH * inputW; i++) |
| 549 | { |
| 550 | hostInputBuffer[i] = 1.0F - static_cast<float>(fileData[i]) / 255.0F; |
| 551 | } |
| 552 | |
| 553 | return true; |
| 554 | } |
| 555 | |
| 556 | //! |
| 557 | //! \brief Verifies that the output is correct and prints it. |
nothing calls this directly
no test coverage detected