set_split_factor#

ivy.set_split_factor(factor, /, *, device=None)[source]#

Set the global split factor for a given device, which can be used to scale batch splitting chunk sizes for the device across the codebase.

Parameters:
  • factor (float) – The factor to set the device-specific split factor to.

  • device (Optional[Union[Device, NativeDevice]], default: None) – The device to set the split factor for. Sets the default device by default.

Return type:

None

Examples

>>> print(ivy.default_device())
cpu
>>> ivy.set_split_factor(0.5)
>>> print(ivy.split_factors)
{'cpu': 0.5}
>>> import torch
>>> ivy.set_backend("torch")
>>> device = torch.device("cuda")
>>> ivy.set_split_factor(0.3, device=device)
>>> print(ivy.split_factors)
{device(type='cuda'): 0.3}
>>> ivy.set_split_factor(0.4, device="tpu")
>>> print(ivy.split_factors)
{'tpu': 0.4}
>>> import torch
>>> ivy.set_backend("torch")
>>> device = torch.device("cuda")
>>> ivy.set_split_factor(0.2)
>>> ivy.set_split_factor(0.3, device='gpu')
>>> print(ivy.split_factors)
{'cpu': 0.2, 'gpu': 0.3}