Datasets:
Download code/reference/3_broadcast.py from willychan21/ParallelKernelBench_Problems: direct link, hf CLI and curl.
- Browser
- Download file 204 Bytes
-
https://huggingface.co/datasets/willychan21/ParallelKernelBench_Problems/resolve/ce3929f17c8636275953e59f870575de9265bf36/code/reference/3_broadcast.py
- Command line
-
hf download hf://datasets/willychan21/ParallelKernelBench_Problems@ce3929f17c8636275953e59f870575de9265bf36/code/reference/3_broadcast.py
-
curl -L -o 3_broadcast.py https://huggingface.co/datasets/willychan21/ParallelKernelBench_Problems/resolve/ce3929f17c8636275953e59f870575de9265bf36/code/reference/3_broadcast.py
204 Bytes
| import torch | |
| import torch.distributed as dist | |
| def solution(tensor: torch.Tensor, src: int = 0) -> torch.Tensor: | |
| out = tensor.clone() | |
| dist.broadcast(out, src=src) | |
| return out | |