pytorch
95489b59 - Throws runtime error when performing integer division using torch.div (#38620)

Commit
4 years ago
Throws runtime error when performing integer division using torch.div (#38620) Summary: **1.6 Deprecation Note** In PyTorch 1.6 attempting to divide two integer tensors or an integer tensor and an integer scalar will throw a runtime error. This behavior was deprecated with a warning in PyTorch 1.5. In PyTorch 1.7 torch.div and the division operator will always perform true division like Python3 and NumPy. To divide integer values use either torch.true_divide, for true division, or torch.floor_divide (the // operator) for floor division. **PR Summary** This PR updates the warning message when performing integer division to be a runtime error. Because some serialized Torchscript programs may rely on torch.div's historic behavior it also implements a "versioned symbol" for div that lets those models retain their current behavior. Extensive tests of this behavior are the majority of this PR. Note this change bumps the produced file format version to delineate which programs should have their historic div behavior preserved. Pull Request resolved: https://github.com/pytorch/pytorch/pull/38620 Differential Revision: D21612598 Pulled By: mruberry fbshipit-source-id: c9c33591abce2f7e97f67f0f859901f5b03ed47d
Author
Mike Ruberry
Parents
Loading