pytorch
3e0c226e - Raise TypeErrors when IValue::getSubValues fails (#56510)

Commit
3 years ago
Raise TypeErrors when IValue::getSubValues fails (#56510) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/56510 The comment for `TORCH_INTERNAL_ASSERT` say to use it for "enforcement of internal invariants in code", meaning "assuming no bugs in PyTorch, the conditions tested by this macro should always be true". However this wasn't the case here, at least for the RPC code: CUDAFuture is calling the `getSubValues` method on a generic IValue of which it doesn't know (or care about) the type. It was thus sometimes triggering the internal assert when users provided non-inspectable types, which was producing an exception with a message containing "please report a bug to PyTorch", which was confusing to users. It makes more sense to me to consider this a type error, which can thus be reported more clearly to the user (and, later on in this stack, to catch). Hence the difference introduced here is just the type and the message of the exception. I don't expect there to be any code depending on the old behavior (as it would mean depending on a violation of an internal invariant). ghstack-source-id: 127035768 Test Plan: Unit tests Reviewed By: mrshenli Differential Revision: D27861066 fbshipit-source-id: 6d41c922257cba5f37c7a4614d8e5ab5c7c87b92
Author
lw lw
Parents
Loading