• 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_CORE_OPS_AFFINE_H_
18 #define MINDSPORE_CORE_OPS_AFFINE_H_
19 #include <string>
20 #include <vector>
21 #include "mindapi/base/types.h"
22 #include "ops/base_operator.h"
23 
24 namespace mindspore {
25 namespace ops {
26 constexpr auto kNameAffine = "Affine";
27 constexpr auto kAffineContext = "context";
28 constexpr auto kAffineOutputDim = "output_dim";
29 
30 /// \brief Assert defined Affine operator prototype of lite.
31 class MIND_API Affine : public BaseOperator {
32  public:
33   MIND_API_BASE_MEMBER(Affine);
34   /// \brief Constructor.
Affine()35   Affine() : BaseOperator(kNameAffine) { InitIOName({"x1", "x2"}, {"outputs"}); }
36   /// \brief Method to init the op's attributes.
37   void Init(const std::vector<int64_t> &contexts, int64_t output_dim, bool transpose_a = false,
38             bool transpose_b = false);
39   /// \brief Method to set context attributes.
40   ///
41   /// \param[in] keep_dims Define the context.
42   void set_context(const std::vector<int64_t> &);
43   /// \brief Method to set output_dim attributes.
44   ///
45   /// \param[in] output_dim Define the output dim.
46   void set_output_dim(int64_t output_dim);
47   /// \brief Method to set transpose_a attributes.
48   ///
49   /// \param[in] transpose_a Define the if transpose a tensor.
50   void set_transpose_a(bool transpose_a);
51   /// \brief Method to set transpose_b attributes.
52   ///
53   /// \param[in] transpose_b Define the if transpose b tensor.
54   void set_transpose_b(bool transpose_b);
55   /// \brief Method to set activation_type attributes.
56   ///
57   /// \param[in] activation_type Define the activation type.
58   void set_activation_type(const ActivationType &activation_type);
59 
60   /// \brief Method to get transpose_a attributes.
61   bool get_transpose_a() const;
62   /// \brief Method to get transpose_b attributes.
63   bool get_transpose_b() const;
64   /// \brief Method to get context attributes.
65   std::vector<int64_t> get_context() const;
66   /// \brief Method to get output_dim attributes.
67   int64_t get_output_dim() const;
68   /// \brief Method to get activation_type attributes.
69   ActivationType get_activation_type() const;
70 };
71 }  // namespace ops
72 }  // namespace mindspore
73 
74 #endif  // MINDSPORE_CORE_OPS_AFFINE_H_
75