Fix bug in PythonFallBack (#85795)

Summary: Previously PythonCallBack fails to find interpreter to dispatch to when it encounters an op with OptionalTensorList parameter, this diff fixes that

Test Plan: CI

Differential Revision: D39881382

Pull Request resolved: https://github.com/pytorch/pytorch/pull/85795
Approved by: https://github.com/ezyang, https://github.com/bdhirsh
This commit is contained in:
Tugsbayasgalan (Tugsuu) Manlaibaatar 2022-09-29 19:16:17 +00:00 committed by PyTorch MergeBot
parent fe87ae692f
commit a9183c0f9e

View File

@ -73,7 +73,7 @@ void pythonFallback(const c10::OperatorHandle& op, torch::jit::Stack* stack) {
(*interpreter)->dispatch(op, stack); (*interpreter)->dispatch(op, stack);
return; return;
} }
} else if (ivalue.isTensorList()) { } else if (ivalue.isTensorList() || (ivalue.isOptionalTensorList() && !ivalue.isNone())) {
// NB: use toListRef as it doesn't induce refcount bumps (toTensorListRef // NB: use toListRef as it doesn't induce refcount bumps (toTensorListRef
// is not a thing) // is not a thing)
for (const auto& nv : ivalue.toListRef()) { for (const auto& nv : ivalue.toListRef()) {