synchronize with latest Ascend software suite 6 Jun 2020

pull/35/head
yanghaoran 5 years ago
parent 97852a0d7f
commit 18d9e39ddf

@ -16,6 +16,7 @@
cmake_minimum_required(VERSION 3.14)
project (GraphEngine[CXX])
set(CMAKE_CXX_STANDARD 14)
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(GE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})
@ -71,6 +72,7 @@ elseif(DEFINED ENV{D_LINK_PATH})
find_library(register libregister.so ${GE_LIB_PATH})
find_library(hccl libhccl.so ${GE_LIB_PATH})
find_library(resource libresource.so ${GE_LIB_PATH})
find_library(error_manager liberror_manager.so ${GE_LIB_PATH})
else()
# Ascend mode
if(DEFINED ENV{ASCEND_CUSTOM_PATH})
@ -88,6 +90,7 @@ else()
find_library(runtime libruntime.so ${ASCEND_RUNTIME_DIR})
find_library(register libregister.so ${ASCEND_RUNTIME_DIR})
find_library(resource libresource.so ${ASCEND_RUNTIME_DIR})
find_library(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR})
endif()
# add compile flags

@ -44,6 +44,9 @@ class GraphOptimizer {
// optimize original graph, using in graph preparation stage
virtual Status OptimizeOriginalGraph(ComputeGraph &graph) = 0;
// optimize original graph, using for conversion operator insert in graph preparation stage
virtual Status OptimizeOriginalGraphJudgeInsert(ComputeGraph &graph) { return SUCCESS; }
// optimize fused graph
virtual Status OptimizeFusedGraph(ComputeGraph &graph) = 0;

@ -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,83 @@
/**
* 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 ERROR_MANAGER_H_
#define ERROR_MANAGER_H_
#include <map>
#include <string>
#include <vector>
class ErrorManager {
public:
///
/// @brief Obtain ErrorManager instance
/// @return ErrorManager instance
///
static ErrorManager &GetInstance();
///
/// @brief init
/// @param [in] path current so path
/// @return int 0(success) -1(fail)
///
int Init(std::string path);
///
/// @brief Report error message
/// @param [in] errCode error code
/// @param [in] mapArgs parameter map
/// @return int 0(success) -1(fail)
///
int ReportErrMessage(std::string error_code, const std::map<std::string, std::string> &args_map);
/// @brief output error message
/// @param [in] handle print handle
/// @return int 0(success) -1(fail)
///
int OutputErrMessage(int handle);
/// @brief Report error message
/// @param [in] vector parameter key, vector parameter value
///
void ATCReportErrMessage(std::string error_code, const std::vector<std::string> &key = {},
const std::vector<std::string> &value = {});
private:
struct ErrorInfo {
std::string error_id;
std::string error_message;
std::vector<std::string> arglist;
};
ErrorManager() {}
~ErrorManager() {}
ErrorManager(const ErrorManager &) = delete;
ErrorManager(ErrorManager &&) = delete;
ErrorManager &operator=(const ErrorManager &) = delete;
ErrorManager &operator=(ErrorManager &&) = delete;
int ParseJsonFile(std::string path);
int ReadJsonFile(const std::string &file_path, void *handle);
bool is_init_ = false;
std::map<std::string, ErrorInfo> error_map_;
std::vector<std::string> error_message_evc_;
};
#endif // ERROR_MANAGER_H_

@ -65,6 +65,8 @@ class PlatformInfoManager {
void ParseUBOfAICoreSpec(map<string, string> &aiCoreSpecMap, PlatformInfo &platformInfoTemp);
void ParseUnzipOfAICoreSpec(map<string, string> &aiCoreSpecMap, PlatformInfo &platformInfoTemp);
void ParseAICoreSpec(map<string, string> &aiCoreSpecMap, PlatformInfo &platformInfoTemp);
void ParseBufferOfAICoreMemoryRates(map<string, string> &aiCoreMemoryRatesMap, PlatformInfo &platformInfoTemp);

@ -65,6 +65,10 @@ typedef struct tagAiCoreSpec {
uint64_t ubbankNum;
uint64_t ubburstInOneBlock;
uint64_t ubbankGroupNum;
uint32_t unzipEngines;
uint32_t unzipMaxRatios;
uint32_t unzipChannels;
uint8_t unzipIsTight;
} AiCoreSpec;
typedef struct tagAiCoreMemoryRates {

@ -82,14 +82,12 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session {
/// @brief run graph in the session with specific session id asynchronously
/// @param [in] graphId: graph id
/// @param [in] inputs: input data
/// @param [out] outputs: output data
/// @param [out] callback: callback while runing graph has been finished.
/// The callback function will not be checked.
/// Please ensure that the implementation of the function is trusted.
/// @return Status result of function
///
Status RunGraphAsync(uint32_t graphId, const std::vector<ge::TensorInfo> &inputs,
std::vector<ge::TensorInfo> &outputs, std::function<void(Status)> callback);
Status RunGraphAsync(uint32_t graphId, const std::vector<ge::InputTensorInfo> &inputs, RunAsyncCallback callback);
///
/// @ingroup ge_graph

@ -21,6 +21,8 @@
#include <string>
#include <vector>
#include <set>
#include <functional>
#include <memory>
namespace ge {
// Option key: graph run mode
@ -40,6 +42,12 @@ 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_DUMP_MODE = "ge.exec.dumpMode";
const char *const OPTION_EXEC_ENABLE_INCRE_BUILD = "ge.exec.enableIncreBuild";
const char *const OPTION_EXEC_INCRE_BUILD_CACHE_PATH = "ge.exec.increBuildCachePath";
// profiling flag
const char *const OPTION_EXEC_PROFILING_MODE = "ge.exec.profilingMode";
const char *const OPTION_EXEC_PROFILING_OPTIONS = "ge.exec.profilingOptions";
// 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";
@ -173,6 +181,9 @@ const std::string AICORE_NUM = "ge.aicoreNum";
// Configure L1FUSION
const std::string L1_FUSION = "ge.l1Fusion";
// Configure l1,l2,and others optimize option
const std::string BUFFER_OPTIMIZE = "ge.bufferOptimize";
// Configure Small Channel flag
const std::string ENABLE_SMALL_CHANNEL = "ge.enableSmallChannel";
@ -188,6 +199,9 @@ const std::string SAVE_ORIGINAL_MODEL = "ge.saveOriginalModel";
// Save original model file name
const std::string ORIGINAL_MODEL_FILE = "ge.originalModelFile";
// FE enable quant optimize
const std::string QUANT_OPTIMIZE = "ge.quantOptimize";
const char *const OPTION_GE_MAX_DUMP_FILE_NUM = "ge.maxDumpFileNum";
const char *const OPTION_GE_MAX_DUMP_FILE_SIZE = "ge.maxDumpFileSize";
const char *const OPTION_GE_MAX_DUMP_OP_NUM = "ge.maxDumpOpNum";
@ -196,36 +210,49 @@ const char *const OPTION_GE_MAX_DUMP_OP_NUM = "ge.maxDumpOpNum";
// Its value should be "0" or "1", default value is "1"
const char *const ENABLE_PRINT_OP_PASS = "ge.enablePrintOpPass";
// Configure whether to use single stream.
// Its value should be "true" or "false", default value is "false"
const char *const ENABLE_SINGLE_STREAM = "ge.enableSingleStream";
// Graph run mode
enum GraphRunMode { PREDICTION = 0, TRAIN };
// Data description
struct DataDesc {
void *data = nullptr; // data address
uint32_t length = 0; // data size
bool isDataSupportMemShare = false;
// Input/Output tensor info
struct InputTensorInfo {
uint32_t data_type; // data type
std::vector<int64_t> dims; // shape description
void *data; // tensor data
int64_t length; // tensor length
};
// Input/Output shape description
struct ShapeDesc {
int64_t num = 0;
int64_t channel = 0;
int64_t height = 0;
int64_t width = 0;
std::vector<int64_t> dims;
struct OutputTensorInfo {
uint32_t data_type; // data type
std::vector<int64_t> dims; // shape description
std::unique_ptr<uint8_t[]> data; // tensor data
int64_t length; // tensor length
OutputTensorInfo() : data_type(0), dims({}), data(nullptr), length(0) {}
OutputTensorInfo(OutputTensorInfo &&out)
: data_type(out.data_type), dims(out.dims), data(std::move(out.data)), length(out.length) {}
OutputTensorInfo &operator=(OutputTensorInfo &&out) {
if (this != &out) {
data_type = out.data_type;
dims = out.dims;
data = std::move(out.data);
length = out.length;
}
return *this;
}
OutputTensorInfo(const OutputTensorInfo &) = delete;
OutputTensorInfo &operator=(const OutputTensorInfo &) = delete;
};
// Input/Output tensor info
struct TensorInfo {
uint32_t dataType; // data type
DataDesc data; // tensor data
ShapeDesc shapeInfo; // tensor shape
};
using Status = uint32_t;
using RunAsyncCallback = std::function<void(Status, std::vector<ge::OutputTensorInfo> &)>;
// for ir build
namespace ir_option {
static const char *const INPUT_FORMAT = "input_format";
static const char *const INPUT_SHAPE = "input_shape";
static const char *const OP_NAME_MAP = "op_name_map";
static const char *const DYNAMIC_BATCH_SIZE = kDynamicBatchSize;
static const char *const DYNAMIC_IMAGE_SIZE = kDynamicImageSize;
static const char *const INSERT_OP_FILE = ge::INSERT_OP_FILE.c_str();
@ -235,13 +262,15 @@ static const char *const HEAD_STREAM = ge::HEAD_STREAM.c_str();
static const char *const AUTO_TUNE_MODE = ge::AUTO_TUNE_MODE.c_str();
static const char *const CORE_TYPE = ge::CORE_TYPE.c_str();
static const char *const SOC_VERSION = ge::SOC_VERSION.c_str();
static const char *const ENABLE_SINGLE_STREAM = ge::ENABLE_SINGLE_STREAM;
// for interface: aclgrphBuildModel
const std::set<std::string> ir_builder_suppported_options = {
INPUT_FORMAT, INPUT_SHAPE, OP_NAME_MAP, DYNAMIC_BATCH_SIZE,
DYNAMIC_IMAGE_SIZE, INSERT_OP_FILE, PRECISION_MODE, EXEC_DISABLE_REUSED_MEMORY,
AUTO_TUNE_MODE};
const std::set<std::string> ir_builder_suppported_options = {INPUT_FORMAT, INPUT_SHAPE, DYNAMIC_BATCH_SIZE,
DYNAMIC_IMAGE_SIZE, INSERT_OP_FILE};
// for interface: aclgrphBuildInitialize
const std::set<std::string> global_options = {HEAD_STREAM, CORE_TYPE, SOC_VERSION};
const std::set<std::string> global_options = {
HEAD_STREAM, CORE_TYPE, SOC_VERSION, PRECISION_MODE, EXEC_DISABLE_REUSED_MEMORY,
AUTO_TUNE_MODE, ENABLE_SINGLE_STREAM};
} // namespace ir_option
} // namespace ge

@ -55,12 +55,16 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Graph {
graphStatus FindOpByName(const string &name, ge::Operator &op) const;
graphStatus FindOpByType(const string &type, std::vector<ge::Operator> &ops) const;
graphStatus GetAllOpName(std::vector<string> &op_name) const;
graphStatus SaveToFile(const string &file_name) const;
graphStatus LoadFromFile(const string &file_name);
const std::string &GetName() const;
///
/// Set is need train iteration.
/// If set true, it means this graph need to be run iteration some

@ -69,7 +69,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InferenceContext {
static std::unique_ptr<InferenceContext> Create();
private:
InferenceContext(std::unique_ptr<InferenceContextImpl> &impl);
explicit InferenceContext(std::unique_ptr<InferenceContextImpl> &impl);
std::shared_ptr<InferenceContextImpl> inference_context_impl_;
};
} // namespace ge

@ -44,11 +44,16 @@
namespace ge {
class OperatorImpl;
class NamedAttrs;
class Graph;
class AttrValue;
using SubgraphBuilder = std::function<Graph(const std::string &name)>;
using OperatorImplPtr = std::shared_ptr<OperatorImpl>;
class Graph;
using GraphBuilderCallback = std::function<Graph()>;
class OpIO;
using OutHandler = std::shared_ptr<OpIO>;
using InHandler = std::shared_ptr<OpIO>;
@ -69,6 +74,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator {
using OpBool = bool;
using OpTensor = Tensor;
using OpType = ge::DataType;
using OpNamedAttrs = ge::NamedAttrs;
using OpListInt = std::vector<int64_t>;
using OpListFloat = std::vector<float>;
using OpListString = std::vector<string>;
@ -77,6 +83,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator {
using OpBytes = std::vector<uint8_t>;
using OpListListInt = std::vector<std::vector<int64_t>>;
using OpListType = std::vector<ge::DataType>;
using OpListNamedAttrs = std::vector<ge::NamedAttrs>;
Operator() {}
@ -132,6 +139,12 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator {
void SetInferenceContext(const InferenceContextPtr &inference_context);
InferenceContextPtr GetInferenceContext() const;
void SetGraphBuilder(const GraphBuilderCallback &builder);
graphStatus GetGraphBuilder(GraphBuilderCallback &builder) const;
void AddSubgraphName(const string &name);
string GetSubgraphName(int index) const;
graphStatus VerifyAllAttr(bool disable_common_verifier = false);
size_t GetInputsSize() const;
@ -190,8 +203,21 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator {
Operator &SetAttr(const string &name, const ge::DataType &attr_value);
graphStatus GetAttr(const string &name, ge::DataType &attr_value) const;
// func type
Operator &SetAttr(const string &name, const ge::NamedAttrs &attr_value);
graphStatus GetAttr(const string &name, ge::NamedAttrs &attr_value) const;
Operator &SetAttr(const string &name, const std::vector<ge::NamedAttrs> &attr_value);
graphStatus GetAttr(const string &name, std::vector<ge::NamedAttrs> &attr_value) const;
void BreakConnect() const;
size_t GetSubgraphNamesCount() const;
std::vector<std::string> GetSubgraphNames() const;
SubgraphBuilder GetSubgraphBuilder(const string &name) const;
Graph GetSubgraph(const string &name) const;
SubgraphBuilder GetDynamicSubgraphBuilder(const string &name, uint32_t index) const;
Graph GetDynamicSubgraph(const string &name, uint32_t index) const;
protected:
void AttrRegister(const string &name, float attr_value);
void AttrRegister(const string &name, const std::vector<float> &attr_value);
@ -207,6 +233,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator {
void AttrRegister(const string &name, const std::vector<std::vector<int64_t>> &attr_value);
void AttrRegister(const string &name, const std::vector<ge::DataType> &attr_value);
void AttrRegister(const string &name, const ge::DataType &attr_value);
void AttrRegister(const string &name, const ge::NamedAttrs &attr_value);
void AttrRegister(const string &name, const std::vector<ge::NamedAttrs> &attr_value);
explicit Operator(OperatorImplPtr &&op_impl);
@ -224,6 +252,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator {
void DynamicInputRegister(const string &name, const unsigned int num, bool is_push_back = true);
void DynamicInputRegisterByIndex(const string &name, const unsigned int num, size_t index);
void DynamicOutputRegister(const string &name, const unsigned int num, bool is_push_back = true);
void RequiredAttrRegister(const string &name);
@ -235,6 +265,10 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator {
Operator &SetInput(const string &dst_name, uint32_t dst_index, const Operator &src_oprt, const string &name);
void SubgraphRegister(const std::string &name, bool dynamic);
void SubgraphCountRegister(const std::string &name, uint32_t count);
void SetSubgraphBuilder(const std::string &name, uint32_t index, const SubgraphBuilder &builder);
private:
Operator &SetInput(const string &dst_name, const OutHandler &out_handler);

@ -22,10 +22,11 @@
#include <string>
#include <vector>
#include "./operator.h"
#include "./operator_factory.h"
#include "./tensor.h"
#include "./types.h"
#include "graph/operator.h"
#include "graph/operator_factory.h"
#include "graph/tensor.h"
#include "graph/types.h"
#include "graph/graph.h"
namespace ge {
using std::function;
@ -46,6 +47,10 @@ class OpReg {
OpReg &OUTPUT() { return *this; }
OpReg &GRAPH() { return *this; }
OpReg &DYNAMIC_GRAPH() { return *this; }
OpReg &INFER_SHAPE_AND_TYPE() { return *this; }
};
@ -191,6 +196,10 @@ class OpReg {
Operator::DynamicInputRegister(#x, num, isPushBack); \
return *this; \
} \
_THIS_TYPE &create_dynamic_input_byindex_##x(unsigned int num, size_t index) { \
Operator::DynamicInputRegisterByIndex(#x, num, index); \
return *this; \
} \
TensorDesc get_dynamic_input_desc_##x(unsigned int index) const { return Operator::GetDynamicInputDesc(#x, index); } \
graphStatus update_dynamic_input_desc_##x(unsigned int index, const TensorDesc &tensorDesc) { \
return Operator::UpdateDynamicInputDesc(#x, index, tensorDesc); \
@ -229,6 +238,51 @@ class OpReg {
void __dy_output_##x() { \
(void)OpReg()
#define GRAPH(x) \
N(); \
__graph_##x(); \
} \
\
public: \
static const string name_graph_##x() { return #x; } \
SubgraphBuilder get_subgraph_builder_##x() const { return Operator::GetSubgraphBuilder(#x); } \
_THIS_TYPE &set_subgraph_builder_##x(const SubgraphBuilder &v) { \
Operator::SetSubgraphBuilder(#x, 0, v); \
return *this; \
} \
Graph get_subgraph_##x() const { return Operator::GetSubgraph(#x); } \
\
private: \
void __graph_##x() { \
Operator::SubgraphRegister(#x, false); \
Operator::SubgraphCountRegister(#x, 1); \
(void)OpReg()
#define DYNAMIC_GRAPH(x) \
N(); \
__graph_##x(); \
} \
\
public: \
static const string name_graph_##x() { return #x; } \
_THIS_TYPE &create_dynamic_subgraph_##x(unsigned int num) { \
Operator::SubgraphCountRegister(#x, num); \
return *this; \
} \
SubgraphBuilder get_dynamic_subgraph_builder_##x(unsigned int index) const { \
return Operator::GetDynamicSubgraphBuilder(#x, index); \
} \
Graph get_dynamic_subgraph_##x(unsigned int index) const { return Operator::GetDynamicSubgraph(#x, index); } \
_THIS_TYPE &set_dynamic_subgraph_builder_##x(unsigned int index, const SubgraphBuilder &v) { \
Operator::SetSubgraphBuilder(#x, index, v); \
return *this; \
} \
\
private: \
void __graph_##x() { \
Operator::SubgraphRegister(#x, true); \
(void)OpReg()
#define PASTE(g_register, y) g_register##y
#define __OP_END_IMPL__(x, y) \
N(); \

@ -21,6 +21,7 @@
#include <memory>
#include <string>
#include <vector>
#include <utility>
#include "./ge_error_codes.h"
#include "./types.h"
@ -62,6 +63,11 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY TensorDesc {
void Update(const Shape &shape, Format format = FORMAT_ND, DataType dt = DT_FLOAT);
Shape GetShape() const;
void SetShape(const Shape &shape);
// set shape with -2, it stand for unknown shape
graphStatus SetUnknownDimNumShape();
// for unknown shape
graphStatus SetShapeRange(const std::vector<std::pair<int64_t, int64_t>> &range);
graphStatus GetShapeRange(std::vector<std::pair<int64_t, int64_t>> &range) const;
Format GetFormat() const;
void SetFormat(Format format);

@ -23,7 +23,9 @@
namespace ge {
static const int64_t UNKNOWN_DIM = -1;
static const int64_t UNKNOWN_DIM_NUM = -2;
static const std::vector<int64_t> UNKNOWN_SHAPE = {0};
static const std::vector<int64_t> UNKNOWN_RANK = {-2};
#ifdef HOST_VISIBILITY
#define GE_FUNC_HOST_VISIBILITY __attribute__((visibility("default")))
@ -140,10 +142,19 @@ enum Format {
FORMAT_NC,
FORMAT_DHWNC,
FORMAT_FRACTAL_Z_3D_TRANSPOSE, // 3D filter(transpose) input tensor format
FORMAT_FRACTAL_ZN_LSTM,
FORMAT_RESERVED,
FORMAT_ALL
};
// for unknown shape op type
enum UnknowShapeOpType {
DEPEND_IN_SHAPE = 1, // op out shape get by input shape
DEPEND_CONST_VALUE = 2, // op out shape get by const op value
DEPEND_SHAPE_RANGE = 3, // op out shape get by range
DEPEND_COMPUTE = 4 // op out shape get by totally computing
};
struct TensorDescInfo {
Format format_ = FORMAT_RESERVED; // tbe op register support format
DataType dataType_ = DT_UNDEFINED; // tbe op register support datatype

@ -58,12 +58,18 @@ Status AutoMappingFn(const google::protobuf::Message *op_src, ge::Operator &op);
Status AutoMappingFnDynamic(const google::protobuf::Message *op_src, ge::Operator &op,
std::map<std::string, std::pair<std::string, std::string>> dynamic_name_attr_value,
int in_pos = -1, int out_pos = -1);
Status AutoMappingSubgraphIndex(const ge::Graph &graph, const std::function<int(int data_index)> &input,
const std::function<int(int netoutput_index)> &output);
Status AutoMappingSubgraphIndex(const ge::Graph &graph,
const std::function<Status(int data_index, int &parent_input_index)> &input,
const std::function<Status(int netoutput_index, int &parent_output_index)> &output);
using google::protobuf::Message;
class OpRegistrationDataImpl;
using ParseParamFunc = std::function<domi::Status(const google::protobuf::Message *, ge::Operator &)>;
using FusionParseParamFunc =
std::function<domi::Status(const std::vector<const google::protobuf::Message *>, ge::Operator &)>;
using ParseSubgraphFunc = std::function<Status(const std::string &subgraph_name, const ge::Graph &graph)>;
class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistrationData {
public:
@ -81,6 +87,8 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistrationData {
OpRegistrationData &FusionParseParamsFn(const FusionParseParamFunc &fusionParseParamFn);
OpRegistrationData &ParseSubgraphPostFn(const ParseSubgraphFunc &subgraph_post_fn);
OpRegistrationData &ImplyType(const domi::ImplyType &imply_type);
OpRegistrationData &DelInputWithCond(int inputIdx, const std::string &attrName, bool attrValue);
@ -93,6 +101,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistrationData {
domi::FrameworkType GetFrameworkType() const;
ParseParamFunc GetParseParamFn() const;
FusionParseParamFunc GetFusionParseParamFn() const;
ParseSubgraphFunc GetParseSubgraphPostFn() const;
private:
std::shared_ptr<OpRegistrationDataImpl> impl_;
@ -116,27 +125,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_

@ -51,24 +51,24 @@ inline pid_t GetTid() {
return tid;
}
#define GE_TIMESTAMP_START(stage) uint64_t startUsec_##stage = domi::GetCurrentTimestap()
#define GE_TIMESTAMP_START(stage) uint64_t startUsec_##stage = ge::GetCurrentTimestap()
#define GE_TIMESTAMP_END(stage, stage_name) \
do { \
uint64_t endUsec_##stage = domi::GetCurrentTimestap(); \
uint64_t endUsec_##stage = ge::GetCurrentTimestap(); \
GEEVENT("[GEPERFTRACE] The time cost of %s is [%lu] micro second.", (stage_name), \
(endUsec_##stage - startUsec_##stage)); \
} while (0);
#define GE_TIMESTAMP_CALLNUM_START(stage) \
uint64_t startUsec_##stage = domi::GetCurrentTimestap(); \
uint64_t call_num_of##stage = 0; \
#define GE_TIMESTAMP_CALLNUM_START(stage) \
uint64_t startUsec_##stage = ge::GetCurrentTimestap(); \
uint64_t call_num_of##stage = 0; \
uint64_t time_of##stage = 0
#define GE_TIMESTAMP_RESTART(stage) (startUsec_##stage = domi::GetCurrentTimestap())
#define GE_TIMESTAMP_RESTART(stage) (startUsec_##stage = ge::GetCurrentTimestap())
#define GE_TIMESTAMP_ADD(stage) \
time_of##stage += domi::GetCurrentTimestap() - startUsec_##stage; \
#define GE_TIMESTAMP_ADD(stage) \
time_of##stage += ge::GetCurrentTimestap() - startUsec_##stage; \
call_num_of##stage++
#define GE_TIMESTAMP_CALLNUM_END(stage, stage_name) \

@ -22,7 +22,6 @@
#include "cce/cce_def.hpp"
#include "common/string_util.h"
#include "common/util.h"
#include "dlog/log.h"
#include "framework/common/debug/ge_log.h"
#include "ge/ge_api_error_codes.h"
@ -30,7 +29,7 @@ using cce::CC_STATUS_SUCCESS;
using cce::ccStatus_t;
#if !defined(__ANDROID__) && !defined(ANDROID)
#define DOMI_LOGE(...) DAV_LOGE("DOMI", __VA_ARGS__)
#define DOMI_LOGE(...) GE_LOG_ERROR(GE_MODULE_NAME, ge::FAILED, __VA_ARGS__)
#else
#include <android/log.h>
#if defined(BUILD_VERSION_PERF)
@ -103,17 +102,17 @@ using cce::ccStatus_t;
} while (0);
// If expr is not true, print the log and return the specified status
#define GE_CHK_BOOL_RET_STATUS(expr, _status, ...) \
do { \
bool b = (expr); \
if (!b) { \
std::string msg; \
(void)msg.append(domi::StringUtils::FormatString(__VA_ARGS__)); \
(void)msg.append( \
domi::StringUtils::FormatString(" Error Code:0x%X(%s)", _status, GET_ERRORNO_STR(_status).c_str())); \
DOMI_LOGE("%s", msg.c_str()); \
return _status; \
} \
#define GE_CHK_BOOL_RET_STATUS(expr, _status, ...) \
do { \
bool b = (expr); \
if (!b) { \
std::string msg; \
(void)msg.append(ge::StringUtils::FormatString(__VA_ARGS__)); \
(void)msg.append( \
ge::StringUtils::FormatString(" Error Code:0x%X(%s)", _status, GET_ERRORNO_STR(_status).c_str())); \
DOMI_LOGE("%s", msg.c_str()); \
return _status; \
} \
} while (0);
// If expr is not true, print the log and return the specified status

@ -152,7 +152,6 @@ GE_ERRORNO_GRAPH(GE_GRAPH_OPTIMIZE_RUN_GRAPH_INVALID, 11, "Get computeGraph by g
GE_ERRORNO_GRAPH(GE_GRAPH_OPTIMIZE_INSERT_DYN_OP_FAILED, 12, "Graph which insert dynamic op failed."); // 1343242252
GE_ERRORNO_GRAPH(GE_GRAPH_OPTIMIZE_PREPROCESS_FAILED, 13, "Graph preprocess failed."); // 1343242253
GE_ERRORNO_GRAPH(GE_GRAPH_OPTIMIZE_GRAPH_FUSION_FAILED, 14, "Graph fusion failed."); // 1343242254
GE_ERRORNO_GRAPH(GE_GRAPH_OPTIMIZE_TINY_CAL_CHECK_FAILED, 15, "Check tiny calibration failed."); // 1343242255
GE_ERRORNO_GRAPH(GE_GRAPH_OPTIMIZE_CALIBRATION_FAILED, 16, "Calibration failed."); // 1343242256
GE_ERRORNO_GRAPH(GE_GRAPH_SUBGRAPH_NUM_ZERO, 17, "Graph partition success, but subGraph num is 0."); // 1343242257
GE_ERRORNO_GRAPH(GE_GRAPH_SUBGRAPH_ENGINENAME_REPEATED, 18, "Graph subGraph engine name is repeated."); // 1343242258

@ -25,6 +25,7 @@
#include "common/fmk_error_codes.h"
#include "ge/ge_api_error_codes.h"
#include "external/graph/types.h"
#include "external/ge/ge_api_types.h"
namespace ge {
enum RuntimeType { HOST = 0, DEVICE = 1 };
@ -130,7 +131,8 @@ class ModelListener {
/// @param [in] data_index Index of the input_data
/// @param [in] resultCode Execution results
///
virtual Status OnComputeDone(uint32_t model_id, uint32_t data_index, uint32_t result_code) = 0;
virtual Status OnComputeDone(uint32_t model_id, uint32_t data_index, uint32_t result_code,
std::vector<ge::OutputTensorInfo> &outputs) = 0;
};
// OMM configuration item
@ -147,6 +149,8 @@ struct Options {
std::string rankTableFile;
int32_t ge_hccl_flag = 0;
int32_t physical_device_id;
std::string profiling_mode;
std::string profiling_options;
};
// Profiling info of task

@ -20,7 +20,7 @@
#include <gflags/gflags.h>
#include <string>
namespace domi {
namespace ge {
class GflagsUtils {
public:
static bool IsSetCommandTrue(const char *name) {
@ -66,6 +66,6 @@ class GflagsUtils {
}
}
};
} // namespace domi
} // namespace ge
#endif // INC_FRAMEWORK_COMMON_GFLAGS_UTIL_H_

@ -26,7 +26,7 @@
#include "graph/model.h"
#include "model/ge_model.h"
namespace domi {
namespace ge {
class ModelHelper {
public:
ModelHelper() = default;
@ -38,7 +38,7 @@ class ModelHelper {
Status LoadModel(const ge::ModelData& model_data);
Status GetModelBufferData(ge::ModelBufferData& model);
ModelFileHeader* GetFileHeader() { return file_header_; }
const ModelFileHeader* GetFileHeader() const { return file_header_; }
GeModelPtr GetGeModel();
void SetSaveMode(bool val) { is_offline_ = val; }
@ -65,9 +65,8 @@ class ModelHelper {
Status LoadTask(OmFileLoadHelper& om_load_helper);
Status LoadTBEKernelStore(OmFileLoadHelper& om_load_helper);
Status ReleaseLocalModelData() noexcept;
Status SaveModelPartition(std::shared_ptr<OmFileSaveHelper>& om_file_save_helper, ModelPartitionType type,
const uint8_t* data, size_t size);
};
} // namespace domi
} // namespace ge
#endif // INC_FRAMEWORK_COMMON_HELPER_MODEL_HELPER_H_

@ -26,8 +26,10 @@
#include "framework/common/ge_types.h"
using ProcParam = struct PROC_PARAM;
using std::string;
using std::vector;
namespace domi {
namespace ge {
struct ModelPartition {
ModelPartitionType type;
uint8_t *data = 0;
@ -88,5 +90,5 @@ class OmFileSaveHelper {
ModelFileHeader model_header_;
OmFileContext context_;
};
} // namespace domi
} // namespace ge
#endif // INC_FRAMEWORK_COMMON_HELPER_OM_FILE_HELPER_H_

@ -30,7 +30,7 @@
using std::vector;
namespace domi {
namespace ge {
// Size of RC memory alignment, 2M
constexpr size_t ALIGN_SIZE = 2097152;
@ -118,6 +118,6 @@ class L2CacheOptimize {
bool Cross(const RCMemoryBlock &l_block, const RCMemoryBlock &r_block);
bool Connect(const RCMemoryBlock &l_block, const RCMemoryBlock &r_block);
};
} // namespace domi
} // namespace ge
#endif // INC_FRAMEWORK_COMMON_L2_CACHE_OPTIMIZE_H_

File diff suppressed because it is too large Load Diff

@ -21,11 +21,17 @@
#include <unordered_map>
#include <string>
#include "common/op/attr_define.h"
#include "common/types.h"
#include "graph/debug/ge_attr_define.h"
#include "proto/om.pb.h"
namespace domi {
using domi::AttrDef;
using domi::AttrDef_ListValue;
using domi::ModelDef;
using domi::NamedAttrs;
using domi::OpDef;
namespace ge {
using AttrDefMap = ::google::protobuf::Map<::std::string, ::domi::AttrDef>;
using AttrDefPair = ::google::protobuf::MapPair<std::string, domi::AttrDef>;
@ -150,6 +156,6 @@ bool GetAttrDefListValue(const std::string &key, int idx, int32_t *value, const
bool GetAttrDefListValue(const std::string &key, int idx, uint32_t *value, const AttrDefMap &attr);
bool GetAttrDefListValue(const std::string &key, int idx, float *value, const AttrDefMap &attr);
bool GetAttrDefListValue(const std::string &key, int idx, double *value, const AttrDefMap &attr);
} // namespace domi
} // namespace ge
#endif // INC_FRAMEWORK_COMMON_OP_ATTR_VALUE_UTIL_H_

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

Loading…
Cancel
Save