From f39899a43de6218634c9cad6d1389ae96746bc5a Mon Sep 17 00:00:00 2001 From: wangchaochaohu Date: Fri, 10 Apr 2020 00:07:00 +0800 Subject: [PATCH] API(create_tensor) error message enhancement (#23571) --- python/paddle/fluid/layers/tensor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/paddle/fluid/layers/tensor.py b/python/paddle/fluid/layers/tensor.py index a7fef16814..0027a25399 100644 --- a/python/paddle/fluid/layers/tensor.py +++ b/python/paddle/fluid/layers/tensor.py @@ -57,6 +57,10 @@ def create_tensor(dtype, name=None, persistable=False): import paddle.fluid as fluid tensor = fluid.layers.create_tensor(dtype='float32') """ + check_dtype(dtype, 'dtype', [ + 'bool', 'float16', 'float32', 'float64', 'int8', 'int32', 'int32', + 'int64' + ], 'create_tensor') helper = LayerHelper("create_tensor", **locals()) return helper.create_variable( name=helper.name, dtype=dtype, persistable=persistable) -- GitLab