blob: c3ba289a3f10fcfbd90073191f6342729de2265e [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
Matthew Bentham4057d912019-01-21 15:45:51 +00009#include <iomanip>
10#include <sstream>
11#include <string>
12
13namespace armnnUtils
14{
15
16/// Converts an int value into the Prototxt octal representation
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
Sang-Hoon Parkdd3f71b2020-02-18 11:27:35 +000031/// Converts an TensorShape into Prototxt representation
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}
Matthew Bentham4057d912019-01-21 15:45:51 +000044} // namespace armnnUtils