Browse Source

modified: ge/graph/preprocess/graph_preprocess.cc

pull/931/head
zhaoxinxin 5 years ago
parent
commit
fc022ea9be
1 changed files with 20 additions and 6 deletions
  1. +20
    -6
      ge/graph/preprocess/graph_preprocess.cc

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

@@ -935,7 +935,10 @@ Status ParseDynamicInputShapeRange(const std::string &shape_range,
return PARAM_INVALID;
}
for (auto &shape_range_str : shape_range_set) {
if (shape_range_str.empty()) {
if (shape_range_str.size() < 3) {
// shape_range_str should be "[2~3,1"
// or ",[2~3,1". because we should trim '[' or ',['
// so shape_range_str.size() < 3 is invalid
continue;
}
// trim start bytes, after that, single input should be "1~20,3,3~6,-1"
@@ -1017,16 +1020,27 @@ Status UpdateDynamicInputShapeRange(const ge::GeAttrValue::INT index,
return PARAM_INVALID;
}
for (size_t i = 0; i < origin_shape.GetDimNum(); ++i) {
if (current_shape_range_vec.at(i).first == current_shape_range_vec.at(i).second) {
auto curr_dim = origin_shape.GetDim(i);
auto left_range = current_shape_range_vec.at(i).first;
auto right_range = current_shape_range_vec.at(i).second;
if (left_range == right_range) {
// given shape_range is known dim, check is same as origin or not
if (origin_shape.GetDim(i) != current_shape_range_vec.at(i).first) {
if (curr_dim != left_range) {
GELOGE(PARAM_INVALID, "Given shape range is %ld, current dim shape is %ld, not match.Pleace Check.",
current_shape_range_vec.at(i).first, origin_shape.GetDim(i));
left_range, curr_dim);
return PARAM_INVALID;
}
origin_shape.SetDim(i, current_shape_range_vec.at(i).first);
origin_shape.SetDim(i, left_range);
} else {
origin_shape.SetDim(i, -1);
// given shape_range is fix range, check input_shape is in this range or not
if (right_range != UNKNOWN_DIM) {
if ((curr_dim < left_range) || (curr_dim > right_range)) {
GELOGE(PARAM_INVALID, "Given shape range is [%ld~%ld], current dim shape is %ld, out of range.Pleace Check.",
left_range, right_range, curr_dim);
return PARAM_INVALID;
}
}
origin_shape.SetDim(i, UNKNOWN_DIM);
}
}
desc.SetShape(origin_shape);


Loading…
Cancel
Save