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