blob: 41f382ad1dea33f7985a7901596cc5185b44a7bc [file] [log] [blame]
Georgios Pinitas12be7ab2018-07-03 12:06:23 +01001/*
John Kesapidesfb68ca12019-01-21 14:13:27 +00002 * Copyright (c) 2018-2019 ARM Limited.
Georgios Pinitas12be7ab2018-07-03 12:06:23 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#ifndef __ARM_COMPUTE_GRAPH_TYPE_LOADER_H__
25#define __ARM_COMPUTE_GRAPH_TYPE_LOADER_H__
26
27#include "arm_compute/graph/Types.h"
28
29#include <istream>
30
31namespace arm_compute
32{
33/** Converts a string to a strong types enumeration @ref DataType
34 *
35 * @param[in] name String to convert
36 *
37 * @return Converted DataType enumeration
38 */
39arm_compute::DataType data_type_from_name(const std::string &name);
40
41/** Input Stream operator for @ref DataType
42 *
43 * @param[in] stream Stream to parse
44 * @param[out] data_type Output data type
45 *
46 * @return Updated stream
47 */
48inline ::std::istream &operator>>(::std::istream &stream, arm_compute::DataType &data_type)
49{
50 std::string value;
51 stream >> value;
52 data_type = data_type_from_name(value);
53 return stream;
54}
55
56/** Converts a string to a strong types enumeration @ref DataLayout
57 *
58 * @param[in] name String to convert
59 *
60 * @return Converted DataLayout enumeration
61 */
62arm_compute::DataLayout data_layout_from_name(const std::string &name);
63
64/** Input Stream operator for @ref DataLayout
65 *
66 * @param[in] stream Stream to parse
67 * @param[out] data_layout Output data layout
68 *
69 * @return Updated stream
70 */
71inline ::std::istream &operator>>(::std::istream &stream, arm_compute::DataLayout &data_layout)
72{
73 std::string value;
74 stream >> value;
75 data_layout = data_layout_from_name(value);
76 return stream;
77}
78
79namespace graph
80{
81/** Converts a string to a strong types enumeration @ref Target
82 *
83 * @param[in] name String to convert
84 *
85 * @return Converted Target enumeration
86 */
87Target target_from_name(const std::string &name);
88
89/** Input Stream operator for @ref Target
90 *
91 * @param[in] stream Stream to parse
92 * @param[out] target Output target
93 *
94 * @return Updated stream
95 */
96inline ::std::istream &operator>>(::std::istream &stream, Target &target)
97{
98 std::string value;
99 stream >> value;
100 target = target_from_name(value);
101 return stream;
102}
John Kesapidesfb68ca12019-01-21 14:13:27 +0000103
104/** Converts a string to a strong types enumeration @ref ConvolutionMethod
105 *
106 * @param[in] name String to convert
107 *
108 * @return Converted Target enumeration
109 */
110ConvolutionMethod Convolution_method_from_name(const std::string &name);
111
112/** Input Stream operator for @ref ConvolutionMethod
113 *
114 * @param[in] stream Stream to parse
115 * @param[out] target Output target
116 *
117 * @return Updated stream
118 */
119inline ::std::istream &operator>>(::std::istream &stream, ConvolutionMethod &target)
120{
121 std::string value;
122 stream >> value;
123 target = Convolution_method_from_name(value);
124 return stream;
125}
John Kesapides8d942692019-02-26 14:52:12 +0000126
127/** Converts a string to a strong types enumeration @ref DepthwiseConvolutionMethod
128 *
129 * @param[in] name String to convert
130 *
131 * @return Converted Target enumeration
132 */
133DepthwiseConvolutionMethod depthwise_convolution_method_from_name(const std::string &name);
134
135/** Input Stream operator for @ref DepthwiseConvolutionMethod
136 *
137 * @param[in] stream Stream to parse
138 * @param[out] target Output target
139 *
140 * @return Updated stream
141 */
142inline ::std::istream &operator>>(::std::istream &stream, DepthwiseConvolutionMethod &target)
143{
144 std::string value;
145 stream >> value;
146 target = depthwise_convolution_method_from_name(value);
147 return stream;
148}
149
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100150} // namespace graph
151} // namespace arm_compute
152#endif /* __ARM_COMPUTE_GRAPH_TYPE_LOADER_H__ */