• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020-2023 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 #include "mindapi/base/type_id.h"
22 #include "mindapi/base/types.h"
23 #include "ops/base_operator.h"
24 
25 namespace mindspore {
26 namespace ops {
27 constexpr auto kNameArgMaxFusion = "ArgMaxFusion";
28 /// \brief ArgMaxFusion defined ArgMax operator prototype of lite.
29 class MIND_API ArgMaxFusion : public BaseOperator {
30  public:
31   MIND_API_BASE_MEMBER(ArgMaxFusion);
32   /// \brief Constructor.
ArgMaxFusion()33   ArgMaxFusion() : BaseOperator(kNameArgMaxFusion) { InitIOName({"x"}, {"output"}); }
34 
35   /// \brief Method to init the op's attributes.
36   ///
37   /// \param[in] keep_dims Define a boolean value to indicate the dimension of output is equal to that of input or not.
38   /// \param[in] out_max_value Define a boolean value to indicate whether to output maximum value.
39   /// \param[in] top_k Define the number of maximum value along with axis.
40   /// \param[in] axis Define where the argmax operation applies to.
41   void Init(const bool keep_dims, const bool out_max_value, const int64_t top_k, const int64_t axis = -1);
42 
43   /// \brief Method to set keep_dims attribute.
44   ///
45   /// \param[in] keep_dims Define a boolean value to indicate the dimension of output is equal to that of input or not.
46   void set_keep_dims(const bool keep_dims);
47 
48   /// \brief Method to set out_max_value attribute.
49   ///
50   /// \param[in] out_max_value Define a boolean value to indicate whether to output maximum value.
51   void set_out_max_value(const bool out_max_value);
52 
53   /// \brief Method to set top_k attribute, default is 1.
54   ///
55   /// \param[in] top_k Define the number of maximum value along with axis.
56   void set_top_k(const int64_t top_k);
57 
58   /// \brief Method to get keep_dims attribute.
59   ///
60   /// \return a boolean value to indicate the dimension of output is equal to that of input or not.
61   bool get_keep_dims() const;
62 
63   /// \brief Method to get out_max_value attribute.
64   ///
65   /// \return a boolean value to indicate whether to output maximum value.
66   bool get_out_max_value() const;
67 
68   /// \brief Method to get top_k attribute.
69   ///
70   /// \return the number of maximum value along with axis.
71   int64_t get_top_k() const;
72 
73   /// \brief Set axis.
74   void set_axis(const int64_t axis);
75 
76   /// \brief Set output_type.
77   void set_output_type(const TypeId output_type);
78 
79   /// \brief Get axis.
80   ///
81   /// \return axis.
82   int64_t get_axis() const;
83 
84   /// \brief Get output_type.
85   ///
86   /// \return output_type.
87   TypeId get_output_type() const;
88 };
89 }  // namespace ops
90 }  // namespace mindspore
91 
92 #endif  // MINDSPORE_CORE_OPS_ARGMAX_FUSION_H_
93