xref: /aosp_15_r20/external/ComputeLibrary/arm_compute/graph/frontend/IStreamOperators.h (revision c217d954acce2dbc11938adb493fc0abd69584f3)
1 /*
2  * Copyright (c) 2018-2019 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_ISTREAM_OPERATORS_H
25 #define ARM_COMPUTE_GRAPH_ISTREAM_OPERATORS_H
26 
27 #include "arm_compute/graph/frontend/IStream.h"
28 #include "arm_compute/graph/frontend/Types.h"
29 
30 namespace arm_compute
31 {
32 namespace graph
33 {
34 namespace frontend
35 {
36 // Forward declarations
37 class ILayer;
38 
39 /** Overloaded stream operator to add a node to the graph
40  *
41  * @param[in, out] s     Stream to add the tensor
42  * @param[in]      layer Layer to be added
43  *
44  * @return Updated stream
45  */
46 inline IStream &operator<<(IStream &s, ILayer &&layer)
47 {
48     s.add_layer(layer);
49     return s;
50 }
51 /** Overloaded stream operator to add a node to the graph
52  *
53  * @param[in, out] s     Stream to add the tensor
54  * @param[in]      layer Layer to be added
55  *
56  * @return Updated stream
57  */
58 inline IStream &operator<<(IStream &s, ILayer &layer)
59 {
60     s.add_layer(layer);
61     return s;
62 }
63 /** Overloaded stream operator to provide a target hint to the graph
64  *
65  * @param[in, out] s           Stream to provide the hint to
66  * @param[in]      target_hint Target hint to be considered
67  *
68  * @return Updated stream
69  */
70 inline IStream &operator<<(IStream &s, Target target_hint)
71 {
72     s.hints().target_hint = target_hint;
73     return s;
74 }
75 /** Overloaded stream operator to provide a convolution method hint to the graph
76  *
77  * @param[in, out] s                       Stream to provide the hint to
78  * @param[in]      convolution_method_hint Convolution method hint to be considered
79  *
80  * @return Updated stream
81  */
82 inline IStream &operator<<(IStream &s, ConvolutionMethod convolution_method_hint)
83 {
84     s.hints().convolution_method_hint = convolution_method_hint;
85     return s;
86 }
87 /** Overloaded stream operator to provide a depthwise convolution method hint to the graph
88  *
89  * @param[in, out] s                                 Stream to provide the hint to
90  * @param[in]      depthwise_convolution_method_hint Depthwise Convolution method hint to be considered
91  *
92  * @return Updated stream
93  */
94 inline IStream &operator<<(IStream &s, DepthwiseConvolutionMethod depthwise_convolution_method_hint)
95 {
96     s.hints().depthwise_convolution_method_hint = depthwise_convolution_method_hint;
97     return s;
98 }
99 /** Overloaded stream operator to provide a fast math hint to the graph
100  *
101  * @param[in, out] s              Stream to provide the hint to
102  * @param[in]      fast_math_hint Convolution method hint to be considered
103  *
104  * @return Updated stream
105  */
106 inline IStream &operator<<(IStream &s, FastMathHint fast_math_hint)
107 {
108     s.hints().fast_math_hint = fast_math_hint;
109     return s;
110 }
111 } // namespace frontend
112 } // namespace graph
113 } // namespace arm_compute
114 #endif /* ARM_COMPUTE_GRAPH_ISTREAM_OPERATORS_H */
115