Browse Source

Pre Merge pull request !365 from lichun/development

pull/365/MERGE
lichun Gitee 4 years ago
parent
commit
9d912e4e51
12 changed files with 52 additions and 21 deletions
  1. +1
    -1
      ge/common/base64.h
  2. +2
    -1
      ge/executor/ge_executor.cc
  3. +1
    -1
      ge/ge_local_engine/engine/host_cpu_engine.h
  4. +9
    -0
      ge/graph/passes/mark_graph_unknown_status_pass.cc
  5. +6
    -2
      ge/hybrid/executor/hybrid_model_async_executor.cc
  6. +1
    -1
      ge/hybrid/executor/rt_callback_manager.cc
  7. +1
    -1
      ge/hybrid/executor/subgraph_executor.cc
  8. +1
    -1
      ge/hybrid/executor/worker/shape_inference_engine.cc
  9. +14
    -4
      ge/hybrid/model/hybrid_model_builder.cc
  10. +3
    -0
      ge/hybrid/node_executor/aicore/aicore_node_executor.cc
  11. +12
    -9
      ge/hybrid/node_executor/node_executor.cc
  12. +1
    -0
      inc/framework/common/ge_types.h

+ 1
- 1
ge/common/base64.h View File

@@ -78,7 +78,7 @@ static std::string EncodeToBase64(const std::string &raw_data) {

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
static Status DecodeFromBase64(const std::string &base64_data, std::string &decode_data) {
__attribute__ ((unused)) static Status DecodeFromBase64(const std::string &base64_data, std::string &decode_data) {
if (base64_data.size() % kFourByteOneGroup != 0) {
GELOGE(PARAM_INVALID, "base64 data size must can be divided by 4, but given data size is %zu",
base64_data.size());


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

@@ -79,6 +79,7 @@ void GetGeTensorDescFromDomiInfo(std::vector<ge::TensorDesc> &ge_descs,
ge::Shape ge_shape(shape_dims);
ge_desc.SetShape(ge_shape);
ge_desc.SetSize(desc_item.size);
ge_desc.SetShapeRange(desc_item.shape_info.shape_ranges);
ge_descs.emplace_back(ge_desc);
++idx;
}
@@ -250,7 +251,7 @@ Status GeExecutor::Initialize() {
return ret;
}

GE_CHK_STATUS_RET(OpsKernelBuilderManager::Instance().Initialize({}, false),
GE_CHK_STATUS_RET(OpsKernelBuilderManager::Instance().Initialize({}, true),
"Failed to initialize OpsKernelBuilders");

// Start profiling


+ 1
- 1
ge/ge_local_engine/engine/host_cpu_engine.h View File

@@ -20,7 +20,7 @@
#include "framework/common/ge_inner_error_codes.h"
#include "graph/node.h"
#include "graph/operator.h"
#include "register/register.h"
#include "external/../register/register.h"

namespace ge {
class HostCpuEngine {


+ 9
- 0
ge/graph/passes/mark_graph_unknown_status_pass.cc View File

@@ -19,6 +19,10 @@
#include "graph/debug/ge_attr_define.h"

namespace ge {
namespace {
const char *const kOwnerGraphIsUnknown = "OwnerGraphIsUnknown";
}

Status MarkGraphUnknownStatusPass::Run(ComputeGraphPtr graph) {
GE_CHECK_NOTNULL(graph);
bool is_unknown_shape = false;
@@ -35,6 +39,11 @@ Status MarkGraphUnknownStatusPass::Run(ComputeGraphPtr graph) {
break;
}
}

for (const auto &node : graph->GetDirectNode()) {
GELOGD("Set OwnerGraphIsUnknown attr to node[%s]", node->GetName().c_str());
(void)AttrUtils::SetBool(node->GetOpDesc(), kOwnerGraphIsUnknown, is_unknown_shape);
}
graph->SetGraphUnknownFlag(is_unknown_shape);
GELOGD("mark graph [%s] unknown status success! value is %d", graph->GetName().c_str(), is_unknown_shape);
return SUCCESS;


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

@@ -58,7 +58,7 @@ Status HybridModelAsyncExecutor::Start(const std::shared_ptr<ModelListener> &lis

run_flag_ = true;
listener_ = listener;
future_ = std::async([&]() -> Status {
future_ = std::async(std::launch::async, [&]() -> Status {
GetContext().SetSessionId(executor_->GetContext()->session_id);
return RunInternal();
});
@@ -72,7 +72,11 @@ Status HybridModelAsyncExecutor::Stop() {
std::lock_guard<std::mutex> lk(mu_);
run_flag_ = false;
data_inputer_->Stop();
auto ret = future_.get();

Status ret = SUCCESS;
if (future_.valid()) {
ret = future_.get();
}

if (stream_ != nullptr) {
GE_CHK_RT(rtStreamDestroy(stream_));


+ 1
- 1
ge/hybrid/executor/rt_callback_manager.cc View File

@@ -49,7 +49,7 @@ Status CallbackManager::RegisterCallback(rtCallback_t callback, void *user_data)
Status CallbackManager::Init() {
rtContext_t ctx = nullptr;
GE_CHK_RT_RET(rtCtxGetCurrent(&ctx));
ret_future_ = std::async([&](rtContext_t context) ->Status {
ret_future_ = std::async(std::launch::async, [&](rtContext_t context) ->Status {
return CallbackProcess(context);
}, ctx);
if (!ret_future_.valid()) {


+ 1
- 1
ge/hybrid/executor/subgraph_executor.cc View File

@@ -307,7 +307,7 @@ Status SubgraphExecutor::LaunchTasks() {

Status SubgraphExecutor::ScheduleTasks() {
GELOGD("[%s] Start to schedule prepare workers.", graph_item_->GetName().c_str());
auto prepare_future = std::async([&]() -> Status {
auto prepare_future = std::async(std::launch::async, [&]() -> Status {
GetContext().SetSessionId(context_->session_id);
auto ret = PrepareNodes();
ready_queue_.Push(nullptr);


+ 1
- 1
ge/hybrid/executor/worker/shape_inference_engine.cc View File

@@ -62,7 +62,7 @@ Status ShapeInferenceEngine::InferShape(NodeState &node_state) {
{
std::lock_guard<std::mutex> lk(mu_);
RECORD_SHAPE_INFERENCE_EVENT(execution_context_, node_item.NodeName().c_str(), "[InferShapeAndType] Start");
GE_CHK_STATUS_RET(ShapeRefiner::InferShapeAndType(node_item.node), "Invoke InferShapeAndType failed.");
GE_CHK_STATUS_RET(ShapeRefiner::InferShapeAndType(node_item.node, 1), "Invoke InferShapeAndType failed.");
RECORD_SHAPE_INFERENCE_EVENT(execution_context_, node_item.NodeName().c_str(), "[InferShapeAndType] End");
}
// Check again to make sure shape is valid after shape inference


+ 14
- 4
ge/hybrid/model/hybrid_model_builder.cc View File

@@ -37,6 +37,16 @@ const uint32_t kSubgraphIndex = 0U;
const uint32_t kVarOutputIndex = 0U;
const uint32_t kAlignment = 32;
const int kBytes = 8;
const char *const kOwnerGraphIsUnknown = "OwnerGraphIsUnknown";

bool IsGraphUnknown(ComputeGraph &graph) {
for (const auto &node : graph.GetDirectNode()) {
bool is_unknown_shape = false;
(void)AttrUtils::GetBool(node->GetOpDesc(), kOwnerGraphIsUnknown, is_unknown_shape);
return is_unknown_shape;
}
return false;
}

int64_t CalcVarSizeInBytes(const GeTensorDesc &desc) {
int64_t var_size = 0;
@@ -556,7 +566,7 @@ Status HybridModelBuilder::UnfoldSubgraphs(ComputeGraph &root_graph, ComputeGrap

auto subgraph = NodeUtils::GetSubgraph(*node, kSubgraphIndex);
GE_CHECK_NOTNULL(subgraph);
bool is_unknown_shape = subgraph->GetGraphUnknownFlag();
bool is_unknown_shape = IsGraphUnknown(*subgraph);
if (!is_unknown_shape) {
merged_graph->AddNode(node);
GELOGD("[%s] Known shape partitioned call added to merged graph.", op_desc->GetName().c_str());
@@ -603,7 +613,7 @@ Status HybridModelBuilder::UnfoldSubgraph(ComputeGraph &root_graph,
if (sub_op_type == PARTITIONEDCALL) {
auto sub_sub_graph = NodeUtils::GetSubgraph(*sub_node, kSubgraphIndex);
GE_CHECK_NOTNULL(sub_sub_graph);
if (sub_sub_graph->GetGraphUnknownFlag()) {
if (IsGraphUnknown(*sub_sub_graph)) {
GE_CHK_STATUS_RET(UnfoldSubgraph(root_graph, parent_graph, *sub_sub_graph),
"[%s] Failed to merge subgraph",
sub_sub_graph->GetName().c_str());
@@ -693,7 +703,7 @@ Status HybridModelBuilder::LoadGraph() {
continue;
}

if (sub_graph->GetGraphUnknownFlag()) {
if (IsGraphUnknown(*sub_graph)) {
GE_CHK_STATUS_RET(LoadDynamicSubgraph(*sub_graph, false),
"Failed to load subgraph: [%s]",
sub_graph->GetName().c_str());
@@ -947,7 +957,7 @@ Status HybridModelBuilder::IndexTaskDefs() {
continue;
}

bool is_unknown_shape = sub_graph->GetGraphUnknownFlag();
bool is_unknown_shape = IsGraphUnknown(*sub_graph);
if (!is_unknown_shape) {
GE_CHK_STATUS_RET_NOLOG(LoadGeModel(*sub_graph, ge_model));
continue;


+ 3
- 0
ge/hybrid/node_executor/aicore/aicore_node_executor.cc View File

@@ -244,6 +244,9 @@ void TaskCompilerFactory::Register(CreateFn fn) {
}

std::unique_ptr<TaskCompiler> TaskCompilerFactory::GetTaskCompiler() {
if (compiler_func_ == nullptr) {
return nullptr;
}
auto compiler_instance = std::unique_ptr<TaskCompiler>(compiler_func_());
return compiler_instance;
}


+ 12
- 9
ge/hybrid/node_executor/node_executor.cc View File

@@ -18,6 +18,7 @@
#include "framework/common/debug/log.h"
#include "graph/utils/node_utils.h"
#include "init/gelib.h"
#include "graph/utils/tensor_utils.h"
#include "hybrid/model/hybrid_model.h"
#include "graph/debug/ge_attr_define.h"
#include "opskernel_manager/ops_kernel_builder_manager.h"
@@ -32,6 +33,7 @@ const char *const kEngineNameAiCpuTf = "aicpu_tf_kernel";
const char *const kEngineNameHccl = "ops_kernel_info_hccl";
const char *const kEngineNameRts = "DNN_VM_RTS_OP_STORE";
const char *const kEngineNameHostCpu = "DNN_VM_HOST_CPU_OP_STORE";
const char *const kOwnerGraphIsUnknown = "OwnerGraphIsUnknown";
}
Status NodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) const {
GE_CHK_STATUS_RET_NOLOG(context.AllocateOutputs());
@@ -80,16 +82,17 @@ NodeExecutorManager::ExecutorType NodeExecutorManager::ResolveExecutorType(Node
auto op_type = node.GetType();
if (op_type == PARTITIONEDCALL) {
const auto &subgraph = NodeUtils::GetSubgraph(node, 0);
if (subgraph != nullptr && subgraph->GetGraphUnknownFlag()) {
GELOGD("node %s was marked as unknown shape in node_executor.", node.GetName().c_str());
return ExecutorType::DYNAMIC_SUBGRAPH;
}
bool is_dynamic = false;
(void) NodeUtils::GetNodeUnknownShapeStatus(node, is_dynamic);
if (is_dynamic) {
return ExecutorType::DYNAMIC_SUBGRAPH;
if (subgraph != nullptr) {
for (const auto &node : subgraph->GetDirectNode()) {
bool is_unknown_shape = false;
(void)AttrUtils::GetBool(node->GetOpDesc(), kOwnerGraphIsUnknown, is_unknown_shape);
if (is_unknown_shape) {
return ExecutorType::DYNAMIC_SUBGRAPH;
} else {
return ExecutorType::COMPILED_SUBGRAPH;
}
}
}
return ExecutorType::COMPILED_SUBGRAPH;
}

// rts kernel store is assigned to NetOutput


+ 1
- 0
inc/framework/common/ge_types.h View File

@@ -117,6 +117,7 @@ struct ShapeDescription {
int64_t height = 0;
int64_t width = 0;
std::vector<int64_t> dims;
std::vector<std::pair<int64_t, int64_t>> shape_ranges;
};

// Definition of input and output description information


Loading…
Cancel
Save