From 6f65b07840e2b18989836dda98e75be2d0ad5dca Mon Sep 17 00:00:00 2001 From: xujiaqi01 <173596896@qq.com> Date: Fri, 15 May 2020 10:31:38 +0800 Subject: [PATCH] fix error check (#24483) (#24531) * fix error check of stack and space_to_depth * test=develop --- python/paddle/fluid/layers/nn.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 99803ccbd8..13a9c5f708 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -10978,6 +10978,11 @@ def stack(x, axis=0): assert len(x) == 1, "If the elements of 'x' in stack are Variable(LoDTensorArray), " \ "number of the elements must be 1, but received %s." % len(x) out_index = helper.create_variable_for_type_inference(dtype="int32") + + for i in x: + check_variable_and_dtype(i, 'x', \ + ['float16', 'float32', 'float64', 'int32', 'int64'], 'stack') + helper.append_op( type='tensor_array_to_tensor', inputs={'X': x[0]}, @@ -13462,6 +13467,9 @@ def space_to_depth(x, blocksize, name=None): if not (isinstance(blocksize, int)): raise ValueError("blocksize must be a python Int") + check_variable_and_dtype(x, 'x', \ + ['float16', 'float32', 'float64', 'int32', 'int64'], 'space_to_depth') + out = helper.create_variable_for_type_inference(dtype=x.dtype) helper.append_op( -- GitLab