blob: 286bfebeb5a3978ec93dc094daad28f8cb8f7e3d [file] [log] [blame]
Georgios Pinitas12be7ab2018-07-03 12:06:23 +01001/*
SiCong Lie357a252020-08-09 20:05:52 +01002 * Copyright (c) 2018-2020 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 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_GRAPH_TYPE_LOADER_H
25#define ARM_COMPUTE_GRAPH_TYPE_LOADER_H
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010026
27#include "arm_compute/graph/Types.h"
28
29#include <istream>
30
31namespace arm_compute
32{
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010033/** Converts a string to a strong types enumeration @ref DataLayout
34 *
35 * @param[in] name String to convert
36 *
37 * @return Converted DataLayout enumeration
38 */
39arm_compute::DataLayout data_layout_from_name(const std::string &name);
40
41/** Input Stream operator for @ref DataLayout
42 *
43 * @param[in] stream Stream to parse
44 * @param[out] data_layout Output data layout
45 *
46 * @return Updated stream
47 */
48inline ::std::istream &operator>>(::std::istream &stream, arm_compute::DataLayout &data_layout)
49{
50 std::string value;
51 stream >> value;
52 data_layout = data_layout_from_name(value);
53 return stream;
54}
55
56namespace graph
57{
58/** Converts a string to a strong types enumeration @ref Target
59 *
60 * @param[in] name String to convert
61 *
62 * @return Converted Target enumeration
63 */
64Target target_from_name(const std::string &name);
65
66/** Input Stream operator for @ref Target
67 *
68 * @param[in] stream Stream to parse
69 * @param[out] target Output target
70 *
71 * @return Updated stream
72 */
73inline ::std::istream &operator>>(::std::istream &stream, Target &target)
74{
75 std::string value;
76 stream >> value;
77 target = target_from_name(value);
78 return stream;
79}
John Kesapidesfb68ca12019-01-21 14:13:27 +000080
81/** Converts a string to a strong types enumeration @ref ConvolutionMethod
82 *
83 * @param[in] name String to convert
84 *
85 * @return Converted Target enumeration
86 */
87ConvolutionMethod Convolution_method_from_name(const std::string &name);
88
89/** Input Stream operator for @ref ConvolutionMethod
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, ConvolutionMethod &target)
97{
98 std::string value;
99 stream >> value;
100 target = Convolution_method_from_name(value);
101 return stream;
102}
John Kesapides8d942692019-02-26 14:52:12 +0000103
104/** Converts a string to a strong types enumeration @ref DepthwiseConvolutionMethod
105 *
106 * @param[in] name String to convert
107 *
108 * @return Converted Target enumeration
109 */
110DepthwiseConvolutionMethod depthwise_convolution_method_from_name(const std::string &name);
111
112/** Input Stream operator for @ref DepthwiseConvolutionMethod
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, DepthwiseConvolutionMethod &target)
120{
121 std::string value;
122 stream >> value;
123 target = depthwise_convolution_method_from_name(value);
124 return stream;
125}
126
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100127} // namespace graph
128} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000129#endif /* ARM_COMPUTE_GRAPH_TYPE_LOADER_H */