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);
55 const std::vector<armnn::ConstTensor>& constants,
69 auto iterator = m_TensorInfos.find(layerBindingId);
72 return m_TensorInfos.at(layerBindingId);
76 throw armnn::Exception(
"Could not retrieve tensor info for binding ID " + std::to_string(layerBindingId));
90 auto iterator = m_TensorInfos.find(layerBindingId);
93 return m_TensorInfos.at(layerBindingId);
97 throw armnn::Exception(
"Could not retrieve tensor info for binding ID " + std::to_string(layerBindingId));
107 passId =
static_cast<unsigned int>(std::stoi(tokens[0]));
109 catch (
const std::invalid_argument&)
112 tokens[0], lineIndex));
122 bindingId = std::stoi(tokens[1]);
124 catch (
const std::invalid_argument&)
127 tokens[1], lineIndex));
136 if (!fs::exists(fileName))
139 fileName, lineIndex));
142 if (fileName.empty())
150 void QuantizationDataSet::ParseCsvFile()
152 std::map<unsigned int, QuantizationInput> passIdToQuantizationInput;
154 if (m_CsvFilePath ==
"")
159 std::ifstream inf (m_CsvFilePath.c_str());
161 std::vector<std::string> tokens;
162 unsigned int lineIndex = 0;
166 throw armnn::Exception(fmt::format(
"CSV file {} not found.", m_CsvFilePath));
169 while (getline(inf, line))
173 if (tokens.size() != 3)
175 throw armnn::Exception(fmt::format(
"CSV file [{}] does not have correct number of entries" \
176 "on line {}. Expected 3 entries but was {}.",
177 m_CsvFilePath, lineIndex, tokens.size()));
185 AddInputData(passId, bindingId, rawFileName, passIdToQuantizationInput);
190 if (passIdToQuantizationInput.empty())
197 for (
auto itr = passIdToQuantizationInput.begin(); itr != passIdToQuantizationInput.end(); ++itr)
199 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).
Base class for all descriptors.
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.