Browse Source

Add ut.

tags/v1.3.0
unknown 3 years ago
parent
commit
a53a705c6f
3 changed files with 29 additions and 4 deletions
  1. +0
    -1
      ge/generator/ge_generator.cc
  2. +2
    -2
      ge/single_op/single_op_model.cc
  3. +27
    -1
      tests/ut/ge/single_op/single_op_model_unittest.cc

+ 0
- 1
ge/generator/ge_generator.cc View File

@@ -665,7 +665,6 @@ namespace {
}

Status CheckNoAicore(const ComputeGraphPtr &graph, bool &no_aicore) {
no_aicore = true;
for (const auto &node : graph->GetDirectNode()) {
GE_CHECK_NOTNULL(node);
auto op_desc = node->GetOpDesc();


+ 2
- 2
ge/single_op/single_op_model.cc View File

@@ -61,7 +61,7 @@ Status IfInferDepend(GeModelPtr &ge_model, bool &flag) {

Status NeedHybridModel(GeModelPtr &ge_model, bool &flag) {
bool infer_depend_flag = false;
GE_CHK_STATUS_RET_NOLOG(IfInferDepend(ge_model, infer_depend_flag));
GE_CHK_STATUS_RET(IfInferDepend(ge_model, infer_depend_flag), "[Check][IfInferDepend] failed.");
auto tasks = ge_model->GetModelTaskDefPtr()->task();
int32_t kernel_task_num = 0;
for (int i = 0; i < tasks.size(); ++i) {
@@ -531,7 +531,7 @@ Status SingleOpModel::BuildDynamicOp(StreamResource &resource, DynamicSingleOp &
auto ge_model = model_helper_.GetGeModel();
GE_CHECK_NOTNULL(ge_model);
bool need_hybrid_model = false;
GE_CHK_STATUS_RET_NOLOG(NeedHybridModel(ge_model, need_hybrid_model));
GE_CHK_STATUS_RET_NOLOG(NeedHybridModel(ge_model, need_hybrid_model), "[Check][NeedHybridModel] failed.");
if (need_hybrid_model) {
GELOGD("Build single op HybridModel.");
GE_CHK_STATUS_RET_NOLOG(hybrid::NodeExecutorManager::GetInstance().EnsureInitialized());


+ 27
- 1
tests/ut/ge/single_op/single_op_model_unittest.cc View File

@@ -17,7 +17,6 @@
#include <gtest/gtest.h>
#include <vector>

//#include "cce/taskdown_common.hpp"
#include "graph/load/model_manager/model_utils.h"
#include "graph/utils/graph_utils.h"
#include "runtime/rt.h"
@@ -196,4 +195,31 @@ TEST_F(UtestSingleOpModel, test_op_task_get_profiler_args) {
ASSERT_EQ(model_id, 1);
}

TEST_F(UtestSingleOpModel, test_build_dynamic_op) {
string model_data_str = "123456789";
SingleOpModel model("model", model_data_str.c_str(), model_data_str.size());
model.netoutput_op_ = make_shared<OpDesc>("NetOutput", "NetOutput");
model.model_helper_.model_ = ge::MakeShared<ge::GeModel>();

// make graph
auto compute_graph = make_shared<ComputeGraph>("graph");
auto data_op = make_shared<OpDesc>("Data", DATA);
auto data_node = compute_graph->AddNode(data_op);
auto graph = GraphUtils::CreateGraphFromComputeGraph(compute_graph);
model.model_helper_.model_->SetGraph(graph);

// set task_def
auto model_task_def = make_shared<domi::ModelTaskDef>();
domi::TaskDef *task_def = model_task_def->add_task();
task_def->set_type(RT_MODEL_TASK_KERNEL);
domi::KernelDef *kernel_def = task_def->mutable_kernel();
domi::KernelContext *context = kernel_def->mutable_context();
context->set_kernel_type(2); // ccKernelType::TE
model.model_helper_.model_->SetModelTaskDef(model_task_def);

std::mutex stream_mu_;
DynamicSingleOp dynamic_single_op(0, &stream_mu_, nullptr);
StreamResource res((uintptr_t)1);
model.BuildDynamicOp(res, dynamic_single_op);
}


Loading…
Cancel
Save