9 #define BOOST_FILESYSTEM_NO_DEPRECATED 13 #include <boost/filesystem/operations.hpp> 14 #include <boost/filesystem/path.hpp> 24 m_QuantizationInputs(),
25 m_CsvFilePath(csvFilePath)
32 const std::string& inputFilePath,
33 std::map<unsigned int, QuantizationInput>& passIdToQuantizationInput)
35 auto iterator = passIdToQuantizationInput.find(passId);
36 if (
iterator == passIdToQuantizationInput.end())
39 passIdToQuantizationInput.emplace(passId, input);
43 auto existingQuantizationInput =
iterator->second;
44 existingQuantizationInput.AddEntry(bindingId, inputFilePath);
62 auto iterator = m_TensorInfos.find(layerBindingId);
65 return m_TensorInfos.at(layerBindingId);
69 throw armnn::Exception(
"Could not retrieve tensor info for binding ID " + std::to_string(layerBindingId));
79 passId =
static_cast<unsigned int>(std::stoi(csvRows[rowIndex].values[0]));
81 catch (
const std::invalid_argument&)
84 " is not correct format on CSV row " + std::to_string(rowIndex));
94 bindingId = std::stoi(csvRows[rowIndex].values[1]);
96 catch (
const std::invalid_argument&)
99 " is not correct format on CSV row " + std::to_string(rowIndex));
106 std::string fileName = csvRows[rowIndex].values[2];
108 if (!boost::filesystem::exists(fileName))
110 throw armnn::ParseException(
"File [ " + fileName +
"] provided on CSV row " + std::to_string(rowIndex) +
114 if (fileName.empty())
122 void QuantizationDataSet::ParseCsvFile()
124 std::map<unsigned int, QuantizationInput> passIdToQuantizationInput;
127 if (m_CsvFilePath ==
"")
133 std::vector<armnnUtils::CsvRow> csvRows = reader.
ParseFile(m_CsvFilePath);
139 for (
unsigned int i = 0; i < csvRows.size(); ++i)
141 if (csvRows[i].values.size() != 3)
143 throw armnn::Exception(
"CSV file [" + m_CsvFilePath +
"] does not have correct number of entries " +
144 "on line " + std::to_string(i) +
". Expected 3 entries " +
145 "but was " + std::to_string(csvRows[i].values.size()));
152 AddInputData(passId, bindingId, rawFileName, passIdToQuantizationInput);
155 if (passIdToQuantizationInput.empty())
162 for (
auto itr = passIdToQuantizationInput.begin(); itr != passIdToQuantizationInput.end(); ++itr)
164 m_QuantizationInputs.emplace_back(itr->second);
void AddInputData(unsigned int passId, armnn::LayerBindingId bindingId, const std::string &inputFilePath, std::map< unsigned int, QuantizationInput > &passIdToQuantizationInput)
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
armnn::LayerBindingId GetBindingIdFromCsvRow(std::vector< armnnUtils::CsvRow > csvRows, unsigned int rowIndex)
QuantizationInputs::iterator iterator
void IgnoreUnused(Ts &&...)
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
std::string GetFileNameFromCsvRow(std::vector< armnnUtils::CsvRow > csvRows, unsigned int rowIndex)
unsigned int GetPassIdFromCsvRow(std::vector< armnnUtils::CsvRow > csvRows, unsigned int rowIndex)
Base class for all ArmNN exceptions so that users can filter to just those.
virtual const TensorInfo & GetTensorInfo() const =0
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
static std::vector< CsvRow > ParseFile(const std::string &csvFile)