diff --git a/mindspore/core/ops/batch_matmul.cc b/mindspore/core/ops/batch_matmul.cc index 661d625543e..ed9fcc3f66c 100644 --- a/mindspore/core/ops/batch_matmul.cc +++ b/mindspore/core/ops/batch_matmul.cc @@ -118,8 +118,8 @@ abstract::ShapePtr BatchMatmulInferShape(const PrimitivePtr &primitive, auto x_c = x_shp[x_offset + (transpose_a ? 0 : 1)]; auto y_r = y_shp[y_offset + (transpose_b ? 1 : 0)]; if (x_c != y_r) { - MS_LOG(EXCEPTION) << "BatchMatMul shape error, got x_col: " << x_c << ", y_row: " << y_r - << ". In BatchMatMul x_col and y_row must be equal."; + MS_LOG(EXCEPTION) << "For '" << prim_name << "', x_col must be equal to y_row. But got x_col: " << x_c + << ", y_row: " << y_r << "."; } } ShapeVector ret_shape; diff --git a/mindspore/core/ops/dynamic_broadcast_gradient_args.cc b/mindspore/core/ops/dynamic_broadcast_gradient_args.cc index 64a8c4a6b2d..340b312b76f 100644 --- a/mindspore/core/ops/dynamic_broadcast_gradient_args.cc +++ b/mindspore/core/ops/dynamic_broadcast_gradient_args.cc @@ -52,7 +52,7 @@ int64_t CheckInputsAndGetShape(const AbstractBasePtr &input_arg, const string &p auto x_shape_data = x_shape->elements(); return SizeToLong(x_shape_data.size()); } else { - MS_EXCEPTION(TypeError) << "For '" << prim_name << "',the input type must be a tuple or Tensor."; + MS_EXCEPTION(TypeError) << "For '" << prim_name << "', the input type must be a tuple or Tensor."; } } diff --git a/mindspore/core/ops/einsum.cc b/mindspore/core/ops/einsum.cc index 573f91a9c4a..3d2e782a0ba 100644 --- a/mindspore/core/ops/einsum.cc +++ b/mindspore/core/ops/einsum.cc @@ -57,8 +57,8 @@ static void seg_left_equation(const std::string &left_equation, const std::strin } if (idx + kEinsumEllLen - 1 >= left_equation.length() || left_equation[idx + 1] != label || left_equation[idx + kEinsumEllLen - 1] != label) { - MS_EXCEPTION(ValueError) << "For " << prim_name - << ", An ellipsis in the equation should consist three \'.\', but got less than 3."; + MS_EXCEPTION(ValueError) << "For '" << prim_name + << "', an ellipsis in the equation must include three \'.\', but got less than 3."; } idx += (kEinsumEllLen - 1); found_ell = true; @@ -66,15 +66,15 @@ static void seg_left_equation(const std::string &left_equation, const std::strin } else if (label == ',') { if ((found_ell && (*left_elements)[cur_element].size() > input_shapes[cur_element].size() + 1) || (!found_ell && (*left_elements)[cur_element].size() != input_shapes[cur_element].size())) { - MS_EXCEPTION(ValueError) << "For " << prim_name << ", The number of subscript in " << cur_element - << " operand in the eqaution should match inputs[" << cur_element + MS_EXCEPTION(ValueError) << "For '" << prim_name << "', the number of subscript in " << cur_element + << " operand in the eqaution must match inputs[" << cur_element << "].dim(), but it does not."; } ++cur_element; if (cur_element >= input_shapes.size()) { MS_EXCEPTION(ValueError) - << "For " << prim_name - << ", the number of inputs must be equal to the number of inputs and equation's operand, but it does not."; + << "For '" << prim_name + << "', the number of inputs must be equal to the number of inputs and equation's operand, but it does not."; } found_ell = false; } else { @@ -84,14 +84,14 @@ static void seg_left_equation(const std::string &left_equation, const std::strin } if (cur_element != input_shapes.size() - 1) { MS_EXCEPTION(ValueError) - << "For " << prim_name - << ", the number of inputs must be equal to the number of inputs and equation's operand, but it does not."; + << "For '" << prim_name + << "', the number of inputs must be equal to the number of inputs and equation's operand, but it does not."; } for (size_t i = 0; i < (*left_elements).size(); ++i) { auto it = std::find((*left_elements)[i].begin(), (*left_elements)[i].end(), kEinsumEllVal); if ((*left_elements)[i].size() != input_shapes[i].size() && it == (*left_elements)[i].end()) { - MS_EXCEPTION(ValueError) << "For " << prim_name << ", The number of subscript in " << i - << " operand in the eqaution should match inputs[" << i << "].dim(), but it does not."; + MS_EXCEPTION(ValueError) << "For '" << prim_name << "', the number of subscript in " << i + << " operand in the eqaution must match inputs[" << i << "].dim(), but it does not."; } } } @@ -108,22 +108,20 @@ static void seg_right_equation_with_arrow(const std::string &left_equation, cons std::vector exit_flag(kEinsumLableNum, false); for (size_t idx = 0; idx < right_equation.length(); ++idx) { if (left_equation.find(right_equation[idx]) == std::string::npos) { - MS_EXCEPTION(ValueError) - << "For " << prim_name - << ", The label to the right of arrow in the equation must have appeared on the left, but the " - << right_equation[idx] << " not."; + MS_EXCEPTION(ValueError) << "For '" << prim_name + << "', the label to the right of arrow in the equation must appear on the left, but the " + << right_equation[idx] << " does not."; } if (right_equation[idx] == '.') { if (found_ell) { - MS_EXCEPTION(ValueError) - << "For " << prim_name - << ", each operand can contain contain only one ellipsis, but it has been found again."; + MS_EXCEPTION(ValueError) << "For '" << prim_name + << "', each operand can contain only one ellipsis, but it has been found again."; } if ((idx + kEinsumEllLen - 1 >= right_equation.length()) || (right_equation[idx + 1] != '.' || right_equation[idx + kEinsumEllLen - 1] != '.')) { - MS_EXCEPTION(ValueError) << "For " << prim_name - << ", An ellipsis in the equation should consist three \'.\', but got less than 3."; + MS_EXCEPTION(ValueError) << "For '" << prim_name + << "', an ellipsis in the equation must include three \'.\', but got less than 3."; } idx += (kEinsumEllLen - 1); found_ell = true; @@ -133,15 +131,15 @@ static void seg_right_equation_with_arrow(const std::string &left_equation, cons auto val = char_to_index(right_equation[idx]); if (exit_flag[val]) { MS_EXCEPTION(ValueError) - << "For " << prim_name - << ", each character in the right of arrow in equation can only exist no more than once, but got" + << "For '" << prim_name + << "', each character in the right of arrow in equation can only exist only once, but got" << right_equation[idx] << " at least twice."; } exit_flag[val] = true; out_shape->insert(out_shape->end(), (*element_shape_map)[val].begin(), (*element_shape_map)[val].end()); } else { - MS_EXCEPTION(ValueError) << "For " << prim_name << ", Operand " << right_equation - << " in the equation contains invalid subscript, which can only consist of [a-zA-z]."; + MS_EXCEPTION(ValueError) << "For '" << prim_name << "', operand " << right_equation + << " in the equation can only be consist of [a-zA-z], but found invalid character(s)."; } } } @@ -175,9 +173,9 @@ static void element_map_shape(const std::string &prim_name, const std::vectorfind(cur_element) != element_shape_map->end()) { if ((*element_shape_map)[cur_element][0] != input_shapes[idx_input][idx_left]) { MS_EXCEPTION(ValueError) - << "For " << prim_name - << ", the same label in equation can only represent the same dimension in inputs, but the " - << static_cast(cur_element + 'a') << " in equation not."; + << "For '" << prim_name + << "', the same label in equation can only represent the same dim in inputs, but got " + << static_cast(cur_element + 'a') << " in equation represented different dims."; } } else { (*element_shape_map)[cur_element] = {input_shapes[idx_input][idx_left]}; @@ -193,9 +191,9 @@ static void element_map_shape(const std::string &prim_name, const std::vectorfind(cur_element) != element_shape_map->end()) { if ((*element_shape_map)[cur_element][0] != input_shapes[idx_input][idx_shape_right]) { MS_EXCEPTION(ValueError) - << "For " << prim_name - << ", the same label in equation can only represent the same dimension in inputs, but the " - << static_cast(cur_element + 'a') << " in equation not."; + << "For '" << prim_name + << "', the same label in equation can only represent the same dimension in inputs, but got " + << static_cast(cur_element + 'a') << " in equation represented different dims."; } } else { (*element_shape_map)[cur_element] = {input_shapes[idx_input][idx_shape_right]}; @@ -208,8 +206,8 @@ static void element_map_shape(const std::string &prim_name, const std::vectorfind(kEinsumEllVal) != element_shape_map->end()) { if ((*element_shape_map)[kEinsumEllVal] != temp_vec) { MS_EXCEPTION(ValueError) - << "For " << prim_name - << ", the same ellipsis in equation can only represent the same dimension in inputs, but it does not."; + << "For '" << prim_name + << "', the same ellipsis in equation can only represent the same dimension in inputs, but it does not."; } } else { (*element_shape_map)[kEinsumEllVal] = temp_vec; @@ -240,7 +238,7 @@ abstract::ShapePtr EinsumInferShape(const PrimitivePtr &primitive, const std::ve const auto seg_pos = equation.find(seg_arrow); if (seg_pos == 0) { MS_EXCEPTION(ValueError) << "For '" << prim_name - << "', the equation should contain characters to the left of the arrow, but got none."; + << "', the equation must contain characters to the left of the arrow, but got none."; } (void)CheckAndConvertUtils::CheckInteger("input number", SizeToLong(input_args.size()), kGreaterEqual, 1, prim_name); @@ -249,7 +247,7 @@ abstract::ShapePtr EinsumInferShape(const PrimitivePtr &primitive, const std::ve } if (!input_args[0]->isa() && !input_args[0]->isa()) { - MS_EXCEPTION(TypeError) << "For " << prim_name << ", The input must be list or tuple of tensors."; + MS_EXCEPTION(TypeError) << "For '" << prim_name << "', the input must be a list or tuple of tensors."; } auto elements = input_args[0]->isa() ? input_args[0]->cast()->elements() diff --git a/mindspore/core/ops/grad/pool_grad.cc b/mindspore/core/ops/grad/pool_grad.cc index e39a85c0e65..bcf337b4e76 100644 --- a/mindspore/core/ops/grad/pool_grad.cc +++ b/mindspore/core/ops/grad/pool_grad.cc @@ -24,9 +24,9 @@ MIND_API_OPERATOR_IMPL(PoolGrad, BaseOperator); std::vector PoolGrad::_grad_check_vector(const std::string &arg_name, std::vector arg_val, const std::string &op_name) { std::vector ret; - std::string error_msg = "For '" + op_name + "'" + " the '" + arg_name + + std::string error_msg = "For '" + op_name + "'," + " the '" + arg_name + "' must be a vector of one, two or four " - "positive int number(s), but got error arg_val"; + "positive int number(s), but got error arg_val size."; switch ((int64_t)arg_val.size()) { case 1: ret = {1, 1, arg_val[0], arg_val[0]}; diff --git a/mindspore/core/ops/lp_norm.cc b/mindspore/core/ops/lp_norm.cc index 113a8d30ea9..87cd4ee125f 100644 --- a/mindspore/core/ops/lp_norm.cc +++ b/mindspore/core/ops/lp_norm.cc @@ -58,7 +58,7 @@ abstract::ShapePtr LpNormInferShape(const PrimitivePtr &primitive, const std::ve auto re_idx = std::find(temp.begin(), temp.end(), axis[i]); if (re_idx != temp.end()) { MS_EXCEPTION(ValueError) << "For '" << prim_name - << "', The element of the axis must be different, but got axis: " << axis << "."; + << "', the element of the axis must be different, but got axis: " << axis << "."; } if (keep_dims == false) { output_shape[axis[i]] = -1;