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