Browse Source

modified: ge/graph/preprocess/graph_preprocess.cc

tags/v1.2.0
zhaoxinxin 3 years ago
parent
commit
965f637f7d
1 changed files with 20 additions and 4 deletions
  1. +20
    -4
      ge/graph/preprocess/graph_preprocess.cc

+ 20
- 4
ge/graph/preprocess/graph_preprocess.cc View File

@@ -967,6 +967,13 @@ Status ParseDynamicInputShapeRange(const std::string &shape_range,
// unknown dim, should get range. // unknown dim, should get range.
auto range_left = StringToLongNoThrow(range_pair_set.at(0).c_str()); auto range_left = StringToLongNoThrow(range_pair_set.at(0).c_str());
auto range_right = StringToLongNoThrow(range_pair_set.at(1).c_str()); auto range_right = StringToLongNoThrow(range_pair_set.at(1).c_str());
if (range_left < 0 || range_right < 0) {
GELOGE(PARAM_INVALID,
"Shape range of input is invalid. Given range pair [%ld,%ld], while correct example: "
"\"[1~20,3,3~6,-1],[1~20,3,3~6,-1]\"",
range_left, range_right);
return PARAM_INVALID;
}
range_pair = std::make_pair(range_left, range_right); range_pair = std::make_pair(range_left, range_right);
} else { } else {
GELOGE(PARAM_INVALID, GELOGE(PARAM_INVALID,
@@ -983,21 +990,30 @@ Status ParseDynamicInputShapeRange(const std::string &shape_range,


Status GetDynamicInputShapeRange(const std::vector<GeTensor> &user_input, const std::map<string, string> &graph_option, Status GetDynamicInputShapeRange(const std::vector<GeTensor> &user_input, const std::map<string, string> &graph_option,
vector<vector<std::pair<int64_t, int64_t>>> &range_vec) { vector<vector<std::pair<int64_t, int64_t>>> &range_vec) {
bool enable_dynamic_execute_mode = true;
auto mode_iter = graph_option.find(OPTION_EXEC_DYNAMIC_EXECUTE_MODE); auto mode_iter = graph_option.find(OPTION_EXEC_DYNAMIC_EXECUTE_MODE);
if (mode_iter == graph_option.end()) { if (mode_iter == graph_option.end()) {
GELOGD("Graph Option: Can not find %s option in graph options.", OPTION_EXEC_DYNAMIC_EXECUTE_MODE); GELOGD("Graph Option: Can not find %s option in graph options.", OPTION_EXEC_DYNAMIC_EXECUTE_MODE);
return SUCCESS;
enable_dynamic_execute_mode = false;
} }
GELOGD("Graph Option: dynamic_input_mode value is %s.", mode_iter->second.c_str());
if (mode_iter->second != "dynamic_execute") {
return SUCCESS;
if (enable_dynamic_execute_mode) {
GELOGD("Graph Option: dynamic_input_mode value is %s.", mode_iter->second.c_str());
if (mode_iter->second != "dynamic_execute") {
enable_dynamic_execute_mode = false;
}
} }

auto iter = graph_option.find(OPTION_EXEC_DATA_INPUTS_SHAPE_RANGE); auto iter = graph_option.find(OPTION_EXEC_DATA_INPUTS_SHAPE_RANGE);
if (iter == graph_option.end()) { if (iter == graph_option.end()) {
GELOGE(PARAM_INVALID, "Graph option %s is required when %s is dynamic_execute", OPTION_EXEC_DATA_INPUTS_SHAPE_RANGE, GELOGE(PARAM_INVALID, "Graph option %s is required when %s is dynamic_execute", OPTION_EXEC_DATA_INPUTS_SHAPE_RANGE,
OPTION_EXEC_DYNAMIC_EXECUTE_MODE); OPTION_EXEC_DYNAMIC_EXECUTE_MODE);
return PARAM_INVALID; return PARAM_INVALID;
} }
if (!enable_dynamic_execute_mode) {
GELOGE(PARAM_INVALID, "Graph option %s is required when %s is enabled", OPTION_EXEC_DYNAMIC_EXECUTE_MODE,
OPTION_EXEC_DATA_INPUTS_SHAPE_RANGE);
return PARAM_INVALID;
}
GELOGD("GraphOption: dynamic_inputs_shape_range value is %s.", iter->second.c_str()); GELOGD("GraphOption: dynamic_inputs_shape_range value is %s.", iter->second.c_str());
auto ret = ParseDynamicInputShapeRange(iter->second, range_vec); auto ret = ParseDynamicInputShapeRange(iter->second, range_vec);
GE_CHK_STATUS_RET(ret, "Parse dynamic input shape range failed."); GE_CHK_STATUS_RET(ret, "Parse dynamic input shape range failed.");


Loading…
Cancel
Save