diff --git a/paddle/phi/api/lib/kernel_dispatch.h b/paddle/phi/api/lib/kernel_dispatch.h index 1ed695f8e0a59069e74556a8c092dec2a310c6dc..1ca88acab8cc1574a7614abdd6dd06b51a2a084b 100644 --- a/paddle/phi/api/lib/kernel_dispatch.h +++ b/paddle/phi/api/lib/kernel_dispatch.h @@ -117,12 +117,10 @@ struct KernelKeyParser : ArgsIterator { } void operator()(const std::vector& x) { - const phi::TensorBase& tensor = *x.at(0).impl(); - key_set.backend_set = - key_set.backend_set | detail::GetTensorBackendSet(tensor); - // TODO(chenweihang): select multi layout and dtype - key_set.layout = tensor.layout(); - key_set.dtype = tensor.dtype(); + if (!x.empty()) { + const phi::TensorBase& tensor = *x.at(0).impl(); + AssignKernelKeySet(tensor); + } } void operator()(const paddle::optional& x) {