@@ -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<DataBuffer> &inputs, | |||
@@ -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; | |||
@@ -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(); | |||
} | |||
@@ -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); | |||
@@ -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<DataBuffer> &inputs, | |||
std::vector<DataBuffer> &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<GeTensorDesc> &input_desc, | |||
const std::vector<DataBuffer> &inputs, std::vector<GeTensorDesc> &output_desc, | |||
std::vector<DataBuffer> &outputs); | |||
@@ -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} | |||
@@ -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 <gtest/gtest.h> | |||
#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 |