pytorch
585a5975 - Return NotImplemented from tensor arithmetic operators (#26507)

Commit
6 years ago
Return NotImplemented from tensor arithmetic operators (#26507) Summary: Fixes https://github.com/pytorch/pytorch/issues/26333 This effectively rewrites all infix arithmetic operators *op* as: ```python def __op__(self, other): try: return self.op(other) except TypeError: return NotImplemented ``` Where `TypeError` is raised from the argument parser when `other` is not a `Tensor`. This should be okay, so long as `TypeError` isn't raised by the function for any other reasons. I couldn't find any examples where this was an issue. Pull Request resolved: https://github.com/pytorch/pytorch/pull/26507 Differential Revision: D17669097 Pulled By: ezyang fbshipit-source-id: 2c1a1087057c9298915d713d3fea7d682d014c72
Author
Parents
Loading