8 #include <fmt/format.h> 22 m_QuantizationInputs(),
23 m_CsvFilePath(csvFilePath)
30 const std::string& inputFilePath,
31 std::map<unsigned int, QuantizationInput>& passIdToQuantizationInput)
33 auto iterator = passIdToQuantizationInput.find(passId);
34 if (
iterator == passIdToQuantizationInput.end())
37 passIdToQuantizationInput.emplace(passId, input);
41 auto existingQuantizationInput =
iterator->second;
42 existingQuantizationInput.AddEntry(bindingId, inputFilePath);
60 auto iterator = m_TensorInfos.find(layerBindingId);
63 return m_TensorInfos.at(layerBindingId);
67 throw armnn::Exception(
"Could not retrieve tensor info for binding ID " + std::to_string(layerBindingId));
77 passId =
static_cast<unsigned int>(std::stoi(tokens[0]));
79 catch (
const std::invalid_argument&)
82 tokens[0], lineIndex));
92 bindingId = std::stoi(tokens[1]);
94 catch (
const std::invalid_argument&)
97 tokens[1], lineIndex));
106 if (!fs::exists(fileName))
109 fileName, lineIndex));
112 if (fileName.empty())
120 void QuantizationDataSet::ParseCsvFile()
122 std::map<unsigned int, QuantizationInput> passIdToQuantizationInput;
124 if (m_CsvFilePath ==
"")
129 std::ifstream inf (m_CsvFilePath.c_str());
131 std::vector<std::string> tokens;
132 unsigned int lineIndex = 0;
136 throw armnn::Exception(fmt::format(
"CSV file {} not found.", m_CsvFilePath));
139 while (getline(inf, line))
143 if (tokens.size() != 3)
145 throw armnn::Exception(fmt::format(
"CSV file [{}] does not have correct number of entries" \
146 "on line {}. Expected 3 entries but was {}.",
147 m_CsvFilePath, lineIndex, tokens.size()));
155 AddInputData(passId, bindingId, rawFileName, passIdToQuantizationInput);
160 if (passIdToQuantizationInput.empty())
167 for (
auto itr = passIdToQuantizationInput.begin(); itr != passIdToQuantizationInput.end(); ++itr)
169 m_QuantizationInputs.emplace_back(itr->second);
std::vector< std::string > StringTokenizer(const std::string &str, const char *delimiters, bool tokenCompression=true)
Function to take a string and a list of delimiters and split the string into tokens based on those de...
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.
std::string GetFileNameFromCsvRow(std::vector< std::string > tokens, unsigned int lineIndex)
QuantizationInputs::iterator iterator
armnn::LayerBindingId GetBindingIdFromCsvRow(std::vector< std::string > tokens, unsigned int lineIndex)
void IgnoreUnused(Ts &&...)
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
unsigned int GetPassIdFromCsvRow(std::vector< std::string > tokens, unsigned int lineIndex)
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.
std::string & StringTrim(std::string &str, const std::string &chars="\\\")
Trim from both the start and the end of a string.