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_TOPK_FUSION_H_ 18 #define MINDSPORE_CORE_OPS_TOPK_FUSION_H_ 19 #include <vector> 20 21 #include "ops/topk.h" 22 #include "ops/op_utils.h" 23 #include "utils/check_convert_utils.h" 24 25 namespace mindspore { 26 namespace ops { 27 constexpr auto kNameTopKFusion = "TopKFusion"; 28 /// \brief TopKFusion defined TopK operator prototype of lite. 29 class MS_CORE_API TopKFusion : public TopK { 30 public: 31 /// \brief Constructor. TopKFusion()32 TopKFusion() : TopK(kNameTopKFusion) {} 33 34 /// \brief Destructor. 35 ~TopKFusion() = default; 36 37 MS_DECLARE_PARENT(TopKFusion, TopK); 38 39 /// \brief Method to init the op's attributes. 40 /// 41 /// \param[in] sorted Define a boolean value indicate whether the output should be sorted. 42 /// \param[in] axis Define the operation axis, which is no use now, but the default is the last dimension. 43 /// \param[in] largest Define the number of largest value along with the axis, which is not attribute now, but the 44 /// second input of this operation. 45 void Init(const bool sorted, const int64_t axis, const int64_t largest); 46 47 /// \brief Method to set axis attribute. Do not use. 48 /// 49 /// \param[in] axis Define the operation axis, which is no use now, but the default is the last dimension. 50 void set_axis(const int64_t axis); 51 52 /// \brief Method to set largest attribute, which is no use and needs to be converted to the second input. 53 /// 54 /// \param[in] largest Define the number of largest value along with the axis, which is not attribute now, but the 55 /// second input of this operation. 56 void set_largest(const int64_t largest); 57 58 /// \brief Method to get axis attribute. 59 /// 60 /// \return axis value. 61 int64_t get_axis() const; 62 63 /// \brief Method to get largest attribute. 64 /// 65 /// \return the number of largest value 66 int64_t get_largest() const; 67 }; 68 } // namespace ops 69 } // namespace mindspore 70 71 #endif // MINDSPORE_CORE_OPS_TOPK_FUSION_H_ 72