Class CNode
Defined in File anf.h
Inheritance Relationships
Base Types
public mindspore::AnfNode
(Class AnfNode)public mindspore::EffectInfoHolder
Class Documentation
-
class CNode : public mindspore::AnfNode, public mindspore::EffectInfoHolder
Public Functions
-
CNode(std::vector<AnfNodePtr> &&inputs, const FuncGraphPtr &func_graph)
Constructor.
- Parameters
inputs – [in] Input nodes of this Cnode.
func_graph – [in] The FuncGraph to which this CNode belongs.
-
CNode(const std::vector<AnfNodePtr> &inputs, const FuncGraphPtr &func_graph)
Constructor.
- Parameters
inputs – [in] Input nodes of this Cnode.
func_graph – [in] The FuncGraph to which this CNode belongs.
-
inline CNode(const std::vector<AnfNodePtr> &inputs, const VarPtr &func_graph_as_var)
Constructor.
- Parameters
inputs – [in] Input nodes of this Cnode.
func_graph_as_var – [in] The FuncGraph of type VarPtr to which this CNode belongs,
-
CNode(std::vector<AnfNodePtr> &&inputs, const FuncGraphPtr &func_graph, NodeDebugInfoPtr &&debug_info)
Constructor.
- Parameters
inputs – [in] Input nodes of this Cnode.
func_graph – [in] The FuncGraph to which this CNode belongs.
debug_info – [in] The debug info to be used for this CNode.
-
~CNode() override = default
Destructor.
-
bool IsApply(const PrimitivePtr&) const
Check whether this cnode has the same primitive value as the first input.
- Returns
True if they have the same primitive value, otherwise false.
-
inline const size_t size() const
Obtain the size of input nodes of this CNode.
- Returns
Size of input nodes.
-
const AnfNodePtr &input(size_t i) const
Get the input node of the given index.
- Parameters
i – [in] The given index.
- Returns
The input node of the given index.
-
inline const std::vector<AnfNodePtr> &inputs() const
Get the input nodes.
- Returns
The input nodes of this CNode.
-
void add_input(const AnfNodePtr &input)
Add the input node to this CNode.
- Parameters
input – [in] Node.
-
void set_input(size_t i, const AnfNodePtr &input)
Set the input node of the given index.
- Parameters
i – [in] The given index.
input – [in] Node.
-
void set_inputs(const std::vector<AnfNodePtr> &inputs)
Set the input nodes for this CNode.
- Parameters
inputs – [in] Input nodes.
-
inline void add_input_value(const ValuePtr &input_value, const std::string &id)
Record the cnode input value and id to inputs_value_.
- Parameters
input_value – [in] Input value.
id – [in] The id.
-
inline void clear_inputs_value()
Clear the record of cnode input value in inputs_value_.
-
inline void set_inputs_value(const std::vector<std::pair<ValuePtr, std::string>> &values)
Set the record of cnode input value.
- Parameters
values – [in] New record.
-
inline const std::vector<std::pair<ValuePtr, std::string>> &inputs_value() const
Get the record of input value of this CNode.
- Returns
The input values of this CNode.
-
inline void set_forward(const ValueNodePtr &forward, const std::string &id)
Record the cnode value and id to output_value_.
- Parameters
forward – [in] The cnode value.
id – [in] The id.
-
inline const std::pair<ValueNodePtr, std::string> &forward() const
Get the record of output value of this CNode.
- Returns
The output value of this CNode.
-
inline bool stop_gradient() const
Check if stop_gradient is set.
- Returns
True if stop_gradient is set, otherwise false.
-
inline void set_stop_gradient(bool stop_gradient)
Set stop_gradient.
- Parameters
stop_gradient – [in] Boolean.
-
inline void set_fullname_with_scope(const std::string full_name)
Set fullname_with_scope for this CNode.
- Parameters
full_name – [in] The fullname_with_scope.
-
inline void set_in_forward_flag(bool flag)
Set in_forward_flag for this CNode.
- Parameters
flag – [in] Boolean.
-
inline bool in_forward_flag() const
Check if in_forward_flag is set.
- Returns
True if in_forward_flag is set, otherwise false.
-
inline void set_load_flag(bool is_load)
Check if the primitive of this CNode is load.
- Parameters
is_load – [in] Boolean.
-
inline bool get_load_flag() const
Check if is_load_ is set.
- Returns
True if is_load_ is set, otherwise false.
-
inline VarPtr func_graph_as_var() const
Get func_graph_as_var of this CNode.
- Returns
func_graph_as_var.
-
inline const mindspore::HashMap<std::string, ValuePtr> &attrs() const
Get all attributes of this CNode.
- Returns
Attributes of this CNode.
-
inline void AddAttr(const std::string &name, const ValuePtr &attr)
Add a new attribute to this CNode.
- Parameters
name – [in] The name of the new attribute.
attr – [in] The value of the new attribute.
-
inline void EraseAttr(const std::string &name)
Erase the attribute with the given name.
- Parameters
name – [in] The name of attribute.
-
inline ValuePtr GetAttr(const std::string &name) const
Get the attribute with the given name.
- Parameters
name – [in] The name of attribute.
- Returns
Attribute.
-
inline bool HasAttr(const std::string &name) const
Check whether this CNode has an attribute with the given name.
- Parameters
name – [in] The name of attribute.
- Returns
Boolean.
-
inline ssize_t input_tensor_num() const
Get the number of input tensors.
- Returns
The number of input tensors.
-
inline const mindspore::HashMap<std::string, ValuePtr> &primal_attrs() const
Get the primal attributes of this CNode.
- Returns
The primal attributes.
-
inline void set_primal_attrs(const mindspore::HashMap<std::string, ValuePtr> &attrs)
Set the primal attributes of this CNode.
- Parameters
attrs – [in] The primal attributes.
-
inline void AddPrimalAttr(const std::string &name, const ValuePtr &attr)
Add the primal attribute to this CNode.
- Parameters
name – [in] The name of the attribute.
attr – [in] The attribute.
-
inline void ErasePrimalAttr(const std::string &name)
Erase the primal attribute with the given name.
- Parameters
name – [in] The name of the attribute.
-
inline ValuePtr GetPrimalAttr(const std::string &name) const
Get the primal attribute with the given name.
- Parameters
name – [in] The name of the attribute.
- Returns
The primal attribute with the given name.
-
inline bool HasPrimalAttr(const std::string &name) const
Check whether this CNode has an attribute with the given name.
- Parameters
name – [in] The name of the attribute.
- Returns
True if it exists, otherwise false.
-
NodeDebugInfoSet primal_debug_infos() const
Get primal debug information.
- Returns
The primal debug information.
-
void set_primal_debug_infos(const NodeDebugInfoSet &debug_infos)
Set primal debug information.
- Parameters
debug_infos – [in] Debug information of this CNode.
-
void AddPrimalDebugInfo(const NodeDebugInfoPtr &debug_info)
Add a primal debug information.
- Parameters
debug_info – [in] A debug information.
-
inline void set_input_tensor_num(ssize_t input_tensor_num)
Set the number of input tensors.
- Parameters
The – [in] number of input tensors.
-
inline bool IsEffectHandled() const
Is effect have been handled.
- Returns
True if effect have been handled, otherwise false.
-
inline void SetEffectHandled(bool handled)
Set effect handled or not.
- Parameters
handled – [in] Boolean.
-
inline NodeDebugInfoSet fused_debug_infos() const
Get the debug infos of fused nodes.
- Returns
A vector of debug infos.
-
inline void set_fused_debug_infos(const NodeDebugInfoSet &fused_debug_infos)
Set the debug infos for CNode.
- Parameters
fused_debug_infos – The debug infos to be set.
-
void AddFusedDebugInfo(const AnfNodePtr &node)
Add a node’s debug info or fused debug info.
- Parameters
node – An anf node.
-
void AddFusedDebugInfoList(const std::vector<AnfNodePtr> &nodes)
Add a vector of nodes’ debug info or fused debug info.
- Parameters
nodes – A vector of anf nodes.
-
void AddFusedDebugInfo(const NodeDebugInfoPtr &debug_info)
Add a node debug info.
- Parameters
node – A node debug info of an anf node.
-
void AddFusedDebugInfoList(const std::vector<NodeDebugInfoPtr> &debug_infos)
Add a list of node debug infos.
- Parameters
node – A node debug info of an anf node.
-
CNode(std::vector<AnfNodePtr> &&inputs, const FuncGraphPtr &func_graph)