blob: 6048994b02538f11a488b0217a09c841cb23890c [file] [log] [blame]
Sheri Zhangfb228032021-11-02 10:45:07 +00001/*
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
27#include "arm_compute/graph/INode.h"
28
29#include <list>
30
31namespace arm_compute
32{
33namespace graph
34{
35/** Convolution node */
36class FusedConvolutionWithPostOpNode final : public INode
37{
38public:
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 */
47 FusedConvolutionWithPostOpNode(PadStrideInfo info,
48 unsigned int num_groups = 1,
49 ConvolutionMethod method = ConvolutionMethod::Default,
50 FastMathHint fast_math_hint = FastMathHint::Disabled,
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 */
56 void set_convolution_method(ConvolutionMethod method);
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 */
64 ConvolutionMethod convolution_method() const;
65 /** Sets the fast math fast hint
66 *
67 * @param[in] hint Hint to use for convolution
68 */
69 void set_fast_math_hint(FastMathHint hint);
70 /** Fast math hint accessor
71 *
72 * @return Fast math hint to be used by the node
73 */
74 FastMathHint fast_math_hint() const;
Sheri Zhangfb228032021-11-02 10:45:07 +000075 /** Convolution metadata accessor
76 *
77 * @return Convolution information
78 */
79 PadStrideInfo convolution_info() const;
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 */
89 ActivationLayerInfo fused_activation() const;
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 */
99 void set_convolution_info(PadStrideInfo info);
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
118public:
119 static constexpr NodeType node_type = NodeType::FusedConvolutionWithPostOp;
120
121private:
Sheri Zhangc65023e2021-11-03 21:24:00 +0000122 PadStrideInfo _info;
123 unsigned int _num_groups;
124 ConvolutionMethod _method;
125 FastMathHint _fast_math_hint;
126 QuantizationInfo _out_quant_info;
127 ActivationLayerInfo _fused_activation;
Sheri Zhangfb228032021-11-02 10:45:07 +0000128};
129} // namespace graph
130} // namespace arm_compute
131
132#endif /* ARM_COMPUTE_GRAPH_FUSED_CONVOLUTION_WITH_POST_OP_NODE_H */