FlowOperator

FlowOperator is the node base class of FlowGraph. It has two derivative classes: FlowData and FlowNode.

FlowData

FlowData is an input node of FlowGraph. It defines the name and index of an input node. For details, see Class FlowData.

FlowNode

FlowNode is a compute node of FlowGraph. It defines the name as well as the number of inputs and outputs of a compute node. The actual compute logic of FlowNode is determined by ProcessPoints added by the AddPp method, which can be FunctionPp or GraphPp. For details, see Class FlowNode.

  • GraphPp
    The main function prototype of GraphPp is as follows:
    1
    2
    GraphPp(const char *pp_name, const GraphBuilder &builder) // GraphPp constructor.
    GraphPp &SetCompileConfig(const char *json_file) // Set the path and name of the JSON configuration file of GraphPp, which are used for mapping between GraphPp and AscendGraph.
    
    The following uses the Add function as an example to describe how to construct a GraphPp. In the example, the Add function has two inputs: data0 and data1. The mapping between GraphPp and AscendGraph is transferred through BuildGraph in the constructor of GraphPp. The add_graph_config.json file is used to configure the compilation information of AscendGraph.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    ge::Graph BuildGraph()
    {
        auto data0 = op::Data("data0").set_attr_index(0);
        auto data1 = op::Data("data1").set_attr_index(1);
        auto add = op::Add("add").set_input_x1(data0).set_input_x2(data1);
        ge::Graph graph("Graph");
        graph.SetInputs({data0, data1}).SetOutputs({add});
        return graph;
    }
    auto graph_pp = dflow::GraphPp("graph_pp", BuildGraph)
                    .SetCompileConfig("add_graph_config.json");
    
  • FunctionPp
    The main function prototype of FunctionPp is as follows:
    1
    2
    3
    FunctionPp(const char_t *pp_name) // FunctionPp constructor.
    FunctionPp &SetCompileConfig(const char *json_file)  // Used for mapping between FunctionPp and UDF. The UDF compilation information is configured in json_file.
    FunctionPp &SetInitParam(const char *attr_name, const ge::DataType &value) // Set initialization parameters of FunctionPp.
    
    The following uses the Add function as an example to describe how to construct a FunctionPp. In the example, the name of FunctionPp is func_pp, whose function is implemented through UDF. The mapping between FunctionPp and UDF is implemented in add_func_config.json.

    The UDF can be implemented using C++ or Python. For details about implementation using C++, see UDF Development. For details about implementation using Python, see ""UDF Development Process"" in the DataFlow Development Guide (Python).

    1
    2
    3
    auto function_pp = dflow::FunctionPp("func_pp")
                       .SetCompileConfig("add_func_config.json")
                       .SetInitParam("out_type", ge::DT_UINT32);