diff --git a/mindspore/ccsrc/minddata/dataset/kernels/data/compose_op.cc b/mindspore/ccsrc/minddata/dataset/kernels/data/compose_op.cc index f856239dcc2..9e5901323bf 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/data/compose_op.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/data/compose_op.cc @@ -53,9 +53,9 @@ Status ComposeOp::Compute(const TensorRow &inputs, TensorRow *outputs) { ComposeOp::ComposeOp(const std::vector> &ops) : ops_(ops) { if (ops_.empty()) { - MS_LOG(ERROR) << "Compose: op_list is empty, this might lead to Segmentation Fault."; + MS_LOG(ERROR) << "Compose: input 'transforms'(op_list) is empty, this might lead to Segmentation Fault."; } else if (ops_.size() == 1) { - MS_LOG(WARNING) << "Compose: op_list has only 1 op. Compose is probably not needed."; + MS_LOG(WARNING) << "Compose: input 'transforms'(op_list) has only 1 op. Compose is probably not needed."; } } diff --git a/mindspore/ccsrc/minddata/dataset/kernels/data/data_utils.cc b/mindspore/ccsrc/minddata/dataset/kernels/data/data_utils.cc index 8e09f38eba1..9d7485e8c1b 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/data/data_utils.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/data/data_utils.cc @@ -55,7 +55,8 @@ Status OneHotEncodingUnsigned(const std::shared_ptr &input, std::shared_ } else if (input->type() == DataType::DE_UINT8) { RETURN_IF_NOT_OK((*output)->SetItemAt({index, static_cast(class_idx)}, 1)); } else { - RETURN_STATUS_UNEXPECTED("OneHot: OneHot unsigned only supports unsigned int as input."); + RETURN_STATUS_UNEXPECTED("OneHot: unsigned input case only supports unsigned int as input, but got:" + + input->type().ToString()); } return Status::OK(); } @@ -81,7 +82,8 @@ Status OneHotEncodingSigned(const std::shared_ptr &input, std::shared_pt } else if (input->type() == DataType::DE_INT8) { RETURN_IF_NOT_OK((*output)->SetItemAt({index, static_cast(class_idx)}, 1)); } else { - RETURN_STATUS_UNEXPECTED("OneHot: OneHot signed only supports signed int as input."); + RETURN_STATUS_UNEXPECTED("OneHot: signed input case only supports signed int as input but got:" + + input->type().ToString()); } return Status::OK(); } @@ -94,7 +96,7 @@ Status OneHotEncoding(const std::shared_ptr &input, std::shared_ptrRank())); } if (!input->type().IsInt()) { - RETURN_STATUS_UNEXPECTED("OneHot: OneHot only not support input of int type."); + RETURN_STATUS_UNEXPECTED("OneHot: OneHot only support input of int type, but got:" + input->type().ToString()); } try { dsize_t num_elements = 1; @@ -209,7 +211,7 @@ Status FillHelper(const std::shared_ptr &input, std::shared_ptr break; } case DataType::DE_UNKNOWN: { - RETURN_STATUS_UNEXPECTED("Fill: unknown input datatype."); + RETURN_STATUS_UNEXPECTED("Fill: unknown input datatype, check input datatype of this operator."); break; } default: @@ -228,8 +230,9 @@ Status Fill(const std::shared_ptr input, std::shared_ptr *output CHECK_FAIL_RETURN_UNEXPECTED(!((fill_type == DataType::DE_STRING) && (input_type != DataType::DE_STRING)), "Fill: fill datatype is string but the input datatype is not string."); - CHECK_FAIL_RETURN_UNEXPECTED(fill_value->shape() == TensorShape({}), - "Fill: the shape of fill_value is not a scalar."); + CHECK_FAIL_RETURN_UNEXPECTED( + fill_value->shape() == TensorShape({}), + "Fill: the shape of fill_value is not a scalar, got shape:" + fill_value->shape().ToString()); std::shared_ptr out, fill_output; @@ -297,7 +300,8 @@ void CastFrom(const std::shared_ptr &input, std::shared_ptr *out Cast(input, output); break; case DataType::DE_UNKNOWN: - MS_LOG(ERROR) << "TypeCast: unknown datatype."; + MS_LOG(ERROR) << "TypeCast: unknown datatype of input data, supported datatype is: [bool, int8, uint8, int16, " + "uint16, int32, uint32, int64, uint64, float16, float32, float64]."; break; } } @@ -367,8 +371,9 @@ Status ToFloat16(const std::shared_ptr &input, std::shared_ptr * float float16_max = static_cast(std::numeric_limits::max()); float float16_min = static_cast(std::numeric_limits::lowest()); if (element > float16_max || element < float16_min) { - RETURN_STATUS_UNEXPECTED("ToFloat16: value " + std::to_string(element) + " is outside of valid float16 range [" + - std::to_string(float16_max) + ", " + std::to_string(float16_min) + "]."); + RETURN_STATUS_UNEXPECTED("ToFloat16: value " + std::to_string(element) + + "in input data is outside of valid float16 range [" + std::to_string(float16_max) + + ", " + std::to_string(float16_min) + "]."); } *out_itr = float16(*in_itr); @@ -440,7 +445,9 @@ Status PadEndNumeric(const std::shared_ptr &src, std::shared_ptr } else if (tensor_type == DataType::DE_FLOAT64) { RETURN_IF_NOT_OK((*dst)->Fill(static_cast(pad_val))); } else { - RETURN_STATUS_UNEXPECTED("PadEnd: Incorrect/Unknown datatype"); + RETURN_STATUS_UNEXPECTED( + "PadEnd: Incorrect/Unknown datatype, supported datatype is: [bool, int8, uint8, int16, uint16, int32, uint32, " + "int64, uint64, float16, float32, float64]."); } std::vector cur_ind(src->Rank(), 0); RETURN_IF_NOT_OK(PadEndNumericHelper(src, *dst, cur_ind, 0)); @@ -535,7 +542,8 @@ Status MaskHelper(const std::shared_ptr &input, const std::shared_ptr &input, std::shared_ptr *outpu CHECK_FAIL_RETURN_UNEXPECTED(input->type().IsNumeric() == value->type().IsNumeric(), "Mask: input datatype does not match the value datatype, both should be numeric or " "non-numerical in the same time."); - CHECK_FAIL_RETURN_UNEXPECTED(value->shape() == TensorShape::CreateScalar(), "Mask: value shape is not a scalar"); + CHECK_FAIL_RETURN_UNEXPECTED(value->shape() == TensorShape::CreateScalar(), + "Mask: value shape should be a scalar, got shape:" + value->shape().ToString()); RETURN_IF_NOT_OK(Tensor::CreateEmpty(input->shape(), DataType(DataType::DE_BOOL), output)); @@ -599,7 +608,9 @@ Status Mask(const std::shared_ptr &input, std::shared_ptr *outpu RETURN_IF_NOT_OK(MaskHelper(input, *output, casted_value, op)); break; case DataType::DE_UNKNOWN: - RETURN_STATUS_UNEXPECTED("Mask: unsupported input datatype."); + RETURN_STATUS_UNEXPECTED( + "Mask: unsupported input datatype, support datatype is:[bool, int8, uint8, int16, uint16, int32, uint32, " + "int64, uint64, float16, float32, float64, string]."); break; } return Status::OK(); @@ -609,7 +620,8 @@ Status Concatenate(const TensorRow &input, TensorRow *output, int8_t axis, std:: std::shared_ptr append) { CHECK_FAIL_RETURN_UNEXPECTED(input.size() > 0, "Concatenate: input is null"); axis = Tensor::HandleNeg(axis, input[0]->shape().Rank()); - CHECK_FAIL_RETURN_UNEXPECTED(axis == 0, "Concatenate: only 1D input supported, got rank: " + std::to_string(axis)); + CHECK_FAIL_RETURN_UNEXPECTED( + axis == 0, "Concatenate: only 1D input supported, input 'axis' should be 0, but got: " + std::to_string(axis)); TensorShape t = TensorShape::CreateScalar(); @@ -620,10 +632,11 @@ Status Concatenate(const TensorRow &input, TensorRow *output, int8_t axis, std:: if (prepend != nullptr) { CHECK_FAIL_RETURN_UNEXPECTED( first_dtype == prepend->type(), - "Concatenate: input datatype does not match the prepend datatype: " + prepend->type().ToString()); + "Concatenate: input datatype does not match the prepend datatype, got input datatype: " + first_dtype.ToString() + + ", prepend datatype:" + prepend->type().ToString()); CHECK_FAIL_RETURN_UNEXPECTED( prepend->shape().Rank() == 1, - "Concatenate: only 1D input supported, got rank of input: " + std::to_string(prepend->shape().Rank())); + "Concatenate: only 1D input supported, got rank of prepend: " + std::to_string(prepend->shape().Rank())); tensor_list.emplace_back(prepend); } @@ -638,10 +651,11 @@ Status Concatenate(const TensorRow &input, TensorRow *output, int8_t axis, std:: if (append != nullptr) { CHECK_FAIL_RETURN_UNEXPECTED( first_dtype == append->type(), - "Concatenate: input datatype does not match the append datatype: " + append->type().ToString()); + "Concatenate: input datatype does not match the append datatype, got input datatype: " + first_dtype.ToString() + + ", append datatype:" + append->type().ToString()); CHECK_FAIL_RETURN_UNEXPECTED( append->shape().Rank() == 1, - "Concatenate: only 1D append supported, got rank of input: " + std::to_string(append->shape().Rank())); + "Concatenate: only 1D append supported, got rank of append:" + std::to_string(append->shape().Rank())); tensor_list.emplace_back(append); } diff --git a/mindspore/ccsrc/minddata/dataset/kernels/data/duplicate_op.cc b/mindspore/ccsrc/minddata/dataset/kernels/data/duplicate_op.cc index 32876e2f54c..dc998dba8e5 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/data/duplicate_op.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/data/duplicate_op.cc @@ -24,9 +24,9 @@ namespace dataset { Status DuplicateOp::Compute(const TensorRow &input, TensorRow *output) { IO_CHECK_VECTOR(input, output); - CHECK_FAIL_RETURN_UNEXPECTED( - input.size() == 1, - "Duplicate: only supports transform one column each time, got column num: " + std::to_string(input.size())); + CHECK_FAIL_RETURN_UNEXPECTED(input.size() == 1, + "Duplicate: only supports transform one column each time, got column num: " + + std::to_string(input.size()) + ", check 'input_columns' when call this operator."); std::shared_ptr out; RETURN_IF_NOT_OK(Tensor::CreateFromTensor(input[0], &out)); output->push_back(input[0]); diff --git a/mindspore/ccsrc/minddata/dataset/kernels/data/random_choice_op.cc b/mindspore/ccsrc/minddata/dataset/kernels/data/random_choice_op.cc index d04bf61a3b3..03decc477f0 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/data/random_choice_op.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/data/random_choice_op.cc @@ -85,10 +85,10 @@ Status RandomChoiceOp::Compute(const TensorRow &input, TensorRow *output) { RandomChoiceOp::RandomChoiceOp(const std::vector> &ops) : ops_(ops), gen_(GetSeed()), rand_int_(0, ops.size() - 1) { if (ops_.empty()) { - MS_LOG(ERROR) << "op_list in RandomChoiceOp is empty."; + MS_LOG(ERROR) << "input 'transforms'(op_list) in RandomChoiceOp is empty."; } if (ops_.size() == 1) { - MS_LOG(WARNING) << "op_list has only 1 op, this op would be picked every time."; + MS_LOG(WARNING) << "input 'transforms'(op_list) has only 1 op, this op would be picked every time."; } is_deterministic_ = false; } diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/decode_op.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/decode_op.cc index 72bcee6614b..8d2fe90ec71 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/decode_op.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/decode_op.cc @@ -44,9 +44,11 @@ Status DecodeOp::Compute(const std::shared_ptr &input, std::shared_ptr &inputs, std::vector &outputs) { RETURN_IF_NOT_OK(TensorOp::OutputShape(inputs, outputs)); outputs.clear(); diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/image_utils.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/image_utils.cc index b39eb16b0fe..27c80d994ab 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/image_utils.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/image_utils.cc @@ -156,7 +156,7 @@ Status Resize(const std::shared_ptr &input, std::shared_ptr *out return Status(StatusCode::kMDShapeMisMatch, err_msg); } if (output_height == 0 || output_width == 0) { - std::string err_msg = "Resize: the resizing width or height is invalid, width or height is zero."; + std::string err_msg = "Resize: the input value of 'resize' is invalid, width or height is zero."; return Status(StatusCode::kMDShapeMisMatch, err_msg); } @@ -378,15 +378,20 @@ Status JpegCropAndDecode(const std::shared_ptr &input, std::shared_ptr::max() - crop_w) > crop_x, - "JpegCropAndDecode: addition(crop x and crop width) out of bounds."); + "JpegCropAndDecode: addition(crop x and crop width) out of bounds, got crop x:" + + std::to_string(crop_x) + ", and crop width:" + std::to_string(crop_w)); CHECK_FAIL_RETURN_UNEXPECTED((std::numeric_limits::max() - crop_h) > crop_y, - "JpegCropAndDecode: addition(crop y and crop height) out of bounds."); + "JpegCropAndDecode: addition(crop y and crop height) out of bounds, got crop y:" + + std::to_string(crop_y) + ", and crop height:" + std::to_string(crop_h)); if (crop_x == 0 && crop_y == 0 && crop_w == 0 && crop_h == 0) { crop_w = cinfo.output_width; crop_h = cinfo.output_height; } else if (crop_w == 0 || static_cast(crop_w + crop_x) > cinfo.output_width || crop_h == 0 || static_cast(crop_h + crop_y) > cinfo.output_height) { - return DestroyDecompressAndReturnError("Crop: invalid crop size."); + return DestroyDecompressAndReturnError( + "Crop: invalid crop size, corresponding crop value equal to 0 or too big, got crop width: " + + std::to_string(crop_w) + ", crop height:" + std::to_string(crop_h) + + ", and crop x coordinate:" + std::to_string(crop_x) + ", crop y coordinate:" + std::to_string(crop_y)); } const int mcu_size = cinfo.min_DCT_scaled_size; CHECK_FAIL_RETURN_UNEXPECTED(mcu_size != 0, "JpegCropAndDecode: divisor mcu_size is zero."); @@ -450,7 +455,8 @@ Status Crop(const std::shared_ptr &input, std::shared_ptr *outpu } RETURN_IF_NOT_OK(ValidateImageRank("Crop", input_cv->Rank())); CHECK_FAIL_RETURN_UNEXPECTED((std::numeric_limits::max() - y) > h, - "Crop: addition(x and height) out of bounds."); + "Crop: addition(x and height) out of bounds, got height:" + std::to_string(h) + + ", and coordinate y:" + std::to_string(y)); // account for integer overflow if (y < 0 || (y + h) > input_cv->shape()[0] || (y + h) < 0) { RETURN_STATUS_UNEXPECTED( @@ -525,7 +531,9 @@ Status HwcToChw(std::shared_ptr input, std::shared_ptr *output) *output = input; return Status::OK(); } - CHECK_FAIL_RETURN_UNEXPECTED(input_cv->shape().Size() > CHANNEL_INDEX, "HWC2CHW: invalid shape."); + CHECK_FAIL_RETURN_UNEXPECTED(input_cv->shape().Size() > CHANNEL_INDEX, + "HWC2CHW: rank of input data should be greater than:" + std::to_string(CHANNEL_INDEX) + + ", but got:" + std::to_string(input_cv->shape().Size())); int num_channels = input_cv->shape()[CHANNEL_INDEX]; if (input_cv->shape().Size() < MIN_IMAGE_DIMENSION || input_cv->shape().Size() > DEFAULT_IMAGE_CHANNELS || (input_cv->shape().Size() == DEFAULT_IMAGE_CHANNELS && num_channels != DEFAULT_IMAGE_CHANNELS && @@ -558,12 +566,14 @@ Status MaskWithTensor(const std::shared_ptr &sub_mat, std::shared_ptr format."); + "input shape doesn't match format, got shape:" + + (*input)->shape().ToString()); } if (CheckTensorShape(sub_mat, 2)) { RETURN_STATUS_UNEXPECTED( "CutMixBatch: MaskWithTensor failed: " - "sub_mat shape doesn't match format."); + "sub_mat shape doesn't match format, got shape:" + + (*input)->shape().ToString()); } int number_of_channels = (*input)->shape()[CHANNEL_INDEX]; for (int i = 0; i < crop_width; i++) { @@ -577,12 +587,14 @@ Status MaskWithTensor(const std::shared_ptr &sub_mat, std::shared_ptr format."); + "input shape doesn't match format, got shape:" + + (*input)->shape().ToString()); } if (CheckTensorShape(sub_mat, 0)) { RETURN_STATUS_UNEXPECTED( "CutMixBatch: MaskWithTensor failed: " - "sub_mat shape doesn't match format."); + "sub_mat shape doesn't match format, got shape:" + + (*input)->shape().ToString()); } int number_of_channels = (*input)->shape()[0]; for (int i = 0; i < crop_width; i++) { @@ -596,12 +608,14 @@ Status MaskWithTensor(const std::shared_ptr &sub_mat, std::shared_ptrRank() != MIN_IMAGE_DIMENSION) { RETURN_STATUS_UNEXPECTED( "CutMixBatch: MaskWithTensor failed: " - "input shape doesn't match format."); + "input shape doesn't match format, got shape:" + + (*input)->shape().ToString()); } if (sub_mat->Rank() != MIN_IMAGE_DIMENSION) { RETURN_STATUS_UNEXPECTED( "CutMixBatch: MaskWithTensor failed: " - "sub_mat shape doesn't match format."); + "sub_mat shape doesn't match format, got shape:" + + (*input)->shape().ToString()); } for (int i = 0; i < crop_width; i++) { for (int j = 0; j < crop_height; j++) { @@ -611,7 +625,8 @@ Status MaskWithTensor(const std::shared_ptr &sub_mat, std::shared_ptr, , or ."); + "image format must be , , or , got shape:" + + (*input)->shape().ToString()); } return Status::OK(); } @@ -641,10 +656,14 @@ Status CopyTensorValue(const std::shared_ptr &source_tensor, std::shared Status SwapRedAndBlue(std::shared_ptr input, std::shared_ptr *output) { try { std::shared_ptr input_cv = CVTensor::AsCVTensor(std::move(input)); - CHECK_FAIL_RETURN_UNEXPECTED(input_cv->shape().Size() > CHANNEL_INDEX, "SwapRedAndBlue: shape is invalid."); + CHECK_FAIL_RETURN_UNEXPECTED( + input_cv->shape().Size() > CHANNEL_INDEX, + "SwapRedAndBlue: rank of input is should greater than:" + std::to_string(CHANNEL_INDEX) + + ", but got:" + std::to_string(input_cv->shape().Size())); int num_channels = input_cv->shape()[CHANNEL_INDEX]; if (input_cv->shape().Size() != 3 || num_channels != DEFAULT_IMAGE_CHANNELS) { - RETURN_STATUS_UNEXPECTED("SwapRedBlue: image shape is not ."); + RETURN_STATUS_UNEXPECTED("SwapRedBlue: image shape should be in format, but got:" + + input_cv->shape().ToString()); } std::shared_ptr output_cv; RETURN_IF_NOT_OK(CVTensor::CreateEmpty(input_cv->shape(), input_cv->type(), &output_cv)); @@ -724,7 +743,9 @@ Status Rotate(const std::shared_ptr &input, std::shared_ptr *out cv::Mat input_img = input_cv->mat(); if (input_img.cols > (MAX_INT_PRECISION * 2) || input_img.rows > (MAX_INT_PRECISION * 2)) { - RETURN_STATUS_UNEXPECTED("Rotate: image is too large and center is not precise."); + RETURN_STATUS_UNEXPECTED("Rotate: image is too large and center is not precise, got image width:" + + std::to_string(input_img.cols) + ", and image height:" + std::to_string(input_img.rows) + + ", both should be small than:" + std::to_string(MAX_INT_PRECISION * 2)); } float fx = 0, fy = 0; if (center.empty()) { @@ -791,7 +812,9 @@ Status Normalize(const std::shared_ptr &input, std::shared_ptr * RETURN_IF_NOT_OK((*output)->ExpandDim(MIN_IMAGE_DIMENSION)); } - CHECK_FAIL_RETURN_UNEXPECTED((*output)->Rank() == DEFAULT_IMAGE_RANK, "Normalize: image shape is not ."); + CHECK_FAIL_RETURN_UNEXPECTED((*output)->Rank() == DEFAULT_IMAGE_RANK, + "Normalize: output image rank should be:" + std::to_string(DEFAULT_IMAGE_RANK) + + ", but got:" + std::to_string((*output)->Rank())); CHECK_FAIL_RETURN_UNEXPECTED(std.size() == mean.size(), "Normalize: mean and std vectors are not of same size, got size of std:" + std::to_string(std.size()) + ", and mean size:" + std::to_string(mean.size())); @@ -948,7 +971,7 @@ Status AdjustContrast(const std::shared_ptr &input, std::shared_ptrshape().Size() > CHANNEL_INDEX, - "AdjustContrast: image rank should not bigger than:" + std::to_string(CHANNEL_INDEX) + + "AdjustContrast: image rank should bigger than:" + std::to_string(CHANNEL_INDEX) + ", but got: " + std::to_string(input_cv->shape().Size())); int num_channels = input_cv->shape()[CHANNEL_INDEX]; if (input_cv->Rank() != DEFAULT_IMAGE_CHANNELS || num_channels != DEFAULT_IMAGE_CHANNELS) { @@ -976,7 +999,8 @@ Status AdjustGamma(const std::shared_ptr &input, std::shared_ptr try { int num_channels = 1; if (input->Rank() < 2) { - RETURN_STATUS_UNEXPECTED("AdjustGamma: input tensor is not in shape of <...,H,W,C> or ."); + RETURN_STATUS_UNEXPECTED("AdjustGamma: input tensor is not in shape of <...,H,W,C> or , got shape:" + + input->shape().ToString()); } if (input->Rank() > 2) { num_channels = input->shape()[-1]; @@ -1037,7 +1061,7 @@ Status AutoContrast(const std::shared_ptr &input, std::shared_ptrRank() != DEFAULT_IMAGE_RANK && input_cv->Rank() != MIN_IMAGE_DIMENSION) { - RETURN_STATUS_UNEXPECTED("AutoContrast: image channel should be 1 or 3, but got: " + + RETURN_STATUS_UNEXPECTED("AutoContrast: image rank should be 2 or 3, but got: " + std::to_string(input_cv->Rank())); } // Reshape to extend dimension if rank is 2 for algorithm to work. then reshape output to be of rank 2 like input @@ -1400,7 +1424,7 @@ Status RgbaToBgr(const std::shared_ptr &input, std::shared_ptr * try { std::shared_ptr input_cv = CVTensor::AsCVTensor(std::move(input)); int num_channels = input_cv->shape()[CHANNEL_INDEX]; - if (input_cv->shape().Size() != DEFAULT_IMAGE_CHANNELS || num_channels != 4) { + if (input_cv->shape().Size() != DEFAULT_IMAGE_CHANNELS || num_channels != MAX_IMAGE_CHANNELS) { std::string err_msg = "RgbaToBgr: rank of image is not: " + std::to_string(DEFAULT_IMAGE_CHANNELS) + ", but got: " + std::to_string(input_cv->shape().Size()) + ", or channels of image should be 4, but got: " + std::to_string(num_channels); @@ -1424,7 +1448,7 @@ Status RgbToBgr(const std::shared_ptr &input, std::shared_ptr *o if (!input_cv->mat().data) { RETURN_STATUS_UNEXPECTED("[Internal ERROR] RgbToBgr: load image failed."); } - if (input_cv->Rank() != 3 || input_cv->shape()[2] != 3) { + if (input_cv->Rank() != DEFAULT_IMAGE_RANK || input_cv->shape()[2] != DEFAULT_IMAGE_CHANNELS) { RETURN_STATUS_UNEXPECTED("RgbToBgr: input tensor is not in shape of or channel is not 3, got rank: " + std::to_string(input_cv->Rank()) + ", and channel: " + std::to_string(input_cv->shape()[2])); diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/mixup_batch_op.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/mixup_batch_op.cc index 9a933820565..7f07d130903 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/mixup_batch_op.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/mixup_batch_op.cc @@ -83,7 +83,7 @@ Status MixUpBatchOp::ComputeLabels(const TensorRow &input, std::shared_ptr> images; @@ -112,7 +112,8 @@ Status MixUpBatchOp::Compute(const TensorRow &input, TensorRow *output) { } if ((image_shape[dimension_one] != value_one && image_shape[dimension_one] != value_three) && (image_shape[dimension_three] != value_one && image_shape[dimension_three] != value_three)) { - RETURN_STATUS_UNEXPECTED("MixUpBatch: images shape is not or ."); + RETURN_STATUS_UNEXPECTED("MixUpBatch: images shape should in or , got shape:" + + input.at(0)->shape().ToString()); } // Move images into a vector of CVTensors diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/random_crop_and_resize_op.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/random_crop_and_resize_op.cc index 50594867279..62cb1dc30da 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/random_crop_and_resize_op.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/random_crop_and_resize_op.cc @@ -55,7 +55,8 @@ Status RandomCropAndResizeOp::Compute(const TensorRow &input, TensorRow *output) RETURN_STATUS_UNEXPECTED(err_msg); } if (input[i]->shape()[0] != input[i + 1]->shape()[0] || input[i]->shape()[1] != input[i + 1]->shape()[1]) { - RETURN_STATUS_UNEXPECTED("RandomCropAndResizeOp: Input images must have the same size."); + RETURN_STATUS_UNEXPECTED( + "RandomCropAndResizeOp: Input images in different column of each row must have the same size."); } } } @@ -100,9 +101,11 @@ Status RandomCropAndResizeOp::GetCropBox(int h_in, int w_in, int *x, int *y, int CHECK_FAIL_RETURN_UNEXPECTED(crop_width != nullptr, "crop_width is nullptr."); *crop_width = w_in; *crop_height = h_in; - CHECK_FAIL_RETURN_UNEXPECTED(w_in != 0, "RandomCropAndResize: Width cannot be 0."); - CHECK_FAIL_RETURN_UNEXPECTED(h_in != 0, "RandomCropAndResize: Height cannot be 0."); - CHECK_FAIL_RETURN_UNEXPECTED(aspect_lb_ > 0, "RandomCropAndResize: aspect lower bound must be greater than zero."); + CHECK_FAIL_RETURN_UNEXPECTED(w_in != 0, "RandomCropAndResize: Width of input cannot be 0."); + CHECK_FAIL_RETURN_UNEXPECTED(h_in != 0, "RandomCropAndResize: Height of input cannot be 0."); + CHECK_FAIL_RETURN_UNEXPECTED( + aspect_lb_ > 0, + "RandomCropAndResize: 'ratio'(aspect) lower bound must be greater than 0, but got:" + std::to_string(aspect_lb_)); for (int32_t i = 0; i < max_iter_; i++) { double const sample_scale = rnd_scale_(rnd_); // In case of non-symmetrical aspect ratios, use uniform distribution on a logarithmic sample_scale. diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/random_crop_op.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/random_crop_op.cc index 09e2c78ef64..641b5964384 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/random_crop_op.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/random_crop_op.cc @@ -128,7 +128,9 @@ Status RandomCropOp::Compute(const TensorRow &input, TensorRow *output) { RETURN_STATUS_UNEXPECTED(err_msg); } if (input[i]->shape()[0] != input[i + 1]->shape()[0] || input[i]->shape()[1] != input[i + 1]->shape()[1]) { - RETURN_STATUS_UNEXPECTED("RandomCropOp: Input images must have the same size."); + RETURN_STATUS_UNEXPECTED( + "RandomCropOp: Input images in different column must have the same shape, check the output shape in " + "specified 'input_columns' before call this operation."); } } } diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/random_select_subpolicy_op.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/random_select_subpolicy_op.cc index 6d6cfa1697e..7f63d0c54da 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/random_select_subpolicy_op.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/random_select_subpolicy_op.cc @@ -89,7 +89,7 @@ Status RandomSelectSubpolicyOp::OutputType(const std::vector &inputs, RandomSelectSubpolicyOp::RandomSelectSubpolicyOp(const std::vector &policy) : gen_(GetSeed()), policy_(policy), rand_int_(0, policy.size() - 1), rand_double_(0, 1) { if (policy_.empty()) { - MS_LOG(ERROR) << "RandomSelectSubpolicy: policy in RandomSelectSubpolicyOp is empty."; + MS_LOG(ERROR) << "RandomSelectSubpolicy: input 'policy' in RandomSelectSubpolicy is empty, check input parameter."; } is_deterministic_ = false; } diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/slice_patches_op.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/slice_patches_op.cc index 3fdc9fd8d54..b42ee35ff59 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/slice_patches_op.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/slice_patches_op.cc @@ -29,14 +29,18 @@ SlicePatchesOp::SlicePatchesOp(int32_t num_height, int32_t num_width, SliceMode Status SlicePatchesOp::Compute(const TensorRow &input, TensorRow *output) { IO_CHECK_VECTOR(input, output); - CHECK_FAIL_RETURN_UNEXPECTED(input.size() == 1, "Input tensor size should be 1."); + CHECK_FAIL_RETURN_UNEXPECTED( + input.size() == 1, + "size of input should be 1, which means 'input_columns' should be 1 when call this operator, but got:" + + std::to_string(input.size())); auto in_tensor = input[0]; auto in_type = in_tensor->type(); auto in_shape = in_tensor->shape(); - CHECK_FAIL_RETURN_UNEXPECTED(in_type.IsNumeric(), "Input Tensor type should be numeric."); - CHECK_FAIL_RETURN_UNEXPECTED(in_shape.Rank() >= 2, "Input Tensor rank should be greater than 2."); + CHECK_FAIL_RETURN_UNEXPECTED(in_type.IsNumeric(), "Input Tensor type should be numeric, got type is non-numeric."); + CHECK_FAIL_RETURN_UNEXPECTED( + in_shape.Rank() >= 2, "Rank of input data should be greater than 2, but got:" + std::to_string(in_shape.Rank())); std::vector> out; RETURN_IF_NOT_OK(SlicePatches(in_tensor, &out, num_height_, num_width_, slice_mode_, fill_value_)); diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/solarize_op.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/solarize_op.cc index a8762e1af8a..e9b8155c5bb 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/solarize_op.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/solarize_op.cc @@ -29,8 +29,10 @@ Status SolarizeOp::Compute(const std::shared_ptr &input, std::shared_ptr uint8_t threshold_min_ = threshold_[0], threshold_max_ = threshold_[1]; - CHECK_FAIL_RETURN_UNEXPECTED(threshold_min_ <= threshold_max_, - "Solarize: threshold_min must be smaller or equal to threshold_max."); + CHECK_FAIL_RETURN_UNEXPECTED( + threshold_min_ <= threshold_max_, + "Solarize: threshold[0] must be smaller or equal to threshold[1], got 'threshold' value: (" + + std::to_string(threshold_min_) + "," + std::to_string(threshold_max_) + ")."); try { std::shared_ptr input_cv = CVTensor::AsCVTensor(input); diff --git a/mindspore/ccsrc/minddata/dataset/kernels/ir/data/transforms_ir.cc b/mindspore/ccsrc/minddata/dataset/kernels/ir/data/transforms_ir.cc index 7cb6778e50a..a2ada61dfcb 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/ir/data/transforms_ir.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/ir/data/transforms_ir.cc @@ -83,18 +83,21 @@ ConcatenateOperation::ConcatenateOperation(int8_t axis, const std::shared_ptrshape().Size() != 1) { - std::string err_msg = "Concatenate: Can only prepend 1D arrays."; + std::string err_msg = "Concatenate: Can only prepend 1D arrays, rank of input 'prepend' should be 1, but got:" + + std::to_string(prepend_->shape().Size()); LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg); } } if (append_) { if (append_->shape().Size() != 1) { - std::string err_msg = "Concatenate: Can only append 1D arrays."; + std::string err_msg = "Concatenate: Can only append 1D arrays, rank of input 'append' should be 1, but got:" + + std::to_string(append_->shape().Size()); LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg); } } @@ -118,7 +121,7 @@ FillOperation::FillOperation(const std::shared_ptr &fill_value) : fill_v Status FillOperation::ValidateParams() { if (fill_value_->shape() != TensorShape::CreateScalar()) { - std::string err_msg = "Fill: fill_value is not a scalar tensor."; + std::string err_msg = "Fill: fill_value is not a scalar tensor, got shape:" + fill_value_->shape().ToString(); LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg); } @@ -145,7 +148,8 @@ MaskOperation::MaskOperation(RelationalOp op, const std::shared_ptr &con Status MaskOperation::ValidateParams() { if (!dtype_.IsBool() && !dtype_.IsFloat() && !dtype_.IsInt()) { - std::string err_msg = "Mask: Only supports bool or numeric datatype for generated mask type."; + std::string err_msg = + "Mask: Only supports bool or numeric datatype for generated mask type, but got:" + dtype_.ToString(); LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg); } return Status::OK(); diff --git a/mindspore/ccsrc/minddata/dataset/kernels/ir/validators.h b/mindspore/ccsrc/minddata/dataset/kernels/ir/validators.h index 08d5871d097..9381be1f336 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/ir/validators.h +++ b/mindspore/ccsrc/minddata/dataset/kernels/ir/validators.h @@ -44,7 +44,7 @@ template Status ValidateScalar(const std::string &op_name, const std::string &scalar_name, const T scalar, const std::vector &range, bool left_open_interval = false, bool right_open_interval = false) { if (range.empty() || range.size() > 2) { - std::string err_msg = "Range check expecting size 1 or 2, but got: " + std::to_string(range.size()); + std::string err_msg = op_name + ": expecting range size 1 or 2, but got: " + std::to_string(range.size()); MS_LOG(ERROR) << err_msg; return Status(StatusCode::kMDSyntaxError, __LINE__, __FILE__, err_msg); } diff --git a/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/auto_contrast_ir.cc b/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/auto_contrast_ir.cc index 05855340369..dadf862c1dd 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/auto_contrast_ir.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/auto_contrast_ir.cc @@ -38,7 +38,7 @@ std::string AutoContrastOperation::Name() const { return kAutoContrastOperation; Status AutoContrastOperation::ValidateParams() { if (cutoff_ < 0 || cutoff_ > 100) { - std::string err_msg = "AutoContrast: cutoff has to be between 0 and 100, got: " + std::to_string(cutoff_); + std::string err_msg = "AutoContrast: 'cutoff' has to be between 0 and 100, got: " + std::to_string(cutoff_); LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg); } @@ -46,7 +46,7 @@ Status AutoContrastOperation::ValidateParams() { for (uint32_t single_ignore : ignore_) { if (single_ignore > kMaxIgnoreSize) { std::string err_msg = - "AutoContrast: invalid size, ignore has to be between 0 and 255, got: " + std::to_string(single_ignore); + "AutoContrast: invalid size, 'ignore' has to be between 0 and 255, got: " + std::to_string(single_ignore); LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg); } } diff --git a/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/crop_ir.cc b/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/crop_ir.cc index a8cacee817f..77db8c6b9b7 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/crop_ir.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/crop_ir.cc @@ -37,7 +37,7 @@ Status CropOperation::ValidateParams() { constexpr size_t size_two = 2; if (coordinates_.size() != size_two) { - std::string err_msg = "Crop: coordinates must be a vector of two values"; + std::string err_msg = "Crop: 'coordinates' must be a vector of two values."; LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg); } RETURN_IF_NOT_OK(ValidateVectorNonNegative("Crop", "coordinates", coordinates_)); diff --git a/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/random_affine_ir.cc b/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/random_affine_ir.cc index c52c43e0478..4cc327cb014 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/random_affine_ir.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/random_affine_ir.cc @@ -67,12 +67,12 @@ Status RandomAffineOperation::ValidateParams() { } // Translate if (translate_range_.size() != size_two && translate_range_.size() != size_four) { - std::string err_msg = "RandomAffine: translate_range expecting size 2 or 4, got: translate_range.size() = " + + std::string err_msg = "RandomAffine: 'translate'(translate_range) expecting size 2 or 4, got size: " + std::to_string(translate_range_.size()); LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg); } if (translate_range_[dimension_zero] > translate_range_[dimension_one]) { - std::string err_msg = "RandomAffine: minimum of translate range on x is greater than maximum: min = " + + std::string err_msg = "RandomAffine: minimum of 'translate'(translate_range) on x is greater than maximum: min = " + std::to_string(translate_range_[dimension_zero]) + ", max = " + std::to_string(translate_range_[dimension_one]); LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg); @@ -82,9 +82,10 @@ Status RandomAffineOperation::ValidateParams() { RETURN_IF_NOT_OK(ValidateScalar("RandomAffine", "translate", translate_range_[dimension_one], {-1, 1}, false, false)); if (translate_range_.size() == size_four) { if (translate_range_[dimension_two] > translate_range_[dimension_three]) { - std::string err_msg = "RandomAffine: minimum of translate range on y is greater than maximum: min = " + - std::to_string(translate_range_[dimension_two]) + - ", max = " + std::to_string(translate_range_[dimension_three]); + std::string err_msg = + "RandomAffine: minimum of 'translate'(translate range) on y is greater than maximum: min = " + + std::to_string(translate_range_[dimension_two]) + + ", max = " + std::to_string(translate_range_[dimension_three]); LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg); } RETURN_IF_NOT_OK( @@ -96,18 +97,18 @@ Status RandomAffineOperation::ValidateParams() { RETURN_IF_NOT_OK(ValidateVectorScale("RandomAffine", scale_range_)); // Shear if (shear_ranges_.size() != size_two && shear_ranges_.size() != size_four) { - std::string err_msg = "RandomAffine: shear_ranges expecting size 2 or 4, got: shear_ranges.size() = " + - std::to_string(shear_ranges_.size()); + std::string err_msg = + "RandomAffine: 'shear'(shear_range) expecting size 2 or 4, got size:" + std::to_string(shear_ranges_.size()); LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg); } if (shear_ranges_[dimension_zero] > shear_ranges_[dimension_one]) { - std::string err_msg = "RandomAffine: minimum of horizontal shear range is greater than maximum: min = " + + std::string err_msg = "RandomAffine: minimum of horizontal 'shear'(shear_range) is greater than maximum: min = " + std::to_string(shear_ranges_[dimension_zero]) + ", max = " + std::to_string(shear_ranges_[dimension_one]); LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg); } if (shear_ranges_.size() == size_four && shear_ranges_[dimension_two] > shear_ranges_[dimension_three]) { - std::string err_msg = "RandomAffine: minimum of vertical shear range is greater than maximum: min = " + + std::string err_msg = "RandomAffine: minimum of vertical 'shear'(shear_range) is greater than maximum: min = " + std::to_string(shear_ranges_[dimension_two]) + ", max = " + std::to_string(scale_range_[dimension_three]); LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg); diff --git a/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/random_color_ir.cc b/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/random_color_ir.cc index bad99e3b22c..32685cacb15 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/random_color_ir.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/ir/vision/random_color_ir.cc @@ -39,14 +39,14 @@ std::string RandomColorOperation::Name() const { return kRandomColorOperation; } Status RandomColorOperation::ValidateParams() { if (t_lb_ < 0 || t_ub_ < 0) { std::string err_msg = - "RandomColor: lower bound or upper bound must be greater than or equal to 0, got t_lb: " + std::to_string(t_lb_) + - ", t_ub: " + std::to_string(t_ub_); + "RandomColor: lower bound or upper bound must be greater than or equal to 0, got 'degree'(t_lb): " + + std::to_string(t_lb_) + ", 'degree'(t_ub): " + std::to_string(t_ub_); LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg); } if (t_lb_ > t_ub_) { std::string err_msg = - "RandomColor: lower bound must be less or equal to upper bound, got t_lb: " + std::to_string(t_lb_) + - ", t_ub: " + std::to_string(t_ub_); + "RandomColor: lower bound must be less or equal to upper bound, got 'degree'(t_lb): " + std::to_string(t_lb_) + + ", 'degree'(t_ub): " + std::to_string(t_ub_); LOG_AND_RETURN_STATUS_SYNTAX_ERROR(err_msg); } return Status::OK(); diff --git a/mindspore/ccsrc/minddata/dataset/kernels/plugin_op.cc b/mindspore/ccsrc/minddata/dataset/kernels/plugin_op.cc index fa8aea19c25..12935231e3d 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/plugin_op.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/plugin_op.cc @@ -26,7 +26,8 @@ Status PluginOp::PluginToTensorRow(const std::vector &in_row, Te for (const auto &tensor : in_row) { std::shared_ptr output; DataType tp = DataType(tensor.type_); - CHECK_FAIL_RETURN_UNEXPECTED(tp.IsNumeric() && tp != DataType::DE_UNKNOWN, "Unsupported type: " + tensor.type_); + CHECK_FAIL_RETURN_UNEXPECTED(tp.IsNumeric() && tp != DataType::DE_UNKNOWN, + "Input datatype should be numeric, got Unsupported type: " + tensor.type_); RETURN_IF_NOT_OK(Tensor::CreateFromMemory(TensorShape(tensor.shape_), tp, tensor.buffer_.data(), &output)); out_row->emplace_back(output); } diff --git a/mindspore/ccsrc/minddata/dataset/kernels/py_func_op.cc b/mindspore/ccsrc/minddata/dataset/kernels/py_func_op.cc index e18dd3ca03f..cf02149e3a2 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/py_func_op.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/py_func_op.cc @@ -93,7 +93,8 @@ ComputeReturn: ShapeMisMatch: ret = Status(StatusCode::kMDShapeMisMatch, __LINE__, __FILE__, - "PyFunc should return a numpy array or a numpy array tuple"); + "PyFunc should return a numpy array or a numpy array tuple, check data type of return value in user " + "defined python function."); goto ComputeReturn; TimeoutError: diff --git a/tests/ut/cpp/dataset/solarize_op_test.cc b/tests/ut/cpp/dataset/solarize_op_test.cc index e1e5a15b5c7..313bec7e6ab 100644 --- a/tests/ut/cpp/dataset/solarize_op_test.cc +++ b/tests/ut/cpp/dataset/solarize_op_test.cc @@ -161,7 +161,7 @@ TEST_F(MindDataTestSolarizeOp, TestOp6) { Status s = op->Compute(test_input_tensor, &test_output_tensor); EXPECT_TRUE(s.IsError()); - EXPECT_NE(s.ToString().find("Solarize: threshold_min must be smaller or equal to threshold_max."), + EXPECT_NE(s.ToString().find("Solarize: threshold[0] must be smaller or equal to threshold[1], got 'threshold' value"), std::string::npos); ASSERT_TRUE(s.StatusCode() == StatusCode::kMDUnexpectedError); } \ No newline at end of file