• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 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_LITE_SRC_RUNTIME_DELEGATE_NPU_OP_ARGMAX_NPU_H_
18 #define MINDSPORE_LITE_SRC_RUNTIME_DELEGATE_NPU_OP_ARGMAX_NPU_H_
19 
20 #include <vector>
21 #include <string>
22 #include "include/graph/op/all_ops.h"
23 #include "include/graph/compatible/all_ops.h"
24 #include "src/litert/delegate/npu/op/npu_op.h"
25 
26 namespace mindspore::lite {
27 
28 class ArgmaxNPUOp : public NPUOp {
29  public:
ArgmaxNPUOp(const schema::Primitive * primitive,const std::vector<mindspore::MSTensor> & in_tensors,const std::vector<mindspore::MSTensor> & out_tensors,std::string name)30   ArgmaxNPUOp(const schema::Primitive *primitive, const std::vector<mindspore::MSTensor> &in_tensors,
31               const std::vector<mindspore::MSTensor> &out_tensors, std::string name)
32       : NPUOp(primitive, in_tensors, out_tensors, name) {}
33 
34   ~ArgmaxNPUOp() override;
35 
IsSupport(const schema::Primitive * primitive,const std::vector<mindspore::MSTensor> & in_tensors,const std::vector<mindspore::MSTensor> & out_tensors)36   int IsSupport(const schema::Primitive *primitive, const std::vector<mindspore::MSTensor> &in_tensors,
37                 const std::vector<mindspore::MSTensor> &out_tensors) override {
38     return RET_OK;
39   }
40 
41   int Init(const schema::Primitive *primitive, const std::vector<mindspore::MSTensor> &in_tensors,
42            const std::vector<mindspore::MSTensor> &out_tensors) override;
43 
44   int SetNPUInputs(const std::vector<mindspore::MSTensor> &in_tensors,
45                    const std::vector<mindspore::MSTensor> &out_tensors,
46                    const std::vector<ge::Operator *> &npu_inputs) override;
47 
48   ge::Operator *GetNPUOp() override;
49 
50  private:
51   hiai::op::ArgMaxExt2 *argmax_ = nullptr;
52   hiai::op::Const *axis_const_ = nullptr;
53 };
54 }  // namespace mindspore::lite
55 #endif  // MINDSPORE_LITE_SRC_RUNTIME_DELEGATE_NPU_OP_ARGMAX_NPU_H_
56