Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GPU] Enabled exec_graph and pc in deserialized models #15975

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/plugins/intel_gpu/include/intel_gpu/graph/network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ struct network {
std::list<std::shared_ptr<primitive_inst>> _data_outputs;
variables_states_map _variables_states;
std::vector<std::shared_ptr<primitive_inst>> _variable_state_primitives;
program::primitives_info _prims_info;
std::map<primitive_id, primitive_id> _ext_id_mapping;

std::unordered_map<primitive_id, event::ptr> _events;
output_chains_map _output_chains;
Expand Down
58 changes: 57 additions & 1 deletion src/plugins/intel_gpu/src/graph/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,40 @@ network::network(cldnn::BinaryInputBuffer& ib, const ExecutionConfig& config, st
}

add_default_output_chains();

size_t prims_info_size;
ib >> prims_info_size;

for (size_t i = 0; i < prims_info_size; i++) {
primitive_id original_id;
std::string type_id;
primitive::primitive_id_arr c_dependencies;
primitive::primitive_id_arr c_users;
primitive::primitive_id_arr c_fused_ids;
layout output_layout;
std::string layout_str;
std::string kernel_id;
data_types runtime_precision;
bool is_cpu;
int exec_id;

ib >> original_id;
ib >> type_id;
ib >> c_dependencies;
ib >> c_users;
ib >> c_fused_ids;
ib >> output_layout;
ib >> layout_str;
ib >> kernel_id;
ib >> make_data(&runtime_precision, sizeof(data_types));
ib >> is_cpu;
ib >> exec_id;
primitive_info prim_info(original_id, type_id, c_dependencies, c_users, c_fused_ids,
output_layout, layout_str, kernel_id, runtime_precision, is_cpu, exec_id);
_prims_info.emplace_back(prim_info);
}

ib >> _ext_id_mapping;
}

network::~network() {
Expand Down Expand Up @@ -544,6 +578,24 @@ void network::save(cldnn::BinaryOutputBuffer& ob) {
for (const auto& p_inst : _variable_state_primitives) {
ob << p_inst->id();
}

auto& prims_info = get_primitives_info();
ob << prims_info.size();
for (auto& prim_info : prims_info) {
ob << prim_info.original_id;
ob << prim_info.type_id;
ob << prim_info.c_dependencies;
ob << prim_info.c_users;
ob << prim_info.c_fused_ids;
ob << prim_info.output_layout;
ob << prim_info.layout_str;
ob << prim_info.kernel_id;
ob << make_data(&prim_info.runtime_precision, sizeof(data_types));
ob << prim_info.is_cpu;
ob << prim_info.exec_id;
}

ob << get_ext_id_mapping();
}

network::ptr network::allocate_network(stream::ptr stream, program::ptr program, bool is_internal, bool is_primary_stream) {
Expand Down Expand Up @@ -1123,14 +1175,18 @@ std::vector<primitive_id> network::get_all_primitive_org_ids() const {
}

const program::primitives_info& network::get_primitives_info() const {
return _program->get_primitives_info();
return (_program == nullptr) ? _prims_info : _program->get_primitives_info();
}

const program::graph_optimizer_info& network::get_optimizer_passes_info() const {
return _program->get_optimizer_passes_info();
}

std::map<primitive_id, primitive_id> network::get_ext_id_mapping() const {
if (_program == nullptr) {
return _ext_id_mapping;
}

std::map<primitive_id, primitive_id> result;
for (auto& prim : _primitives) {
result.emplace(prim.first, prim.second->get_node().get_primitive()->origin_op_name);
Expand Down
47 changes: 46 additions & 1 deletion src/plugins/intel_gpu/src/plugin/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ Graph::Graph(cldnn::BinaryInputBuffer &ib, RemoteContextImpl::Ptr context, const
m_program->AddVariableStateInfo(variablesStateInfo.first, *variablesStateInfo.second.begin());
}
ib >> primitiveIDs;
ib >> prevPrimitiveIDs;
ib >> profilingIDs;
{
size_t perfMap_size;
ib >> perfMap_size;
for (size_t i = 0; i < perfMap_size; ++i) {
cldnn::primitive_id prim_id;
ib >> prim_id;
perfMap[prim_id].first = prim_id;
auto& perfEntry = perfMap[prim_id].second;
ib >> perfEntry.layerType;
ib >> cldnn::make_data(&perfEntry.status, sizeof(InferenceEngine::InferenceEngineProfileInfo::LayerStatus));
perfEntry.cpu_uSec = perfEntry.realTime_uSec = 0;
ib >> perfEntry.isCPU;
ib >> perfEntry.parentPrimitive;
}
}
ib >> outputDims;

size_t num_networks;
Expand Down Expand Up @@ -502,6 +519,18 @@ void Graph::Export(cldnn::BinaryOutputBuffer &ob) {
ob << m_program->inputLayouts;
ob << m_program->GetVariablesStatesInfo();
ob << primitiveIDs;
ob << prevPrimitiveIDs;
ob << profilingIDs;
{
ob << perfMap.size();
for (auto& perf_item : perfMap) {
ob << perf_item.first;
ob << perf_item.second.second.layerType;
ob << cldnn::make_data(&perf_item.second.second.status, sizeof(InferenceEngine::InferenceEngineProfileInfo::LayerStatus));
ob << perf_item.second.second.isCPU;
ob << perf_item.second.second.parentPrimitive;
}
}
ob << outputDims;

ob << m_networks.size();
Expand Down Expand Up @@ -597,6 +626,13 @@ std::map<std::string, InferenceEngine::InferenceEngineProfileInfo> Graph::GetPer
auto executedPrimitives = GetNetwork()->get_executed_primitives();
auto primitivesInfo = GetNetwork()->get_primitives_info();
auto extIdMap = GetNetwork()->get_ext_id_mapping();
std::map<std::string, std::string> implementation_info;

if (GetNetwork()->get_program() == nullptr) {
for (auto& pi : primitivesInfo) {
implementation_info[pi.original_id] = pi.kernel_id;
}
}

auto getUpperCaseName = [](std::string name) {
std::vector<char> res;
Expand Down Expand Up @@ -641,7 +677,16 @@ std::map<std::string, InferenceEngine::InferenceEngineProfileInfo> Graph::GetPer
static const std::string cpuExecType("CPU");
cpuExecType.copy(extPerfEntry.exec_type, cpuExecType.length()); // Override execType as CPU
} else {
std::string impl = GetNetwork()->get_implementation_info(primId);
std::string impl;
if (GetNetwork()->get_program() != nullptr) {
impl = GetNetwork()->get_implementation_info(primId);
} else {
if (implementation_info.find(primId) != implementation_info.end()) {
impl = implementation_info[primId];
} else {
impl = "undef";
}
}
impl.copy(extPerfEntry.exec_type, impl.length());
}

Expand Down