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.

base.h 1.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * Copyright 2020 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_PYNATIVE_BASE_H_
  17. #define MINDSPORE_CCSRC_PYNATIVE_BASE_H_
  18. #include <vector>
  19. #include <utility>
  20. #include <string>
  21. #include <memory>
  22. #include <set>
  23. #include <unordered_map>
  24. #include <unordered_set>
  25. #include "pybind11/pybind11.h"
  26. #include "ir/primitive.h"
  27. #include "pipeline/static_analysis/abstract_value.h"
  28. namespace mindspore {
  29. namespace pynative {
  30. namespace py = pybind11;
  31. enum PynativeStatusCode {
  32. PYNATIVE_SUCCESS = 0,
  33. PYNATIVE_OP_NOT_IMPLEMENTED_ERR = 1,
  34. PYNATIVE_OP_INPUTS_ERR = 2,
  35. PYNATIVE_OP_PARAMS_ERR = 3,
  36. PYNATIVE_OP_ATTRS_ERR = 4,
  37. PYNATIVE_GRAPH_MANAGER_ERR = 5,
  38. PYNATIVE_GRAPH_GE_BUILD_ERR = 6,
  39. PYNATIVE_GRAPH_GE_RUN_ERR = 7,
  40. PYNATIVE_UNKNOWN_STATE = 0XFF
  41. };
  42. enum RunOpArgsEnum { PY_PRIM = 0, PY_NAME, PY_INPUTS, PY_ARGS_NUM };
  43. struct OpExecInfo {
  44. PrimitivePyPtr py_primitive;
  45. std::string op_name;
  46. AbstractBasePtr abstract;
  47. py::tuple op_inputs;
  48. py::tuple inputs_mask;
  49. py::dict op_attrs;
  50. };
  51. using OpExecInfoPtr = std::shared_ptr<OpExecInfo>;
  52. OpExecInfoPtr GenerateOpExecInfo(const py::args &args, py::list *const out_args);
  53. const std::set<std::string> ignore_infer_prim = {"make_ref"};
  54. } // namespace pynative
  55. } // namespace mindspore
  56. #endif // MINDSPORE_CCSRC_PYNATIVE_BASE_H_