ArmNN
 20.02
PrototxtConversions.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 #include "armnn/Tensor.hpp"
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 
33 /// Converts an TensorShape into Prototxt representation
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 }
46 } // namespace armnnUtils
std::string ConvertInt32ToOctalString(int value)
Converts an int value into the Prototxt octal representation.
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:43
std::string ConvertTensorShapeToString(const armnn::TensorShape &shape)
Converts an TensorShape into Prototxt representation.