mindspore/docs/api/api_python/mindspore.parallel.rst

62 lines
3.3 KiB
ReStructuredText
Raw Normal View History

2022-02-15 19:11:35 +08:00
mindspore.parallel
============================
并行相关功能的接口。
2022-04-27 16:45:26 +08:00
.. py:function:: mindspore.parallel.set_algo_parameters(**kwargs)
2022-02-15 19:11:35 +08:00
2022-03-08 17:17:53 +08:00
设置并行策略搜索算法中的参数。有关典型用法请参见mindspore/tests/ut/python/parallel/test_auto_parallel_resnet.py。
2022-02-15 19:11:35 +08:00
.. note::
2022-02-15 19:11:35 +08:00
属性名称为必填项。此接口仅在AUTO_PARALLEL模式下工作。
**参数:**
2022-03-08 17:17:53 +08:00
- **fully_use_devices** (bool) - 表示是否仅搜索充分利用所有可用设备的策略。默认值True。例如如果有8个可用设备当该参数设为true时策略(4, 1)将不包括在ReLU的候选策略中因为策略(4, 1)仅使用4个设备。
2022-03-29 22:00:57 +08:00
- **elementwise_op_strategy_follow** (bool) - 表示elementwise算子是否具有与后续算子一样的策略。默认值False。例如Add的输出给了ReLU其中ReLU是elementwise算子。如果该参数设置为true则算法搜索的策略可以保证这两个算子的策略是一致的例如ReLU的策略(8, 1)和Add的策略((8, 1), (8, 1))。
2022-03-08 17:17:53 +08:00
- **enable_algo_approxi** (bool) - 表示是否在算法中启用近似。默认值False。由于大型DNN模型的并行搜索策略有较大的解空间该算法在这种情况下耗时较长。为了缓解这种情况如果该参数设置为true则会进行近似丢弃一些候选策略以便缩小解空间。
- **algo_approxi_epsilon** (float) - 表示近似算法中使用的epsilon值。默认值0.1 此值描述了近似程度。例如一个算子的候选策略数量为S如果 `enable_algo_approxi` 为true则剩余策略的大小为min{S, 1/epsilon}。
- **tensor_slice_align_enable** (bool) - 表示是否检查MatMul的tensor切片的shape。默认值False 受某些硬件的属性限制只有shape较大的MatMul内核才能显示出优势。如果该参数为true则检查MatMul的切片shape以阻断不规则的shape。
- **tensor_slice_align_size** (int) - 表示MatMul的最小tensor切片的shape该值必须在[1,1024]范围内。默认值16。 如果 `tensor_slice_align_enable` 设为true则MatMul tensor的最后维度的切片大小应该是该值的倍数。
2022-02-15 19:11:35 +08:00
**异常:**
2022-03-08 17:17:53 +08:00
- **ValueError** - 无法识别传入的关键字。
2022-02-15 19:11:35 +08:00
2022-04-27 16:45:26 +08:00
.. py:function:: mindspore.parallel.reset_algo_parameters()
2022-02-15 19:11:35 +08:00
重置算法参数属性。
.. note::
2022-02-15 19:11:35 +08:00
此接口仅在AUTO_PARALLEL模式下工作。
重置后,属性值为:
2022-02-25 10:40:32 +08:00
- fully_use_devicesTrue
- elementwise_op_strategy_followFalse
- enable_algo_approxiFalse
- algo_approxi_epsilon0.1
- tensor_slice_align_enableFalse
- tensor_slice_align_size16
2022-02-15 19:11:35 +08:00
2022-04-27 16:45:26 +08:00
.. py:function:: mindspore.parallel.get_algo_parameters(attr_key)
2022-03-08 17:17:53 +08:00
获取算法参数配置属性。
2022-02-15 19:11:35 +08:00
.. note::
2022-02-15 19:11:35 +08:00
属性名称为必填项。此接口仅在AUTO_PARALLEL模式下工作。
**参数:**
2022-03-08 17:17:53 +08:00
- **attr_key** (str) - 属性的key。key包括"fully_use_devices"、"elementwise_op_strategy_follow"、"enable_algo_approxi"、"algo_approxi_epsilon"、"tensor_slice_align_enable”和"tensor_slice_align_size"。
**返回:**
根据key返回属性值。
2022-02-15 19:11:35 +08:00
**异常:**
2022-03-29 22:00:57 +08:00
- **ValueError** - 无法识别传入的关键字。