From a8cc48c6b8c4bef9c720191da254ad3c7893ed2f Mon Sep 17 00:00:00 2001 From: xiefangqi Date: Tue, 18 Aug 2020 19:02:25 +0800 Subject: [PATCH] Add decodeOp validate --- mindspore/ccsrc/minddata/dataset/kernels/image/decode_op.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/decode_op.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/decode_op.cc index 5bc5377de9..6e73fde8b7 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/decode_op.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/decode_op.cc @@ -32,6 +32,10 @@ DecodeOp::DecodeOp(bool is_rgb_format) : is_rgb_format_(is_rgb_format) { Status DecodeOp::Compute(const std::shared_ptr &input, std::shared_ptr *output) { IO_CHECK(input, output); + // check the input tensor shape + if (input->Rank() != 1) { + RETURN_STATUS_UNEXPECTED("DecodeOp error: invalid input shape, only support 1D input."); + } if (is_rgb_format_) { // RGB colour mode return Decode(input, output); } else { // BGR colour mode