• 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 #include "backend/kernel_compiler/rts/rt_kernel.h"
18 
19 namespace mindspore {
20 namespace kernel {
Register(const std::string & name,RtKernelCreater && fun)21 void RtKernelFactory::Register(const std::string &name, RtKernelCreater &&fun) {
22   (void)fmap_.emplace(name, std::move(fun));
23 }
24 
Create(const std::string & name)25 std::shared_ptr<RtKernel> RtKernelFactory::Create(const std::string &name) {
26   const auto &map = Get().fmap_;
27   auto it = map.find(name);
28   if (it != map.end() && it->second) {
29     return (it->second)();
30   }
31   return nullptr;
32 }
33 
Get()34 RtKernelFactory &RtKernelFactory::Get() {
35   static RtKernelFactory _this{};
36   return _this;
37 }
38 
RtKernel()39 RtKernel::RtKernel() {}
40 
~RtKernel()41 RtKernel::~RtKernel() {}
42 
Init(const mindspore::AnfNodePtr &)43 bool RtKernel::Init(const mindspore::AnfNodePtr & /*anf_node*/) { return true; }
44 
GetInputSizeList() const45 const std::vector<size_t> &RtKernel::GetInputSizeList() const { return input_size_list_; }
46 
GetOutputSizeList() const47 const std::vector<size_t> &RtKernel::GetOutputSizeList() const { return output_size_list_; }
48 
GetWorkspaceSizeList() const49 const std::vector<size_t> &RtKernel::GetWorkspaceSizeList() const { return workspace_size_list_; }
50 }  // namespace kernel
51 }  // namespace mindspore
52