!24 Update GraphEngine to synchronize with latest Ascend driver software suite 9 May 2020

Merge pull request !24 from yanghaoran/master
pull/24/MERGE
mindspore-ci-bot 5 years ago committed by Gitee
commit cf29b3d853

@ -176,7 +176,7 @@ cd ${BASEPATH}
mkdir -p output/plugin/nnengine/ge_config/
find output/ -name graphengine_lib.tar -exec rm {} \;
cp src/ge/engine_manager/engine_conf.json output/plugin/nnengine/ge_config/
find output/ -maxdepth 1 -name libengine.so -exec mv {} output/plugin/nnengine/ \;
find output/ -maxdepth 1 -name libengine.so -exec mv -f {} output/plugin/nnengine/ \;
tar -cf graphengine_lib.tar output/*
mv -f graphengine_lib.tar output
echo "---------------- GraphEngine package archive generated ----------------"

@ -0,0 +1,36 @@
/**
* 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.
*/
#ifndef COMPRESS_H
#define COMPRESS_H
#include <uchar.h>
enum CmpStatus { RET_SUCCESS = 0, RET_ERROR = -1 };
struct CompressConfig {
size_t inputSize; // length of data to compress
size_t engineNum; // how many decompress engines
size_t maxRatio; // how much size of a basic compression block, only 64 supported now (8x: 64 4x: 32)
size_t channel; // channels of L2 or DDR. For load balance
size_t fractalSize; // size of compressing block
bool isTight; // whether compose compressed data tightly
};
CmpStatus CompressWeights(char* input, const CompressConfig& compressConfig, char* indexs, char* output,
size_t& compressedLength);
#endif // COMPRESS_H

@ -0,0 +1,97 @@
/**
* 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.
*/
#ifndef PLATFORM_INFO_H
#define PLATFORM_INFO_H
#include <map>
#include <string>
#include <vector>
#include "platform_info_def.h"
using std::map;
using std::string;
using std::vector;
namespace fe {
class PlatformInfoManager {
public:
PlatformInfoManager(const PlatformInfoManager &) = delete;
PlatformInfoManager &operator=(const PlatformInfoManager &) = delete;
static PlatformInfoManager &Instance();
uint32_t InitializePlatformInfo();
uint32_t Finalize();
uint32_t GetPlatformInfo(const string SoCVersion, PlatformInfo &platformInfo, OptionalInfo &optiCompilationInfo);
void SetOptionalCompilationInfo(OptionalInfo &optiCompilationInfo);
private:
PlatformInfoManager();
~PlatformInfoManager();
uint32_t LoadIniFile(string iniFileRealPath);
void Trim(string &str);
uint32_t LoadConfigFile(string realPath);
string RealPath(const std::string &path);
string GetSoFilePath();
void ParseVersion(map<string, string> &versionMap, string &socVersion, PlatformInfo &platformInfoTemp);
void ParseSocInfo(map<string, string> &socInfoMap, PlatformInfo &platformInfoTemp);
void ParseCubeOfAICoreSpec(map<string, string> &aiCoreSpecMap, PlatformInfo &platformInfoTemp);
void ParseBufferOfAICoreSpec(map<string, string> &aiCoreSpecMap, PlatformInfo &platformInfoTemp);
void ParseUBOfAICoreSpec(map<string, string> &aiCoreSpecMap, PlatformInfo &platformInfoTemp);
void ParseAICoreSpec(map<string, string> &aiCoreSpecMap, PlatformInfo &platformInfoTemp);
void ParseBufferOfAICoreMemoryRates(map<string, string> &aiCoreMemoryRatesMap, PlatformInfo &platformInfoTemp);
void ParseAICoreMemoryRates(map<string, string> &aiCoreMemoryRatesMap, PlatformInfo &platformInfoTemp);
void ParseUBOfAICoreMemoryRates(map<string, string> &aiCoreMemoryRatesMap, PlatformInfo &platformInfoTemp);
void ParseAICoreintrinsicDtypeMap(map<string, string> &aiCoreintrinsicDtypeMap, PlatformInfo &platformInfoTemp);
void ParseVectorCoreSpec(map<string, string> &vectorCoreSpecMap, PlatformInfo &platformInfoTemp);
void ParseVectorCoreMemoryRates(map<string, string> &vectorCoreMemoryRatesMap, PlatformInfo &platformInfoTemp);
void ParseVectorCoreintrinsicDtypeMap(map<string, string> &vectorCoreintrinsicDtypeMap,
PlatformInfo &platformInfoTemp);
uint32_t ParsePlatformInfoFromStrToStruct(map<string, map<string, string>> &contentInfoMap, string &socVersion,
PlatformInfo &platformInfoTemp);
uint32_t AssemblePlatformInfoVector(map<string, map<string, string>> &contentInfoMap);
private:
bool initFlag_;
map<string, PlatformInfo> platformInfoMap_;
OptionalInfo optiCompilationInfo_;
};
} // namespace fe
#endif

@ -0,0 +1,122 @@
/**
* 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.
*/
#ifndef PLATFORM_INFO_DEF_H
#define PLATFORM_INFO_DEF_H
#include <map>
#include <string>
#include <vector>
using std::map;
using std::string;
using std::vector;
namespace fe {
enum MemoryType { DDR = 0, HBM };
enum L2Type { Cache = 0, Buff };
typedef struct tagStrInfo {
string aicVersion;
string ccecAICVersion;
string ccecAIVVersion;
string isSupportAIcpuCompiler;
} StrInfo;
typedef struct tagSoCInfo {
uint32_t aiCoreCnt;
uint32_t vectorCoreCnt;
uint32_t aiCpuCnt;
MemoryType memoryType;
uint64_t memorySize;
L2Type l2Type;
uint64_t l2Size;
uint32_t l2PageNum;
} SoCInfo;
typedef struct tagAiCoreSpec {
double cubeFreq;
uint64_t cubeMSize;
uint64_t cubeNSize;
uint64_t cubeKSize;
uint64_t vecCalcSize;
uint64_t l0ASize;
uint64_t l0BSize;
uint64_t l0CSize;
uint64_t l1Size;
uint64_t smaskBuffer;
uint64_t ubSize;
uint64_t ubblockSize;
uint64_t ubbankSize;
uint64_t ubbankNum;
uint64_t ubburstInOneBlock;
uint64_t ubbankGroupNum;
} AiCoreSpec;
typedef struct tagAiCoreMemoryRates {
double ddrRate;
double l2Rate;
double l2ReadRate;
double l2WriteRate;
double l1ToL0ARate;
double l1ToL0BRate;
double l1ToUBRate;
double l0CToUBRate;
double ubToL2Rate;
double ubToDdrRate;
double ubToL1Rate;
} AiCoreMemoryRates;
typedef struct tagVectorCoreSpec {
uint64_t vecCalcSize;
uint64_t smaskBuffer;
uint64_t ubSize;
uint64_t ubblockSize;
uint64_t ubbankSize;
uint64_t ubbankNum;
uint64_t ubburstInOneBlock;
uint64_t ubbankGroupNum;
} VectorCoreSpec;
typedef struct tagVectorCoreMemoryRates {
double ddrRate;
double l2Rate;
double l2ReadRate;
double l2WriteRate;
double ubToL2Rate;
double ubToDdrRate;
} VectorCoreMemoryRates;
typedef struct tagPlatformInfo {
StrInfo strInfo;
SoCInfo socInfo;
AiCoreSpec aiCoreSpec;
AiCoreMemoryRates aiCoreMemoryRates;
map<string, vector<string>> aiCoreIntrinsicDtypeMap;
VectorCoreSpec vectorCoreSpec;
VectorCoreMemoryRates vectorCoreMemoryRates;
map<string, vector<string>> vectorCoreIntrinsicDtypeMap;
} PlatformInfo;
typedef struct tagOptionalInfo {
string socVersion;
string coreType;
uint32_t aiCoreNum;
string l1FusionFlag;
} OptionalInfo;
} // namespace fe
#endif

@ -40,6 +40,8 @@ const char *const OPTION_EXEC_EXTERN_PLUGIN_PATH = "ge.soLoadPath";
const char *const OPTION_EXEC_ENABLE_DUMP = "ge.exec.enableDump";
const char *const OPTION_EXEC_DUMP_PATH = "ge.exec.dumpPath";
const char *const OPTION_EXEC_DUMP_STEP = "ge.exec.dumpStep";
const char *const OPTION_EXEC_ENABLE_INCRE_BUILD = "ge.exec.enableIncreBuild";
const char *const OPTION_EXEC_INCRE_BUILD_CACHE_PATH = "ge.exec.increBuildCachePath";
// Hccl flag, if ge.exec.hcclFlag =1, it means load plugin for opskernel, else:ge.exec.hcclFlag =0
const char *const OPTION_EXEC_HCCL_FLAG = "ge.exec.hcclFlag";
const char *const OPTION_EXEC_ATOMIC_FLAG = "ge.exec.enable_atomic";

@ -116,27 +116,5 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpReceiver {
namespace ge {
using OpRegistrationData = domi::OpRegistrationData;
using OpReceiver = domi::OpReceiver;
class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY HostCpuOp {
public:
HostCpuOp() = default;
virtual ~HostCpuOp() = default;
virtual graphStatus Compute(Operator &op, const std::map<std::string, const Tensor> &inputs,
std::map<std::string, Tensor> &outputs) = 0;
};
class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY HostCpuOpRegistrar {
public:
HostCpuOpRegistrar(const char *op_type, HostCpuOp *(*create_fn)());
};
#define REGISTER_HOST_CPU_OP_BUILDER(name, op) REGISTER_HOST_CPU_OP_BUILDER_UNIQ_HELPER(__COUNTER__, name, op)
#define REGISTER_HOST_CPU_OP_BUILDER_UNIQ_HELPER(ctr, name, op) REGISTER_HOST_CPU_OP_BUILDER_UNIQ(ctr, name, op)
#define REGISTER_HOST_CPU_OP_BUILDER_UNIQ(ctr, name, op) \
static ::ge::HostCpuOpRegistrar register_host_cpu_op##ctr __attribute__((unused)) = \
::ge::HostCpuOpRegistrar(name, []() -> ::ge::HostCpuOp * { return new (std::nothrow) op(); })
} // namespace ge
#endif // INC_EXTERNAL_REGISTER_REGISTER_H_

@ -434,6 +434,7 @@ REGISTER_OPTYPE_DECLARE(STREAMSWITCH, "StreamSwitch");
REGISTER_OPTYPE_DECLARE(STREAMSWITCHN, "StreamSwitchN");
REGISTER_OPTYPE_DECLARE(STREAMACTIVE, "StreamActive");
REGISTER_OPTYPE_DECLARE(MEMCPYASYNC, "MemcpyAsync");
REGISTER_OPTYPE_DECLARE(MEMCPYADDRASYNC, "MemcpyAddrAsync");
REGISTER_OPTYPE_DECLARE(STREAMMERGE, "StreamMerge");
REGISTER_OPTYPE_DECLARE(ENDGRAPH, "EndGraph");
REGISTER_OPTYPE_DECLARE(SEND, "Send");
@ -441,6 +442,7 @@ REGISTER_OPTYPE_DECLARE(RECV, "Recv");
REGISTER_OPTYPE_DECLARE(LABELSET, "LabelSet");
REGISTER_OPTYPE_DECLARE(LABELGOTO, "LabelGoto");
REGISTER_OPTYPE_DECLARE(LABELGOTOEX, "LabelGotoEx");
REGISTER_OPTYPE_DECLARE(LABELSWITCH, "LabelSwitch");
REGISTER_OPTYPE_DECLARE(LABELSWITCHBYINDEX, "LabelSwitchByIndex");

@ -979,9 +979,14 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAM
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_N_BATCH_SPILT;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NO_TASK_AND_DUMP_NEEDED;
// functional ops attr
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_WHILE_COND;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_WHILE_BODY;
// used for label switch
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_LABEL_SWITCH_INDEX;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_LABEL_SWITCH_LIST;
// Varible
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REF_VAR_SRC_VAR_NAME;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_SRC_VAR_NAME;

@ -22,7 +22,7 @@
#include <string>
#include <vector>
#include "graph/anchor.h"
#include "detail/attributes_holder.h"
#include "graph/detail/attributes_holder.h"
#include "graph/ge_tensor.h"
#include "graph/graph.h"
#include "graph/node.h"

@ -262,6 +262,8 @@ class GraphUtils {
static graphStatus MoveOutCtrlEdges(NodePtr &src_node, NodePtr &dst_node);
static ComputeGraphPtr FindRootGraph(ComputeGraphPtr graph);
static graphStatus TopologicalSortingByName(const ge::ComputeGraphPtr &compute_graph, vector<NodePtr> &node_vec);
};
class ComputeGraphBuilder {

@ -54,17 +54,34 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY size_t ComputeGraph::GetAllNodesS
return s;
}
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ComputeGraph::Vistor<NodePtr> ComputeGraph::GetAllNodes() const {
vector<NodePtr> all_nodes(nodes_.size());
(void)std::copy(nodes_.begin(), nodes_.end(), all_nodes.begin());
for (const auto &sub_graph : sub_graph_) {
if (sub_graph == nullptr) {
GELOGW("sub graph is nullptr");
if (sub_graph_.empty()) {
return Vistor<NodePtr>(shared_from_this(), nodes_);
}
std::vector<NodePtr> all_nodes;
std::deque<NodePtr> candidates;
candidates.insert(candidates.begin(), nodes_.begin(), nodes_.end());
while (!candidates.empty()) {
NodePtr node = candidates.front();
all_nodes.emplace_back(node);
candidates.pop_front();
OpDescPtr op_desc = node->GetOpDesc();
if (op_desc == nullptr) {
continue;
}
for (const auto &node : sub_graph->GetAllNodes()) {
all_nodes.push_back(node);
const auto &subgraph_names = op_desc->GetSubgraphInstanceNames();
for (auto name_iter = subgraph_names.rbegin(); name_iter != subgraph_names.rend(); ++name_iter) {
auto subgraph = GetSubgraph(*name_iter);
if (subgraph != nullptr) {
candidates.insert(candidates.begin(), subgraph->nodes_.begin(), subgraph->nodes_.end());
}
}
}
return Vistor<NodePtr>(shared_from_this(), all_nodes);
}
size_t ComputeGraph::GetDirectNodesSize() const { return nodes_.size(); }
@ -602,7 +619,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ComputeGraph::InsertE
graphStatus ComputeGraph::DFSTopologicalSorting(std::vector<NodePtr> &node_vec,
std::map<NodePtr, uint32_t> &map_in_edge_num,
std::vector<NodePtr> &stack) {
GELOGI("Runing_Dfs_Sort");
GELOGI("Runing_Dfs_Sort: %s", name_.c_str());
// Record the number of non data nodes but no input nodes
GE_CHK_BOOL_EXEC(SortNodes(stack, map_in_edge_num) == GRAPH_SUCCESS, return GRAPH_FAILED, "sort nodes failed");
@ -647,7 +664,7 @@ graphStatus ComputeGraph::DFSTopologicalSorting(std::vector<NodePtr> &node_vec,
graphStatus ComputeGraph::BFSTopologicalSorting(std::vector<NodePtr> &node_vec,
std::map<NodePtr, uint32_t> &map_in_edge_num,
std::deque<NodePtr> &stack) {
GELOGI("Runing_Bfs_Sort");
GELOGI("Runing_Bfs_Sort: %s", name_.c_str());
std::vector<NodePtr> stack_input;
std::map<string, NodePtr> breadth_node_map;
// Record the number of non data nodes but no input nodes
@ -735,7 +752,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ComputeGraph::Topolog
use_BFS = true;
}
} else {
GELOGW("Get OPTION_GRAPH_RUN_MODE failed, use BFSTopologicalSorting by default.");
GELOGW("OPTION_GRAPH_RUN_MODE not set, use BFSTopologicalSorting by default.");
}
if (use_BFS) {

@ -955,11 +955,8 @@ const std::string ATTR_NAME_DATA_DUMP_ORIGIN_FORMAT = "_datadump_origin_format";
const std::string ATTR_NAME_DATA_DUMP_ORIGIN_DATA_TYPE = "_datadump_origin_data_type";
// functional ops attr
const std::string ATTR_NAME_TCOND = "Tcond";
const std::string ATTR_NAME_TIN = "Tin";
const std::string ATTR_NAME_TOUT = "Tout";
const std::string ATTR_NAME_THEN_BRANCH = "then_branch";
const std::string ATTR_NAME_ELSE_BRANCH = "else_branch";
const std::string ATTR_NAME_WHILE_COND = "cond";
const std::string ATTR_NAME_WHILE_BODY = "body";
// used for label switch
const std::string ATTR_NAME_LABEL_SWITCH_INDEX = "_label_switch_index";

@ -28,6 +28,7 @@
#include <cstring>
#include <fstream>
#include <iomanip>
#include <queue>
#include "./ge_context.h"
#include "debug/ge_util.h"
@ -1999,4 +2000,60 @@ void PartialGraphBuilder::BuildExistNodes(graphStatus &error_code, std::string &
GELOGD("Build exist nodes succ.");
}
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus
GraphUtils::TopologicalSortingByName(const ge::ComputeGraphPtr &compute_graph, vector<NodePtr> &node_vec) {
std::vector<NodePtr> stack_input;
std::map<NodePtr, uint32_t> map_in_edge_num;
graphStatus ret = compute_graph->SortNodes(stack_input, map_in_edge_num);
if (ret != GRAPH_SUCCESS) {
GELOGE(GRAPH_FAILED, "Sort nodes failed.");
return GRAPH_FAILED;
}
const size_t non_user_input_index = stack_input.size() - compute_graph->inputs_order_.size() - 1;
std::sort(stack_input.begin(), stack_input.begin() + non_user_input_index,
[](const NodePtr &a, const NodePtr &b) -> bool { return (a->GetName() > b->GetName()); });
std::queue<NodePtr> stack;
NodePtr cur_node = nullptr;
std::map<string, NodePtr> name_node_map;
vector<string> nodes_name;
while (!stack_input.empty() || !stack.empty()) {
if (!stack.empty()) {
cur_node = stack.front();
stack.pop();
} else {
cur_node = stack_input.back();
stack_input.pop_back();
}
node_vec.emplace_back(cur_node);
compute_graph->CollectBreadthOutNode(cur_node, map_in_edge_num, name_node_map);
for (const auto &iter : name_node_map) {
nodes_name.emplace_back(iter.first);
}
std::sort(nodes_name.begin(), nodes_name.end());
for (const auto &iter : nodes_name) {
stack.push(name_node_map[iter]);
}
name_node_map.clear();
nodes_name.clear();
}
// If they are not equal, there is a closed loop
if (node_vec.size() != compute_graph->nodes_.size()) {
std::set<Node *> itered_nodes_set;
for (auto &node : node_vec) {
itered_nodes_set.insert(node.get());
}
GE_LOGE("Failed to do topo sorting total %zu, itered %zu, exist closed loop in graph.",
compute_graph->nodes_.size(), node_vec.size());
for (auto &node : compute_graph->nodes_) {
if (itered_nodes_set.count(node.get()) == 0) {
GE_LOGE("The node %s does not itered when topological sorting", node->GetName().c_str());
}
}
return GRAPH_FAILED;
}
return GRAPH_SUCCESS;
}
} // namespace ge

@ -41,6 +41,7 @@ include_directories(${GE_SOURCE_DIR}/inc/external/graph)
include_directories(${GE_SOURCE_DIR}/inc/framework)
include_directories(${GE_SOURCE_DIR}/inc/framework/common)
include_directories(${GE_SOURCE_DIR}/inc/runtime)
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib)
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc)
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce)
include_directories(${GE_SOURCE_DIR}/third_party/securec/include)
@ -55,6 +56,7 @@ file(GLOB TRAIN_SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"common/formats/utils/formats_trans_utils.cc"
"common/fp16_t.cc"
"common/ge/plugin_manager.cc"
"common/helper/model_cache_helper.cc"
"common/profiling/profiling_manager.cc"
"engine_manager/dnnengine_manager.cc"
"ge_local_engine/engine/host_cpu_engine.cc"
@ -92,6 +94,7 @@ file(GLOB TRAIN_SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"graph/load/new_model_manager/task_info/kernel_task_info.cc"
"graph/load/new_model_manager/task_info/label_goto_task_info.cc"
"graph/load/new_model_manager/task_info/label_set_task_info.cc"
"graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc"
"graph/load/new_model_manager/task_info/memcpy_async_task_info.cc"
"graph/load/new_model_manager/task_info/profiler_trace_task_info.cc"
"graph/load/new_model_manager/task_info/stream_active_task_info.cc"
@ -269,6 +272,7 @@ file(GLOB INFER_SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"common/formats/utils/formats_trans_utils.cc"
"common/fp16_t.cc"
"common/ge/plugin_manager.cc"
"common/helper/model_cache_helper.cc"
"common/profiling/profiling_manager.cc"
"engine_manager/dnnengine_manager.cc"
"ge_local_engine/engine/host_cpu_engine.cc"
@ -305,6 +309,7 @@ file(GLOB INFER_SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"graph/load/new_model_manager/task_info/kernel_task_info.cc"
"graph/load/new_model_manager/task_info/label_goto_task_info.cc"
"graph/load/new_model_manager/task_info/label_set_task_info.cc"
"graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc"
"graph/load/new_model_manager/task_info/memcpy_async_task_info.cc"
"graph/load/new_model_manager/task_info/profiler_trace_task_info.cc"
"graph/load/new_model_manager/task_info/stream_active_task_info.cc"
@ -470,7 +475,7 @@ target_link_libraries(ge_compiler
${slog}
${mmpa}
${msprof}
${runtime}
${runtime_compiler}
${resouce}
rt
dl)

@ -134,10 +134,6 @@ Status DataTypeTransfer::TransDataType(const CastArgs &args, TransResult &result
}
auto trans_mode = iter->second;
if (args.src_data_size == 0) {
GELOGE(PARAM_INVALID, "Invalid src data size %zu", args.src_data_size);
return PARAM_INVALID;
}
int size = GetSizeByDataType(args.dst_data_type);
if (size <= 0) {
GELOGE(PARAM_INVALID, "Failed to calc size from data type %s",
@ -149,6 +145,12 @@ Status DataTypeTransfer::TransDataType(const CastArgs &args, TransResult &result
return PARAM_INVALID;
}
size_t total_size = static_cast<size_t>(args.src_data_size * size);
result.length = total_size;
if (total_size == 0) {
GELOGI("In TransDataType, total_size is zero, has no data.");
return SUCCESS;
}
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) {
GELOGE(OUT_OF_MEMORY, "Failed to alloc the memory for dst buf %zu, data size %zu", total_size, args.src_data_size);
@ -162,7 +164,6 @@ Status DataTypeTransfer::TransDataType(const CastArgs &args, TransResult &result
return INTERNAL_ERROR;
}
result.data = dst;
result.length = total_size;
return SUCCESS;
}

@ -134,6 +134,11 @@ Status FormatTransferC1hwncoc0Hwcn::TransFormat(const TransArgs &args, TransResu
int size = GetSizeByDataType(args.src_data_type);
int64_t total_size = GetItemNumByShape(args.dst_shape) * size;
if (total_size <= 0) {
int64_t src_size = GetItemNumByShape(args.src_shape);
if (total_size == 0 && src_size == 0) {
result.length = static_cast<size_t>(total_size);
return SUCCESS;
}
GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size,
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str());
return PARAM_INVALID;

@ -88,6 +88,11 @@ Status TransFormatDhwckToFz3D(const TransArgs &args, TransResult &result) {
dst_size *= dim;
}
dst_size *= data_size;
if (dst_size == 0) {
result.length = static_cast<size_t>(dst_size);
return SUCCESS;
}
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) {
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld",

@ -89,6 +89,11 @@ Status TransFormatDhwncToFz3DTranspose(const TransArgs &args, TransResult &resul
dst_size *= dim;
}
dst_size *= data_size;
if (dst_size == 0) {
result.length = static_cast<size_t>(dst_size);
return SUCCESS;
}
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) {
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld",

@ -116,6 +116,11 @@ Status CheckShapeRelation(const TransArgs &args, ShapeVector &hw_shape) {
Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, const ShapeVector &hw_shape) {
int size = GetSizeByDataType(args.src_data_type);
int64_t dst_size = GetItemNumByShape(args.dst_shape) * size;
if (dst_size == 0) {
result.length = static_cast<size_t>(dst_size);
return SUCCESS;
}
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size](), std::default_delete<uint8_t[]>());
if (dst == nullptr) {
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld",
@ -184,6 +189,11 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con
Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, const ShapeVector &dst_hw_shape) {
int size = GetSizeByDataType(args.src_data_type);
int64_t dst_size = GetItemNumByShape(args.dst_shape) * size;
if (dst_size == 0) {
result.length = static_cast<size_t>(dst_size);
return SUCCESS;
}
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) {
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld",

@ -119,6 +119,11 @@ Status TransFormatFromNchwToFz(const TransArgs &args, TransResult &result) {
int64_t total_ele_cnt = hf_cnt * vf_cnt * fractal_ele_cnt;
int size = GetSizeByDataType(args.src_data_type);
int64_t dst_size = total_ele_cnt * size;
if (dst_size == 0) {
result.length = static_cast<size_t>(dst_size);
return SUCCESS;
}
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) {
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld",
@ -194,6 +199,11 @@ Status TransFormatHwcnToFz(const TransArgs &args, TransResult &result) {
dst_size *= dim;
}
dst_size *= data_size;
if (dst_size == 0) {
result.length = static_cast<size_t>(dst_size);
return SUCCESS;
}
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) {
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld",
@ -259,6 +269,11 @@ Status TransFormatNhwcToFz(const TransArgs &args, TransResult &result) {
dst_size *= dim;
}
dst_size *= data_size;
if (dst_size == 0) {
result.length = static_cast<size_t>(dst_size);
return SUCCESS;
}
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) {
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld",

@ -117,6 +117,11 @@ Status CheckShapeRelation(const TransArgs &args, ShapeVector &hw_shape) {
Status TransFormatFromNdToFracZz(const TransArgs &args, TransResult &result, const ShapeVector &hw_shape) {
int size = GetSizeByDataType(args.src_data_type);
int64_t dst_size = GetItemNumByShape(args.dst_shape) * size;
if (dst_size == 0) {
result.length = static_cast<size_t>(dst_size);
return SUCCESS;
}
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size](), std::default_delete<uint8_t[]>());
if (dst == nullptr) {
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld",
@ -153,8 +158,8 @@ Status TransFormatFromNdToFracZz(const TransArgs &args, TransResult &result, con
auto src_offset = (src_h_head + w1_idx * w0) * size;
auto dst_offset = (h0_head + w1_idx * h0w0) * size;
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN)
? dst_size - dst_offset
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN);
? dst_size - dst_offset
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN);
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
static_cast<size_t>(size * w0));
if (ret != EOK) {
@ -169,8 +174,8 @@ Status TransFormatFromNdToFracZz(const TransArgs &args, TransResult &result, con
auto src_offset = (src_h_head + src_w_idx) * size;
auto dst_offset = (w0_head + w0_idx) * size;
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN)
? dst_size - dst_offset
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN);
? dst_size - dst_offset
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN);
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
static_cast<size_t>(size));
if (ret != EOK) {
@ -189,6 +194,11 @@ Status TransFormatFromNdToFracZz(const TransArgs &args, TransResult &result, con
Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, const ShapeVector &dst_hw_shape) {
int size = GetSizeByDataType(args.src_data_type);
int64_t dst_size = GetItemNumByShape(args.dst_shape) * size;
if (dst_size == 0) {
result.length = static_cast<size_t>(dst_size);
return SUCCESS;
}
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size](), std::default_delete<uint8_t[]>());
if (dst == nullptr) {
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld",
@ -226,8 +236,8 @@ Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, con
auto src_offset = (h0_head + w1_idx * h0w0) * size;
auto dst_offset = (dst_h_head + w1_idx * w0) * size;
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN)
? dst_size - dst_offset
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN);
? dst_size - dst_offset
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN);
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
static_cast<size_t>(size * w0));
if (ret != EOK) {
@ -242,8 +252,8 @@ Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, con
auto dst_w_idx = w1_head + w0_idx;
auto dst_offset = (dst_h_head + dst_w_idx) * size;
auto protected_size = dst_size - dst_offset < static_cast<int64_t>(SECUREC_MEM_MAX_LEN)
? dst_size - dst_offset
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN);
? dst_size - dst_offset
: static_cast<int64_t>(SECUREC_MEM_MAX_LEN);
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
static_cast<size_t>(size));
if (ret != EOK) {

@ -133,6 +133,12 @@ Status FormatTransferFracZHwcn::TransFormat(const TransArgs &args, TransResult &
int size = GetSizeByDataType(args.src_data_type);
auto total_size = GetItemNumByShape(args.dst_shape) * size;
if (total_size <= 0) {
int64_t src_size = GetItemNumByShape(args.src_shape);
if (total_size == 0 && src_size == 0) {
result.length = static_cast<size_t>(total_size);
return SUCCESS;
}
GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size,
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str());
return PARAM_INVALID;

@ -133,6 +133,12 @@ Status FormatTransferFracZNchw::TransFormat(const TransArgs &args, TransResult &
int size = GetSizeByDataType(args.src_data_type);
auto total_size = GetItemNumByShape(args.dst_shape) * size;
if (total_size <= 0) {
int64_t src_size = GetItemNumByShape(args.src_shape);
if (total_size == 0 && src_size == 0) {
result.length = static_cast<size_t>(total_size);
return SUCCESS;
}
GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size,
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str());
return PARAM_INVALID;
@ -140,6 +146,7 @@ Status FormatTransferFracZNchw::TransFormat(const TransArgs &args, TransResult &
GELOGD("Begin to trans format from FracZ to NCHW, src shape %s, data type %s, dst shape %s, memory size %ld",
ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(),
ShapeToString(args.dst_shape).c_str(), total_size);
if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld",
ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(),

@ -132,6 +132,12 @@ Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult &
int size = GetSizeByDataType(args.src_data_type);
auto total_size = GetItemNumByShape(args.dst_shape) * size;
if (total_size <= 0) {
int64_t src_size = GetItemNumByShape(args.src_shape);
if (total_size == 0 && src_size == 0) {
result.length = static_cast<size_t>(total_size);
return SUCCESS;
}
GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size,
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str());
return PARAM_INVALID;

@ -35,7 +35,7 @@ Status TransShapeHwcnToC1hwncoc0(const DataType &data_type, const std::vector<in
std::vector<int64_t> &dst_shape) {
auto cube_size = GetCubeSizeByDataType(data_type);
dst_shape.clear();
dst_shape.push_back((src_shape.at(kHwcnC) - 1) / cube_size + 1);
dst_shape.push_back(Ceil(src_shape.at(kHwcnC), static_cast<int64_t>(cube_size)));
dst_shape.push_back(src_shape.at(kHwcnH));
dst_shape.push_back(src_shape.at(kHwcnW));
dst_shape.push_back(src_shape.at(kHwcnN));
@ -169,6 +169,12 @@ Status FormatTransferHwcnC1hwncoc0::TransFormat(const TransArgs &args, TransResu
int size = GetSizeByDataType(args.src_data_type);
auto total_size = GetItemNumByShape(args.dst_shape) * size;
if (total_size <= 0) {
int64_t src_size = GetItemNumByShape(args.src_shape);
if (total_size == 0 && src_size == 0) {
result.length = static_cast<size_t>(total_size);
return SUCCESS;
}
GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size,
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str());
return PARAM_INVALID;

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

Loading…
Cancel
Save