| // |
| // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
| // SPDX-License-Identifier: MIT |
| // |
| |
| #pragma once |
| |
| #include "CsvReader.hpp" |
| #include <armnn/IRuntime.hpp> |
| #include <armnn/Types.hpp> |
| |
| #include <mapbox/variant.hpp> |
| |
| #include <iostream> |
| |
| |
| std::vector<unsigned int> ParseArray(std::istream& stream); |
| |
| /// Splits a given string at every accurance of delimiter into a vector of string |
| std::vector<std::string> ParseStringList(const std::string& inputString, const char* delimiter); |
| |
| struct TensorPrinter |
| { |
| TensorPrinter(const std::string& binding, |
| const armnn::TensorInfo& info, |
| const std::string& outputTensorFile, |
| bool dequantizeOutput); |
| |
| void operator()(const std::vector<float>& values); |
| |
| void operator()(const std::vector<uint8_t>& values); |
| |
| void operator()(const std::vector<int>& values); |
| |
| private: |
| template<typename Container, typename Delegate> |
| void ForEachValue(const Container& c, Delegate delegate); |
| |
| template<typename T> |
| void WriteToFile(const std::vector<T>& values); |
| |
| std::string m_OutputBinding; |
| float m_Scale; |
| int m_Offset; |
| std::string m_OutputTensorFile; |
| bool m_DequantizeOutput; |
| }; |
| |
| using TContainer = mapbox::util::variant<std::vector<float>, std::vector<int>, std::vector<unsigned char>>; |
| using QuantizationParams = std::pair<float, int32_t>; |
| |
| void PopulateTensorWithData(TContainer& tensorData, |
| unsigned int numElements, |
| const std::string& dataTypeStr, |
| const armnn::Optional<QuantizationParams>& qParams, |
| const armnn::Optional<std::string>& dataFile); |
| |
| /** |
| * Verifies if the given string is a valid path. Reports invalid paths to std::err. |
| * @param file string - A string containing the path to check |
| * @param expectFile bool - If true, checks for a regular file. |
| * @return bool - True if given string is a valid path., false otherwise. |
| * */ |
| bool ValidatePath(const std::string& file, const bool expectFile); |
| |
| /** |
| * Verifies if a given vector of strings are valid paths. Reports invalid paths to std::err. |
| * @param fileVec vector of string - A vector of string containing the paths to check |
| * @param expectFile bool - If true, checks for a regular file. |
| * @return bool - True if all given strings are valid paths., false otherwise. |
| * */ |
| bool ValidatePaths(const std::vector<std::string>& fileVec, const bool expectFile); |