DataFlow API List
DataFlow graphs can be constructed using DataFlow Python APIs for inference. Graph ProcessPoints and UDF ProcessPoints can be defined to describe the data flow relationship between ProcessPoints. IR files of TensorFlow, ONNX, and MindSpore can be imported to define the computation logic of graph ProcessPoints.
DataFlow Graph Construction APIs
API |
Description |
|---|---|
Indicates data nodes in a DataFlow graph. Each FlowData corresponds to an input. |
|
Indicates compute nodes in a DataFlow graph. |
|
Adds a mapping ProcessPoint (PP) to a FlowNode. Currently, only one PP can be added to a FlowNode. After a PP is added, the input and output of the FlowNode are mapped to those of the PP in sequence by default. |
|
Maps inputs to FlowNode, indicating that the node_input_index input of FlowNode is sent to the pp_input_index input of ProcessPoint, all attributes in attr are set for the input of ProcessPoint, and the mapped FlowNode is returned. This function is optional. If it is not called, the inputs of FlowNode and ProcessPoint are mapped in sequence by default. |
|
Maps outputs to FlowNode, indicating that the pp_output_index output of pp is sent to the node_output_index output of FlowNode and then the mapped FlowNode is returned. |
|
Sets the attributes of FlowNode. |
|
Calls FlowNode for computation. |
|
Sets the balance scatter attribute. The UDF with the balance scatter attribute can use balance options to set the load balancing output. |
|
Sets the balance gather attribute. The UDF with the balance gather attribute can use balance options to set the load balancing and affinity output. |
|
Sets the node alias. When option:ge.experiment.data_flow_deploy_info_path is used to specify the node deployment location, the flow_node_list field can be specified using the alias. |
|
Sets flags in the FlowMsg message header. |
|
Defines a DataFlow graph, which consists of the input node FlowData and compute node FlowNode. |
|
Sets whether FlowGraph contains an n_mapping node. |
|
Sets the attribute of input alignment in FlowGraph. |
|
Enables or disables the user exception catch function. |
|
Describes the output of FlowNode. |
|
Sets the framework of the original network model. |
|
Defines the FuncProcessPoint constructor, which returns a FuncProcessPoint object. |
|
Sets the initialization parameters of FuncProcessPoint. |
|
Adds GraphProcessPoint or FlowGraphProcessPoint to be called by FuncProcessPoint, and returns FuncProcessPoint. |
|
Defines the GraphProcessPoint constructor, which returns a GraphProcessPoint object. |
|
Generates a FlowNode based on the current GraphProcessPoint and returns a FlowNode object. |
|
Defines the GraphProcessPoint constructor, which returns a GraphProcessPoint object. |
|
Defines the Tensor constructor. |
|
Converts a tensor into an ndarray of NumPy. |
|
Describes a tensor. |
|
Allocates a dataflow tensor based on the shape, data type, and alignment size. |
|
Generates a template of files required by the "ge.experiment.data_flow_deploy_info_path" option in a specified deployment location based on FlowGraph. |
|
Registers the serialization, deserialization, and size calculation functions corresponding to the user-defined type. This function can be used together with the feed and fetch APIs to feed or fetch any Python type. |
|
Checks whether the message type ID has been registered. |
|
Obtains the registered message type based on the type definition. |
|
Obtains the registered serialization function based on the message type ID. |
|
Obtains the registered deserialization function based on the message type ID. |
|
Obtains the registered function for calculating the size of the serialized memory based on the message type ID. |
|
Deserializes the serialized pickle file to restore Python objects. |
|
Enables functions to be run locally or remotely as pipeline tasks. |
|
Enables classes to be run locally or remotely as pipeline tasks in complex scenarios. |
|
If the UDF is deployed on the host, data needs to be copied from the device to the local host for computation. In PyTorch scenarios, when all computations, inputs, and outputs reside on the device, data still has to be copied from the device to the host during execution, followed by PyTorch transferring the data back to the device, which degrades performance. The npu_model API optimizes this process by eliminating data transfer overhead, allowing computations to be directly offloaded to the device for execution. |
|
CountBatch is used to combine multiple data records into batches based on batchSize, by using UDFs as compute ProcessPoints. This function applies to asynchronous DataFlow scenarios. |
|
The TimeBatch function is based on the UDF. In normal scenarios, a model processes a piece of data each time. To process multiple pieces of data at a time, you need to combine the data into a batch. A basic way is to directly combine the data (N pieces), and add N before the shape. In some scenarios, data of one or more time segments needs to be combined into a batch based on specific dimensions. In this case, you can use TimeBatch. |
DataFlow Execution APIs
API |
Description |
|---|---|
Initializes options in DataFlow. |
|
Indicates the flow information of DataFlow. |
|
Sets user information. |
|
Obtains user information. |
|
Obtains user information. |
|
Obtains the length of user_data. |
|
Reads and sets the start time of FlowInfo in attribute mode. |
|
Reads and sets the end time of FlowInfo in attribute mode. |
|
Reads and sets flow_flags of FlowInfo in attribute mode. |
|
Reads and writes transaction IDs in attribute mode. |
|
Inputs data to a graph. |
|
Inputs data to a graph. A serializable input is supported. |
|
Obtains the graph output data. |
|
Obtains the graph output data. A serializable output is supported. |
|
Frees the DataFlow initialization resources. |
|
Obtains the ID of the device where the current UDF runs during execution. This information is sourced from the UDF deployment location configuration. |
|
Obtains IDs of running instances of the current UDF during execution. This information is sourced from the logic_device_list configuration in the data_flow_deploy_info.json file. |
|
Obtains the number of running instances of the current UDF during execution. The information is sourced from the logic_device_list configuration in data_flow_deploy_info.json. |
Module
dataflow module: namespace of common APIs
Class
- CountBatch: class of the CountBatch attribute
- FlowData: input node class
- FlowFlag: data mark class
- FlowGraph: DataFlow graph class
- FlowInfo: information class carried in the input and output data
- FlowNode: compute node class
- FlowOutput: output class of the compute node
- Framework: enumeration class of the IR file framework type
- FuncProcessPoint: class of the UDF processing point
- GraphProcessPoint: class of the graph processing point
- Tensor: tensor data class
- TensorDesc: tensor description class
- TimeBatch: class of the TimeBatch attribute
Function
- init(...): DataFlow resource initialization method
- finalize(...): DataFlow resource release method
Other Members
Name |
Description |
|---|---|
DT_FLOAT |
Object of df.data_type.DType 32-bit single-precision floating point number |
DT_FLOAT16 |
Object of df.data_type.DType 16-bit half-precision floating point number |
DT_INT8 |
Object of df.data_type.DType 8-bit signed integer |
DT_INT16 |
Object of df.data_type.DType 16-bit signed integer |
DT_UINT16 |
Object of df.data_type.DType 16-bit unsigned integer |
DT_UINT8 |
Object of df.data_type.DType 8-bit unsigned integer |
DT_INT32 |
Object of df.data_type.DType 32-bit signed integer |
DT_INT64 |
Object of df.data_type.DType 64-bit signed integer |
DT_UINT32 |
Object of df.data_type.DType 32-bit unsigned integer |
DT_UINT64 |
Object of df.data_type.DType 64-bit unsigned integer |
DT_BOOL |
Object of df.data_type.DType Boolean |
DT_DOUBLE |
Object of df.data_type.DType 64-bit double-precision floating point number |
DT_STRING |
Object of df.data_type.DType String |