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