diff --git a/mindspore/core/ops/primitive_c.h b/mindspore/core/ops/primitive_c.h index 0334aa25fcf..cd6f2acfeb3 100644 --- a/mindspore/core/ops/primitive_c.h +++ b/mindspore/core/ops/primitive_c.h @@ -25,11 +25,22 @@ #include "ir/value.h" namespace mindspore { namespace ops { +/// \brief PrimitiveC defines the base class for end side operators. class MS_CORE_API PrimitiveC : public Primitive { public: + /// \brief Constructor for PrimitiveC. + /// + /// \param[in] name The name of the end side operator. explicit PrimitiveC(const std::string &name) : Primitive(name) {} MS_DECLARE_PARENT(PrimitiveC, Primitive); + + /// \brief Destructor of PrimitiveC. ~PrimitiveC() = default; + + /// \brief Derive the abstract of the PrimitiveC object. + /// + /// \param[in] abstract_list The abstract of the inputs of the PrimitiveC object. + /// \return The abstract of the PrimitiveC object. AbstractBasePtr Infer(const AbstractBasePtrList &abstract_list); protected: @@ -37,11 +48,26 @@ class MS_CORE_API PrimitiveC : public Primitive { }; using OpPrimCDefineFunc = std::function()>; +/// \brief OpPrimCRegister defines the singleton to save the end side operators. class MS_CORE_API OpPrimCRegister { public: + /// \brief Destructor of OpPrimCRegister. ~OpPrimCRegister() {} + + /// \brief Get the OpPrimCRegister singleton. + /// + /// \return The OpPrimCRegister singleton. static OpPrimCRegister &GetInstance(); + + /// \brief Get PrimCMap of the OpPrimCRegister singleton. + /// + /// \return The PrimCMap of the OpPrimCRegister singleton. std::map GetPrimCMap(); + + /// \brief Add an element into the PrimCMap of the OpPrimCRegister singleton. + /// + /// param[in] kname The name of the input end side operator. + /// param[in] fn The input end side operator. void SetPrimCMap(const std::string &kname, const OpPrimCDefineFunc &fn); private: @@ -49,11 +75,18 @@ class MS_CORE_API OpPrimCRegister { std::map op_primc_fns_; }; +/// \brief OpPrimCRegisterHelper defines the helper class for the OpPrimCRegister singleton. class MS_CORE_API OpPrimCRegisterHelper { public: + /// \brief Constructor for OpPrimCRegisterHelper. + /// + /// param[in] kname The name of the input end side operator. + /// param[in] fn The input end side operator. OpPrimCRegisterHelper(const std::string &kname, const OpPrimCDefineFunc &fn) { OpPrimCRegister::GetInstance().SetPrimCMap(kname, fn); } + + /// Destructor of OpPrimCRegisterHelper. ~OpPrimCRegisterHelper() = default; private: