Fix some bugs in SymFloat IValue and toPyObject handling (#86072)

- Test for symbolic cases first before non-symbolic, as symbolic
  ints/floats advertise as being ints/floats
- Add missing case for toPyObject

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/86072
Approved by: https://github.com/wconstab
This commit is contained in:
Edward Z. Yang
2022-10-02 12:50:17 -07:00
committed by PyTorch MergeBot
parent a66506b136
commit 8753703b68
2 changed files with 12 additions and 9 deletions

View File

@ -627,8 +627,9 @@ py::object toPyObject(IValue ivalue) {
TORCH_CHECK(false, "RRef is only supported with the distributed package");
#endif
} else if (ivalue.isSymInt()) {
auto si = ivalue.toSymInt();
return py::cast(si);
return py::cast(ivalue.toSymInt());
} else if (ivalue.isSymFloat()) {
return py::cast(ivalue.toSymFloat());
} else {
AT_ERROR(
"Missing cases in 'toPyObject'! Can't convert ",