xref: /aosp_15_r20/external/armnn/src/armnnOnnxParser/test/OnnxParserTestUtils.cpp (revision 89c4ff92f2867872bb9e2354d150bf0c8c502810)
1 //
2 // Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "OnnxParserTestUtils.hpp"
7 
8 #include <fmt/format.h>
9 
10 namespace armnnUtils
11 {
12 
ConstructTensorShapeString(const std::vector<int> & shape)13 std::string ConstructTensorShapeString(const std::vector<int>& shape)
14 {
15     std::string shapeStr;
16     for (int i : shape)
17     {
18         shapeStr = fmt::format("{} dim {{ dim_value: {} }}", shapeStr, i);
19     }
20     return shapeStr;
21 }
22 
ConstructIntsAttribute(const std::string & name,const std::vector<int> & values)23 std::string ConstructIntsAttribute(const std::string& name,
24                                    const std::vector<int>& values)
25 {
26     std::string attrString = fmt::format("attribute {{ name: '{}'", name);;
27     for (int i : values)
28     {
29         attrString = fmt::format(" {} ints: {}", attrString, i);
30     }
31     attrString = fmt::format(" {} type: INTS }}", attrString);
32     return attrString;
33 }
34 
35 } // namespace armnnUtils