1 /** 2 * Copyright 2022 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_SPARSE_MATRIX_SPARSE_MAT_MUL_H_ 18 #define MINDSPORE_CORE_OPS_SPARSE_MATRIX_SPARSE_MAT_MUL_H_ 19 #include <algorithm> 20 #include <map> 21 #include <memory> 22 #include <set> 23 #include <string> 24 #include <vector> 25 #include "mindapi/base/types.h" 26 #include "mindspore/core/ops/sparse_ops.h" 27 #include "ops/base_operator.h" 28 #include "ops/op_utils.h" 29 30 namespace mindspore { 31 namespace ops { 32 constexpr auto kNameSparseMatrixSparseMatMul = "SparseMatrixSparseMatMul"; 33 /// \brief return a matrix multiplication of a sparse matrix a with a sparse matrix b; 34 /// returns a sparse matrix a * b, unless either a or b is transposed or adjointed.. 35 /// Refer to Python API @ref mindspore.ops.SparseMatrixSparseMatMul for more details. 36 class MIND_API SparseMatrixSparseMatMul : public BaseOperator { 37 public: 38 MIND_API_BASE_MEMBER(SparseMatrixSparseMatMul); 39 /// \brief Constructor. SparseMatrixSparseMatMul()40 SparseMatrixSparseMatMul() : BaseOperator(kNameSparseMatrixSparseMatMul) { 41 InitIOName({"x1_dense_shape", "x1_batch_pointers", "x1_row_pointers", "x1_col_indices", "x1_values", 42 "x2_dense_shape", "x2_batch_pointers", "x2_row_pointers", "x2_col_indices", "x2_values"}, 43 {"y_dense_shape", "y_batch_pointers", "y_row_pointers", "y_col_indices", "y_values"}); 44 } get_transpose_a()45 bool get_transpose_a() const { 46 auto value_ptr = GetAttr(kTransposeA); 47 return GetValue<bool>(value_ptr); 48 } get_transpose_b()49 bool get_transpose_b() const { 50 auto value_ptr = GetAttr(kTransposeB); 51 return GetValue<bool>(value_ptr); 52 } get_adjoint_a()53 bool get_adjoint_a() const { 54 auto value_ptr = GetAttr(kAdjointA); 55 return GetValue<bool>(value_ptr); 56 } get_adjoint_b()57 bool get_adjoint_b() const { 58 auto value_ptr = GetAttr(kAdjointB); 59 return GetValue<bool>(value_ptr); 60 } 61 /// \brief Init. Init()62 void Init() const {} 63 }; 64 MIND_API abstract::AbstractBasePtr SparseMatrixSparseMatMulInfer( 65 const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, 66 const std::vector<abstract::AbstractBasePtr> &input_args); 67 using kPrimSparseMatrixSparseMatMul = std::shared_ptr<SparseMatrixSparseMatMul>; 68 } // namespace ops 69 } // namespace mindspore 70 71 #endif // MINDSPORE_CORE_OPS_SPARSE_MATRIX_SPARSE_MAT_MUL_H_ 72