diff --git a/ge/ir_build/atc_ir_common.cc b/ge/ir_build/atc_ir_common.cc index 6ce6ce7b..4d4a67f0 100755 --- a/ge/ir_build/atc_ir_common.cc +++ b/ge/ir_build/atc_ir_common.cc @@ -55,6 +55,7 @@ const char *const kDigitError = "is not digit"; const char *const kCompressWeightError = "it must be appointed when appoint parameter[--optypelist_for_implmode]"; const char *const kSelectImplmodeError = "only support high_performance, high_precision"; const char *const kDynamicBatchSizeError = "It can only contains digit, \",\", \" \""; +const char *const kDynamicImageSizeError = "It can only contains digit, \",\", \" \" and \";\""; const char *const kKeepDtypeError = "file not found"; const char *const kInputShapeRangeInvalid = "format of shape range is invalid"; const char *const kShapeRangeValueConvertError = "transfer from string to int64 error"; @@ -170,6 +171,16 @@ bool CheckDynamicImagesizeInputShapeValid(map> shape_map } EraseEndSemicolon(dynamic_image_size); + for (char c : dynamic_image_size) { + bool is_char_valid = isdigit(c) || (c == ',') || (c == ' ') || (c == ';'); + if (!is_char_valid) { + ErrorManager::GetInstance().ATCReportErrMessage( + "E10033", {"value", "reason"}, {dynamic_image_size, kDynamicImageSizeError}); + GELOGE(ge::PARAM_INVALID, "[Check][DynamicImageSizeInputShape] --dynamic_image_size:%s is invalid. reason: %s", + dynamic_image_size.c_str(), kDynamicImageSizeError); + return false; + } + } // Different parameter sets are split string by ';' std::vector split_set = StringUtils::Split(dynamic_image_size, ';'); // Different dimensions are split by ',' diff --git a/tests/ut/ge/graph_ir/ge_ir_build_unittest.cc b/tests/ut/ge/graph_ir/ge_ir_build_unittest.cc index dd6b1881..0c7bf651 100644 --- a/tests/ut/ge/graph_ir/ge_ir_build_unittest.cc +++ b/tests/ut/ge/graph_ir/ge_ir_build_unittest.cc @@ -108,3 +108,13 @@ TEST(UtestIrCommon, update_dynamic_shape_range_failed) { ret = UpdateDynamicInputShapeRange(graph, input_shape_range); EXPECT_EQ(ret, ge::PARAM_INVALID); } + +TEST(UtestIrCommon, check_dynamic_image_size_fail) { + map> shape_map; + shape_map["input1"] = {8, 3, -1, -1}; + string input_format = "NCHW"; + string dynamic_image_size = "@64,64;128,128;"; + + bool ret = CheckDynamicImagesizeInputShapeValid(shape_map, input_format, dynamic_image_size); + EXPECT_EQ(ret, false); +} \ No newline at end of file