Class NodeDefBuilder

NodeDef is a protocol buffer used to construct the name, type, inputs, and outputs of the node for the framework UT or ST.

This class provides APIs for the construction of NodeDef, adding the inputs, outputs, and attributes of NodeDef. Developers do not directly call the following APIs.

Table 1 Member functions of NodeDefBuilder class

API

Description

static std::shared_ptr<NodeDef> CreateNodeDef();

Creates NodeDef of an operator and returns the pointer to NodeDef.

NodeDefBuilder(NodeDef *nodeDef, std::string name, std::string opName);

Constructs NodeDef with the input parameters nodeDef, name, and opName. Returns the object of NodeDefBuilder class.

NodeDefBuilder& Input(const InputOutputNode& input);

Adds an input tensor to NodeDef. Constructs NodeDef based on the shape, type, and format of the node, which are provided by InputOutputNode.

NodeDefBuilder& Output(const InputOutputNode& output);

Adds an output tensor to NodeDef. Constructs NodeDef based on the shape, type, and format of the node, which are provided by InputOutputNode.

NodeDefBuilder& Attr(std::string name, int32_t value);

Adds an attribute (int32) to NodeDef.

NodeDefBuilder& Attr(std::string name, int64_t value);

Adds an attribute (int64) to NodeDef.

NodeDefBuilder& Attr(std::string name, float value);

Adds an attribute (float) to NodeDef.

NodeDefBuilder& Attr(std::string name, double value);

Adds an attribute (double) to NodeDef.

NodeDefBuilder& Attr(std::string name, bool value);

Adds an attribute (bool) to NodeDef.

NodeDefBuilder& Attr(std::string name, aicpu::DataType value);

Adds an attribute (aicpu::DataType) to NodeDef.

NodeDefBuilder& Attr(std::string name, const std::vector<bool> &value);

Adds an attribute (std::vector<bool>) to NodeDef.

NodeDefBuilder& Attr(std::string name, const std::string &value);

Adds an attribute (std::string) to NodeDef.

NodeDefBuilder& Attr(std::string name, const std::vector<std::string> &value);

Adds an attribute (std::vector<std::string>) to NodeDef.

NodeDefBuilder& Attr(std::string name, const std::vector<int64_t> &value);

Adds an attribute (std::vector<int64_t>) to NodeDef.

NodeDefBuilder& Attr(std::string name, const std::vector<float> &value);

Adds an attribute (std::vector<float>) to NodeDef.

NodeDefBuilder& Attr(std::string name, const std::vector<aicpu::DataType> &value);

Adds an attribute (std::vector<aicpu::DataType>) to NodeDef.

NodeDefBuilder& Attr(std::string name, const std::vector<int64_t> &shape, std::string type);

Adds an attribute (std::vector<int64_t>) to NodeDef. The input parameter type needs to be set to shape.

NodeDefBuilder& Attr(std::string name, const std::vector<std::vector<int64_t>> &shapeLists, std::string type);

Adds an attribute (std::vector<std::vector<int64_t>>) to NodeDef. The input parameter type needs to be set to shape_list.

NodeDefBuilder& Attr(std::string name, aicpu::Tensor *tensor);

Adds an attribute (aicpu::Tensor) to NodeDef.

NodeDefBuilder& Attr(std::string name, std::vector<aicpu::Tensor *> &tensors);

Adds an attribute (std::vector<aicpu::Tensor *>) to NodeDef.