mindspore.ops.communication.send_object_list
- mindspore.ops.communication.send_object_list(object_list, dst, group=None, device=None)[source]
Send picklable objects to dst synchronously.
Note
Only support PyNative mode, Graph mode is not currently supported.
Similar to
mindspore.ops.communication.send(), but Python objects can be passed in.
Warning
This interface will implicitly use the pickle module, which is not secure. The core reason is that deserialization can execute arbitrary code, and attackers can trigger system command execution by constructing malicious objects. Therefore, the caller must ensure the security of the data used by the interface on their own.
- Parameters
object_list (list[Any]) – List of input objects to sent. Each object must be picklable. Receiver must provide lists of equal sizes.
dst (int) – Destination global rank to send object_list to.
group (str, optional) – The process group to work on. Default:
None, which means"hccl_world_group"in Ascend.device (str, optional) – Currently it is a reserved parameter. Default:
None.
- Raises
TypeError – If dst is not of type int, group is not of type str, or object_ist is not of type list.
ValueError – If the dst process rank id is same as the current process.
- Supported Platforms:
Ascend
Examples
Note
Before running the following examples, you need to configure the communication environment variables.
For Ascend devices, it is recommended to use the msrun startup method without any third-party or configuration file dependencies. Please see the msrun startup for more details.
This example should be run with 2 devices.
>>> from mindspore.ops.communication import init_process_group, send_object_list, recv_object_list, get_rank >>> init_process_group() >>> this_rank = get_rank() >>> if this_rank == 0: ... objects = ["foo", 12, {1: 2}] # any picklable object ... send_object_list(objects, dst=1) >>> else: ... objects = [None, None, None] ... recv_object_list(objects, src=0) ... print(objects) ['foo', 12, {1: 2}]