torchfix icon indicating copy to clipboard operation
torchfix copied to clipboard

Use torch.*_like()

Open adsharma opened this issue 7 months ago • 2 comments

b = torch.zeros_like(a)

should be preferred over

b = torch.zeros(...).to(a)

to avoid copies.

adsharma avatar Jul 11 '24 20:07 adsharma