Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
Matthew Bentham | 4057d91 | 2019-01-21 15:45:51 +0000 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "PrototxtConversions.hpp" |
Sang-Hoon Park | dd3f71b | 2020-02-18 11:27:35 +0000 | [diff] [blame] | 7 | #include "armnn/Tensor.hpp" |
Matthew Bentham | 4057d91 | 2019-01-21 15:45:51 +0000 | [diff] [blame] | 8 | |
| 9 | #include <boost/format.hpp> |
| 10 | |
| 11 | #include <iomanip> |
| 12 | #include <sstream> |
| 13 | #include <string> |
| 14 | |
| 15 | namespace armnnUtils |
| 16 | { |
| 17 | |
| 18 | /// Converts an int value into the Prototxt octal representation |
| 19 | std::string ConvertInt32ToOctalString(int value) |
| 20 | { |
| 21 | std::stringstream ss; |
| 22 | std::string returnString; |
| 23 | for (int i = 0; i < 4; ++i) |
| 24 | { |
| 25 | ss << "\\"; |
| 26 | ss << std::setw(3) << std::setfill('0') << std::oct << ((value >> (i * 8)) & 0xFF); |
| 27 | } |
| 28 | |
| 29 | ss >> returnString; |
| 30 | return returnString; |
| 31 | } |
| 32 | |
Sang-Hoon Park | dd3f71b | 2020-02-18 11:27:35 +0000 | [diff] [blame] | 33 | /// Converts an TensorShape into Prototxt representation |
| 34 | std::string ConvertTensorShapeToString(const armnn::TensorShape& shape) |
| 35 | { |
| 36 | std::stringstream ss; |
| 37 | for (unsigned int i = 0 ; i < shape.GetNumDimensions() ; i++) |
| 38 | { |
| 39 | ss << "dim {\n"; |
| 40 | ss << "size: " << std::to_string(shape[i]) << "\n"; |
| 41 | ss << "}\n"; |
| 42 | } |
| 43 | return ss.str(); |
| 44 | |
| 45 | } |
Matthew Bentham | 4057d91 | 2019-01-21 15:45:51 +0000 | [diff] [blame] | 46 | } // namespace armnnUtils |