Browse Source

Description: ir build inferface optimize.Shape format dtype modified to get from tensor_desc

pull/91/head
wxl 5 years ago
parent
commit
381c2b7e0c
3 changed files with 35 additions and 6 deletions
  1. +5
    -0
      inc/graph/ge_local_context.h
  2. +19
    -0
      src/common/graph/option/ge_local_context.cc
  3. +11
    -6
      src/ge/ir_build/ge_ir_build.cc

+ 5
- 0
inc/graph/ge_local_context.h View File

@@ -33,6 +33,11 @@ class GEThreadLocalContext {
void SetSessionOption(map<std::string, string> options_map);
void SetGlobalOption(map<std::string, string> options_map);

map<string, string> GetAllGraphOptions() const;
map<string, string> GetAllSessionOptions() const;
map<string, string> GetAllGlobalOptions() const;
map<string, string> GetAllOptions() const;

private:
map<string, string> graph_options_;
map<string, string> session_options_;


+ 19
- 0
src/common/graph/option/ge_local_context.cc View File

@@ -57,4 +57,23 @@ void GEThreadLocalContext::SetGraphOption(map<std::string, string> options_map)
graph_options_.clear();
graph_options_ = std::move(options_map);
}

map<string, string> GEThreadLocalContext::GetAllGraphOptions() const {
return graph_options_;
}

map<string, string> GEThreadLocalContext::GetAllSessionOptions() const {
return session_options_;
}

map<string, string> GEThreadLocalContext::GetAllGlobalOptions() const {
return global_options_;
}

map<string, string> GEThreadLocalContext::GetAllOptions() const {
map<string, string> options_all;
options_all.insert(global_options_.begin(), global_options_.end());
options_all.insert(session_options_.begin(), session_options_.end());
options_all.insert(graph_options_.begin(), graph_options_.end());
}
} // namespace ge

+ 11
- 6
src/ge/ir_build/ge_ir_build.cc View File

@@ -167,7 +167,7 @@ class Impl {
graphStatus InitDomiOmgContext(const string &input_shape, const string &input_format, const string &net_format,
bool is_dynamic_input);
void SetRtSocVersion();
void UpdateThreadContext();
public:
ge::GeGenerator generator_;
std::map<std::string, std::string> options_;
@@ -220,8 +220,6 @@ graphStatus Impl::Init(const std::map<std::string, std::string> &options) {
return ret;
}

GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions());
GetThreadLocalContext().SetGraphOption(options_);
std::string build_mode = (options_.find(BUILD_MODE) == options_.end() || options_[BUILD_MODE] == BUILD_MODE_NORMAL)
? ""
: options_[BUILD_MODE];
@@ -276,7 +274,7 @@ graphStatus Impl::Init(const std::map<std::string, std::string> &options) {
ge::PrintOptionMap(options_, "ge option");

SetRtSocVersion();
UpdateThreadContext();
// 3. init generator with options_
ret = generator_.Initialize(options_, omg_context_);
if (ret != GRAPH_SUCCESS) {
@@ -300,6 +298,11 @@ void Impl::SetRtSocVersion() {
}
}

void Impl::UpdateThreadContext() {
GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions());
GetThreadLocalContext().SetGraphOption(options_);
}

graphStatus Impl::CreateInputsForIRBuild(const ge::Graph &graph, vector<ge::GeTensor> &inputs) {
auto compute_graph = ge::GraphUtils::GetComputeGraph(graph);
GE_CHECK_NOTNULL(compute_graph);
@@ -323,13 +326,15 @@ graphStatus Impl::CreateInputsForIRBuild(const ge::Graph &graph, vector<ge::GeTe
data_shape = tensor.GetShape();
GELOGI("Data op get shape from InputDesc in ge ir graph.");
}

// If user point input format, do work for all data ops; else do according to tensor_desc
auto data_format = omg_context_.format != domi::DOMI_TENSOR_ND ?
ge::TypeUtils::DomiFormatToFormat(omg_context_.format) : tensor.GetFormat();
ge::DataType data_type = tensor.GetDataType();
string data_type_str = ge::TypeUtils::DataTypeToSerialString(data_type);
GELOGI("Data op get data type:%s from InputDesc in ge ir graph.", data_type_str.c_str());

ge::GeTensor inputTensor;
ge::GeTensorDesc desc(data_shape, ge::Format(omg_context_.format), data_type);
ge::GeTensorDesc desc(data_shape, ge::Format(data_format), data_type);
inputTensor.SetTensorDesc(desc);
inputs.push_back(inputTensor);
}


Loading…
Cancel
Save