torchfix icon indicating copy to clipboard operation
torchfix copied to clipboard

New rule: use `dtype` instead of converting after creation

Open kit1980 opened this issue 8 months ago • 0 comments

For many ops dtype parameter can be provided, and it should be preferred (from readability and performance point of views) to use it instead of converting the op results to a different type.

For example, torch.arange(1, N).float() should be changed to torch.arange(1, N, dtype=torch.float32)

cc @malfet

kit1980 avatar Jun 03 '24 19:06 kit1980