• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019 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_CCSRC_BACKEND_KERNEL_COMPILER_TBE_TBE_KERNEL_MOD_H_
18 #define MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_TBE_TBE_KERNEL_MOD_H_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 #include <utility>
24 #include "backend/kernel_compiler/ascend_kernel_mod.h"
25 #include "backend/kernel_compiler/tbe/tbe_utils.h"
26 
27 namespace mindspore {
28 namespace kernel {
29 class TbeKernelMod : public AscendKernelMod {
30  public:
TbeKernelMod(KernelPackPtr kernel_pack)31   explicit TbeKernelMod(KernelPackPtr kernel_pack) : kernel_pack_(std::move(kernel_pack)) {}
32   ~TbeKernelMod() override = default;
33 
SetInputSizeList(const std::vector<size_t> & size_list)34   void SetInputSizeList(const std::vector<size_t> &size_list) { input_size_list_ = size_list; }
SetOutputSizeList(const std::vector<size_t> & size_list)35   void SetOutputSizeList(const std::vector<size_t> &size_list) { output_size_list_ = size_list; }
SetWorkspaceSizeList(const std::vector<size_t> & size_list)36   void SetWorkspaceSizeList(const std::vector<size_t> &size_list) { workspace_size_list_ = size_list; }
GetInputSizeList()37   const std::vector<size_t> &GetInputSizeList() const override { return input_size_list_; }
GetOutputSizeList()38   const std::vector<size_t> &GetOutputSizeList() const override { return output_size_list_; }
GetWorkspaceSizeList()39   const std::vector<size_t> &GetWorkspaceSizeList() const override { return workspace_size_list_; }
40 
41   bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
42               const std::vector<AddressPtr> &outputs, void *stream_ptr) override;
43   std::vector<TaskInfoPtr> GenTask(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspaces,
44                                    const std::vector<AddressPtr> &outputs, uint32_t stream_id) override;
45   device::DynamicKernelPtr GenDynamicKernel(const CNodePtr &cnode_ptr, void *stream_ptr) override;
46   std::vector<size_t> GenParameters() override;
47 
48  private:
49   KernelPackPtr kernel_pack_;
50   std::vector<size_t> input_size_list_;
51   std::vector<size_t> output_size_list_;
52   std::vector<size_t> workspace_size_list_;
53 };
54 
55 using TbeKernelModPtr = std::shared_ptr<TbeKernelMod>;
56 }  // namespace kernel
57 }  // namespace mindspore
58 #endif  // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_TBE_TBE_KERNEL_MOD_H_
59