Set graph configuration to the IpuStrategy instance. Args: num_ipus (int, optional): Number of IPU devices. Default 1, which means only use 1 IPU. is_training (bool, optional): True is training graph, False is inference graph. Default True, which means is tr
(
self,
num_ipus: int = 1,
is_training: bool = True,
micro_batch_size: int = 1,
enable_manual_shard: bool = False,
)
| 746 | return optimizer_attrs |
| 747 | |
| 748 | def set_graph_config( |
| 749 | self, |
| 750 | num_ipus: int = 1, |
| 751 | is_training: bool = True, |
| 752 | micro_batch_size: int = 1, |
| 753 | enable_manual_shard: bool = False, |
| 754 | ) -> None: |
| 755 | """ |
| 756 | Set graph configuration to the IpuStrategy instance. |
| 757 | |
| 758 | Args: |
| 759 | num_ipus (int, optional): Number of IPU devices. Default 1, which means only use 1 IPU. |
| 760 | is_training (bool, optional): True is training graph, False is inference graph. Default True, which means is training mode. |
| 761 | batch_size (int, optional): The batch-size in the graph. Used to make the graph batch-size fixed, |
| 762 | if the batch-size in the graph is dynamic. Default 1, which means the batch-size would be set 1, if the batch-size is dynamic. |
| 763 | enable_manual_shard (bool, optional): Enable graph sharding or not. Only if num_ipus > 1, enable_manual_shard is able to be set True. |
| 764 | Default False, which means disabled. |
| 765 | |
| 766 | Returns: |
| 767 | None. |
| 768 | |
| 769 | Examples: |
| 770 | .. code-block:: pycon |
| 771 | |
| 772 | >>> # doctest: +REQUIRES(env:IPU) |
| 773 | |
| 774 | >>> import paddle |
| 775 | >>> import paddle.static as static |
| 776 | |
| 777 | >>> paddle.enable_static() |
| 778 | |
| 779 | >>> ipu_strategy = static.IpuStrategy() |
| 780 | >>> ipu_strategy.set_graph_config( |
| 781 | ... num_ipus=1, |
| 782 | ... is_training=True, |
| 783 | ... micro_batch_size=1, |
| 784 | ... enable_manual_shard=False, |
| 785 | ... ) |
| 786 | """ |
| 787 | if num_ipus == 1 and enable_manual_shard: |
| 788 | raise RuntimeError( |
| 789 | "Only if num_ipus > 1, enable_manual_shard is able to be set True." |
| 790 | ) |
| 791 | options = { |
| 792 | 'num_ipus': num_ipus, |
| 793 | 'is_training': is_training, |
| 794 | 'micro_batch_size': micro_batch_size, |
| 795 | 'enable_manual_shard': enable_manual_shard, |
| 796 | } |
| 797 | self.set_options(options) |
| 798 | |
| 799 | def set_pipelining_config( |
| 800 | self, |