Open resuly opened 3 years ago
torch.floor_divide() is deprecated and will be removed in a future PyTorch release. Its name is a misnomer because it actually rounds the quotient towards zero instead of taking its floor. To keep the current behavior use torch.div() with rounding_mode='trunc'. To actually perform floor division, use torch.div() with rounding_mode='floor'.
@resuly @yueshengbin Hello, has your problem been solved? I have the same problem: /opt/conda/lib/python3.7/site-packages/thop/vision/basic_hooks.py:92: UserWarning: floordiv is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor'). kernel = torch.DoubleTensor([*(x[0].shape[2:])]) // torch.DoubleTensor(list((m.output_size,))).squeeze()
@resuly @yueshengbin Hello, has your problem been solved? I have the same problem: /opt/conda/lib/python3.7/site-packages/thop/vision/basic_hooks.py:92: UserWarning: floordiv is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor'). kernel = torch.DoubleTensor([*(x[0].shape[2:])]) // torch.DoubleTensor(list((m.output_size,))).squeeze()
you can use:
kernel = torch.div(torch.DoubleTensor([*(x[0].shape[2:])]) , torch.DoubleTensor(list((m.output_size,))).squeeze(), rounding_mode="floor")
this is equals to // in python.
Got this warning with PyTorch 1.9.0+:
https://github.com/NVIDIA/MinkowskiEngine/blob/bb362c7a037afffdc9682264acd966d234ea1ef6/MinkowskiEngine/MinkowskiSparseTensor.py#L537
There are many similar codes that could lead to this issue.