9 #define BOOST_FILESYSTEM_NO_DEPRECATED 11 #include <boost/core/ignore_unused.hpp> 12 #include <boost/filesystem/operations.hpp> 13 #include <boost/filesystem/path.hpp> 23 m_QuantizationInputs(),
24 m_CsvFilePath(csvFilePath)
31 const std::string& inputFilePath,
32 std::map<unsigned int, QuantizationInput>& passIdToQuantizationInput)
34 auto iterator = passIdToQuantizationInput.find(passId);
35 if (
iterator == passIdToQuantizationInput.end())
38 passIdToQuantizationInput.emplace(passId, input);
42 auto existingQuantizationInput =
iterator->second;
43 existingQuantizationInput.AddEntry(bindingId, inputFilePath);
55 boost::ignore_unused(name);
61 auto iterator = m_TensorInfos.find(layerBindingId);
64 return m_TensorInfos.at(layerBindingId);
68 throw armnn::Exception(
"Could not retrieve tensor info for binding ID " + std::to_string(layerBindingId));
78 passId =
static_cast<unsigned int>(std::stoi(csvRows[rowIndex].values[0]));
80 catch (
const std::invalid_argument&)
83 " is not correct format on CSV row " + std::to_string(rowIndex));
93 bindingId = std::stoi(csvRows[rowIndex].values[1]);
95 catch (
const std::invalid_argument&)
98 " is not correct format on CSV row " + std::to_string(rowIndex));
105 std::string fileName = csvRows[rowIndex].values[2];
107 if (!boost::filesystem::exists(fileName))
109 throw armnn::ParseException(
"File [ " + fileName +
"] provided on CSV row " + std::to_string(rowIndex) +
113 if (fileName.empty())
121 void QuantizationDataSet::ParseCsvFile()
123 std::map<unsigned int, QuantizationInput> passIdToQuantizationInput;
126 if (m_CsvFilePath ==
"")
132 std::vector<armnnUtils::CsvRow> csvRows = reader.
ParseFile(m_CsvFilePath);
138 for (
unsigned int i = 0; i < csvRows.size(); ++i)
140 if (csvRows[i].values.size() != 3)
142 throw armnn::Exception(
"CSV file [" + m_CsvFilePath +
"] does not have correct number of entries " +
143 "on line " + std::to_string(i) +
". Expected 3 entries " +
144 "but was " + std::to_string(csvRows[i].values.size()));
151 AddInputData(passId, bindingId, rawFileName, passIdToQuantizationInput);
154 if (passIdToQuantizationInput.empty())
161 for (
auto itr = passIdToQuantizationInput.begin(); itr != passIdToQuantizationInput.end(); ++itr)
163 m_QuantizationInputs.emplace_back(itr->second);
void AddInputData(unsigned int passId, armnn::LayerBindingId bindingId, const std::string &inputFilePath, std::map< unsigned int, QuantizationInput > &passIdToQuantizationInput)
virtual const TensorInfo & GetTensorInfo() const =0
armnn::LayerBindingId GetBindingIdFromCsvRow(std::vector< armnnUtils::CsvRow > csvRows, unsigned int rowIndex)
unsigned int GetPassIdFromCsvRow(std::vector< armnnUtils::CsvRow > csvRows, unsigned int rowIndex)
QuantizationInputs::iterator iterator
std::string GetFileNameFromCsvRow(std::vector< armnnUtils::CsvRow > csvRows, unsigned int rowIndex)
static std::vector< CsvRow > ParseFile(const std::string &csvFile)
Base class for all ArmNN exceptions so that users can filter to just those.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0