• 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 #ifndef LITE_MINDSPORE_LITE_TOOLS_CONVERTER_OPS_ATTENTION_H_
17 #define LITE_MINDSPORE_LITE_TOOLS_CONVERTER_OPS_ATTENTION_H_
18 #include <map>
19 #include <vector>
20 #include <string>
21 #include <memory>
22 #include "utils/check_convert_utils.h"
23 #include "ops/primitive_c.h"
24 #include "abstract/abstract_value.h"
25 
26 namespace mindspore {
27 namespace ops {
28 constexpr auto kNameAttention = "Attention";
29 /// \brief MultiHead-Attention op in MindIR.
30 class MS_CORE_API Attention : public PrimitiveC {
31  public:
32   /// \brief Constructor.
Attention()33   Attention() : PrimitiveC(kNameAttention) {
34     InitIOName(
35       {"q", "k", "v", "weight_q", "weight_k", "weight_v", "weight_o", "bias_q", "bias_k", "bias_v", "bias_o", "mask"},
36       {"output"});
37   }
38   /// \brief Destructor.
39   ~Attention() override = default;
40   MS_DECLARE_PARENT(Attention, PrimitiveC);
41   /// \brief Initialize Attention op.
Init()42   void Init() {}
43 };
44 }  // namespace ops
45 }  // namespace mindspore
46 #endif  // LITE_MINDSPORE_LITE_TOOLS_CONVERTER_OPS_ATTENTION_H_
47