Compute Library
 22.05
FusedConvolutionWithPostOpNode.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 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_FUSED_CONVOLUTION_WITH_POST_OP_NODE_H
25 #define ARM_COMPUTE_GRAPH_FUSED_CONVOLUTION_WITH_POST_OP_NODE_H
26 
28 
29 #include <list>
30 
31 namespace arm_compute
32 {
33 namespace graph
34 {
35 /** Convolution node */
37 {
38 public:
39  /** Constructor
40  *
41  * @param[in] info Convolution layer attributes
42  * @param[in] num_groups (Optional) Number of groups (Defaults to 1)
43  * @param[in] method (Optional) Convolution method to use
44  * @param[in] fast_math_hint (Optional) Fast math hint
45  * @param[in] out_quant_info (Optional) Output quantization info
46  */
48  unsigned int num_groups = 1,
51  QuantizationInfo out_quant_info = QuantizationInfo());
52  /** Sets the convolution layer method to use
53  *
54  * @param[in] method Method to use for convolution
55  */
57  /** Convolution layer method accessor
58  *
59  * @note This is an indication on which convolution layer implementation to use,
60  * if it fails to be created the library's heuristic approach will be used
61  *
62  * @return Convolution layer method to be used by the node
63  */
65  /** Sets the fast math fast hint
66  *
67  * @param[in] hint Hint to use for convolution
68  */
70  /** Fast math hint accessor
71  *
72  * @return Fast math hint to be used by the node
73  */
75  /** Convolution metadata accessor
76  *
77  * @return Convolution information
78  */
80  /** Number of groups in convolution accessor
81  *
82  * @return Number of groups in convolution
83  */
84  unsigned int num_groups() const;
85  /** Returns fused activation
86  *
87  * @return Fused activation
88  */
90  /** Sets fused activation
91  *
92  * @param[in] fused_activation Fused activation to set
93  */
94  void set_fused_activation(ActivationLayerInfo fused_activation);
95  /** Sets convolution info
96  *
97  * @param[in] info Convolution info to set
98  */
100  /** Computes convolution output descriptor
101  *
102  * @param[in] input_descriptor Input descriptor
103  * @param[in] weights_descriptor Weights descriptor
104  * @param[in] info Convolution operation attributes
105  *
106  * @return Output descriptor
107  */
108  static TensorDescriptor compute_output_descriptor(const TensorDescriptor &input_descriptor,
109  const TensorDescriptor &weights_descriptor,
110  const PadStrideInfo &info);
111 
112  // Inherited overridden methods:
113  NodeType type() const override;
114  bool forward_descriptors() override;
115  TensorDescriptor configure_output(size_t idx) const override;
116  void accept(INodeVisitor &v) override;
117 
118 public:
120 
121 private:
122  PadStrideInfo _info;
123  unsigned int _num_groups;
124  ConvolutionMethod _method;
125  FastMathHint _fast_math_hint;
126  QuantizationInfo _out_quant_info;
127  ActivationLayerInfo _fused_activation;
128 };
129 } // namespace graph
130 } // namespace arm_compute
131 
132 #endif /* ARM_COMPUTE_GRAPH_FUSED_CONVOLUTION_WITH_POST_OP_NODE_H */
void set_convolution_info(PadStrideInfo info)
Sets convolution info.
void set_convolution_method(ConvolutionMethod method)
Sets the convolution layer method to use.
FusedConvolutionWithPostOpNode(PadStrideInfo info, unsigned int num_groups=1, ConvolutionMethod method=ConvolutionMethod::Default, FastMathHint fast_math_hint=FastMathHint::Disabled, QuantizationInfo out_quant_info=QuantizationInfo())
Constructor.
FastMathHint fast_math_hint() const
Fast math hint accessor.
void accept(INodeVisitor &v) override
Accepts a node visitor.
Activation Layer Information class.
Definition: Types.h:1625
Copyright (c) 2017-2022 Arm Limited.
static TensorDescriptor compute_output_descriptor(const TensorDescriptor &input_descriptor, const TensorDescriptor &weights_descriptor, const PadStrideInfo &info)
Computes convolution output descriptor.
Fast math disabled for Convolution layer.
bool forward_descriptors() override
Forwards descriptor information to outputs if possible.
Quantization information.
Node interface.
Definition: INode.h:46
void set_fast_math_hint(FastMathHint hint)
Sets the fast math fast hint.
ActivationLayerInfo fused_activation() const
Returns fused activation.
NodeType
Supported nodes.
Definition: Types.h:199
Padding and stride information class.
Definition: Types.h:669
FastMathHint
Enable or disable fast math for Convolution layer.
Definition: Types.h:143
PadStrideInfo convolution_info() const
Convolution metadata accessor.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
ConvolutionMethod convolution_method() const
Convolution layer method accessor.
NodeType type() const override
Returns node&#39;s type.
TensorDescriptor configure_output(size_t idx) const override
Calculates output configuration.
unsigned int num_groups() const
Number of groups in convolution accessor.
ConvolutionMethod
Supported Convolution layer methods.
Definition: Types.h:126
static constexpr NodeType node_type
Default approach using internal heuristics.
Node visitor interface.
Definition: INodeVisitor.h:34
Convolution node.
void set_fused_activation(ActivationLayerInfo fused_activation)
Sets fused activation.