Update GraphEngine to synchronize with latest Ascend driver software suite 4 May 2020

pull/22/head
yanghaoran 5 years ago
parent 5a5a566a30
commit 0577970fee

@ -18,7 +18,6 @@
#define INC_COMMON_BLOCKING_QUEUE_H_
#include <stdint.h>
#include <condition_variable>
#include <list>
#include <mutex>
@ -87,7 +86,7 @@ class BlockingQueue {
is_stoped_ = false;
}
// if the queue stop , the function to release the unprocessed items will be call
// if the queue is stoped ,need call this function to release the unprocessed items
std::list<T> GetRemainItems() {
std::unique_lock<std::mutex> lock(mutex_);

@ -19,10 +19,10 @@
#include <stdint.h>
///
/// @ingroup dnn
/// @brief struct define of dynamic aipp batch parameter.
///
/**
* @ingroup dnn
* @brief struct define of dynamic aipp batch parameter.
*/
typedef struct tagAippDynamicBatchPara {
int8_t cropSwitch; // crop switch
int8_t scfSwitch; // resize switch
@ -66,10 +66,10 @@ typedef struct tagAippDynamicBatchPara {
int8_t reserve1[16]; // 32B assign, for ub copy
} kAippDynamicBatchPara;
///
/// @ingroup dnn
/// @brief struct definition of dynamic aipp parameter. lite:64+96*batchNum byte ; tiny:64+64*batchNum byte
///
/**
* @ingroup dnn
* @brief struct define of dynamic aipp parameter. lite:64+96*batchNum byte ; tiny:64+64*batchNum byte
*/
typedef struct tagAippDynamicPara {
uint8_t inputFormat; // input formatYUV420SP_U8/XRGB8888_U8/RGB888_U8
int8_t cscSwitch; // csc switch

@ -61,19 +61,19 @@ typedef enum tagHiAiNpuModuleId {
HIAI_DP = 23,
} HiAiNpuModuleId;
// bit 31-bit30 to be hiai local
/* bit 31-bit30 to be hiai local */
#define HIAI_NPULOCAL_MASK 0xC0000000
#define SHIFT_LOCAL_MASK 30
#define HIAI_NPULOCAL_VAL_MASK 0x3
// bit 29 -bit28 to be hiai aicpu code type
/* bit 29 -bit28 to be hiai aicpu code type */
#define HIAI_CODE_TYPE_MASK 0x30000000
#define SHIFT_CODE_MASK 28
#define HIAI_CODE_TYPE_VAL_MASK 0x3
// bit 27 -bit25 to be hiai error level
/* bit 27 -bit25 to be hiai error level */
#define HIAI_ERROR_LEVEL_MASK 0x0E000000
#define SHIFT_ERROR_LVL_MASK 25
#define HIAI_ERROR_LEVEL_VAL_MASK 0x7
// bit 24 -bit17 to be hiai mod
/* bit 24 -bit17 to be hiai mod */
#define HIAI_MODE_ID_MASK 0x01FE0000
#define SHIFT_MODE_MASK 17
#define HIAI_MODE_ID_VAL_MASK 0xFF

@ -19,13 +19,12 @@
#include <runtime/rt.h>
#include <stdint.h>
#include <string>
#include <vector>
using std::string;
namespace ge {
// DAVINCI_TRAIN/DAVINCI_CLOUD is not needed when GETaskKernelHcclInfo needed
// when need to eliminate GETaskKernelHcclInfo, so not need DAVINCI_TRAIN/DAVINCI_CLOUD
struct GETaskKernelHcclInfo {
string hccl_type;
void *inputDataAddr;

@ -21,7 +21,6 @@
#include <map>
#include <string>
#include <vector>
#include "./ge_task_info.h"
#include "./ops_kernel_info_types.h"
#include "cce/aicpu_engine_struct.h"
@ -29,7 +28,6 @@
#include "common/ge_inner_error_codes.h"
#include "graph/node.h"
#include "proto/task.pb.h"
using std::map;
using std::string;
using std::to_string;
@ -47,7 +45,7 @@ class OpsKernelInfoStore {
// initialize opsKernelInfoStore
virtual Status Initialize(const map<string, string> &options) = 0;
// finalize opsKernelInfoStore
// close opsKernelInfoStore
virtual Status Finalize() = 0;
virtual Status CreateSession(const std::map<std::string, std::string> &session_options) { return SUCCESS; }
@ -57,18 +55,20 @@ class OpsKernelInfoStore {
// get all opsKernelInfo
virtual void GetAllOpsKernelInfo(map<string, OpInfo> &infos) const = 0;
// check whether opsKernelInfoStore is supported based on the operator attribute
// whether the opsKernelInfoStore is supported based on the operator attribute
virtual bool CheckSupported(const OpDescPtr &opDescPtr, std::string &un_supported_reason) const = 0;
virtual bool CheckAccuracySupported(const OpDescPtr &opDescPtr, std::string &un_supported_reason,
bool realQuery = false) const {
return CheckSupported(opDescPtr, un_supported_reason);
}
// opsFlag opsFlag[0] indicates constant folding is supported or not
virtual void opsFlagCheck(const ge::Node &node, std::string &opsFlag){};
// requirement of memory allocation
// memory allocation requirement
virtual Status CalcOpRunningParam(Node &node) = 0;
// generate task for op
// generate task for op
virtual Status GenerateTask(const Node &node, RunContext &context, std::vector<domi::TaskDef> &tasks) = 0;
// only call fe engine interface to compile single op
@ -77,10 +77,10 @@ class OpsKernelInfoStore {
// load task for op
virtual Status LoadTask(GETaskInfo &task) { return SUCCESS; }
// only to call aicpu interface for generating task struct
// only call aicpu interface to generate task struct
virtual Status GenSingleOpRunTask(const NodePtr &node, STR_FWK_OP_KERNEL &task, string &task_info) { return SUCCESS; }
// only to call aicpu interface for generating task struct
// only call aicpu interface to generate task struct
virtual Status GenMemCopyTask(uint64_t count, STR_FWK_OP_KERNEL &task, string &task_info) { return SUCCESS; }
};
} // namespace ge

@ -37,6 +37,7 @@ struct RunContext {
ge::Buffer weightsBuffer;
std::vector<rtStream_t> graphStreamList; // all streams of graph, order by ge stream id(0,1,...)
std::vector<rtEvent_t> graphEventList; // all events of graph, order by ge event id(0,1,...)
std::vector<rtLabel_t> graphLabelList; // all labels of graph, order by ge label id(0,1,...)
};
struct Task {

@ -19,7 +19,6 @@
#include <map>
#include <string>
#include "./graph_optimizer_types.h"
#include "common/ge_inner_error_codes.h"
#include "common/opskernel/ops_kernel_info_types.h"
@ -39,19 +38,19 @@ class GraphOptimizer {
// close graphOptimizer
virtual Status Finalize() = 0;
// optimize original graph for FE quant optimization
// optimize original graph for FE quant optimize
virtual Status OptimizeGraphPrepare(ComputeGraph &graph) { return SUCCESS; }
// optimize original graph used in the graph preparation stage
// optimize original graph, using in graph preparation stage
virtual Status OptimizeOriginalGraph(ComputeGraph &graph) = 0;
// optimize fused graph
virtual Status OptimizeFusedGraph(ComputeGraph &graph) = 0;
// optimize the whole graph which will be used after graph merged
// optimize whole graph, using after graph merged stage
virtual Status OptimizeWholeGraph(ComputeGraph &graph) = 0;
// get attributes of graph optimizer
// get attribute of graph optimizer
virtual Status GetAttributes(GraphOptimizerAttribute &attrs) const = 0;
// optimize streamed Graph

@ -19,8 +19,6 @@
#include <stdint.h>
#include <string>
using std::string;
namespace ge {
enum OPTIMIZER_SCOPE {
UNIT = 0,
@ -28,7 +26,7 @@ enum OPTIMIZER_SCOPE {
};
struct GraphOptimizerAttribute {
string engineName;
std::string engineName;
OPTIMIZER_SCOPE scope;
};
} // namespace ge

@ -20,6 +20,7 @@
#include <cstdint>
#include <string>
#include <vector>
#include <set>
namespace ge {
// Option key: graph run mode
@ -38,9 +39,11 @@ const char *const GE_AICPU_FLAG = "ge.aicpuFlag";
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";
// 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";
const char *const OPTION_EXEC_DISABLE_REUSED_MEMORY = "ge.exec.disableReuseMemory";
// Option key: memory init
const char *const GRAPH_MEMORY_MAX_SIZE = "ge.graphMemoryMaxSize";
@ -141,19 +144,43 @@ const std::string STREAM_MAX_PARALLEL_NUM = "ge.streamMaxParallelNum";
// congigure outputDatatype to setting net output type
const std::string OUTPUT_DATATYPE = "ge.outputDatatype";
// congigure opSelectImplmode to setting op select implmode
const std::string kOpSelectImplmode = "ge.opSelectImplmode";
// configure whether to enable hcom parallel by session constructor options param,
// its value should be "0" or "1", default value is "0"
const std::string HCOM_PARALLEL = "ge.hcomParallel";
// configure whether to use dynamic batch size
const char *const kDynamicBatchSize = "ge.dynamicBatchSize";
// configure whether to use dynamic image size
const char *const kDynamicImageSize = "ge.dynamicImageSize";
// Configure auto tune mode, this option only take effect while AUTO_TUNE_FLAG is Y,
// example: GA|RL, support configure multiple, split by |
const std::string AUTO_TUNE_MODE = "ge.autoTuneMode";
// Configure soc version , example: "Ascend310"
const std::string SOC_VERSION = "ge.socVersion";
// Configure core type "VectorEngine", default value is "AIcoreEngine"
const std::string CORE_TYPE = "ge.engineType";
// Configure soc version , example: "Ascend310"
const std::string SOC_VERSION = "ge.socVersion";
// Configure AICORE NUM
const std::string AICORE_NUM = "ge.aicoreNum";
// Configure L1FUSION
const std::string L1_FUSION = "ge.l1Fusion";
// Configure Small Channel flag
const std::string ENABLE_SMALL_CHANNEL = "ge.enableSmallChannel";
// Configure Compress Weight flag
const std::string ENABLE_COMPRESS_WEIGHT = "ge.enableCompressWeight";
// Configure fusion switch file path
const std::string FUSION_SWITCH_FILE = "ge.fusionSwitchFile";
// Save original model
const std::string SAVE_ORIGINAL_MODEL = "ge.saveOriginalModel";
@ -194,6 +221,28 @@ struct TensorInfo {
DataDesc data; // tensor data
ShapeDesc shapeInfo; // tensor shape
};
// 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();
static const char *const PRECISION_MODE = ge::PRECISION_MODE.c_str();
static const char *const EXEC_DISABLE_REUSED_MEMORY = ge::OPTION_EXEC_DISABLE_REUSED_MEMORY;
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();
// 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};
// for interface: aclgrphBuildInitialize
const std::set<std::string> global_options = {HEAD_STREAM, CORE_TYPE, SOC_VERSION};
} // namespace ir_option
} // namespace ge
#endif // INC_EXTERNAL_GE_GE_API_TYPES_H_

@ -0,0 +1,75 @@
/**
* 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 INC_EXTERNAL_GE_IR_BUILD_H_
#define INC_EXTERNAL_GE_IR_BUILD_H_
#include <string>
#include <map>
#include <memory>
#include "graph/graph.h"
#include "graph/ge_error_codes.h"
namespace ge {
struct ModelBufferData {
std::shared_ptr<uint8_t> data = nullptr;
uint64_t length;
};
/**
* @ingroup AscendCL
* @brief build model.Notice the model is stored in buffer
*
* @param global_options[IN] global init params for build
* @retval GRAPH_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
graphStatus aclgrphBuildInitialize(std::map<std::string, std::string> global_options);
/**
* @ingroup AscendCL
* @brief build model.Notice the model is stored in buffer
*
*/
void aclgrphBuildFinalize();
/**
* @ingroup AscendCL
* @brief build model.Notice the model is stored in buffer
*
* @param graph[IN] the graph ready to build
* @param options[IN] options used for build
* @param model[OUT] builded model
* @retval GRAPH_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map<std::string, std::string> &build_options,
ModelBufferData &model);
/**
* @ingroup AscendCL
* @brief save model buffer to file
*
* @param output_file[IN] the file path to be saved
* @param model[IN] model buffer data
* @retval GRAPH_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
graphStatus aclgrphSaveModel(const string &output_file, const ModelBufferData &model);
}; // namespace ge
#endif

@ -22,7 +22,7 @@
#include <string>
#include <vector>
#include "external/graph/ge_error_codes.h"
#include "./ge_error_codes.h"
using std::make_shared;
using std::map;

@ -22,7 +22,7 @@
#include <utility>
#include <vector>
#include "external/graph/operator.h"
#include "./operator.h"
namespace ge {
class GraphImpl;

@ -21,8 +21,8 @@
#include <string>
#include <vector>
#include "external/graph/tensor.h"
#include "external/graph/types.h"
#include "./tensor.h"
#include "./types.h"
namespace ge {
class InferenceContext;
@ -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

@ -23,9 +23,9 @@
#include <string>
#include <vector>
#include "external/graph/ge_error_codes.h"
#include "external/graph/inference_context.h"
#include "external/graph/tensor.h"
#include "./ge_error_codes.h"
#include "./inference_context.h"
#include "./tensor.h"
#ifndef USER_GE_LOGI
#define USER_GE_LOGI(...)

@ -22,8 +22,8 @@
#include <string>
#include <vector>
#include "external/graph//operator.h"
#include "external/graph/ge_error_codes.h"
#include "./operator.h"
#include "./ge_error_codes.h"
namespace ge {
using OpCreator = std::function<Operator(const std::string &)>;

@ -22,10 +22,10 @@
#include <string>
#include <vector>
#include "external/graph/operator.h"
#include "external/graph/operator_factory.h"
#include "external/graph/tensor.h"
#include "external/graph/types.h"
#include "./operator.h"
#include "./operator_factory.h"
#include "./tensor.h"
#include "./types.h"
namespace ge {
using std::function;
@ -60,7 +60,7 @@ class OpReg {
\
private: \
void __##x() { \
OpReg()
OpReg()
#define ATTR(x, Type, ...) \
N(); \
@ -86,7 +86,7 @@ class OpReg {
void __attr_##x() { \
Operator::AttrRegister(#x, Op##Type(__VA_ARGS__)); \
string attr_name(#x); \
(void)OpReg()
(void)OpReg()
#define REQUIRED_ATTR(x, Type) \
N(); \
@ -112,7 +112,7 @@ class OpReg {
void __required_attr_##x() { \
Operator::RequiredAttrRegister(#x); \
string attr_name(#x); \
(void)OpReg()
(void)OpReg()
#define INPUT(x, t) \
N(); \
@ -137,7 +137,7 @@ class OpReg {
private: \
void __input_##x() { \
Operator::InputRegister(#x); \
(void)OpReg()
(void)OpReg()
#define OPTIONAL_INPUT(x, t) \
N(); \
@ -162,7 +162,7 @@ class OpReg {
private: \
void __optional_input_##x() { \
Operator::OptionalInputRegister(#x); \
(void)OpReg()
(void)OpReg()
#define OUTPUT(x, t) \
N(); \
@ -179,7 +179,7 @@ class OpReg {
private: \
void __out_##x() { \
Operator::OutputRegister(#x); \
(void)OpReg()
(void)OpReg()
#define DYNAMIC_INPUT(x, t) \
N(); \
@ -206,7 +206,7 @@ class OpReg {
\
private: \
void __dy_input_##x() { \
(void)OpReg()
(void)OpReg()
#define DYNAMIC_OUTPUT(x, t) \
N(); \
@ -227,18 +227,18 @@ class OpReg {
\
private: \
void __dy_output_##x() { \
(void)OpReg()
(void)OpReg()
#define PASTE(g_register, y) g_register##y
#define __OP_END_IMPL__(x, y) \
N(); \
} \
static_assert( \
std::is_same<x, _THIS_TYPE>::value, \
"The class name entered into the OP_END_FACTORY_REG needs to be the same as the operator name you define."); \
} \
; \
static const OperatorCreatorRegister PASTE(g_register, y)(#x, [](const std::string &name) { return x(name); }); \
#define __OP_END_IMPL__(x, y) \
N(); \
} \
static_assert( \
std::is_same<x, _THIS_TYPE>::value, \
"The class name entered into the OP_END_FACTORY_REG needs to be the same as the operator name you define."); \
} \
; \
static const OperatorCreatorRegister PASTE(g_register, y)(#x, [](const std::string &name) { return x(name); }); \
}
#define OP_END_FACTORY_REG(x) __OP_END_IMPL__(x, __COUNTER__)
@ -286,7 +286,7 @@ class OpReg {
// Common shape inferencer
#define ELMTWISE_INFER_SHAPEANDTYPE(in_name, out_name) \
[](Operator op)->graphStatus { \
[](Operator op) -> graphStatus { \
auto x_shape = op.GetInputDesc(in_name).GetShape().GetDims(); \
auto x_type = op.GetInputDesc(in_name).GetDataType(); \
TensorDesc op_output_desc = op.GetOutputDesc(out_name); \
@ -300,7 +300,7 @@ graphStatus BroadCastInfer(const function<vector<int64_t>()> &get_in1_shape,
const function<void(const vector<int64_t> &y_shape)> &set_out_shape);
#define BROADCAST_INFER(in1_name, in2_name, out_name) \
[](Operator op)->graphStatus { \
[](Operator op) -> graphStatus { \
return BroadCastInfer([&]() { return op.GetInputDesc(in1_name).GetShape().GetDims(); }, \
[&]() { return op.GetInputDesc(in2_name).GetShape().GetDims(); }, \
[&](const vector<int64_t> &y_shape) { \

@ -22,8 +22,8 @@
#include <string>
#include <vector>
#include "external/graph/ge_error_codes.h"
#include "external/graph/types.h"
#include "./ge_error_codes.h"
#include "./types.h"
namespace ge {
class ShapeImpl;

@ -133,11 +133,13 @@ enum Format {
FORMAT_FRACTAL_ZZ,
FORMAT_FRACTAL_NZ,
FORMAT_NCDHW,
FORMAT_DHWCK, // 3D filter input tensor format
FORMAT_DHWCN, // 3D filter input tensor format
FORMAT_NDC1HWC0,
FORMAT_FRACTAL_Z_3D,
FORMAT_CN,
FORMAT_NC,
FORMAT_DHWNC,
FORMAT_FRACTAL_Z_3D_TRANSPOSE, // 3D filter(transpose) input tensor format
FORMAT_RESERVED,
FORMAT_ALL
};

@ -47,6 +47,12 @@ class Tensor;
class TBEPluginManager;
} // namespace ge
namespace google {
namespace protobuf {
class Message;
}
} // namespace google
namespace domi {
Status AutoMappingFn(const google::protobuf::Message *op_src, ge::Operator &op);
Status AutoMappingFnDynamic(const google::protobuf::Message *op_src, ge::Operator &op,
@ -56,6 +62,8 @@ 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 &)>;
class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistrationData {
public:
@ -71,15 +79,20 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistrationData {
OpRegistrationData &ParseParamsFn(const ParseParamFunc &parseParamFn);
OpRegistrationData &FusionParseParamsFn(const FusionParseParamFunc &fusionParseParamFn);
OpRegistrationData &ImplyType(const domi::ImplyType &imply_type);
OpRegistrationData &DelInputWithCond(int inputIdx, const std::string &attrName, bool attrValue);
OpRegistrationData &DelInputWithOriginalType(int input_idx, const std::string &ori_type);
domi::ImplyType GetImplyType() const;
std::string GetOmOptype() const;
std::set<std::string> GetOriginOpTypeSet() const;
domi::FrameworkType GetFrameworkType() const;
ParseParamFunc GetParseParamFn() const;
FusionParseParamFunc GetFusionParseParamFn() const;
private:
std::shared_ptr<OpRegistrationDataImpl> impl_;
@ -103,5 +116,27 @@ 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_

@ -22,7 +22,7 @@
#define DECLARE_ERRORNO(sysid, modid, name, value) \
const domi::Status name = \
((0xFF & ((uint8_t)sysid)) << 24) | ((0xFF & ((uint8_t)modid)) << 16) | (0xFFFF & ((uint16_t)value));
((0xFF & ((uint8_t)sysid)) << 24) | ((0xFF & ((uint8_t)modid)) << 16) | (0xFFFF & ((uint16_t)value));
#define DECLARE_ERRORNO_COMMON(name, value) DECLARE_ERRORNO(SYSID_FWK, MODID_COMMON, name, value)
@ -33,6 +33,7 @@ using Status = uint32_t;
DECLARE_ERRORNO(0, 0, SUCCESS, 0);
DECLARE_ERRORNO(0xFF, 0xFF, FAILED, 0xFFFFFFFF);
DECLARE_ERRORNO_COMMON(PARAM_INVALID, 1); // 50331649
DECLARE_ERRORNO(SYSID_FWK, 1, SCOPE_NOT_CHANGED, 201);
} // namespace domi
#endif // INC_EXTERNAL_REGISTER_REGISTER_ERROR_CODES_H_

@ -48,6 +48,10 @@ typedef enum tagDomiTensorFormat {
DOMI_TENSOR_BN_WEIGHT,
DOMI_TENSOR_CHWN, // Android NN Depth CONV
DOMI_TENSOR_FILTER_HWCK, // filter input tensor format
DOMI_TENSOR_NDHWC,
DOMI_TENSOR_NCDHW,
DOMI_TENSOR_DHWCN, // 3D filter input tensor format
DOMI_TENSOR_DHWNC,
DOMI_TENSOR_RESERVED
} domiTensorFormat_t;
} // namespace domi

@ -18,11 +18,13 @@
#define INC_FRAMEWORK_COMMON_DEBUG_GE_LOG_H_
#include <cstdint>
#include <unistd.h>
#include <sys/syscall.h>
#include "framework/common/ge_inner_error_codes.h"
#include "toolchain/slog.h"
#define GE_MODULE_NAME GE
#define GE_MODULE_NAME static_cast<int>(GE)
// trace status of log
enum TraceStatus { TRACE_INIT = 0, TRACE_RUNNING, TRACE_WAITING, TRACE_STOP };
@ -35,15 +37,20 @@ enum TraceStatus { TRACE_INIT = 0, TRACE_RUNNING, TRACE_WAITING, TRACE_STOP };
#define GELOGO(...) GE_LOG_OPLOG(GE_MODULE_NAME, __VA_ARGS__)
#define GELOGT(VALUE, ...) GE_LOG_TRACE(GE_MODULE_NAME, VALUE, __VA_ARGS__)
inline bool IsLogEnable(int module_name, int log_level) noexcept {
int32_t enable_event = 0;
int32_t dlog_level = dlog_getlevel(module_name, &enable_event);
if (dlog_level <= log_level) {
inline bool IsLogEnable(int module_name, int log_level) {
int32_t enable = CheckLogLevel(module_name, log_level);
// 1:enable, 0:disable
if (enable == 1) {
return true;
}
return false;
}
inline pid_t GetTid() {
thread_local static pid_t tid = syscall(__NR_gettid);
return tid;
}
#define GE_TIMESTAMP_START(stage) uint64_t startUsec_##stage = ge::GetCurrentTimestap()
#define GE_TIMESTAMP_END(stage, stage_name) \
@ -68,29 +75,35 @@ inline bool IsLogEnable(int module_name, int log_level) noexcept {
GEEVENT("[GEPERFTRACE] The time cost of %s is [%lu] micro second, call num is %lu", (stage_name), time_of##stage, \
call_num_of##stage)
#define GE_LOG_ERROR(MOD_NAME, ERROR_CODE, fmt, ...) \
dlog_error(static_cast<int>(MOD_NAME), "%s: ErrorNo: %d(%s) " fmt, __FUNCTION__, ERROR_CODE, \
#define GE_LOG_ERROR(MOD_NAME, ERROR_CODE, fmt, ...) \
dlog_error(MOD_NAME, "%lu %s: ErrorNo: %d(%s) " fmt, GetTid(), __FUNCTION__, ERROR_CODE, \
((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ##__VA_ARGS__)
#define GE_LOG_WARN(MOD_NAME, fmt, ...) \
if (IsLogEnable(static_cast<int>(MOD_NAME), DLOG_WARN)) \
dlog_warn(static_cast<int>(MOD_NAME), "%s:" fmt, __FUNCTION__, ##__VA_ARGS__)
#define GE_LOG_INFO(MOD_NAME, fmt, ...) \
if (IsLogEnable(static_cast<int>(MOD_NAME), DLOG_INFO)) \
dlog_info(static_cast<int>(MOD_NAME), "%s:" fmt, __FUNCTION__, ##__VA_ARGS__)
#define GE_LOG_DEBUG(MOD_NAME, fmt, ...) \
if (IsLogEnable(static_cast<int>(MOD_NAME), DLOG_DEBUG)) \
dlog_debug(static_cast<int>(MOD_NAME), "%s:" fmt, __FUNCTION__, ##__VA_ARGS__)
#define GE_LOG_EVENT(MOD_NAME, fmt, ...) dlog_event(static_cast<int>(MOD_NAME), "%s:" fmt, __FUNCTION__, ##__VA_ARGS__)
#define GE_LOG_WARN(MOD_NAME, fmt, ...) \
if (IsLogEnable(MOD_NAME, DLOG_WARN)) dlog_warn(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GE_LOG_INFO(MOD_NAME, fmt, ...) \
if (IsLogEnable(MOD_NAME, DLOG_INFO)) dlog_info(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GE_LOG_DEBUG(MOD_NAME, fmt, ...) \
if (IsLogEnable(MOD_NAME, DLOG_DEBUG)) dlog_debug(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GE_LOG_EVENT(MOD_NAME, fmt, ...) dlog_event(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GE_LOG_OPLOG(MOD_NAME, fmt, ...) \
Dlog(static_cast<int>(MOD_NAME), DLOG_OPLOG, "%s:" fmt, __FUNCTION__, ##__VA_ARGS__)
#define GE_LOG_TRACE(MOD_NAME, value, fmt, ...) \
do { \
TraceStatus stat = value; \
const char *const TraceStatStr[] = {"INIT", "RUNNING", "WAITING", "STOP"}; \
int idx = static_cast<int>(stat); \
char *k = const_cast<char *>("status"); \
char *v = const_cast<char *>(TraceStatStr[idx]); \
KeyValue kv = {k, v}; \
DlogWithKV(static_cast<int>(MOD_NAME), DLOG_TRACE, &kv, 1, "%s:" fmt, __FUNCTION__, ##__VA_ARGS__); \
Dlog(MOD_NAME, DLOG_OPLOG, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GE_LOG_TRACE(MOD_NAME, value, fmt, ...) \
do { \
TraceStatus stat = value; \
const char *const TraceStatStr[] = {"INIT", "RUNNING", "WAITING", "STOP"}; \
int idx = static_cast<int>(stat); \
char *k = const_cast<char *>("status"); \
char *v = const_cast<char *>(TraceStatStr[idx]); \
KeyValue kv = {k, v}; \
DlogWithKV(static_cast<int>(MOD_NAME), DLOG_TRACE, &kv, 1, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__); \
} while (0)
// print memory when it is greater than 1KB.
#define GE_PRINT_DYNAMIC_MEMORY(FUNC, PURPOSE, SIZE) \
do { \
if ((SIZE) > 1024) { \
GELOGI("MallocMemory, func=%s, size=%zu, purpose=%s", (#FUNC), static_cast<size_t>(SIZE), (PURPOSE)); \
} \
} while (0);
#endif // INC_FRAMEWORK_COMMON_DEBUG_GE_LOG_H_

@ -29,7 +29,18 @@
using cce::CC_STATUS_SUCCESS;
using cce::ccStatus_t;
#define GE_LOGE(...) DAV_LOGE("GE", __VA_ARGS__)
#if !defined(__ANDROID__) && !defined(ANDROID)
#define DOMI_LOGE(...) DAV_LOGE("DOMI", __VA_ARGS__)
#else
#include <android/log.h>
#if defined(BUILD_VERSION_PERF)
#define DOMI_LOGE(fmt, ...)
#else
// The Android system has strict log control. Do not modify the log.
#define DOMI_LOGE(fmt, ...) \
__android_log_print(ANDROID_LOG_ERROR, "NPU_FMK", "%s %s(%d)::" #fmt, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
#endif
#endif
// ge marco
#define GE_LOGI_IF(condition, ...) \
@ -44,7 +55,7 @@ using cce::ccStatus_t;
#define GE_LOGE_IF(condition, ...) \
if ((condition)) { \
GE_LOGE(__VA_ARGS__); \
DOMI_LOGE(__VA_ARGS__); \
}
// If expr is not SUCCESS, print the log and return the same value
@ -52,7 +63,7 @@ using cce::ccStatus_t;
do { \
const ge::Status _status = (expr); \
if (_status != ge::SUCCESS) { \
GE_LOGE(__VA_ARGS__); \
DOMI_LOGE(__VA_ARGS__); \
return _status; \
} \
} while (0);
@ -62,7 +73,7 @@ using cce::ccStatus_t;
do { \
const ge::Status _status = (expr); \
if (_status != ge::SUCCESS) { \
GE_LOGE(__VA_ARGS__); \
DOMI_LOGE(__VA_ARGS__); \
} \
} while (0);
@ -75,6 +86,15 @@ using cce::ccStatus_t;
} \
} while (0);
// If expr is not GRAPH_SUCCESS, print the log and return FAILED
#define GE_CHK_GRAPH_STATUS_RET(expr, ...) \
do { \
if ((expr) != ge::GRAPH_SUCCESS) { \
DOMI_LOGE(__VA_ARGS__); \
return FAILED; \
} \
} while (0);
// If expr is not SUCCESS, print the log and execute a custom statement
#define GE_CHK_STATUS_EXEC(expr, exec_expr, ...) \
do { \
@ -91,25 +111,11 @@ using cce::ccStatus_t;
(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())); \
GE_LOGE("%s", msg.c_str()); \
DOMI_LOGE("%s", msg.c_str()); \
return _status; \
} \
} while (0);
// If expr is not true, print the Info log and return the specified status
#define GE_CHK_BOOL_RET_STATUS_LOGI(expr, _status, ...) \
do { \
bool b = (expr); \
if (!b) { \
std::string msg; \
(void)msg.append(StringUtils::FormatString(__VA_ARGS__)); \
(void)msg.append( \
StringUtils::FormatString(" Check result false, status: 0x%X %s", _status, GET_ERRORNO_STR(_status).c_str())); \
GELOGI("%s", msg.c_str()); \
return _status; \
} \
} while (0);
// If expr is not true, print the log and return the specified status
#define GE_CHK_BOOL_RET_STATUS_NOLOG(expr, _status, ...) \
do { \
@ -124,7 +130,7 @@ using cce::ccStatus_t;
{ \
bool b = (expr); \
if (!b) { \
GE_LOGE(__VA_ARGS__); \
DOMI_LOGE(__VA_ARGS__); \
exec_expr; \
} \
};
@ -163,7 +169,7 @@ using cce::ccStatus_t;
{ \
bool b = (expr); \
if (b) { \
GE_LOGE(__VA_ARGS__); \
DOMI_LOGE(__VA_ARGS__); \
exec_expr; \
} \
};
@ -182,7 +188,7 @@ using cce::ccStatus_t;
{ \
bool b = (expr); \
if (b) { \
GE_LOGE(__VA_ARGS__); \
DOMI_LOGE(__VA_ARGS__); \
exec_expr; \
return; \
} \
@ -193,7 +199,7 @@ using cce::ccStatus_t;
{ \
bool b = (expr); \
if (b) { \
GE_LOGE(__VA_ARGS__); \
DOMI_LOGE(__VA_ARGS__); \
exec_expr; \
return _status; \
} \
@ -210,62 +216,42 @@ using cce::ccStatus_t;
// -----------------runtime related macro definitions-------------------------------
// If expr is not RT_ERROR_NONE, print the log
#define GE_CHK_RT(expr) \
do { \
rtError_t _rt_ret = (expr); \
if (_rt_ret != RT_ERROR_NONE) { \
GE_LOGE("Call rt api failed, ret: 0x%X", _rt_ret); \
} \
#define GE_CHK_RT(expr) \
do { \
rtError_t _rt_ret = (expr); \
if (_rt_ret != RT_ERROR_NONE) { \
DOMI_LOGE("Call rt api failed, ret: 0x%X", _rt_ret); \
} \
} while (0);
// If expr is not RT_ERROR_NONE, print the log and execute the exec_expr expression
#define GE_CHK_RT_EXEC(expr, exec_expr) \
{ \
rtError_t _rt_ret = (expr); \
if (_rt_ret != RT_ERROR_NONE) { \
GE_LOGE("Call rt api failed, ret: 0x%X", _rt_ret); \
exec_expr; \
} \
#define GE_CHK_RT_EXEC(expr, exec_expr) \
{ \
rtError_t _rt_ret = (expr); \
if (_rt_ret != RT_ERROR_NONE) { \
DOMI_LOGE("Call rt api failed, ret: 0x%X", _rt_ret); \
exec_expr; \
} \
}
// If expr is not RT_ERROR_NONE, print the log and return
#define GE_CHK_RT_RET(expr) \
do { \
rtError_t _rt_ret = (expr); \
if (_rt_ret != RT_ERROR_NONE) { \
GE_LOGE("Call rt api failed, ret: 0x%X", _rt_ret); \
return ge::RT_FAILED; \
} \
#define GE_CHK_RT_RET(expr) \
do { \
rtError_t _rt_ret = (expr); \
if (_rt_ret != RT_ERROR_NONE) { \
DOMI_LOGE("Call rt api failed, ret: 0x%X", _rt_ret); \
return ge::RT_FAILED; \
} \
} while (0);
// ------------------------cce related macro definitions----------------------------
// If expr is not CC_STATUS_SUCCESS, print the log
#define GE_CHK_CCE(expr) \
do { \
ccStatus_t _cc_ret = (expr); \
if (_cc_ret != CC_STATUS_SUCCESS) { \
GE_LOGE("Call cce api failed, ret: 0x%X", _cc_ret); \
} \
} while (0);
// If expr is not CC_STATUS_SUCCESS, print the log and execute the exec_expr expression
#define GE_CHK_CCE_EXEC(expr, exec_expr) \
do { \
ccStatus_t _cc_ret = (expr); \
if (_cc_ret != CC_STATUS_SUCCESS) { \
GE_LOGE("Call cce api failed, ret: 0x%X", _cc_ret); \
exec_expr; \
} \
} while (0);
// If expr is not CC_STATUS_SUCCESS, print the log and return
#define GE_CHK_CCE_RET(expr) \
do { \
ccStatus_t _cc_ret = (expr); \
if (_cc_ret != CC_STATUS_SUCCESS) { \
GE_LOGE("Call cce api failed, ret: 0x%X", _cc_ret); \
return ge::CCE_FAILED; \
} \
#define GE_CHK_CCE(expr) \
do { \
ccStatus_t _cc_ret = (expr); \
if (_cc_ret != CC_STATUS_SUCCESS) { \
DOMI_LOGE("Call cce api failed, ret: 0x%X", _cc_ret); \
} \
} while (0);
// If expr is true, execute exec_expr without printing logs
@ -281,37 +267,8 @@ using cce::ccStatus_t;
try { \
exec_expr0; \
} catch (const std::bad_alloc &) { \
GE_LOGE("Make shared failed"); \
DOMI_LOGE("Make shared failed"); \
exec_expr1; \
}
#define GE_CHECK_INT32_MUL_OVERFLOW(a, b, ...) \
do { \
if ((a) > 0) { \
if ((b) > 0) { \
if ((a) > (INT32_MAX / (b))) { \
GE_LOGE(__VA_ARGS__); \
return ge::FAILED; \
} \
} else { \
if ((b) < (INT32_MIN / (a))) { \
GE_LOGE(__VA_ARGS__); \
return ge::FAILED; \
} \
} \
} else { \
if ((b) > 0) { \
if ((a) < (INT32_MAX / (b))) { \
GE_LOGE(__VA_ARGS__); \
return ge::FAILED; \
} \
} else { \
if (((a) != 0) && ((b) < (INT32_MAX / (a)))) { \
GE_LOGE(__VA_ARGS__); \
return ge::FAILED; \
} \
} \
} \
} while (0);
#endif // INC_FRAMEWORK_COMMON_DEBUG_LOG_H_

@ -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
@ -204,15 +203,16 @@ GE_ERRORNO_GRAPH(GE_GRAPH_NODE_SEARCHER_GET_GRAPH_REBUILD_FAILED, 60,
GE_ERRORNO_GRAPH(GE_GRAPH_NODE_SEARCHER_SET_GRAPH_FINISH_REBUILD_GRAPH_FAILED, 61,
"Failed set graph finish rebuild in node searcher."); // 1343242301
GE_ERRORNO_GRAPH(GE_GRAPH_VARIABLE_OP_PASS_FAILED, 62, "Failed to run variable pass."); // 1343242302
// Optimize errocode
GE_ERRORNO_GRAPH(TO_BE_DELETED, 200, "The node of the graph to be deleted.");
GE_ERRORNO_GRAPH(NOT_CHANGED, 201, "NThe node of the graph not changed.");
// Engine_manager module error code definition
GE_ERRORNO_ENGINE(GE_ENG_INIT_FAILED, 0, "Failed to initialize engine."); // 1343246336
GE_ERRORNO_ENGINE(GE_ENG_FINALIZE_FAILED, 1, "Engine finalize failed."); // 1343246337
GE_ERRORNO_ENGINE(GE_ENG_MEMTYPE_ERROR, 2, "Memory type HBM is necessary when engine is in device"); // 1343246338
// Optimize errocode
GE_ERRORNO_GRAPH(TO_BE_DELETED, 63, "The node of the graph to be deleted."); // 1343242303
GE_ERRORNO_GRAPH(NOT_CHANGED, 64, "The node of the graph no changed."); // 1343242304
// Ops module error code definition
GE_ERRORNO_OPS(GE_OPS_KERNEL_STORE_INIT_FAILED, 0, "Failed to initialize OpsKernelInfoStore."); // 1343250432
GE_ERRORNO_OPS(GE_OPS_GRAPH_OPTIMIZER_INIT_FAILED, 1, "Failed to initialize GraphOptimizer."); // 1343250433

@ -24,8 +24,7 @@
#include "common/fmk_error_codes.h"
#include "ge/ge_api_error_codes.h"
using std::string;
#include "external/graph/types.h"
namespace ge {
enum RuntimeType { HOST = 0, DEVICE = 1 };
@ -56,7 +55,7 @@ struct DataBuffer {
///
/// @ingroup domi_ome
/// @brief External inputdata
/// @brief External input data
///
struct InputData {
uint32_t index; // Index of input data
@ -65,13 +64,14 @@ struct InputData {
uint32_t model_id; // Model ID required for data processing
uint64_t request_id = 0; // Request ID
std::vector<DataBuffer> blobs; // Actual input data, currently only supports one input
bool is_dynamic_batch = false; // Whether is dynamic batch size scene, default:false
std::string batch_label; // Gear used for current inference in dynamic batch scene
};
// The definition of output result structure
/// Output result structure definition
struct OutputData {
uint32_t index; // Index of input data
uint32_t model_id; // The model ID corresponding to the processing result
/// Output data cache, arranged in sequence of output operators.
/// If the operator has multiple outputs,
/// the data buffer order of the operator is the same as that defined in the
@ -142,11 +142,31 @@ struct Options {
bool deployMode;
bool isAICPUMode;
bool enable_atomic;
string podName;
std::string podName;
int64_t rankId;
string rankTableFile;
std::string rankTableFile;
int32_t ge_hccl_flag = 0;
int32_t physical_device_id;
};
// Profiling info of task
struct TaskDescInfo {
std::string op_name;
uint32_t block_dim;
uint32_t task_id;
uint32_t stream_id;
};
// Profiling info of graph
struct ComputeGraphDescInfo {
std::string op_name;
std::string op_type;
std::vector<Format> input_format;
std::vector<std::vector<int64_t>> input_shape;
std::vector<DataType> input_data_type;
std::vector<Format> output_format;
std::vector<std::vector<int64_t>> output_shape;
std::vector<DataType> output_data_type;
};
} // namespace ge
#endif // INC_FRAMEWORK_COMMON_GE_TYPES_H_

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

Loading…
Cancel
Save