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.

ops.h 4.4 kB

5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * Copyright 2019-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_FRONTEND_OPERATOR_OPS_H_
  17. #define MINDSPORE_CCSRC_FRONTEND_OPERATOR_OPS_H_
  18. #include <iostream>
  19. #include <string>
  20. #include <memory>
  21. #include "ir/anf.h"
  22. #include "ir/primitive.h"
  23. #include "base/core_ops.h"
  24. namespace mindspore {
  25. // namespace to support primitive operators
  26. namespace prim {
  27. ValuePtr GetPythonOps(const std::string &op_name,
  28. const std::string &module_name = "mindspore._extends.parse.standard_method",
  29. bool use_signature = false);
  30. // Primitives only used by frontend;
  31. // Type introspection
  32. inline const PrimitivePtr kPrimTypeOf = std::make_shared<Primitive>("typeof");
  33. inline const PrimitivePtr kPrimHasType = std::make_shared<Primitive>("hastype");
  34. inline const PrimitivePtr kPrimResolve = std::make_shared<Primitive>("resolve");
  35. inline const PrimitivePtr kPrimEmbed = std::make_shared<Primitive>("embed");
  36. inline const PrimitivePtr kPrimRefToEmbed = std::make_shared<Primitive>("RefToEmbed");
  37. inline const PrimitivePtr kPrimCreateInstance = std::make_shared<Primitive>("create_instance");
  38. // Other miscellaneous
  39. inline const PrimitivePtr kPrimGetRefOrigin = std::make_shared<Primitive>("get_ref_origin");
  40. inline const PrimitivePtr kPrimInsertGradientOf = std::make_shared<Primitive>("InsertGradientOf");
  41. inline const PrimitivePtr kPrimCheckBprop = std::make_shared<Primitive>("CheckBprop");
  42. inline const PrimitivePtr kPrimMixedPrecisionCast = std::make_shared<Primitive>("mixed_precision_cast");
  43. inline const PrimitivePtr kPrimMakeRecord = std::make_shared<Primitive>("make_record");
  44. // Structures
  45. inline const PrimitivePtr kPrimListMap = std::make_shared<Primitive>("list_map");
  46. inline const PrimitivePtr kPrimListReduce = std::make_shared<Primitive>("list_reduce");
  47. inline const PrimitivePtr kPrimTupleReversed = std::make_shared<Primitive>("tuple_reversed");
  48. inline const PrimitivePtr kPrimReducedShape = std::make_shared<Primitive>("reduced_shape");
  49. inline const PrimitivePtr kPrimTupleDiv = std::make_shared<Primitive>("tuple_div");
  50. inline const PrimitivePtr kPrimTupleToArray = std::make_shared<Primitive>("tuple_to_array");
  51. inline const PrimitivePtr kPrimShapeMul = std::make_shared<Primitive>("shape_mul");
  52. inline const PrimitivePtr kPrimTupleEqual = std::make_shared<Primitive>("tuple_equal");
  53. inline const PrimitivePtr kPrimListEqual = std::make_shared<Primitive>("list_equal");
  54. inline const PrimitivePtr kPrimMakeRange = std::make_shared<Primitive>("make_range");
  55. inline const PrimitivePtr kPrimStopGradient = std::make_shared<Primitive>("stop_gradient");
  56. inline const PrimitivePtr kPrimStringEqual = std::make_shared<Primitive>("string_equal");
  57. inline const PrimitivePtr kPrimStringConcat = std::make_shared<Primitive>("string_concat");
  58. inline const PrimitivePtr kPrimDictLen = std::make_shared<Primitive>("dict_len");
  59. inline const PrimitivePtr kPrimFakeBprop = std::make_shared<Primitive>("fake_bprop");
  60. inline const PrimitivePtr kPrimBroadcastGradientArgs = std::make_shared<Primitive>("BroadcastGradientArgs");
  61. class UnpackGraphPrimitive : public Primitive {
  62. public:
  63. explicit UnpackGraphPrimitive(const std::string &name, const bool &with_sens, const bool &need_unpack_args)
  64. : Primitive("UnpackGraph"), with_sens_in_args_(with_sens), need_unpack_args_(need_unpack_args) {}
  65. ~UnpackGraphPrimitive() override = default;
  66. MS_DECLARE_PARENT(UnpackGraphPrimitive, Primitive)
  67. bool with_sens_in_args() const { return with_sens_in_args_; }
  68. bool need_unpack_args() const { return need_unpack_args_; }
  69. private:
  70. bool with_sens_in_args_;
  71. bool need_unpack_args_;
  72. };
  73. using UnpackGraphPrimitivePtr = std::shared_ptr<UnpackGraphPrimitive>;
  74. } // namespace prim
  75. } // namespace mindspore
  76. #endif // MINDSPORE_CCSRC_FRONTEND_OPERATOR_OPS_H_