Class Primitive
Defined in File primitive.h
Inheritance Relationships
Base Type
public mindspore::api::Value
(Class Value)
Derived Type
public mindspore::ops::BaseOperator
(Class BaseOperator)
Class Documentation
-
class Primitive : public mindspore::api::Value
Primitive defines a primitive operator.
Subclassed by mindspore::ops::BaseOperator
Public Functions
-
explicit Primitive(const std::string &name)
Create primitive with the given name.
- Parameters
name – [in] The primitive name.
-
const std::string &name() const
Get name of the primitive.
- Returns
The name of primitive.
-
Primitive &AddAttr(const std::string &name, const ValuePtr &attr)
Add attribute to primitive.
- Parameters
name – [in] The attribute name.
attr – [in] The attribute value.
- Returns
The primitive to which attribute has been added.
-
Primitive &SetAttrs(const std::unordered_map<std::string, ValuePtr> &attrs)
Add attributes by using a map, all elements of the map will be added to this primitive.
- Parameters
attrs – [in] The attribute map needs to be added in the primitive attribute.
- Returns
The primitive to which attribute has been added.
-
void EraseAttr(const std::string &name)
Erase attribute to the primitive attribute map.
- Parameters
name – [in] The attribute name.
-
ValuePtr GetAttr(const std::string &name) const
Get attribute value by name.
- Parameters
name – [in] the attribute name.
- Returns
The value of the attribute, null if attribute name not found.
-
bool HasAttr(const std::string &name) const
Check If Primitive has an attribute with then given name.
- Parameters
name – [in] The attribute name.
- Returns
True if there is an attribute with the given name, otherwise false.
-
std::unordered_map<std::string, ValuePtr> attrs() const
Get all attributes of this primitive as a map.
- Returns
The attribute map of this primitive.
-
explicit Primitive(const std::string &name)