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.

oplib.h 2.1 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #ifndef MINDSPORE_CCSRC_KERNEL_OPLIB_OPLIB_H_
  17. #define MINDSPORE_CCSRC_KERNEL_OPLIB_OPLIB_H_
  18. #include <vector>
  19. #include <string>
  20. #include <memory>
  21. #include <nlohmann/json.hpp>
  22. #include "kernel/oplib/opinfo.h"
  23. namespace mindspore {
  24. namespace kernel {
  25. class OpLib {
  26. public:
  27. OpLib() = default;
  28. virtual ~OpLib() = default;
  29. bool RegOp(const std::string& json_string, const std::string& impl_path);
  30. static std::shared_ptr<OpInfo> FindOp(const std::string& op_name, OpImplyType imply_type);
  31. protected:
  32. static std::vector<std::shared_ptr<OpInfo>> op_info_;
  33. private:
  34. static bool DecodeOpInfo(const nlohmann::json& obj, const OpImplyType imply_type, const std::string& impl_path);
  35. static bool DecodeAttr(const nlohmann::json& obj, const OpImplyType imply_type,
  36. const std::shared_ptr<OpInfo>& op_info);
  37. static bool DecodeDtypeFormat(const nlohmann::json& dtype_format, const std::shared_ptr<OpIOInfo>& op_io,
  38. size_t index);
  39. static bool DecodeInputOutput(const nlohmann::json& obj, const OpImplyType imply_type, const OpIOType io_type,
  40. const std::shared_ptr<OpInfo>& op_info, const nlohmann::json& dtype_format);
  41. static bool GetRefInfo(const std::shared_ptr<OpInfo>& op_info);
  42. static bool CheckRepetition(const std::shared_ptr<OpInfo>& op_info);
  43. };
  44. } // namespace kernel
  45. } // namespace mindspore
  46. #endif // MINDSPORE_CCSRC_KERNEL_OPLIB_OPLIB_H_