BuildAndReset
Applicability
Product |
Supported or Not |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
Function Usage
Builds a computational graph.
Prototype
- Build a computational graph.
1std::unique_ptr<Graph> BuildAndReset() const
- Build a computational graph based on the output tensor list.
1std::unique_ptr<Graph> BuildAndReset(const std::vector<EsTensorHolder> &outputs)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
outputs |
Input |
Tensor holder vector output. |
Returns
Parameter |
Type |
Description |
|---|---|---|
- |
std::unique_ptr<Graph> |
Smart pointer to the built graph. If the operation fails, nullptr is returned. After the API is called, the graph builder is no longer available. |
Constraints
None
Examples
- Build a computational graph.
1 2 3 4 5 6 7 8 9 10
//1. Create a graph builder (EsGraphBuilder). EsGraphBuilder builder("graph_name"); // 2. Add two input nodes. EsTensorHolder [data0, data1] = builder.CreateInputs<2>(); // 3. Add an intermediate node. In C++, common operators such as addition, subtraction, multiplication, and division have been overloaded for direct use. EsTensorHolder add = data0 + data1; // 4. Set the graph output. builder.SetOutput(add, 0); // 5. Build a graph and obtain the built graph object. The resources in the builder are destroyed along with the destructor. std::unique_ptr<ge::Graph> graph = builder.BuildAndReset();
- Build a computational graph based on the output tensor list.
1 2 3 4 5 6 7 8
//1. Create a graph builder (EsGraphBuilder). EsGraphBuilder builder("graph_name"); // 2. Add two input nodes. EsTensorHolder [data0, data1] = builder.CreateInputs<2>(); // 3. Add an intermediate node. In C++, common operators such as addition, subtraction, multiplication, and division have been overloaded for direct use. // 4. Set the graph output. // 5. Build a graph and obtain the built graph object. The resources in the builder are destroyed along with the destructor. std::unique_ptr<ge::Graph> graph = builder.BuildAndReset({data0 + data1}); // Complete steps 3, 4, and 5 in one line.
Parent topic: EsGraphBuilder