1 // Tencent is pleased to support the open source community by making ncnn available.
2 //
3 // Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
4 //
5 // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6 // in compliance with the License. You may obtain a copy of the License at
7 //
8 // https://opensource.org/licenses/BSD-3-Clause
9 //
10 // Unless required by applicable law or agreed to in writing, software distributed
11 // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 // specific language governing permissions and limitations under the License.
14 
15 #ifndef LAYER_REDUCTION_H
16 #define LAYER_REDUCTION_H
17 
18 #include "layer.h"
19 
20 namespace ncnn {
21 
22 class Reduction : public Layer
23 {
24 public:
25     Reduction();
26 
27     virtual int load_param(const ParamDict& pd);
28 
29     virtual int forward(const Mat& bottom_blob, Mat& top_blob, const Option& opt) const;
30 
31     enum ReductionOp
32     {
33         ReductionOp_SUM = 0,
34         ReductionOp_ASUM = 1,
35         ReductionOp_SUMSQ = 2,
36         ReductionOp_MEAN = 3,
37         ReductionOp_MAX = 4,
38         ReductionOp_MIN = 5,
39         ReductionOp_PROD = 6,
40         ReductionOp_L1 = 7,
41         ReductionOp_L2 = 8,
42         ReductionOp_LogSum = 9,
43         ReductionOp_LogSumExp = 10
44     };
45 
46 public:
47     // param
48     int operation;
49     int reduce_all;
50     float coeff;
51     Mat axes;
52     int keepdims;
53 };
54 
55 } // namespace ncnn
56 
57 #endif // LAYER_REDUCTION_H
58