You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

rt_kernel.cc 1.6 kB

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