From a4ce346a855d47fd7789ad62b9a9e349c688899c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 Feb 2021 20:25:42 +0800 Subject: [PATCH 1/2] Add check input out of range. --- .../executor/hybrid_model_async_executor.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ge/hybrid/executor/hybrid_model_async_executor.cc b/ge/hybrid/executor/hybrid_model_async_executor.cc index a30f7daf..2f02e38b 100644 --- a/ge/hybrid/executor/hybrid_model_async_executor.cc +++ b/ge/hybrid/executor/hybrid_model_async_executor.cc @@ -241,7 +241,22 @@ Status HybridModelAsyncExecutor::PrepareInputs(const InputData ¤t_data, Hy return PARAM_INVALID; } auto &tensor_desc = input_tensor_desc_[input_index]; - tensor_desc->SetShape(GeShape(current_data.shapes[input_index])); + GeShape shape(current_data.shapes[input_index]); + std::vector> range; + auto range_ret = tensor_desc->GetShapeRange(range); + GE_CHK_BOOL_RET_STATUS(range_ret == GRAPH_SUCCESS, INTERNAL_ERROR, + "Get shape range failed, ret=%u.", range_ret); + for (size_t k = 0; k < range.size(); ++k) { + if (k >= shape.GetDimNum()) { + break; + } + if (shape.GetDim(k) < range[k].first || shape.GetDim(k) > range[k].second) { + GELOGE(PARAM_INVALID, "Dim out of range, shape idx = %zu, dim idx = %zu, dim = %ld, range = [%ld, %ld]", + input_index, k, shape.GetDim(k), range[k].first, range[k].second); + return PARAM_INVALID; + } + } + tensor_desc->SetShape(shape); args.input_desc[input_index] = tensor_desc; GELOGD("Update shape of input[%zu] to [%s]", input_index, tensor_desc->MutableShape().ToString().c_str()); GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetTensorMemorySizeInBytes(*tensor_desc, tensor_size), From 34efdaa68efe96975b35d7dc3bb08211fb5ae175 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 Feb 2021 20:35:51 +0800 Subject: [PATCH 2/2] Add check input out of range. --- ge/hybrid/executor/hybrid_model_async_executor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/hybrid/executor/hybrid_model_async_executor.cc b/ge/hybrid/executor/hybrid_model_async_executor.cc index 2f02e38b..1b5afb83 100644 --- a/ge/hybrid/executor/hybrid_model_async_executor.cc +++ b/ge/hybrid/executor/hybrid_model_async_executor.cc @@ -245,7 +245,7 @@ Status HybridModelAsyncExecutor::PrepareInputs(const InputData ¤t_data, Hy std::vector> range; auto range_ret = tensor_desc->GetShapeRange(range); GE_CHK_BOOL_RET_STATUS(range_ret == GRAPH_SUCCESS, INTERNAL_ERROR, - "Get shape range failed, ret=%u.", range_ret); + "Get shape range failed, ret=%u.", range_ret); for (size_t k = 0; k < range.size(); ++k) { if (k >= shape.GetDimNum()) { break;