• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MINDSPORE_CORE_OPS_FUSED_BATCH_NORM_H_
18 #define MINDSPORE_CORE_OPS_FUSED_BATCH_NORM_H_
19 #include <map>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 #include "mindapi/base/types.h"
24 #include "ops/base_operator.h"
25 
26 namespace mindspore {
27 namespace ops {
28 constexpr auto kNameFusedBatchNorm = "FusedBatchNorm";
29 /// \brief FusedBatchNorm defined Enhanced BatchNorm operator prototype.
30 class MIND_API FusedBatchNorm : public BaseOperator {
31  public:
32   MIND_API_BASE_MEMBER(FusedBatchNorm);
33   /// \brief Constructor.
FusedBatchNorm()34   FusedBatchNorm() : BaseOperator(kNameFusedBatchNorm) {
35     InitIOName({"x", "scale", "b", "mean", "variance"},
36                {"y", "running_mean", "running_variance", "save_mean", "save_inv_variance"});
37   }
38 
39   /// \brief Method to init the op's attributes.
40   ///
41   /// \param[in] mode Define the mode of batchnorm, which is useless.
42   /// \param[in] epsilon Define a small value added for numerical stability, which is used to avoid that divisor is
43   ///            zero.
44   /// \param[in] momentum Define the hyper parameter to compute moving average for running_mean and running_var.
45   void Init(const int64_t mode = 0, const float epsilon = 1e-5, const float momentum = 0.1);
46 
47   /// \brief Method to set mode attribute, which has been abandoned.
48   ///
49   /// \param[in] mode Define the mode of batchnorm, which is useless.
50   void set_mode(const int64_t mode);
51 
52   /// \brief Method to set epsilon attribute.
53   ///
54   /// \param[in] epsilon Define a small value added for numerical stability, which is used to avoid that divisor is
55   ///            zero.
56   void set_epsilon(const float epsilon);
57 
58   /// \brief Method to set momentum attribute.
59   ///
60   /// \param[in] momentum Define the hyper parameter to compute moving average for running_mean and running_var.
61   void set_momentum(const float momentum);
62 
63   /// \brief Method to get mode attribute, which has been abandoned.
64   int64_t get_mode() const;
65 
66   /// \brief Method to get epsilon attribute.
67   ///
68   /// \return a small float value.
69   float get_epsilon() const;
70 
71   /// \brief Method to get momentum attribute.
72   ///
73   /// \return the hyper parameter .
74   float get_momentum() const;
75 };
76 }  // namespace ops
77 }  // namespace mindspore
78 
79 #endif  // MINDSPORE_CORE_OPS_FUSED_BATCH_NORM_H_
80