From 4140d7eca3010f08e988676e2f02aba4c82711f9 Mon Sep 17 00:00:00 2001 From: HongyuJia Date: Thu, 29 Sep 2022 10:30:32 +0800 Subject: [PATCH] [Fix KernelKeyParser] Unify the logic of `operator()` in `KernelKeyParser` (#46560) * add datatype check for ParseKernelKeyByInputArgs * polish error message * Actually, einsum has vector inpute with DataType::COMPLEX64, see test_einsum_v2.py * headerfile remove enforce.h --- paddle/phi/api/lib/kernel_dispatch.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/paddle/phi/api/lib/kernel_dispatch.h b/paddle/phi/api/lib/kernel_dispatch.h index 1ed695f8e0a..1ca88acab8c 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) { -- GitLab