From cb44858dbf5fd892952ced1f83ea55cf526560d5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 26 Feb 2021 20:36:38 +0800 Subject: [PATCH 1/7] Add single_op model_id. --- inc/framework/executor/ge_executor.h | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/framework/executor/ge_executor.h b/inc/framework/executor/ge_executor.h index c546f63d..59a1f8ab 100644 --- a/inc/framework/executor/ge_executor.h +++ b/inc/framework/executor/ge_executor.h @@ -260,6 +260,7 @@ class GE_FUNC_VISIBILITY GeExecutor { static ge::Status LoadSingleOp(const std::string &modelName, const ge::ModelData &modelData, void *stream, SingleOp **single_op); + static ge::Status ExecuteAsync(SingleOp *executor, const std::vector &inputs, std::vector &outputs); From 8143392f00cfd491248606d277826c74bdfa1132 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 27 Feb 2021 15:53:36 +0800 Subject: [PATCH 2/7] Add single_op model_id. --- ge/executor/ge_executor.cc | 14 ++++++- .../executor/hybrid_model_async_executor.cc | 3 +- ge/single_op/single_op_manager.cc | 9 ++-- ge/single_op/single_op_manager.h | 6 ++- inc/framework/executor/ge_executor.h | 5 +++ tests/ut/ge/CMakeLists.txt | 5 +++ tests/ut/ge/executor/ge_exeutor_unittest.cc | 42 +++++++++++++++++++ 7 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 tests/ut/ge/executor/ge_exeutor_unittest.cc diff --git a/ge/executor/ge_executor.cc b/ge/executor/ge_executor.cc index c4088421..fe223b1b 100755 --- a/ge/executor/ge_executor.cc +++ b/ge/executor/ge_executor.cc @@ -931,12 +931,22 @@ Status GeExecutor::GetMemAndWeightSize(const void *model_data, size_t model_size Status GeExecutor::LoadSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, SingleOp **single_op) { - return SingleOpManager::GetInstance().GetOpFromModel(model_name, modelData, stream, single_op); + return LoadSingleOp(model_name, modelData, stream, single_op, 0); +} + +Status GeExecutor::LoadSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, + SingleOp **single_op, const uint64_t model_id) { + return SingleOpManager::GetInstance().GetOpFromModel(model_name, modelData, stream, single_op, model_id); } Status GeExecutor::LoadDynamicSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, DynamicSingleOp **single_op) { - return SingleOpManager::GetInstance().GetDynamicOpFromModel(model_name, modelData, stream, single_op); + return LoadDynamicSingleOp((model_name, modelData, stream, single_op, 0); +} + +Status GeExecutor::LoadDynamicSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, + DynamicSingleOp **single_op, const uint64_t model_id) { + return SingleOpManager::GetInstance().GetDynamicOpFromModel(model_name, modelData, stream, single_op, model_id); } Status GeExecutor::ExecuteAsync(SingleOp *executor, const std::vector &inputs, diff --git a/ge/hybrid/executor/hybrid_model_async_executor.cc b/ge/hybrid/executor/hybrid_model_async_executor.cc index 97fb9d50..967b17bf 100644 --- a/ge/hybrid/executor/hybrid_model_async_executor.cc +++ b/ge/hybrid/executor/hybrid_model_async_executor.cc @@ -251,7 +251,8 @@ Status HybridModelAsyncExecutor::PrepareInputs(const InputData ¤t_data, Hy if (k >= shape.GetDimNum()) { break; } - if (shape.GetDim(k) < range[k].first || shape.GetDim(k) > range[k].second) { + // range[k].second can be -1 + if (shape.GetDim(k) < range[k].first || (range[k].second >= 0 && 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; diff --git a/ge/single_op/single_op_manager.cc b/ge/single_op/single_op_manager.cc index ccbdbe3f..3cdb7f7d 100644 --- a/ge/single_op/single_op_manager.cc +++ b/ge/single_op/single_op_manager.cc @@ -30,8 +30,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY SingleOpManager::~SingleOpManag FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status SingleOpManager::GetOpFromModel(const std::string &model_name, const ModelData &model_data, void *stream, - SingleOp **single_op) { - GELOGI("GetOpFromModel in. model name = %s", model_name.c_str()); + SingleOp **single_op, + const uint64_t model_id) { + GELOGI("GetOpFromModel in. model name = %s, model id = %lu", model_name.c_str(), model_id); if (single_op == nullptr) { GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "single op is null"); return ACL_ERROR_GE_INTERNAL_ERROR; @@ -99,7 +100,9 @@ StreamResource *SingleOpManager::TryGetResource(uintptr_t resource_id) { Status SingleOpManager::GetDynamicOpFromModel(const string &model_name, const ModelData &model_data, void *stream, - DynamicSingleOp **single_op) { + DynamicSingleOp **single_op, + const uint64_t model_id) { + GELOGI("GetOpFromModel in. model name = %s, model id = %lu", model_name.c_str(), model_id); if (!tiling_func_registered_) { RegisterTilingFunc(); } diff --git a/ge/single_op/single_op_manager.h b/ge/single_op/single_op_manager.h index e6d10980..c3fff3f4 100644 --- a/ge/single_op/single_op_manager.h +++ b/ge/single_op/single_op_manager.h @@ -37,12 +37,14 @@ class SingleOpManager { Status GetOpFromModel(const std::string &model_name, const ge::ModelData &model_data, void *stream, - SingleOp **single_op); + SingleOp **single_op, + const uint64_t model_id); Status GetDynamicOpFromModel(const std::string &model_name, const ge::ModelData &model_data, void *stream, - DynamicSingleOp **dynamic_single_op); + DynamicSingleOp **dynamic_single_op, + const uint64_t model_id); StreamResource *GetResource(uintptr_t resource_id, rtStream_t stream); diff --git a/inc/framework/executor/ge_executor.h b/inc/framework/executor/ge_executor.h index 59a1f8ab..ac08e473 100644 --- a/inc/framework/executor/ge_executor.h +++ b/inc/framework/executor/ge_executor.h @@ -260,6 +260,8 @@ class GE_FUNC_VISIBILITY GeExecutor { static ge::Status LoadSingleOp(const std::string &modelName, const ge::ModelData &modelData, void *stream, SingleOp **single_op); + static ge::Status LoadSingleOp(const std::string &modelName, const ge::ModelData &modelData, void *stream, + SingleOp **single_op, const uint64_t model_id); static ge::Status ExecuteAsync(SingleOp *executor, const std::vector &inputs, std::vector &outputs); @@ -267,6 +269,9 @@ class GE_FUNC_VISIBILITY GeExecutor { static ge::Status LoadDynamicSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, DynamicSingleOp **single_op); + static ge::Status LoadDynamicSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, + DynamicSingleOp **single_op, const uint64_t model_id); + static ge::Status ExecuteAsync(DynamicSingleOp *executor, const std::vector &input_desc, const std::vector &inputs, std::vector &output_desc, std::vector &outputs); diff --git a/tests/ut/ge/CMakeLists.txt b/tests/ut/ge/CMakeLists.txt index b8eb3e22..a2b4a6dd 100755 --- a/tests/ut/ge/CMakeLists.txt +++ b/tests/ut/ge/CMakeLists.txt @@ -760,6 +760,10 @@ set(GENERATOR_TEST_FILES "generator/ge_generator_unittest.cc" ) +set(EXECUTOR_TEST_FILES + "executor/ge_executor_unittest.cc" +) + set(SINGLE_OP_TEST_FILES "single_op/single_op_model_unittest.cc" "single_op/single_op_manager_unittest.cc" @@ -1066,6 +1070,7 @@ target_link_libraries(ut_libge_kernel_utest add_executable(ut_libge_distinct_load_utest ${COMMON_TEST_FILES} ${GENERATOR_TEST_FILES} + ${EXECUTOR_TEST_FILES} ${DISTINCT_GRAPH_LOAD_TEST_FILES} ${DISTINCT_GRAPH_LOAD_SRC_FILES} ${SINGLE_OP_TEST_FILES} diff --git a/tests/ut/ge/executor/ge_exeutor_unittest.cc b/tests/ut/ge/executor/ge_exeutor_unittest.cc new file mode 100644 index 00000000..a98f9290 --- /dev/null +++ b/tests/ut/ge/executor/ge_exeutor_unittest.cc @@ -0,0 +1,42 @@ +/** + * Copyright 2019-2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#define private public +#define protected public +#include "executor/ge_executor.h" +#include "graph/utils/tensor_utils.h" + +using namespace std; + +namespace ge { +class UtestGeExecutor : public testing::Test { + protected: + void SetUp() {} + + void TearDown() {} +}; + +TEST_F(UtestGeExecutor, test_single_op_exec) { + GeExecutor exeutor; + ModelData model_data; + string model_name = "1234"; + + EXPECT_EQ(exeutor.LoadSingleOp(model_name, model_data, nullptr, nullptr), ACL_ERROR_GE_INTERNAL_ERROR); + EXPECT_EQ(exeutor.LoadDynamicSingleOp(model_name, model_data, nullptr, nullptr), PARAM_INVALID); +} +} // namespace ge \ No newline at end of file From 5287444a69e2d1188134ca94af64513ac1c9dd48 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 27 Feb 2021 15:59:23 +0800 Subject: [PATCH 3/7] Add single_op model_id. --- .../executor/{ge_exeutor_unittest.cc => ge_executor_unittest.cc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/ut/ge/executor/{ge_exeutor_unittest.cc => ge_executor_unittest.cc} (100%) diff --git a/tests/ut/ge/executor/ge_exeutor_unittest.cc b/tests/ut/ge/executor/ge_executor_unittest.cc similarity index 100% rename from tests/ut/ge/executor/ge_exeutor_unittest.cc rename to tests/ut/ge/executor/ge_executor_unittest.cc From e84eb1eb43c90ab180673d887807d68600ca0c26 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 27 Feb 2021 16:27:59 +0800 Subject: [PATCH 4/7] Add single_op model_id. --- ge/executor/ge_executor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/executor/ge_executor.cc b/ge/executor/ge_executor.cc index fe223b1b..b3353af8 100755 --- a/ge/executor/ge_executor.cc +++ b/ge/executor/ge_executor.cc @@ -941,7 +941,7 @@ Status GeExecutor::LoadSingleOp(const std::string &model_name, const ge::ModelDa Status GeExecutor::LoadDynamicSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, DynamicSingleOp **single_op) { - return LoadDynamicSingleOp((model_name, modelData, stream, single_op, 0); + return LoadDynamicSingleOp(model_name, modelData, stream, single_op, 0); } Status GeExecutor::LoadDynamicSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, From 1c10a5ace33dc555aa6d15112042acb3db16a362 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 27 Feb 2021 17:21:27 +0800 Subject: [PATCH 5/7] Add single_op model_id. --- ge/executor/ge_executor.cc | 8 ++++---- inc/framework/executor/ge_executor.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ge/executor/ge_executor.cc b/ge/executor/ge_executor.cc index b3353af8..f33d7758 100755 --- a/ge/executor/ge_executor.cc +++ b/ge/executor/ge_executor.cc @@ -931,20 +931,20 @@ Status GeExecutor::GetMemAndWeightSize(const void *model_data, size_t model_size Status GeExecutor::LoadSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, SingleOp **single_op) { - return LoadSingleOp(model_name, modelData, stream, single_op, 0); + return LoadSingleOpV2(model_name, modelData, stream, single_op, 0); } -Status GeExecutor::LoadSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, +Status GeExecutor::LoadSingleOpV2(const std::string &model_name, const ge::ModelData &modelData, void *stream, SingleOp **single_op, const uint64_t model_id) { return SingleOpManager::GetInstance().GetOpFromModel(model_name, modelData, stream, single_op, model_id); } Status GeExecutor::LoadDynamicSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, DynamicSingleOp **single_op) { - return LoadDynamicSingleOp(model_name, modelData, stream, single_op, 0); + return LoadDynamicSingleOpV2(model_name, modelData, stream, single_op, 0); } -Status GeExecutor::LoadDynamicSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, +Status GeExecutor::LoadDynamicSingleOpV2(const std::string &model_name, const ge::ModelData &modelData, void *stream, DynamicSingleOp **single_op, const uint64_t model_id) { return SingleOpManager::GetInstance().GetDynamicOpFromModel(model_name, modelData, stream, single_op, model_id); } diff --git a/inc/framework/executor/ge_executor.h b/inc/framework/executor/ge_executor.h index ac08e473..732e47aa 100644 --- a/inc/framework/executor/ge_executor.h +++ b/inc/framework/executor/ge_executor.h @@ -260,7 +260,7 @@ class GE_FUNC_VISIBILITY GeExecutor { static ge::Status LoadSingleOp(const std::string &modelName, const ge::ModelData &modelData, void *stream, SingleOp **single_op); - static ge::Status LoadSingleOp(const std::string &modelName, const ge::ModelData &modelData, void *stream, + static ge::Status LoadSingleOpV2(const std::string &modelName, const ge::ModelData &modelData, void *stream, SingleOp **single_op, const uint64_t model_id); static ge::Status ExecuteAsync(SingleOp *executor, const std::vector &inputs, @@ -269,7 +269,7 @@ class GE_FUNC_VISIBILITY GeExecutor { static ge::Status LoadDynamicSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, DynamicSingleOp **single_op); - static ge::Status LoadDynamicSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, + static ge::Status LoadDynamicSingleOpV2(const std::string &model_name, const ge::ModelData &modelData, void *stream, DynamicSingleOp **single_op, const uint64_t model_id); static ge::Status ExecuteAsync(DynamicSingleOp *executor, const std::vector &input_desc, From c580af353b17f025259d612f86659e89f699be82 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 27 Feb 2021 17:47:40 +0800 Subject: [PATCH 6/7] Add single_op model_id. --- inc/framework/executor/ge_executor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/framework/executor/ge_executor.h b/inc/framework/executor/ge_executor.h index 732e47aa..9da630c9 100644 --- a/inc/framework/executor/ge_executor.h +++ b/inc/framework/executor/ge_executor.h @@ -261,7 +261,7 @@ class GE_FUNC_VISIBILITY GeExecutor { SingleOp **single_op); static ge::Status LoadSingleOpV2(const std::string &modelName, const ge::ModelData &modelData, void *stream, - SingleOp **single_op, const uint64_t model_id); + SingleOp **single_op, const uint64_t model_id); static ge::Status ExecuteAsync(SingleOp *executor, const std::vector &inputs, std::vector &outputs); @@ -270,7 +270,7 @@ class GE_FUNC_VISIBILITY GeExecutor { DynamicSingleOp **single_op); static ge::Status LoadDynamicSingleOpV2(const std::string &model_name, const ge::ModelData &modelData, void *stream, - DynamicSingleOp **single_op, const uint64_t model_id); + DynamicSingleOp **single_op, const uint64_t model_id); static ge::Status ExecuteAsync(DynamicSingleOp *executor, const std::vector &input_desc, const std::vector &inputs, std::vector &output_desc, From 608c054f2beb933cee1cf4d19772a3c9bbd264ef Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 27 Feb 2021 18:09:51 +0800 Subject: [PATCH 7/7] Add single_op model_id. --- ge/executor/ge_executor.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ge/executor/ge_executor.cc b/ge/executor/ge_executor.cc index f33d7758..d02ae3dc 100755 --- a/ge/executor/ge_executor.cc +++ b/ge/executor/ge_executor.cc @@ -935,7 +935,7 @@ Status GeExecutor::LoadSingleOp(const std::string &model_name, const ge::ModelDa } Status GeExecutor::LoadSingleOpV2(const std::string &model_name, const ge::ModelData &modelData, void *stream, - SingleOp **single_op, const uint64_t model_id) { + SingleOp **single_op, const uint64_t model_id) { return SingleOpManager::GetInstance().GetOpFromModel(model_name, modelData, stream, single_op, model_id); } @@ -945,7 +945,7 @@ Status GeExecutor::LoadDynamicSingleOp(const std::string &model_name, const ge:: } Status GeExecutor::LoadDynamicSingleOpV2(const std::string &model_name, const ge::ModelData &modelData, void *stream, - DynamicSingleOp **single_op, const uint64_t model_id) { + DynamicSingleOp **single_op, const uint64_t model_id) { return SingleOpManager::GetInstance().GetDynamicOpFromModel(model_name, modelData, stream, single_op, model_id); }