Program Listing for File func_graph.h
↰ Return to documentation for file (include/converter/include/mindapi/ir/func_graph.h
)
#ifndef MINDSPORE_CORE_MINDAPI_IR_FUNC_GRAPH_H_
#define MINDSPORE_CORE_MINDAPI_IR_FUNC_GRAPH_H_
#include <vector>
#include <string>
#include <utility>
#include <memory>
#include "mindapi/base/base.h"
#include "mindapi/ir/common.h"
#include "mindapi/ir/anf.h"
#include "mindapi/ir/primitive.h"
#include "mindapi/ir/value.h"
#include "mindapi/ir/utils.h"
namespace mindspore {
class FuncGraphManager;
}
namespace mindspore::api {
class MIND_API FuncGraph : public Value {
public:
MIND_API_BASE_MEMBER(FuncGraph);
std::vector<AnfNodePtr> get_inputs() const;
std::vector<AnfNodePtr> parameters() const;
void add_parameter(const ParameterPtr &p);
ParameterPtr add_parameter();
AnfNodePtr output() const;
CNodePtr get_return() const;
void set_output(const AnfNodePtr &value, bool force_new_ret = false);
void set_return(const CNodePtr &cnode);
CNodePtr NewCNode(const std::vector<AnfNodePtr> &inputs = std::vector<AnfNodePtr>());
CNodePtr NewCNode(const PrimitivePtr &primitive, const std::vector<AnfNodePtr> &prim_inputs);
std::vector<AnfNodePtr> nodes() const;
bool has_attr(const std::string &key) const;
ValuePtr get_attr(const std::string &key) const;
void set_attr(const std::string &key, const ValuePtr &value);
FuncGraphManagerPtr manager() const;
static FuncGraphPtr Create();
static std::vector<AnfNodePtr> TopoSort(const AnfNodePtr &node);
};
class MIND_API FuncGraphManager {
public:
explicit FuncGraphManager(const std::shared_ptr<mindspore::FuncGraphManager> &impl);
const std::shared_ptr<mindspore::FuncGraphManager> &impl() const { return impl_; }
bool Replace(const AnfNodePtr &old_node, const AnfNodePtr &new_node);
void SetEdge(const AnfNodePtr &node, int index, const AnfNodePtr &value);
void AddEdge(const AnfNodePtr &node, const AnfNodePtr &value);
std::vector<std::pair<AnfNodePtr, int>> GetUsers(const AnfNodePtr &node) const;
static FuncGraphManagerPtr Manage(const FuncGraphPtr &func_graph, bool manage = true);
private:
const std::shared_ptr<mindspore::FuncGraphManager> impl_;
};
} // namespace mindspore::api
#endif // MINDSPORE_CORE_MINDAPI_IR_FUNC_GRAPH_H_