• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020-2021 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_ARGMAX_FUSION_H_
18 #define MINDSPORE_CORE_OPS_ARGMAX_FUSION_H_
19 #include <memory>
20 #include <vector>
21 
22 #include "ops/arg_max.h"
23 
24 namespace mindspore {
25 namespace ops {
26 constexpr auto kNameArgMaxFusion = "ArgMaxFusion";
27 /// \brief ArgMaxFusion defined ArgMax operator prototype of lite.
28 class MS_CORE_API ArgMaxFusion : public ArgMax {
29  public:
30   /// \brief Constructor.
ArgMaxFusion()31   ArgMaxFusion() : ArgMax(kNameArgMaxFusion) { InitIOName({"x"}, {"output"}); }
32 
33   /// \brief Destructor.
34   ~ArgMaxFusion() = default;
35 
36   MS_DECLARE_PARENT(ArgMaxFusion, ArgMax);
37 
38   /// \brief Method to init the op's attributes.
39   ///
40   /// \param[in] keep_dims Define a boolean value to indicate the dimension of output is equal to that of input or not.
41   /// \param[in] out_max_value Define a boolean value to indicate whether to output maximum value.
42   /// \param[in] top_k Define the number of maximum value along with axis.
43   /// \param[in] axis Define where the argmax operation applies to.
44   void Init(const bool keep_dims, const bool out_max_value, const int64_t top_k, const int64_t axis = -1);
45 
46   /// \brief Method to set keep_dims attribute.
47   ///
48   /// \param[in] keep_dims Define a boolean value to indicate the dimension of output is equal to that of input or not.
49   void set_keep_dims(const bool keep_dims);
50 
51   /// \brief Method to set out_max_value attribute.
52   ///
53   /// \param[in] out_max_value Define a boolean value to indicate whether to output maximum value.
54   void set_out_max_value(const bool out_max_value);
55 
56   /// \brief Method to set top_k attribute, default is 1.
57   ///
58   /// \param[in] top_k Define the number of maximum value along with axis.
59   void set_top_k(const int64_t top_k);
60 
61   /// \brief Method to get keep_dims attribute.
62   ///
63   /// \return a boolean value to indicate the dimension of output is equal to that of input or not.
64   bool get_keep_dims() const;
65 
66   /// \brief Method to get out_max_value attribute.
67   ///
68   /// \return a boolean value to indicate whether to output maximum value.
69   bool get_out_max_value() const;
70 
71   /// \brief Method to get top_k attribute.
72   ///
73   /// \return the number of maximum value along with axis.
74   int64_t get_top_k() const;
75 };
76 AbstractBasePtr ArgMaxFusionInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive,
77                                   const std::vector<AbstractBasePtr> &input_args);
78 using PrimArgMaxFusion = std::shared_ptr<ArgMaxFusion>;
79 }  // namespace ops
80 }  // namespace mindspore
81 
82 #endif  // MINDSPORE_CORE_OPS_ARGMAX_FUSION_H_
83