ArmNN
 24.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 <iomanip>
10 #include <sstream>
11 #include <string>
12 
13 namespace armnnUtils
14 {
15 
16 /// Converts an int value into the Prototxt octal representation
17 std::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
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
armnnUtils::ConvertTensorShapeToString
std::string ConvertTensorShapeToString(const armnn::TensorShape &shape)
Converts an TensorShape into Prototxt representation.
Definition: PrototxtConversions.cpp:32
armnn::TensorShape
Definition: Tensor.hpp:20
armnnUtils::ConvertInt32ToOctalString
std::string ConvertInt32ToOctalString(int value)
Converts an int value into the Prototxt octal representation.
Definition: PrototxtConversions.cpp:17
armnn::TensorShape::GetNumDimensions
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Definition: Tensor.cpp:174
armnnUtils
Definition: CompatibleTypes.hpp:10
PrototxtConversions.hpp
Tensor.hpp