sync src code from yellow zone master

pull/187/head
taoxiangdong 4 years ago
parent dea1063e80
commit 416127b1f1

@ -41,6 +41,7 @@ if (ENABLE_OPEN_SRC)
message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated")
endif()
set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH})
set(STATIC_ACL_LIB ${GE_LIB_PATH})
find_module(slog libslog.so ${GE_LIB_PATH})
find_module(mmpa libmmpa.so ${GE_LIB_PATH})
find_module(msprof libmsprof.so ${GE_LIB_PATH})
@ -53,7 +54,6 @@ if (ENABLE_OPEN_SRC)
find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH})
find_module(error_manager_static liberror_manager.a ${GE_LIB_PATH})
find_module(msprofiler libmsprofiler.a ${GE_LIB_PATH})
find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH})
else()
if(DEFINED ENV{ASCEND_CUSTOM_PATH})
set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH})
@ -66,6 +66,7 @@ if (ENABLE_OPEN_SRC)
set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64)
set(ASCEND_ATC_DIR ${ASCEND_DIR}/atc/lib64)
set(ASCEND_ACL_DIR ${ASCEND_DIR}/acllib/lib64)
set(STATIC_ACL_LIB ${ASCEND_ACL_DIR})
find_module(slog libslog.so ${ASCEND_ATC_DIR})
find_module(mmpa libmmpa.so ${ASCEND_ATC_DIR})
if(PLATFORM STREQUAL "train")
@ -88,7 +89,6 @@ if (ENABLE_OPEN_SRC)
find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR})
find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR})
find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR})
find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR})
if(PRODUCT STREQUAL "flr3")
find_module(msprof libmsprof.so ${ASCEND_DRIVER_SHARE_DIR})
elseif(PRODUCT STREQUAL "flr1")
@ -111,7 +111,6 @@ if (ENABLE_OPEN_SRC)
find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR})
find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR})
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver)
find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR})
else()
message(FATAL_ERROR "PLATFORM param is invalid, should be train or inference, build terminated")
endif()

@ -1,6 +0,0 @@
inc_path := $(shell pwd)/metadef/inc/external/
out_path := $(shell pwd)/out/graph/lib64/stub/
stub_path := $(shell pwd)/metadef/graph/stub/
mkdir_stub := $(shell mkdir -p $(out_path))
graph_local_stub := $(shell $(HI_PYTHON) $(stub_path)/gen_stubapi.py $(inc_path) $(out_path))

File diff suppressed because it is too large Load Diff

@ -719,10 +719,24 @@ target_link_libraries(ge_compiler
############ libascendcl.so ############
file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/dummy.c CONTENT "")
add_library(dummy_obj OBJECT ${CMAKE_BINARY_DIR}/dummy.c)
set(DUMMY_OBJ $<TARGET_OBJECTS:dummy_obj>)
#add_library(dummy_obj OBJECT ${CMAKE_BINARY_DIR}/dummy.c)
#set(DUMMY_OBJ $<TARGET_OBJECTS:dummy_obj>)
add_library(opensrc_ascendcl SHARED ${DUMMY_OBJ})
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ascendcl_object)
if(EXISTS ${STATIC_ACL_LIB}/libascendcl.a)
execute_process(
COMMAND ar x ${STATIC_ACL_LIB}/libascendcl.a
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ascendcl_object
)
file(GLOB OBJECT_LIST ${CMAKE_CURRENT_BINARY_DIR}/ascendcl_object/*.o)
else()
set(OBJECT_LIST ${CMAKE_BINARY_DIR}/dummy.c)
endif()
add_library(opensrc_ascendcl SHARED
${OBJECT_LIST}
)
target_compile_options(opensrc_ascendcl PRIVATE
-O2
-fvisibility=hidden

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* 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.
@ -40,34 +40,32 @@ const std::string kFilePath = "./";
const std::string kAnalyzeFile = "ge_check_op.json";
const std::string kUnknownShape = "unknownshape";
const std::string kUnsupport = "unsupport";
const std::string kUnsupport = "unsupport";
const std::string kSessionId = "session_id";
const std::string kGraphId = "graph_id";
const std::string kOpInfo = "op_info";
const std::string kGraphId = "graph_id";
const std::string kOpInfo = "op_info";
const std::string kErrorType = "error_type";
const std::string kOpName = "name";
const std::string kOpType = "type";
const std::string kReason = "reason";
const std::string kInput = "input";
const std::string kOutput = "output";
const std::string kShape = "shape";
const std::string kDataType = "data_type";
const std::string kLayout = "layout";
const std::string kResult = "result";
const std::string kOp = "op";
std::map<analyzer::AnalyzeType, std::string> errors_map {
{PARSER, "paser_error"},
{INFER_SHAPE, "infer_shape_error"},
{CHECKSUPPORT, "check_support_error"},
{GRAPH_OPTIMIZE, "graph_optimize_error"},
{GRAPH_PARTION, "graph_partion_error"},
{GRAPH_BUILDER, "graph_builder_error"}
};
}
Analyzer* Analyzer::GetInstance() {
const std::string kOpName = "name";
const std::string kOpType = "type";
const std::string kReason = "reason";
const std::string kInput = "input";
const std::string kOutput = "output";
const std::string kShape = "shape";
const std::string kDataType = "data_type";
const std::string kLayout = "layout";
const std::string kResult = "result";
const std::string kOp = "op";
std::map<analyzer::AnalyzeType, std::string> errors_map{{PARSER, "paser_error"},
{INFER_SHAPE, "infer_shape_error"},
{CHECKSUPPORT, "check_support_error"},
{GRAPH_OPTIMIZE, "graph_optimize_error"},
{GRAPH_PARTION, "graph_partion_error"},
{GRAPH_BUILDER, "graph_builder_error"}};
} // namespace
Analyzer *Analyzer::GetInstance() {
static Analyzer instance;
return &instance;
}
@ -77,8 +75,9 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) {
std::lock_guard<std::recursive_mutex> lg(mutex_);
auto iter = graph_infos_.find(session_id);
if (iter == graph_infos_.end()) {
std::shared_ptr<GraphInfo> graph_info(new(std::nothrow) GraphInfo());
GE_CHECK_NOTNULL(graph_info);
auto p = new (std::nothrow) GraphInfo();
GE_CHECK_NOTNULL(p);
std::shared_ptr<GraphInfo> graph_info(p);
std::map<uint64_t, std::shared_ptr<GraphInfo>> graph_map;
graph_map[graph_id] = graph_info;
graph_info->session_id = session_id;
@ -87,8 +86,9 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) {
} else {
auto iter1 = (iter->second).find(graph_id);
if (iter1 == (iter->second).end()) {
std::shared_ptr<GraphInfo> graph_info(new(std::nothrow) GraphInfo());
GE_CHECK_NOTNULL(graph_info);
auto p = new (std::nothrow) GraphInfo();
GE_CHECK_NOTNULL(p);
std::shared_ptr<GraphInfo> graph_info(p);
graph_info->session_id = session_id;
graph_info->graph_id = graph_id;
(iter->second).insert({graph_id, graph_info});
@ -100,14 +100,7 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) {
}
ge::Status Analyzer::Initialize() {
// Initialize file
string real_path = RealPath(kFilePath.c_str());
if (real_path.empty()) {
GELOGE(FAILED, "File path is invalid.");
return FAILED;
}
json_file_name_ = real_path + "/" + kAnalyzeFile;
ClearHistoryFile();
return SUCCESS;
}
@ -145,7 +138,6 @@ void Analyzer::DestroyGraphJsonObject(uint64_t session_id, uint64_t graph_id) {
if (iter1 == (iter->second).end()) {
GELOGW("Can not find the graph json object by session_id[%lu] and graph_id[%lu]. Do nothing.", session_id,
graph_id);
return;
}
(iter->second).erase(iter1);
}
@ -182,8 +174,15 @@ ge::Status Analyzer::CreateAnalyzerFile() {
return SUCCESS;
}
GELOGD("start to create analyzer file!");
// Check whether the manifest exists, if not, create it.
string real_path = RealPath(kFilePath.c_str());
if (real_path.empty()) {
GELOGE(FAILED, "File path is invalid.");
return FAILED;
}
std::lock_guard<std::mutex> lg(file_mutex_);
json_file_name_ = real_path + "/" + kAnalyzeFile;
GELOGD("Created analyzer file:[%s]", json_file_name_.c_str());
int fd = open(json_file_name_.c_str(), O_WRONLY | O_CREAT | O_TRUNC, kFileAuthority);
if (fd < 0) {
GELOGE(INTERNAL_ERROR, "Fail to open the file: %s.", json_file_name_.c_str());
@ -199,27 +198,25 @@ ge::Status Analyzer::CreateAnalyzerFile() {
return SUCCESS;
}
ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_id) {
ge::Status Analyzer::SaveAnalyzerDataToFile() {
GELOGD("start to save analyze file!");
auto graph_info = GetJsonObject(session_id, graph_id);
GE_CHECK_NOTNULL(graph_info);
if (graph_info->op_info.size() == 0) {
GELOGD("session_id:%lu graph_id:%lu does not owner op info, break it!", session_id, graph_id);
return SUCCESS;
}
std::lock_guard<std::mutex> lg(file_mutex_);
json_file_.open(json_file_name_, std::ios::app);
json_file_.open(json_file_name_, std::ios::out);
if (!json_file_.is_open()) {
GELOGE(FAILED, "analyzer file does not exist[%s]", json_file_name_.c_str());
return PARAM_INVALID;
}
json jsn;
GraphInfoToJson(jsn, *graph_info);
json_file_ << jsn.dump(kJsonDumpLevel) << std::endl;
json_file_.close();
std::lock_guard<std::recursive_mutex> lk(mutex_);
for (auto &ele : graph_infos_) {
for (auto &ele2 : ele.second) {
json jsn;
GraphInfoToJson(jsn, *(ele2.second));
json_file_ << jsn.dump(kJsonDumpLevel) << std::endl;
}
}
json_file_.close();
return SUCCESS;
}
@ -240,7 +237,13 @@ ge::Status Analyzer::DoAnalyze(DataInfo &data_info) {
return FAILED;
}
// create json file
return CreateAnalyzerFile();
status = CreateAnalyzerFile();
if (status != SUCCESS) {
GELOGE(status, "create analyzer file failed!");
return status;
}
// save data to file
return SaveAnalyzerDataToFile();
}
ge::Status Analyzer::SaveOpInfo(ge::OpDescPtr desc, DataInfo &data_info,
@ -253,18 +256,18 @@ ge::Status Analyzer::SaveOpInfo(ge::OpDescPtr desc, DataInfo &data_info,
op_info.error_type = iter->second;
op_info.op_name = desc->GetName();
op_info.op_type = desc->GetType();
op_info.reason = data_info.reason;
op_info.reason = data_info.reason;
for (const auto &ptr : desc->GetAllInputsDescPtr()) {
TensorInfo tensor_info;
tensor_info.shape = ptr->GetShape().GetDims();
tensor_info.shape = ptr->GetShape().GetDims();
tensor_info.d_type = ge::TypeUtils::DataTypeToSerialString(ptr->GetDataType());
tensor_info.layout = ge::TypeUtils::FormatToSerialString(ptr->GetFormat());
op_info.input_info.emplace_back(tensor_info);
}
for (const auto &ptr : desc->GetAllOutputsDescPtr()) {
TensorInfo tensor_info;
tensor_info.shape = ptr->GetShape().GetDims();
tensor_info.shape = ptr->GetShape().GetDims();
tensor_info.d_type = ge::TypeUtils::DataTypeToSerialString(ptr->GetDataType());
tensor_info.layout = ge::TypeUtils::FormatToSerialString(ptr->GetFormat());
op_info.output_info.emplace_back(tensor_info);
@ -274,13 +277,13 @@ ge::Status Analyzer::SaveOpInfo(ge::OpDescPtr desc, DataInfo &data_info,
return SUCCESS;
}
void Analyzer::TensorInfoToJson(json& j, const TensorInfo &tensor_info) {
void Analyzer::TensorInfoToJson(json &j, const TensorInfo &tensor_info) {
j[kShape] = tensor_info.shape;
j[kDataType] = tensor_info.d_type;
j[kLayout] = tensor_info.layout;
}
void Analyzer::OpInfoToJson(json& j, const OpInfo &op_info) {
void Analyzer::OpInfoToJson(json &j, const OpInfo &op_info) {
j[kErrorType] = op_info.error_type;
j[kOpName] = op_info.op_name;
j[kOpType] = op_info.op_type;
@ -297,7 +300,7 @@ void Analyzer::OpInfoToJson(json& j, const OpInfo &op_info) {
}
}
void Analyzer::GraphInfoToJson(json& j, const GraphInfo &graph_info) {
void Analyzer::GraphInfoToJson(json &j, const GraphInfo &graph_info) {
GELOGD("start to buff graph info!");
j[kSessionId] = graph_info.session_id;
j[kGraphId] = graph_info.graph_id;
@ -309,4 +312,4 @@ void Analyzer::GraphInfoToJson(json& j, const GraphInfo &graph_info) {
}
j[kOp] = json_op_infos;
}
} // namespace ge
} // namespace ge

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* 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.
@ -33,12 +33,12 @@
namespace ge {
namespace analyzer {
enum AnalyzeType {
PARSER = 0,
INFER_SHAPE = 1,
CHECKSUPPORT = 2,
PARSER = 0,
INFER_SHAPE = 1,
CHECKSUPPORT = 2,
GRAPH_OPTIMIZE = 3,
GRAPH_PARTION = 4,
GRAPH_BUILDER = 5,
GRAPH_PARTION = 4,
GRAPH_BUILDER = 5,
};
struct TensorInfo {
@ -66,8 +66,7 @@ struct DataInfo {
DataInfo() = default;
~DataInfo() = default;
DataInfo(uint64_t sess, uint64_t graph, AnalyzeType type,
ge::NodePtr node, std::string error_info) {
DataInfo(uint64_t sess, uint64_t graph, AnalyzeType type, ge::NodePtr node, std::string error_info) {
session_id = sess;
graph_id = graph;
analyze_type = type;
@ -80,10 +79,10 @@ struct DataInfo {
ge::NodePtr node_ptr{nullptr};
std::string reason;
};
}
} // namespace analyzer
class Analyzer {
public:
public:
/**
* @ingroup ge
* @brief: get analyzer instance.
@ -157,39 +156,33 @@ public:
*/
ge::Status DoAnalyze(analyzer::DataInfo &data_info);
/**
* @ingroup ge
* @brief: Buff analyzed data and output to json file
* @param [in]: session id , graph id
* @return: 0: SUCCESS other: FAILED
*/
ge::Status SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_id);
Analyzer(const Analyzer &) = delete;
Analyzer& operator=(const Analyzer&) = delete;
Analyzer &operator=(const Analyzer &) = delete;
Analyzer(Analyzer &&) = delete;
Analyzer& operator=(Analyzer &&) = delete;
private:
void TensorInfoToJson(nlohmann::json& j, const analyzer::TensorInfo &tensor_info);
void OpInfoToJson(nlohmann::json& j, const analyzer::OpInfo &op_info);
void GraphInfoToJson(nlohmann::json& j, const analyzer::GraphInfo &graph_info);
Analyzer &operator=(Analyzer &&) = delete;
private:
void TensorInfoToJson(nlohmann::json &j, const analyzer::TensorInfo &tensor_info);
void OpInfoToJson(nlohmann::json &j, const analyzer::OpInfo &op_info);
void GraphInfoToJson(nlohmann::json &j, const analyzer::GraphInfo &graph_info);
ge::Status SaveAnalyzerDataToFile();
ge::Status SaveOpInfo(ge::OpDescPtr desc, analyzer::DataInfo &data_info,
std::shared_ptr<analyzer::GraphInfo> graph_info);
std::shared_ptr<analyzer::GraphInfo> graph_info);
void ClearHistoryFile();
ge::Status CreateAnalyzerFile();
explicit Analyzer() {};
explicit Analyzer(){};
~Analyzer() = default;
private:
private:
std::map<uint64_t, std::map<uint64_t, std::shared_ptr<analyzer::GraphInfo>>> graph_infos_;
std::recursive_mutex mutex_; // protect graph_infos_
std::mutex file_mutex_; // protect json_file_
std::recursive_mutex mutex_; // protect graph_infos_
std::mutex file_mutex_; // protect json_file_
std::ofstream json_file_;
std::string json_file_name_;
std::atomic_bool is_json_file_create_{false};
};
} // namespace ge
#endif // DOMI_ANALYZER_ANANLYZER_H_
} // namespace ge
#endif // DOMI_ANALYZER_ANANLYZER_H_

@ -384,7 +384,7 @@ Status Session::RunGraphAsync(uint32_t graph_id, const std::vector<InputTensorIn
}
GELOGT(TRACE_RUNNING, "Run Graph Asynchronously");
GELOGW(
"The callback function will not be checked. Please ensure that the implementation of the function is trusted.");
"The callback function will not be checked. Please ensure that the implementation of the function is trusted.");
Status ret = ge::GELib::GetInstance()->SessionManagerObj().RunGraphAsync(sessionId_, graph_id, inputs, callback);
if (ret != SUCCESS) {

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* 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.
@ -39,21 +39,12 @@ const std::string kDeviceIdList = "devIdList";
const std::string kAicoreMetrics = "aicoreMetrics";
const std::map<ge::ProfilingAicoreMetrics, std::string> kProfAicoreMetricsToString = {
<<<<<<< HEAD:ge/client/ge_prof.cc
{ge::kAicoreArithmaticThroughput, "AICORE_ARITHMATIC_THROUGHPUT"},
{ge::kAicorePipeline, "AICORE_PIPELINE"},
{ge::kAicoreSynchronization, "AICORE_SYNCHRONIZATION"},
{ge::kAicoreMemory, "AICORE_MEMORY"},
{ge::kAicoreInternalMemory, "AICORE_INTERNAL_MEMORY"},
{ge::kAicoreStall, "AICORE_STALL"}};
=======
{ge::kAicoreArithmaticThroughput, "AICORE_ARITHMATIC_THROUGHPUT"},
{ge::kAicorePipeline, "AICORE_PIPELINE"},
{ge::kAicoreSynchronization, "AICORE_SYNCHRONIZATION"},
{ge::kAicoreMemory, "AICORE_MEMORY"},
{ge::kAicoreInternalMemory, "AICORE_INTERNAL_MEMORY"},
{ge::kAicoreStall, "AICORE_STALL"}};
>>>>>>> cd365aa247c64e30487d1e71e4f724a889848f80:src/ge/client/ge_prof.cc
} // namespace
static bool g_graph_prof_init_ = false;
@ -174,7 +165,7 @@ bool TransProfConfigToParam(const aclgrphProfConfig *profiler_config, vector<str
prof_config_params.push_back(devID);
prof_config_params.push_back(kAicoreMetrics);
auto iter =
kProfAicoreMetricsToString.find(static_cast<ProfilingAicoreMetrics>(profiler_config->config.aicoreMetrics));
kProfAicoreMetricsToString.find(static_cast<ProfilingAicoreMetrics>(profiler_config->config.aicoreMetrics));
if (iter == kProfAicoreMetricsToString.end()) {
GELOGW("The prof aicore metrics is invalid.");
return false;
@ -333,17 +324,10 @@ Status aclgrphProfStop(aclgrphProfConfig *profiler_config) {
return GE_PROF_NOT_INIT;
}
for (uint32_t i = 0; i < profiler_config->config.devNums; i++) {
uint64_t data_type_config;
Status status = ProfGetDataTypeConfig(profiler_config->config.devIdList[i], data_type_config);
if (status != SUCCESS) {
GELOGE(status, "Prof get data type config failed, prof result = %d", status);
return status;
}
if (data_type_config != profiler_config->config.dataTypeConfig) {
GELOGE(FAILED, "data type config verify failed");
return FAILED;
}
Status ret = ProfStopProfiling(&profiler_config->config);
if (ret != SUCCESS) {
GELOGE(ret, "Stop profiling failed, prof result = %d", ret);
return ret;
}
std::vector<string> prof_params;
@ -360,22 +344,12 @@ Status aclgrphProfStop(aclgrphProfConfig *profiler_config) {
command.module_index = profiler_config->config.dataTypeConfig;
GELOGI("Profiling will stop, device nums:%s , deviceID:[%s], data type config: 0x%llx", prof_params[0].c_str(),
prof_params[kDeviceListIndex].c_str(), command.module_index);
<<<<<<< HEAD:ge/client/ge_prof.cc
Status ret = graph_loader.CommandHandle(command);
=======
ret = graph_loader.CommandHandle(command);
>>>>>>> cd365aa247c64e30487d1e71e4f724a889848f80:src/ge/client/ge_prof.cc
if (ret != SUCCESS) {
GELOGE(ret, "Handle profiling command failed");
return FAILED;
}
ret = ProfStopProfiling(&profiler_config->config);
if (ret != SUCCESS) {
GELOGE(ret, "Stop profiling failed, prof result = %d", ret);
return ret;
}
GELOGI("Successfully execute GraphProfStopProfiling.");
return SUCCESS;
}

@ -1 +1,104 @@
../../proto/ge_api.proto
/**
* 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.
*/
syntax = "proto3";
package ge.api_pb;
import "ge_ir.proto";
// GE initialize
message GEInitialize {
map<string, string> options = 1;
};
// initialize response
message GEInitializeResponse {
uint32 status = 1;
uint32 clientId = 2;
};
// GE finalize
message GEFinalize {
bool final = 1;
uint32 clientId = 2;
};
message GEFinalizeResponse {
uint32 status = 1;
};
// GE Session
message CreateSession{
map<string, string> options = 1;
};
message CreateSessionResponse {
uint32 status = 1;
uint64 sessionId = 2;
};
//GE AddGraph
//model serialize :: serializegraph
message SessionAddGraph{
uint32 graphId = 1;
uint64 sessionId = 2;
ge.proto.GraphDef graph = 3;
};
message SessionAddGraphResponse {
uint32 status = 1;
};
//GE SessionRemoveGraph
message SessionRemoveGraph{
uint32 graphId = 1;
uint64 sessionId = 2;
};
message SessionRemoveGraphResponse {
uint32 status = 1;
};
message SessionRunGraph{
uint32 graphId = 1;
uint64 sessionId = 2;
repeated ge.proto.TensorDef tensor = 3;
};
message SessionBuildGraph{
uint32 graphId = 1;
uint64 sessionId = 2;
repeated ge.proto.TensorDef tensor = 3;
string savePath = 4;
};
message SessionRunGraphResponse {
uint32 status = 1;
repeated ge.proto.TensorDef tensor = 2;
};
message SessionBuildGraphResponse {
uint32 status = 1;
};
message DestroySession{
bool final = 1;
uint64 sessionId = 2;
};
message DestroySessionResponse {
uint32 status = 1;
};

@ -1,3 +1,19 @@
/**
* 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.
*/
syntax = "proto3";
package ge.proto;

@ -1,3 +1,19 @@
/**
* 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.
*/
syntax = "proto3";
package domi;
@ -45,9 +61,6 @@ message AippOpParams {
// AIPP2AIPPrelated_input_rank1
uint32 related_input_rank = 2;
// related_input_name is optional and the top name of data node which inserts aipp
string related_input_name = 6;
// input_edge_idx>=0
// DataAIPPrelated_input_rankAIPP
// <= Data

@ -1,14 +1,19 @@
/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved.
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Apache License Version 2.0.You may not use this file except in compliance with the License.
* 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
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Apache License for more details 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.
*/
syntax = "proto3";
package domi;

@ -1,14 +1,19 @@
/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved.
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Apache License Version 2.0.You may not use this file except in compliance with the License.
* 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
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Apache License for more details 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.
*/
syntax = "proto3";
package domi;

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* 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.
@ -55,26 +55,9 @@ Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) {
Status FileSaver::WriteData(const void *data, uint32_t size, int32_t fd) {
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(size == 0 || data == nullptr, return PARAM_INVALID);
mmSsize_t write_count;
uint32_t size_2g = ((uint32_t) 0x1 << 31);
uint32_t size_1g = ((uint32_t) 0x1 << 30);
// Write data
if (size > size_2g) {
auto seek = reinterpret_cast<uint8_t *>(const_cast<void *>(data));
while (size > size_1g) {
write_count = mmWrite(fd, reinterpret_cast<void *>(seek), size_1g);
if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) {
GELOGE(FAILED, "Write data failed. mmpa_errorno = %d, %s", write_count, strerror(errno));
return FAILED;
}
size -= size_1g;
seek += size_1g;
}
write_count = mmWrite(fd, reinterpret_cast<void *>(seek), size);
} else {
write_count = mmWrite(fd, const_cast<void *>(data), size);
}
// Write data
int32_t write_count = mmWrite(fd, const_cast<void *>(data), size);
// -1: Failed to write to file; - 2: Illegal parameter
if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) {
GELOGE(FAILED, "Write data failed. mmpa_errorno = %d, %s", write_count, strerror(errno));
@ -116,10 +99,10 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi
ModelPartitionTable &model_partition_table,
const std::vector<ModelPartition> &partition_datas) {
GE_CHK_BOOL_RET_STATUS(!partition_datas.empty() && model_partition_table.num != 0
&& model_partition_table.num == partition_datas.size(), FAILED,
"Invalid param:partition data size is (%u), model_partition_table.num is (%zu).",
model_partition_table.num, partition_datas.size());
GE_CHK_BOOL_RET_STATUS(
!partition_datas.empty() && model_partition_table.num != 0 && model_partition_table.num == partition_datas.size(),
FAILED, "Invalid param:partition data size is (%u), model_partition_table.num is (%zu).", model_partition_table.num,
partition_datas.size());
// Open file
int32_t fd = 0;
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(OpenFile(fd, file_path) != SUCCESS, return FAILED);
@ -127,18 +110,16 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi
do {
// Write file header
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
WriteData(static_cast<const void *>(&file_header), sizeof(ModelFileHeader), fd) != SUCCESS, ret = FAILED;
break);
WriteData(static_cast<const void *>(&file_header), sizeof(ModelFileHeader), fd) != SUCCESS, ret = FAILED; break);
// Write model partition table
uint32_t table_size = static_cast<uint32_t>(SIZE_OF_MODEL_PARTITION_TABLE(model_partition_table));
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
WriteData(static_cast<const void *>(&model_partition_table), table_size, fd) != SUCCESS, ret = FAILED; break);
WriteData(static_cast<const void *>(&model_partition_table), table_size, fd) != SUCCESS, ret = FAILED; break);
// Write partition data
for (const auto &partitionData : partition_datas) {
GELOGI("GC:size[%zu]", partitionData.size);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
WriteData(static_cast<const void *>(partitionData.data), partitionData.size, fd) != SUCCESS, ret = FAILED;
break);
WriteData(static_cast<const void *>(partitionData.data), partitionData.size, fd) != SUCCESS, ret = FAILED;
break);
}
} while (0);
// Close file
@ -151,9 +132,9 @@ Status FileSaver::SaveToBuffWithFileHeader(const ModelFileHeader &file_header,
const std::vector<ModelPartition> &partitionDatas,
ge::ModelBufferData &model) {
GE_CHK_BOOL_RET_STATUS(
!partitionDatas.empty() && model_partition_table.num != 0 && model_partition_table.num == partitionDatas.size(),
FAILED, "Invalid param:partition data size is (%u), model_partition_table.num is (%zu).",
model_partition_table.num, partitionDatas.size());
!partitionDatas.empty() && model_partition_table.num != 0 && model_partition_table.num == partitionDatas.size(),
FAILED, "Invalid param:partition data size is (%u), model_partition_table.num is (%zu).", model_partition_table.num,
partitionDatas.size());
uint32_t model_header_size = sizeof(ModelFileHeader);
uint32_t table_size = static_cast<uint32_t>(SIZE_OF_MODEL_PARTITION_TABLE(model_partition_table));
uint32_t total_size = model_header_size + table_size;

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* 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.
@ -74,10 +74,8 @@ class FileSaver {
ModelPartitionTable &model_partition_table,
const std::vector<ModelPartition> &partition_datas);
static Status SaveToBuffWithFileHeader(const ModelFileHeader &file_header,
ModelPartitionTable &model_partition_table,
const std::vector<ModelPartition> &partitionDatas,
ge::ModelBufferData& model);
static Status SaveToBuffWithFileHeader(const ModelFileHeader &file_header, ModelPartitionTable &model_partition_table,
const std::vector<ModelPartition> &partitionDatas, ge::ModelBufferData &model);
static Status SaveToFile(const string &file_path, const void *data, int len);

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* 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.
@ -25,24 +25,23 @@
namespace ge {
namespace {
const char* kBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
const char *kBase64Chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
const char kEqualSymbol = '=';
const size_t kBase64CharsNum = 64;
const size_t kThreeByteOneGroup = 3;
const size_t kFourByteOneGroup = 4;
}
} // namespace
namespace base64 {
static inline bool IsBase64Char(const char &c) {
return (isalnum(c) || (c == '+') || (c == '/'));
}
static inline bool IsBase64Char(const char &c) { return (isalnum(c) || (c == '+') || (c == '/')); }
static std::string EncodeToBase64(const std::string &raw_data) {
size_t encode_length = raw_data.size() / kThreeByteOneGroup * kFourByteOneGroup;
encode_length += raw_data.size() % kThreeByteOneGroup == 0 ? 0 : kFourByteOneGroup;
size_t raw_data_index = 0 ;
size_t raw_data_index = 0;
size_t encode_data_index = 0;
std::string encode_data;
encode_data.resize(encode_length);
@ -80,8 +79,7 @@ static std::string EncodeToBase64(const std::string &raw_data) {
#pragma GCC diagnostic ignored "-Wunused-function"
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());
GELOGE(PARAM_INVALID, "base64 data size must can be divided by 4, but given data size is %zu", base64_data.size());
return PARAM_INVALID;
}
decode_data.clear();
@ -94,8 +92,7 @@ static Status DecodeFromBase64(const std::string &base64_data, std::string &deco
for (std::size_t input_data_index = 0; input_data_index < base64_data_len; input_data_index += 4) {
for (size_t i = 0; i < kFourByteOneGroup; ++i) {
if (base64_data[input_data_index + i] == kEqualSymbol &&
input_data_index >= base64_data_len - 4 && i > 1) {
if (base64_data[input_data_index + i] == kEqualSymbol && input_data_index >= base64_data_len - 4 && i > 1) {
byte_4[i] = kBase64CharsNum;
} else if (IsBase64Char(base64_data[input_data_index + i])) {
byte_4[i] = FindCharInBase64Chars(base64_data[input_data_index + i]);
@ -105,18 +102,18 @@ static Status DecodeFromBase64(const std::string &base64_data, std::string &deco
}
}
decode_data += static_cast<char>((byte_4[0] << 2u) + ((byte_4[1] & 0x30) >> 4u));
if (byte_4[2] >= kBase64CharsNum){
if (byte_4[2] >= kBase64CharsNum) {
break;
} else if (byte_4[3] >= kBase64CharsNum) {
decode_data += static_cast<char>(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u));
decode_data += static_cast<char>(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u));
break;
}
decode_data += static_cast<char>(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u));
decode_data += static_cast<char>(((byte_4[2] & 0x03) << 6u) + byte_4[3]);
decode_data += static_cast<char>(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u));
decode_data += static_cast<char>(((byte_4[2] & 0x03) << 6u) + byte_4[3]);
}
return SUCCESS;
}
#pragma GCC diagnostic pop
}
} // namespace base64
} // namespace ge
#endif // GE_COMMON_BASE64_H_

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* 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.

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* 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.
@ -20,9 +20,7 @@ namespace ge {
CustAICPUKernelStore::CustAICPUKernelStore() {}
void CustAICPUKernelStore::AddCustAICPUKernel(const CustAICPUKernelPtr &kernel) {
AddKernel(kernel);
}
void CustAICPUKernelStore::AddCustAICPUKernel(const CustAICPUKernelPtr &kernel) { AddKernel(kernel); }
void CustAICPUKernelStore::LoadCustAICPUKernelBinToOpDesc(const std::shared_ptr<ge::OpDesc> &op_desc) const {
GELOGI("LoadCustAICPUKernelBinToOpDesc in");

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* 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.

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* 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.

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* 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.

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* 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.

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* 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.

@ -252,4 +252,4 @@ Status DumpOp::LaunchDumpOp() {
}
return SUCCESS;
}
} // namesapce ge
} // namespace ge

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* 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.

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save