send

Description

Sends data to a rank within a collective communication group.

Prototype

def send(tensor, sr_tag, dest_rank, group = "hccl_world_group")

Parameters

Parameter

Input/Output

Description

tensor

Input

TensorFlow tensor type.

Atlas Training Series Product: The supported data types are int8, uint8, int16, uint16, int32, uint32, int64, uint64, float16, float32, and float64.

sr_tag

Input

An int.

Message tag. The send/recv pairs with the same sr_tag can receive and send data.

dest_rank

Input

An int.

Target node of 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

None

Constraints

  • The caller rank must be within the range defined by the group argument passed to this API call. Otherwise, the API call fails.
  • To perform point-to-point data sending and receiving between ranks from different AI servers, the sending and receiving ranks must 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

Atlas Training Series Product

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
dest_rank = 1
result = hccl_ops.send(tensor, sr_tag, dest_rank)