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.

op_registry.cc 1.5 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 "src/op_registry.h"
  17. namespace mindspore {
  18. namespace predict {
  19. OpRegistry::OpRegistry() = default;
  20. OpRegistry::~OpRegistry() = default;
  21. OpRegistry *OpRegistry::GetInstance() {
  22. static OpRegistry instance;
  23. return &instance;
  24. }
  25. OpCreator OpRegistry::GetOpCreator(const OpDesc &desc) {
  26. auto it = creators.find(desc);
  27. if (it != creators.end()) {
  28. return it->second;
  29. }
  30. return nullptr;
  31. }
  32. void OpRegistry::RegOp(const OpDesc desc, OpCreator creator) { creators[desc] = creator; }
  33. void OpRegistry::RegOp(const OP_ARCH arch, const OpT type, OpCreator creator) {
  34. OpDesc desc = {arch, type};
  35. creators[desc] = creator;
  36. }
  37. bool OpRegistry::Merge(const std::unordered_map<OpDesc, OpCreator> &newCreators) { return false; }
  38. const std::map<OpDesc, OpCreator> &OpRegistry::GetOpCreators() { return creators; }
  39. } // namespace predict
  40. } // namespace mindspore