• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_SPARSE_MATRIX_MUL_CPU_KERNEL_H_
17 #define MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_SPARSE_MATRIX_MUL_CPU_KERNEL_H_
18 
19 #include <vector>
20 #include <map>
21 #include <utility>
22 #include "plugin/device/cpu/kernel/cpu_kernel.h"
23 #include "plugin/factory/ms_factory.h"
24 
25 namespace mindspore {
26 namespace kernel {
27 class SparseMatrixMulCpuKernelMod : public NativeCpuKernelMod, public MatchKernelHelper<SparseMatrixMulCpuKernelMod> {
28  public:
29   SparseMatrixMulCpuKernelMod() = default;
30   ~SparseMatrixMulCpuKernelMod() override = default;
31 
32   bool Init(const std::vector<KernelTensor *> &inputs, const std::vector<KernelTensor *> &outputs) override;
33 
Launch(const std::vector<KernelTensor * > & inputs,const std::vector<KernelTensor * > & workspace,const std::vector<KernelTensor * > & outputs)34   bool Launch(const std::vector<KernelTensor *> &inputs, const std::vector<KernelTensor *> &workspace,
35               const std::vector<KernelTensor *> &outputs) override {
36     return kernel_func_(this, inputs, workspace, outputs);
37   }
38   int Resize(const std::vector<KernelTensor *> &inputs, const std::vector<KernelTensor *> &outputs) override;
39 
40   const std::vector<std::pair<KernelAttr, KernelRunFunc>> &GetFuncList() const override;
41 
42  protected:
GetOpSupport()43   std::vector<KernelAttr> GetOpSupport() override { return OpSupport(); }
44 
45  private:
46   template <typename T, typename S>
47   const bool LaunchKernel(const std::vector<kernel::KernelTensor *> &inputs, const std::vector<KernelTensor *> &,
48                           const std::vector<kernel::KernelTensor *> &outputs);
49 
50   size_t row_ = 0;
51   size_t col_ = 0;
52   size_t dense_size_ = 0;
53   std::vector<TypeId> types_;
54 };
55 }  // namespace kernel
56 }  // namespace mindspore
57 
58 #endif  // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_SPARSE_MATRIX_MUL_CPU_KERNEL_H_
59