Compute Library
 21.05
TypeLoader.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020 Arm Limited.
3  *
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 
28 
29 #include <istream>
30 
31 namespace arm_compute
32 {
33 /** 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  */
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  */
48 inline ::std::istream &operator>>(::std::istream &stream, arm_compute::DataLayout &data_layout)
49 {
50  std::string value;
51  stream >> value;
53  return stream;
54 }
55 
56 namespace 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  */
64 Target 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  */
73 inline ::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 }
80 
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  */
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  */
96 inline ::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 }
103 
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  */
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  */
119 inline ::std::istream &operator>>(::std::istream &stream, DepthwiseConvolutionMethod &target)
120 {
121  std::string value;
122  stream >> value;
124  return stream;
125 }
126 
127 } // namespace graph
128 } // namespace arm_compute
129 #endif /* ARM_COMPUTE_GRAPH_TYPE_LOADER_H */
inline ::std::istream & operator>>(::std::istream &stream, Target &target)
Input Stream operator for Target.
Definition: TypeLoader.h:73
DepthwiseConvolutionMethod depthwise_convolution_method_from_name(const std::string &name)
Converts a string to a strong types enumeration DepthwiseConvolutionMethod.
Definition: TypeLoader.cpp:105
ConvolutionMethod Convolution_method_from_name(const std::string &name)
Converts a string to a strong types enumeration ConvolutionMethod.
Definition: TypeLoader.cpp:80
const DataLayout data_layout
Definition: Im2Col.cpp:151
ConvolutionMethod
Available ConvolutionMethod.
Definition: Types.h:132
Copyright (c) 2017-2021 Arm Limited.
arm_compute::DataLayout data_layout_from_name(const std::string &name)
Converts a string to a strong types enumeration DataLayout.
Definition: TypeLoader.cpp:32
DepthwiseConvolutionMethod
Supported Depthwise Convolution layer methods.
Definition: Types.h:133
const char * name
Target target_from_name(const std::string &name)
Converts a string to a strong types enumeration Target.
Definition: TypeLoader.cpp:56
ConvolutionMethod
Supported Convolution layer methods.
Definition: Types.h:124
DataLayout
[DataLayout enum definition]
Definition: Types.h:114
inline ::std::istream & operator>>(::std::istream &stream, DataType &data_type)
Input Stream operator for DataType.
Definition: Utils.h:926