Class FuncGraph

Inheritance Relationships

Base Type

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.

返回

Input parameters of this graph.

std::vector<AnfNodePtr> parameters() const

Get all parameters.

返回

All parameters of this graph.

void add_parameter(const ParameterPtr &p)

Adds a parameter to this graph.

参数

p[in] The parameter to be added.

ParameterPtr add_parameter()

Adds a new parameter to this graph.

返回

The new added parameter.

AnfNodePtr output() const

Get the output node.

返回

The output node, nullptr if output not set.

CNodePtr get_return() const

Get the return CNode.

返回

The return CNode, nullptr if no return node.

void set_output(const AnfNodePtr &value, bool force_new_ret = false)

Set the output node.

参数
  • 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.

参数

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.

参数

inputs[in] The input nodes of the new CNode.

返回

The created CNode.

CNodePtr NewCNode(const PrimitivePtr &primitive, const std::vector<AnfNodePtr> &prim_inputs)

Creates a new primitive CNode in this graph.

参数
  • primitive[in] The primitive of the new CNode.

  • prim_inputs[in] The argument inputs of the primitive CNode.

返回

The created primitive CNode.

std::vector<AnfNodePtr> nodes() const

Get all nodes in this graph.

返回

All nodes in this graph.

bool has_attr(const std::string &key) const

Check whether an attribute is set for this graph.

参数

key[in] The attribute key (name).

返回

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.

参数

key[in] The attribute key (name).

返回

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.

参数
  • key[in] The attribute key (name).

  • value[in] The attribute value.

FuncGraphManagerPtr manager() const

Get the manager for this graph.

返回

The manager of this graph, nullptr if not set.

Public Static Functions

static FuncGraphPtr Create()

Creates an empty function graph.

返回

The created function graph.

static std::vector<AnfNodePtr> TopoSort(const AnfNodePtr &node)

Topological sort a graph from the given end node.

参数

node[in] The end node of the graph to be sorted.

返回

The sorted nodes.