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/aa1bb86f2c59256de88c97e6d1447957e673607e/code/reference/3_broadcast.py
- Command line
-
hf download hf://datasets/willychan21/ParallelKernelBench_Problems@aa1bb86f2c59256de88c97e6d1447957e673607e/code/reference/3_broadcast.py
-
curl -L -o 3_broadcast.py https://huggingface.co/datasets/willychan21/ParallelKernelBench_Problems/resolve/aa1bb86f2c59256de88c97e6d1447957e673607e/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 | |