1 /* 2 * Copyright (c) 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_FUSED_DEPTHWISE_CONVOLUTION_BATCH_NORMALIZATION_NODE_H 25 #define ARM_COMPUTE_GRAPH_FUSED_DEPTHWISE_CONVOLUTION_BATCH_NORMALIZATION_NODE_H 26 27 #include "arm_compute/graph/INode.h" 28 29 namespace arm_compute 30 { 31 namespace graph 32 { 33 /** Fused Depthwise Convolution Batch Normalization node */ 34 class FusedDepthwiseConvolutionBatchNormalizationNode final : public INode 35 { 36 public: 37 /** Constructor 38 * 39 * @param[in] epsilon Epsilon parameter. 40 * @param[in] info Convolution layer attributes. 41 * @param[in] depth_multiplier (Optional) Multiplier to apply to the input's depth in order to retrieve the output's depth. Defaults to 1. 42 * @param[in] method (Optional) Convolution method to use 43 * @param[in] fused_activation (Optional) Fused activation layer. Disabled if not specified 44 */ 45 FusedDepthwiseConvolutionBatchNormalizationNode(float epsilon, 46 PadStrideInfo info, 47 unsigned int depth_multiplier, 48 DepthwiseConvolutionMethod method, 49 ActivationLayerInfo fused_activation = ActivationLayerInfo()); 50 51 /** Sets the depthwise convolution layer method to use 52 * 53 * @param[in] method Method to use for depthwise convolution 54 */ 55 void set_depthwise_convolution_method(DepthwiseConvolutionMethod method); 56 57 /** Depthwise convolution layer method accessor 58 * 59 * @note This is an indication on which depthwise convolution layer implementation to use, 60 * if it fails to be created the library's heuristic approach will be used 61 * 62 * @return Depthwise convolution layer method to be used by the node 63 */ 64 DepthwiseConvolutionMethod depthwise_convolution_method() const; 65 66 /** Epsilon parameter accessor 67 * 68 * @return Epsilon parameter 69 */ 70 float epsilon() const; 71 72 /** Returns fused activation 73 * 74 * @return Fused activation 75 */ 76 ActivationLayerInfo fused_activation() const; 77 78 /** Sets fused activation 79 * 80 * @param[in] fused_activation Fused activation to set 81 */ 82 void set_fused_activation(ActivationLayerInfo fused_activation); 83 84 /** Computes convolution output descriptor 85 * 86 * @param[in] input_descriptor Input descriptor 87 * @param[in] weights_descriptor Weights descriptor 88 * @param[in] info Convolution operation attributes 89 * @param[in] depth_multiplier Depth multiplier 90 * 91 * @return Output descriptor 92 */ 93 static TensorDescriptor compute_output_descriptor(const TensorDescriptor &input_descriptor, 94 const TensorDescriptor &weights_descriptor, 95 const PadStrideInfo &info, 96 int depth_multiplier); 97 98 /** Sets the convolution layer method to use 99 * 100 * @param[in] method Method to use for convolution 101 */ 102 void set_convolution_method(ConvolutionMethod method); 103 104 /** Depth multiplier accessor 105 * 106 * @return Depth multiplier 107 */ 108 unsigned int depth_multiplier() const; 109 110 /** Convolution metadata accessor 111 * 112 * @return Convolution information 113 */ 114 PadStrideInfo convolution_info() const; 115 116 // Inherited overridden methods: 117 NodeType type() const override; 118 bool forward_descriptors() override; 119 TensorDescriptor configure_output(size_t idx) const override; 120 void accept(INodeVisitor &v) override; 121 122 public: 123 static constexpr NodeType node_type = NodeType::FusedDepthwiseConvolutionBatchNormalizationLayer; 124 125 private: 126 float _epsilon; 127 128 PadStrideInfo _info; 129 unsigned int _depth_multiplier; 130 DepthwiseConvolutionMethod _method; 131 ActivationLayerInfo _fused_activation; 132 }; 133 134 } // namespace graph 135 } // namespace arm_compute 136 #endif /* ARM_COMPUTE_GRAPH_FUSED_DEPTHWISE_CONVOLUTION_BATCH_NORMALIZATION_NODE_H */ 137