Datasets:
Download reference/3_broadcast.py from togethercomputer/ParallelKernelBench_Problems: direct link, hf CLI and curl.
- Browser
- Download file 204 Bytes
-
https://huggingface.co/datasets/togethercomputer/ParallelKernelBench_Problems/resolve/870e72514a702514424fd3a3314cb57df25da0be/reference/3_broadcast.py
- Command line
-
hf download hf://datasets/togethercomputer/ParallelKernelBench_Problems@870e72514a702514424fd3a3314cb57df25da0be/reference/3_broadcast.py
-
curl -L -o 3_broadcast.py https://huggingface.co/datasets/togethercomputer/ParallelKernelBench_Problems/resolve/870e72514a702514424fd3a3314cb57df25da0be/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 | |