blob: 77f096133d7451793b6cfc1877ce31850aafe636 [file] [log] [blame]
Georgios Pinitas12be7ab2018-07-03 12:06:23 +01001/*
2 * Copyright (c) 2018 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
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}
103} // namespace graph
104} // namespace arm_compute
105#endif /* __ARM_COMPUTE_GRAPH_TYPE_LOADER_H__ */