From d848ff04093673d07288f46721c48aded8a7e918 Mon Sep 17 00:00:00 2001 From: chentianyu03 Date: Wed, 8 Dec 2021 19:04:52 +0800 Subject: [PATCH] Revert "pylayer support tuple/list type args (#37727)" (#37956) This reverts commit a73064f2e237b9f05e4e932f0ae5fc04da9877e1. --- paddle/fluid/imperative/py_layer_fwd.h | 44 -------------------------- 1 file changed, 44 deletions(-) diff --git a/paddle/fluid/imperative/py_layer_fwd.h b/paddle/fluid/imperative/py_layer_fwd.h index 159371970d..e01fd6e001 100644 --- a/paddle/fluid/imperative/py_layer_fwd.h +++ b/paddle/fluid/imperative/py_layer_fwd.h @@ -101,28 +101,6 @@ py::object PyLayerApply(const platform::Place& place, const py::handle& cls, "`%s` type argument can not be cast into `Tensor`.", ptr->ptr()->ob_type->tp_name)); } - } else if (py::isinstance(*ptr) || - py::isinstance(*ptr)) { - try { - auto tuple_arg = ptr->cast(); - for (auto iter = tuple_arg.begin(); iter != tuple_arg.end(); ++iter) { - try { - auto t = iter->cast>(); - input_vars.push_back(t); - } catch (py::cast_error& err) { - PADDLE_THROW(platform::errors::InvalidArgument( - "The `PyLayer.forward` function contains invalid argument, " - "the " - "`%s` type argument can not be cast into `Tensor`.", - ptr->ptr()->ob_type->tp_name)); - } - } - } catch (py::cast_error& err) { - PADDLE_THROW(platform::errors::InvalidArgument( - "The `PyLayer.forward` function contains invalid argument, the " - "`%s` type argument can not be cast into `Tensor`.", - ptr->ptr()->ob_type->tp_name)); - } } } } @@ -141,28 +119,6 @@ py::object PyLayerApply(const platform::Place& place, const py::handle& cls, "`%s` type argument can not be cast into `Tensor`.", ptr->second.ptr()->ob_type->tp_name)); } - } else if (py::isinstance(*ptr->second) || - py::isinstance(*ptr->second)) { - try { - auto tuple_arg = ptr->second.cast(); - for (auto iter = tuple_arg.begin(); iter != tuple_arg.end(); ++iter) { - try { - auto t = iter->cast>(); - input_vars.push_back(t); - } catch (py::cast_error& err) { - PADDLE_THROW(platform::errors::InvalidArgument( - "The `PyLayer.forward` function contains invalid argument, " - "the " - "`%s` type argument can not be cast into `Tensor`.", - ptr->second.ptr()->ob_type->tp_name)); - } - } - } catch (py::cast_error& err) { - PADDLE_THROW(platform::errors::InvalidArgument( - "The `PyLayer.forward` function contains invalid argument, the " - "`%s` type argument can not be cast into `Tensor`.", - ptr->second.ptr()->ob_type->tp_name)); - } } } } -- GitLab