Browse Source

ut cov

pull/1193/head
wangxiaotian22 5 years ago
parent
commit
fee49b798b
4 changed files with 128 additions and 19 deletions
  1. +18
    -18
      ge/graph/load/model_manager/davinci_model.cc
  2. +1
    -1
      ge/graph/manager/graph_manager.cc
  3. +1
    -0
      tests/ut/ge/CMakeLists.txt
  4. +108
    -0
      tests/ut/ge/graph/build/graph_builder_unittest.cc

+ 18
- 18
ge/graph/load/model_manager/davinci_model.cc View File

@@ -214,12 +214,12 @@ DavinciModel::~DavinciModel() {
UnbindTaskSinkStream();
for (size_t i = 0; i < label_list_.size(); ++i) {
if (label_list_[i] != nullptr) {
GE_LOGW_IF(rtLabelDestroy(label_list_[i]) != RT_ERROR_NONE, "Destroy label failed, index:%zu", i);
GE_LOGW_IF(rtLabelDestroy(label_list_[i]) != RT_ERROR_NONE, "Destroy label failed, index:%zu.", i);
}
}

for (size_t i = 0; i < stream_list_.size(); ++i) {
GE_LOGW_IF(rtStreamDestroy(stream_list_[i]) != RT_ERROR_NONE, "Destroy stream failed, index:%zu", i);
GE_LOGW_IF(rtStreamDestroy(stream_list_[i]) != RT_ERROR_NONE, "Destroy stream failed, index:%zu.", i);
}

for (size_t i = 0; i < event_list_.size(); ++i) {
@@ -278,7 +278,7 @@ void DavinciModel::UnbindHcomStream() {
for (size_t i = 0; i < all_hccl_stream_list_.size(); i++) {
GE_LOGW_IF(rtModelUnbindStream(rt_model_handle_, all_hccl_stream_list_[i]) != RT_ERROR_NONE,
"Unbind hccl stream from model failed! Index: %zu", i);
GE_LOGW_IF(rtStreamDestroy(all_hccl_stream_list_[i]) != RT_ERROR_NONE, "Destroy hccl stream for rt_model failed!")
GE_LOGW_IF(rtStreamDestroy(all_hccl_stream_list_[i]) != RT_ERROR_NONE, "Destroy hccl stream for rt_model failed")
}
}
return;
@@ -364,7 +364,7 @@ Status DavinciModel::InitWeightMem(void *dev_ptr, void *weight_ptr, size_t weigh

Status DavinciModel::InitFeatureMapAndP2PMem(void *dev_ptr, size_t mem_size) {
if (is_feature_map_mem_has_inited_) {
GELOGE(PARAM_INVALID, "call InitFeatureMapMem more than once.");
GELOGE(PARAM_INVALID, "call InitFeatureMapMem more than once");
return PARAM_INVALID;
}
is_feature_map_mem_has_inited_ = true;
@@ -387,7 +387,7 @@ Status DavinciModel::InitFeatureMapAndP2PMem(void *dev_ptr, size_t mem_size) {
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Alloc feature map memory failed. size: %zu", data_size);
return ACL_ERROR_GE_MEMORY_ALLOCATION;
}
GEEVENT("[IMAS]InitFeatureMapAndP2PMem graph_%u MallocMemory type[F] memaddr[%p] mem_size[%zu].",
GEEVENT("[IMAS]InitFeatureMapAndP2PMem graph_%u MallocMemory type[F] memaddr[%p] mem_size[%zu]",
runtime_param_.graph_id, mem_base_, data_size);

if (!is_inner_weight_base_) {
@@ -408,7 +408,7 @@ Status DavinciModel::InitFeatureMapAndP2PMem(void *dev_ptr, size_t mem_size) {
is_inner_p2p_mem_base_ = true;
}

GE_CHK_STATUS_RET(InitVariableMem(), "Init variable memory failed");
GE_CHK_STATUS_RET(InitVariableMem(), "Init variable memory failed.");
runtime_param_.mem_base = mem_base_;
runtime_param_.weight_base = weights_mem_base_;
runtime_param_.memory_infos[RT_MEMORY_P2P_DDR].memory_base = p2p_mem_base_;
@@ -480,7 +480,7 @@ void DavinciModel::CheckHasHcomOp(const ComputeGraphPtr &compute_graph) {

for (const auto &node : compute_graph->GetAllNodes()) {
OpDescPtr op_desc = node->GetOpDesc();
GE_IF_BOOL_EXEC(op_desc == nullptr, GELOGW("Node OpDesc is nullptr"); continue);
GE_IF_BOOL_EXEC(op_desc == nullptr, GELOGW("Node OpDesc is nullptr."); continue);
if (hcom_opp_types.count(op_desc->GetType()) > 0) {
uint32_t stream_id = static_cast<uint32_t>(op_desc->GetStreamId());
hcom_streams_.emplace(stream_id);
@@ -527,25 +527,25 @@ Status DavinciModel::DoTaskSink() {
}

GE_CHK_RT_RET(rtGetAicpuDeploy(&deploy_type_));
GELOGI("do task_sink. AiCpu deploy type is: %x", deploy_type_);
GELOGI("do task_sink. AiCpu deploy type is: %x.", deploy_type_);

GE_CHK_STATUS_RET(BindModelStream(), "Bind model stream failed.");
GE_CHK_STATUS_RET(BindModelStream(), "Bind model stream failed");

if (known_node_) {
GE_CHK_STATUS_RET(MallocKnownArgs(), "Mallloc known node args failed.");
GE_CHK_STATUS_RET(MallocKnownArgs(), "Mallloc known node args failed");
}

GE_CHK_STATUS_RET(InitTaskInfo(*model_task_def.get()), "InitTaskInfo failed.");
GE_CHK_STATUS_RET(InitTaskInfo(*model_task_def.get()), "InitTaskInfo failed");

GE_CHK_STATUS_RET(ModelManager::GetInstance()->LaunchCustAicpuSo(), "Launch cust aicpu so failed.");
GE_CHK_STATUS_RET(ModelManager::GetInstance()->LaunchCustAicpuSo(), "Launch cust aicpu so failed");

GE_CHK_STATUS_RET(ModelManager::GetInstance()->CheckAicpuOpList(ge_model_), "Check aicpu op type failed.");
GE_CHK_STATUS_RET(ModelManager::GetInstance()->CheckAicpuOpList(ge_model_), "Check aicpu op type failed");

GE_CHK_STATUS_RET(InitEntryTask(), "InitEntryTask failed.");
GE_CHK_STATUS_RET(InitEntryTask(), "InitEntryTask failed");

GE_CHK_STATUS_RET(InitL1DataDumperArgs(), "InitL1DataDumperArgs failed.");
GE_CHK_STATUS_RET(InitL1DataDumperArgs(), "InitL1DataDumperArgs failed");

GE_CHK_STATUS_RET(DistributeTask(), "Distribute failed.");
GE_CHK_STATUS_RET(DistributeTask(), "Distribute failed");

GE_CHK_RT_RET(rtModelLoadComplete(rt_model_handle_));

@@ -558,7 +558,7 @@ Status DavinciModel::SetTSDevice() {
int64_t value = 0;
bool ret = ge::AttrUtils::GetInt(ge_model_, ATTR_MODEL_CORE_TYPE, value);
uint32_t core_type = ret ? static_cast<uint32_t>(value) : 0;
GELOGD("SetTSDevice: %u.", core_type);
GELOGD("SetTSDevice: %u", core_type);
rtError_t rt_ret = rtSetTSDevice(core_type);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "SetTSDevice failed, ret: 0x%X", rt_ret);
@@ -570,7 +570,7 @@ Status DavinciModel::SetTSDevice() {
Status DavinciModel::OpDebugRegister() {
bool is_op_debug = false;
(void)ge::AttrUtils::GetBool(ge_model_, ATTR_OP_DEBUG_FLAG, is_op_debug);
GELOGD("The value of op debug in ge_model is %d.", is_op_debug);
GELOGD("The value of op debug in ge_model is %d", is_op_debug);
if (is_op_debug) {
debug_reg_mutex_.lock();
rtError_t rt_ret = rtMalloc(&op_debug_addr_, kOpDebugMemorySize, RT_MEMORY_DDR);


+ 1
- 1
ge/graph/manager/graph_manager.cc View File

@@ -1524,7 +1524,7 @@ Status GraphManager::ParseOptions(const std::map<std::string, std::string> &opti
Status GraphManager::ParseTrainGraphFlag(bool &options, bool &option) {
std::shared_ptr<GELib> ge_instance_ptr = ge::GELib::GetInstance();
if (ge_instance_ptr == nullptr) {
GELOGW("[Initialize] set train_graph_flag to 0 when GE is not initialized or finalized.");
GELOGW("[Initialize] set train_graph_flag to 0 when GE is not initialized or finalized");
option = false;
} else if (!ge_instance_ptr->isTrainMode()) {
option = false;


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

@@ -752,6 +752,7 @@ set(MULTI_PARTS_TEST_FILES
"graph/variable_accelerate_ctrl_unittest.cc"
"graph/build/logical_stream_allocator_unittest.cc"
"graph/build/mem_assigner_unittest.cc"
"graph/build/graph_builder_unittest.cc"
"graph/preprocess/graph_preprocess_unittest.cc"
"graph/manager/hcom_util_unittest.cc"
"graph/manager/graph_caching_allocator_unittest.cc"


+ 108
- 0
tests/ut/ge/graph/build/graph_builder_unittest.cc View File

@@ -0,0 +1,108 @@
/**
* 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 <string>
#include <vector>
#include <gtest/gtest.h>
#define protected public
#define private public
#include "graph/manager/graph_manager_utils.h"
#undef protected
#undef private
#include "graph/build/logical_stream_allocator.h"
#include "common/types.h"
#include "common/util.h"
#include "graph/compute_graph.h"
#include "graph/utils/attr_utils.h"
#include "graph/utils/graph_utils.h"
using namespace std;
class UtestGraphBuilder : public testing::Test {
protected:
void SetUp() {}
void TearDown() {}
void MakeGraph(ge::ComputeGraphPtr &graph) {
ge::OpDescPtr op_def_a = CreateOpWithWsSize("A", 6000);
op_def_a->SetStreamId(0);
ge::OpDescPtr op_def_b = CreateOpWithWsSize("B", 120000);
op_def_b->SetStreamId(0);
ge::OpDescPtr op_def_c = CreateOpWithWsSize("C", 16000);
op_def_c->SetStreamId(1);
ge::OpDescPtr op_def_d = CreateOpWithWsSize("D", 24000);
op_def_d->SetStreamId(2);
ge::OpDescPtr op_def_e = CreateOpWithWsSize("E", 24000);
op_def_e->SetStreamId(3);
ge::OpDescPtr op_def_f = CreateOpWithWsSize("F", 30000);
op_def_f->SetStreamId(2);
ge::OpDescPtr op_def_g = CreateOpWithWsSize("G", 32000);
op_def_g->SetStreamId(3);
ge::OpDescPtr op_def_h = CreateOpWithWsSize("H", 48000);
op_def_h->SetStreamId(2);
ge::OpDescPtr op_def_i = CreateOpWithWsSize("I", 60000);
op_def_i->SetStreamId(2);
ge::OpDescPtr op_def_j = CreateOpWithWsSize("J", 256000, NETOUTPUT);
op_def_j->SetStreamId(3);
// add node
ge::NodePtr node_a = graph->AddNode(op_def_a);
ge::NodePtr node_b = graph->AddNode(op_def_b);
ge::NodePtr node_c = graph->AddNode(op_def_c);
ge::NodePtr node_d = graph->AddNode(op_def_d);
ge::NodePtr node_e = graph->AddNode(op_def_e);
ge::NodePtr node_f = graph->AddNode(op_def_f);
ge::NodePtr node_g = graph->AddNode(op_def_g);
ge::NodePtr node_h = graph->AddNode(op_def_h);
ge::NodePtr node_i = graph->AddNode(op_def_i);
ge::NodePtr node_j = graph->AddNode(op_def_j);
// add edge
ge::GraphUtils::AddEdge(node_a->GetOutDataAnchor(0), node_b->GetInDataAnchor(0));
ge::GraphUtils::AddEdge(node_a->GetOutDataAnchor(0), node_c->GetInDataAnchor(0));
ge::GraphUtils::AddEdge(node_b->GetOutDataAnchor(0), node_d->GetInDataAnchor(0));
ge::GraphUtils::AddEdge(node_b->GetOutDataAnchor(0), node_e->GetInDataAnchor(0));
ge::GraphUtils::AddEdge(node_c->GetOutDataAnchor(0), node_g->GetInDataAnchor(0));
ge::GraphUtils::AddEdge(node_d->GetOutDataAnchor(0), node_f->GetInDataAnchor(0));
ge::GraphUtils::AddEdge(node_e->GetOutDataAnchor(0), node_g->GetInDataAnchor(1));
ge::GraphUtils::AddEdge(node_f->GetOutDataAnchor(0), node_h->GetInDataAnchor(0));
ge::GraphUtils::AddEdge(node_g->GetOutDataAnchor(0), node_j->GetInDataAnchor(0));
ge::GraphUtils::AddEdge(node_h->GetOutDataAnchor(0), node_i->GetInDataAnchor(0));
ge::GraphUtils::AddEdge(node_i->GetOutDataAnchor(0), node_j->GetInDataAnchor(1));
GetContext().out_nodes_map["H"] = {0};
GetContext().out_nodes_map["I"] = {0};
GetContext().out_nodes_map["J"] = {0};
graph->TopologicalSorting();
}
};
TEST_F(UtestGraphBuilder, BuildForKnownShapeGraph_test) {
ge::ComputeGraphPtr graph = make_shared<ge::ComputeGraph>("");
MakeGraph(graph);
GraphBuilder builder;
GeModelPtr ge_model_ptr = nullptr;
builder.BuildForKnownShapeGraph(graph, ge_model_ptr, 0);
}

Loading…
Cancel
Save