in functorch/csrc/DynamicLayer.cpp [315:345]
static bool allTensors(
ArrayRef<IValue> args,
std::function<bool(const Tensor&)> pred) {
for (const auto& ivalue : args) {
// Tensor?[] translates to a c10::List<IValue> so we need to peek inside List
if (ivalue.isList()) {
for (const auto& elt : ivalue.toListRef()) {
if (elt.isTensor() && !pred(elt.toTensor())) {
return false;
}
}
continue;
}
if (ivalue.isTensorList()) {
for (const auto& elt : ivalue.toTensorList()) {
if (!pred(elt)) {
return false;
}
}
continue;
}
TORCH_INTERNAL_ASSERT(!ivalue.isGenericDict(), "No operators can accept GenericDict");
if (!ivalue.isTensor()) {
continue;
}
if (!pred(ivalue.toTensor())) {
return false;
}
}
return true;
}