blob: 8681da165ba4542b102d5f5a7ba55a9000a43392 [file] [log] [blame]
Laurent Carlier749294b2020-06-01 09:03:17 +01001//
Matthew Bentham4057d912019-01-21 15:45:51 +00002// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "PrototxtConversions.hpp"
Sang-Hoon Parkdd3f71b2020-02-18 11:27:35 +00007#include "armnn/Tensor.hpp"
Matthew Bentham4057d912019-01-21 15:45:51 +00008
9#include <boost/format.hpp>
10
11#include <iomanip>
12#include <sstream>
13#include <string>
14
15namespace armnnUtils
16{
17
18/// Converts an int value into the Prototxt octal representation
19std::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 Parkdd3f71b2020-02-18 11:27:35 +000033/// Converts an TensorShape into Prototxt representation
34std::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 Bentham4057d912019-01-21 15:45:51 +000046} // namespace armnnUtils