Class FuncGraph
Defined in File func_graph.h
Inheritance Relationships
Base Type
public mindspore::api::Value
(Class Value)
Class Documentation
-
class FuncGraph : public mindspore::api::Value
FuncGraph defines interface for a function graph.
Public Functions
-
std::vector<AnfNodePtr> get_inputs() const
Get the input parameters.
- Returns
Input parameters of this graph.
-
std::vector<AnfNodePtr> parameters() const
Get all parameters.
- Returns
All parameters of this graph.
-
void add_parameter(const ParameterPtr &p)
Adds a parameter to this graph.
- Parameters
p – [in] The parameter to be added.
-
ParameterPtr add_parameter()
Adds a new parameter to this graph.
- Returns
The new added parameter.
-
AnfNodePtr output() const
Get the output node.
- Returns
The output node, nullptr if output not set.
-
CNodePtr get_return() const
Get the return CNode.
- Returns
The return CNode, nullptr if no return node.
-
void set_output(const AnfNodePtr &value, bool force_new_ret = false)
Set the output node.
- Parameters
value – [in] The output node to be set.
force_new_ret – [in] If true, a new return node is always created.
-
void set_return(const CNodePtr &cnode)
Set the return node.
- Parameters
cnode – [in] The return CNode to be set.
-
CNodePtr NewCNode(const std::vector<AnfNodePtr> &inputs = std::vector<AnfNodePtr>())
Creates a new CNode in this graph.
- Parameters
inputs – [in] The input nodes of the new CNode.
- Returns
The created CNode.
-
CNodePtr NewCNode(const PrimitivePtr &primitive, const std::vector<AnfNodePtr> &prim_inputs)
Creates a new primitive CNode in this graph.
- Parameters
primitive – [in] The primitive of the new CNode.
prim_inputs – [in] The argument inputs of the primitive CNode.
- Returns
The created primitive CNode.
-
std::vector<AnfNodePtr> nodes() const
Get all nodes in this graph.
- Returns
All nodes in this graph.
-
bool has_attr(const std::string &key) const
Check whether an attribute is set for this graph.
- Parameters
key – [in] The attribute key (name).
- Returns
True if the attribute with the given key is set, false otherwise.
-
ValuePtr get_attr(const std::string &key) const
Get an attribute value by its key.
- Parameters
key – [in] The attribute key (name).
- Returns
The attribute value for the given key, nullptr if attribute not found.
-
void set_attr(const std::string &key, const ValuePtr &value)
Set an attribute value.
- Parameters
key – [in] The attribute key (name).
value – [in] The attribute value.
-
FuncGraphManagerPtr manager() const
Get the manager for this graph.
- Returns
The manager of this graph, nullptr if not set.
Public Static Functions
-
static FuncGraphPtr Create()
Creates an empty function graph.
- Returns
The created function graph.
-
static std::vector<AnfNodePtr> TopoSort(const AnfNodePtr &node)
Topological sort a graph from the given end node.
- Parameters
node – [in] The end node of the graph to be sorted.
- Returns
The sorted nodes.
-
std::vector<AnfNodePtr> get_inputs() const