Browse Source

!1648 dts: shape range support update shape

From: @zhengyuanhua
Reviewed-by: @ji_chen,@wqtshg
Signed-off-by: @ji_chen
tags/v1.3.0
mindspore-ci-bot Gitee 4 years ago
parent
commit
375652e05c
1 changed files with 15 additions and 5 deletions
  1. +15
    -5
      ge/ir_build/option_utils.cc

+ 15
- 5
ge/ir_build/option_utils.cc View File

@@ -847,18 +847,23 @@ Status UpdateDataOpShapeRange(const OpDescPtr &op,
GELOGE(PARAM_INVALID, "[Check][OpDescPtr] Check shape by shape range failed for op:%s.", data_op_name.c_str());
return PARAM_INVALID;
}
for (size_t idx = 0; idx < cur_shape_range.size(); idx++) {
std::vector<int64_t> dims;
for (size_t idx = 0; idx < cur_shape_range.size(); ++idx) {
auto left_range = cur_shape_range[idx].first;
auto right_range = cur_shape_range[idx].second;
if (left_range != right_range) {
origin_shape.SetDim(idx, UNKNOWN_DIM);
dims.push_back(UNKNOWN_DIM);
} else {
dims.push_back(left_range);
}
}
origin_shape = GeShape(dims);
tensor_input->SetShape(origin_shape);
tensor_input->SetShapeRange(cur_shape_range);
tensor_output->SetShape(origin_shape);
tensor_output->SetShapeRange(cur_shape_range);
GELOGI("Update input [%s] shape range info", data_op_name.c_str());
GELOGI("Update input [%s] shape range and shape [%s] info success.",
data_op_name.c_str(), origin_shape.ToString().c_str());
} else {
GELOGI("No need to update input [%s] attr because not found from input_shape_range.", data_op_name.c_str());
}
@@ -900,18 +905,23 @@ Status UpdateDataOpShapeRange(const OpDescPtr &op,
GELOGE(PARAM_INVALID, "[Check][OpDescPtr] Check shape by shape range failed for op:%s.", data_op_name.c_str());
return PARAM_INVALID;
}
std::vector<int64_t> dims;
for (size_t idx = 0; idx < cur_shape_range.size(); ++idx) {
auto left_range = cur_shape_range[idx].first;
auto right_range = cur_shape_range[idx].second;
if (left_range != right_range) {
origin_shape.SetDim(idx, UNKNOWN_DIM);
dims.push_back(UNKNOWN_DIM);
} else {
dims.push_back(left_range);
}
}
origin_shape = GeShape(dims);
tensor_input->SetShape(origin_shape);
tensor_input->SetShapeRange(cur_shape_range);
tensor_output->SetShape(origin_shape);
tensor_output->SetShapeRange(cur_shape_range);
GELOGI("Update input [%s] shape range info success.", data_op_name.c_str());
GELOGI("Update input [%s] shape range and shape [%s] info success.",
data_op_name.c_str(), origin_shape.ToString().c_str());

return SUCCESS;
}


Loading…
Cancel
Save