From c2103c48449bc112fb30c21f41f111bbffec5ccf Mon Sep 17 00:00:00 2001 From: xujiaqi01 <173596896@qq.com> Date: Thu, 14 May 2020 11:35:47 +0800 Subject: [PATCH] fix error check (#24483) * 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 fb61ba0956b..8bd500b9d0f 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -9752,6 +9752,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]}, @@ -12237,6 +12242,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