receive
Description
Receives data from a rank within a collective communication group.
Prototype
def receive(shape, data_type, sr_tag, src_rank, group = "hccl_world_group")
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
shape |
Input |
Shape of the received tensor. |
data_type |
Input |
Data type of the received data. |
sr_tag |
Input |
An int. Message tag. The send/recv pairs with the same sr_tag can receive and send data. |
src_rank |
Input |
An int. Source node of the received data. rank indicates the rank ID in the group. |
group |
Input |
A string containing a maximum of 128 bytes, including the end character. Group name, which can be a user-defined value or hccl_world_group. |
Returns
The result tensor
Constraints
- The caller rank must be within the range defined by the group argument passed to this API call. Otherwise, the API call fails.
- Ranks for point-to-point data sending and receiving must belong to different servers but have the same physical ID of the Ascend AI Processor.
- The sending and receiving functions must be used in pairs and depend on other operators in the graph.
Applicability
Example
The following is only a code snippet and cannot be executed. For details about how to call the HCCL Python APIs to perform collective communication, see Sample Code.
1 2 3 4 5 | from npu_bridge.npu_init import * tensor = tf.random_uniform((1, 3), minval=1, maxval=10, dtype=tf.float32) sr_tag = 0 src_rank = 0 tensor = hccl_ops.receive(tensor.shape, tensor.dtype, sr_tag, src_rank) |