Browse Source

!1164 Add single_op model_id.

From: @zhao_zhixuan
Reviewed-by: @xchu42,@ji_chen
Signed-off-by: @ji_chen
tags/v1.2.0
mindspore-ci-bot Gitee 3 years ago
parent
commit
1409400164
7 changed files with 77 additions and 8 deletions
  1. +12
    -2
      ge/executor/ge_executor.cc
  2. +2
    -1
      ge/hybrid/executor/hybrid_model_async_executor.cc
  3. +6
    -3
      ge/single_op/single_op_manager.cc
  4. +4
    -2
      ge/single_op/single_op_manager.h
  5. +6
    -0
      inc/framework/executor/ge_executor.h
  6. +5
    -0
      tests/ut/ge/CMakeLists.txt
  7. +42
    -0
      tests/ut/ge/executor/ge_executor_unittest.cc

+ 12
- 2
ge/executor/ge_executor.cc View File

@@ -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 LoadSingleOpV2(model_name, modelData, stream, single_op, 0);
}

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 SingleOpManager::GetInstance().GetDynamicOpFromModel(model_name, modelData, stream, single_op);
return LoadDynamicSingleOpV2(model_name, modelData, stream, single_op, 0);
}

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);
}

Status GeExecutor::ExecuteAsync(SingleOp *executor, const std::vector<DataBuffer> &inputs,


+ 2
- 1
ge/hybrid/executor/hybrid_model_async_executor.cc View File

@@ -251,7 +251,8 @@ Status HybridModelAsyncExecutor::PrepareInputs(const InputData &current_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;


+ 6
- 3
ge/single_op/single_op_manager.cc View File

@@ -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();
}


+ 4
- 2
ge/single_op/single_op_manager.h View File

@@ -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);



+ 6
- 0
inc/framework/executor/ge_executor.h View File

@@ -260,12 +260,18 @@ 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 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<DataBuffer> &inputs,
std::vector<DataBuffer> &outputs);

static ge::Status LoadDynamicSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream,
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);

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);


+ 5
- 0
tests/ut/ge/CMakeLists.txt View File

@@ -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}


+ 42
- 0
tests/ut/ge/executor/ge_executor_unittest.cc View File

@@ -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

Loading…
Cancel
Save