Browse Source

!2099 upgrade Ascend package 17 Dec 21

Merge pull request !2099 from yanghaoran/r1.6
pull/2100/MERGE
yanghaoran Gitee 3 years ago
parent
commit
ca6cea7617
50 changed files with 897 additions and 862 deletions
  1. +14
    -0
      inc/external/acl/acl_base.h
  2. +51
    -0
      inc/external/acl/acl_op_compiler.h
  3. +91
    -0
      inc/external/acl/acl_prof.h
  4. +33
    -32
      inc/external/acl/error_codes/ge_error_codes.h
  5. +7
    -1
      inc/external/acl/error_codes/rt_error_codes.h
  6. +8
    -44
      inc/external/ge/ge_api_error_codes.h
  7. +1
    -1
      inc/external/runtime/rt_error_codes.h
  8. +8
    -8
      inc/framework/common/debug/ge_log.h
  9. +1
    -1
      inc/framework/common/fmk_error_codes.h
  10. +3
    -3
      inc/framework/common/ge_types.h
  11. +1
    -1
      inc/framework/common/helper/model_helper.h
  12. +15
    -18
      inc/framework/common/helper/om_file_helper.h
  13. +10
    -135
      inc/framework/common/op/attr_value_util.h
  14. +8
    -41
      inc/framework/common/op/ge_op_utils.h
  15. +5
    -3
      inc/framework/common/op_types.h
  16. +136
    -0
      inc/framework/common/profiling_definitions.h
  17. +2
    -2
      inc/framework/common/scope_guard.h
  18. +28
    -241
      inc/framework/common/types.h
  19. +93
    -93
      inc/framework/common/util.h
  20. +13
    -0
      inc/framework/executor/ge_executor.h
  21. +2
    -2
      inc/framework/generator/ge_generator.h
  22. +0
    -4
      inc/framework/memory/memory_api.h
  23. +1
    -1
      inc/framework/memory/memory_assigner.h
  24. +0
    -35
      inc/framework/omg/model_tool.h
  25. +1
    -1
      inc/framework/omg/omg.h
  26. +6
    -34
      inc/framework/omg/omg_inner_types.h
  27. +4
    -4
      inc/framework/omg/parser/op_parser.h
  28. +3
    -3
      inc/framework/omg/parser/parser_inner_ctx.h
  29. +1
    -3
      inc/framework/omg/version.h
  30. +1
    -1
      metadef
  31. +9
    -7
      third_party/fwkacllib/inc/cce/fwk_adpt_struct.h
  32. +3
    -0
      third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_linux.h
  33. +86
    -83
      third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_win.h
  34. +42
    -0
      third_party/fwkacllib/inc/ops/array_ops.h
  35. +6
    -0
      third_party/fwkacllib/inc/ops/elewise_calculation_ops.h
  36. +33
    -1
      third_party/fwkacllib/inc/ops/nn_detect_ops.h
  37. +30
    -0
      third_party/fwkacllib/inc/ops/nn_norm_ops.h
  38. +15
    -0
      third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h
  39. +1
    -0
      third_party/fwkacllib/inc/ops/ocr_ops.h
  40. +37
    -0
      third_party/fwkacllib/inc/ops/reduce_ops.h
  41. +2
    -2
      third_party/fwkacllib/inc/runtime/base.h
  42. +1
    -1
      third_party/fwkacllib/inc/runtime/context.h
  43. +3
    -3
      third_party/fwkacllib/inc/runtime/dev.h
  44. +2
    -2
      third_party/fwkacllib/inc/runtime/dvfsprofile.h
  45. +4
    -4
      third_party/fwkacllib/inc/runtime/kernel.h
  46. +16
    -16
      third_party/fwkacllib/inc/runtime/rt_mem_queue.h
  47. +1
    -0
      third_party/fwkacllib/inc/runtime/rt_model.h
  48. +31
    -0
      third_party/fwkacllib/inc/runtime/rt_stars_define.h
  49. +21
    -16
      third_party/fwkacllib/inc/toolchain/prof_acl_api.h
  50. +7
    -15
      third_party/fwkacllib/inc/toolchain/prof_callback.h

+ 14
- 0
inc/external/acl/acl_base.h View File

@@ -134,6 +134,7 @@ static const int ACL_ERROR_DRV_FAILURE = 500004;
static const int ACL_ERROR_PROFILING_FAILURE = 500005;

#define ACL_TENSOR_SHAPE_RANGE_NUM 2
#define ACL_TENSOR_VALUE_RANGE_NUM 2
#define ACL_UNKNOWN_RANK 0xFFFFFFFFFFFFFFFE

typedef enum {
@@ -338,6 +339,19 @@ ACL_FUNC_VISIBILITY aclError aclSetTensorShapeRange(aclTensorDesc *desc, size_t

/**
* @ingroup AscendCL
* @brief set value range for aclTensorDesc
*
* @param desc [OUT] pointer to the data of aclTensorDesc
* @param valueCount [IN] the number of value
* @param valueRange [IN] the range of value
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclSetTensorValueRange(aclTensorDesc *desc, size_t valueCount,
int64_t valueRange[][ACL_TENSOR_VALUE_RANGE_NUM]);
/**
* @ingroup AscendCL
* @brief get data type specified by the tensor description
*
* @param desc [IN] pointer to the instance of aclTensorDesc


+ 51
- 0
inc/external/acl/acl_op_compiler.h View File

@@ -41,6 +41,8 @@ typedef enum {

typedef enum aclCompileFlag { ACL_OP_COMPILE_DEFAULT, ACL_OP_COMPILE_FUZZ } aclOpCompileFlag;

typedef struct aclGraphDumpOption aclGraphDumpOption;

/**
* @ingroup AscendCL
* @brief compile op
@@ -114,6 +116,55 @@ ACL_FUNC_VISIBILITY aclError aclSetCompileopt(aclCompileOpt opt, const char *val
*/
ACL_FUNC_VISIBILITY aclError aclopSetCompileFlag(aclOpCompileFlag flag);

/**
* @ingroup AscendCL
* @brief generate graph and dump
*
* @param opType [IN] op type
* @param numInputs [IN] number of inputs
* @param inputDesc [IN] pointer to array of input tensor descriptions
* @param inputs [IN] pointer to array of input buffers
* @param numOutputs [IN] number of outputs
* @param outputDesc [IN] pointer to array of output tensor descriptions
* @param outputs [IN] pointer to array of outputs buffers
* @param attr [IN] pointer to instance of aclopAttr.
* may pass nullptr if the op has no attribute
* @param engineType [IN] engine type
* @param graphDumpPath [IN] dump path, if the suffix is ".txt", it means file path, else it means directory path
* @param graphDumpOpt [IN] dump option, nullptr is supported
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
ACL_FUNC_VISIBILITY aclError aclGenGraphAndDumpForOp(
const char *opType, int numInputs, const aclTensorDesc *const inputDesc[], const aclDataBuffer *const inputs[],
int numOutputs, const aclTensorDesc *const outputDesc[], aclDataBuffer *const outputs[], const aclopAttr *attr,
aclopEngineType engineType, const char *graphDumpPath, const aclGraphDumpOption *graphDumpOpt);

/**
* @ingroup AscendCL
* @brief Create the graph dump option
*
* @retval null for failed
* @retval OtherValues success
*
* @see aclDestroyGraphDumpOpt
*/
ACL_FUNC_VISIBILITY aclGraphDumpOption *aclCreateGraphDumpOpt();

/**
* @ingroup AscendCL
* @brief Destroy graph dump option
*
* @param graphDumpOpt [IN] pointer to the graph dump option
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*
* @see aclCreateGraphDumpOpt
*/
ACL_FUNC_VISIBILITY aclError aclDestroyGraphDumpOpt(const aclGraphDumpOption *graphDumpOpt);

#ifdef __cplusplus
}
#endif


+ 91
- 0
inc/external/acl/acl_prof.h View File

@@ -367,6 +367,97 @@ MSVP_PROF_API aclprofStepInfo *aclprofCreateStepInfo();
*/
MSVP_PROF_API void aclprofDestroyStepInfo(aclprofStepInfo *stepinfo);

/**
* @ingroup AscendCL
* @brief create pointer to aclprofstamp
*
*
* @retval aclprofStamp pointer
*/
MSVP_PROF_API void *aclprofCreateStamp();

/**
* @ingroup AscendCL
* @brief destory stamp pointer
*
*
* @retval void
*/
MSVP_PROF_API void aclprofDestroyStamp(void *stamp);

/**
* @ingroup AscendCL
* @brief set category and name
*
*
* @retval void
*/
MSVP_PROF_API aclError aclprofSetCategoryName(uint32_t category, const char *categoryName);

/**
* @ingroup AscendCL
* @brief set category to stamp
*
*
* @retval void
*/
MSVP_PROF_API aclError aclprofSetStampCategory(void *stamp, uint32_t category);

/**
* @ingroup AscendCL
* @brief set message to stamp
*
*
* @retval void
*/
MSVP_PROF_API aclError aclprofSetStampTraceMessage(void *stamp, const char *msg, uint32_t msgLen);

/**
* @ingroup AscendCL
* @brief Record mark timestamp
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
MSVP_PROF_API aclError aclprofMark(void *stamp);

/**
* @ingroup AscendCL
* @brief Record push timestamp
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
MSVP_PROF_API aclError aclprofPush(void *stamp);

/**
* @ingroup AscendCL
* @brief Record pop timestamp
*
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
MSVP_PROF_API aclError aclprofPop();

/**
* @ingroup AscendCL
* @brief Record range start timestamp
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
MSVP_PROF_API aclError aclprofRangeStart(void *stamp, uint32_t *rangeId);

/**
* @ingroup AscendCL
* @brief Record range end timestamp
*
* @retval ACL_SUCCESS The function is successfully executed.
* @retval OtherValues Failure
*/
MSVP_PROF_API aclError aclprofRangeStop(uint32_t rangeId);

#ifdef __cplusplus
}
#endif


+ 33
- 32
inc/external/acl/error_codes/ge_error_codes.h View File

@@ -32,42 +32,43 @@
#endif

#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif
static const uint32_t ACL_ERROR_GE_PARAM_INVALID = 145000;
static const uint32_t ACL_ERROR_GE_EXEC_NOT_INIT = 145001;
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID = 145002;
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_ID_INVALID = 145003;
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID = 145006;
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_ADDR_INVALID = 145007;
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_QUEUE_ID_INVALID = 145008;
static const uint32_t ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED = 145009;
static const uint32_t ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID = 145011;
static const uint32_t ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID = 145012;
static const uint32_t ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID = 145013;
static const uint32_t ACL_ERROR_GE_AIPP_BATCH_EMPTY = 145014;
static const uint32_t ACL_ERROR_GE_AIPP_NOT_EXIST = 145015;
static const uint32_t ACL_ERROR_GE_AIPP_MODE_INVALID = 145016;
static const uint32_t ACL_ERROR_GE_OP_TASK_TYPE_INVALID = 145017;
static const uint32_t ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID = 145018;
static const uint32_t ACL_ERROR_GE_PLGMGR_PATH_INVALID = 145019;
static const uint32_t ACL_ERROR_GE_FORMAT_INVALID = 145020;
static const uint32_t ACL_ERROR_GE_SHAPE_INVALID = 145021;
static const uint32_t ACL_ERROR_GE_DATATYPE_INVALID = 145022;
static const uint32_t ACL_ERROR_GE_MEMORY_ALLOCATION = 245000;
static const uint32_t ACL_ERROR_GE_MEMORY_OPERATE_FAILED = 245001;
static const uint32_t ACL_ERROR_GE_INTERNAL_ERROR = 545000;
static const uint32_t ACL_ERROR_GE_LOAD_MODEL = 545001;
static const uint32_t ACL_ERROR_GE_EXEC_LOAD_MODEL_PARTITION_FAILED = 545002;
static const uint32_t ACL_ERROR_GE_EXEC_LOAD_WEIGHT_PARTITION_FAILED = 545003;
static const uint32_t ACL_ERROR_GE_EXEC_LOAD_TASK_PARTITION_FAILED = 545004;
static const uint32_t ACL_ERROR_GE_EXEC_LOAD_KERNEL_PARTITION_FAILED = 545005;
static const uint32_t ACL_ERROR_GE_EXEC_RELEASE_MODEL_DATA = 545006;
static const uint32_t ACL_ERROR_GE_COMMAND_HANDLE = 545007;
static const uint32_t ACL_ERROR_GE_GET_TENSOR_INFO = 545008;
static const uint32_t ACL_ERROR_GE_UNLOAD_MODEL = 545009;
static const uint32_t ACL_ERROR_GE_PARAM_INVALID = 145000U;
static const uint32_t ACL_ERROR_GE_EXEC_NOT_INIT = 145001U;
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID = 145002U;
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_ID_INVALID = 145003U;
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID = 145006U;
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_ADDR_INVALID = 145007U;
static const uint32_t ACL_ERROR_GE_EXEC_MODEL_QUEUE_ID_INVALID = 145008U;
static const uint32_t ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED = 145009U;
static const uint32_t ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID = 145011U;
static const uint32_t ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID = 145012U;
static const uint32_t ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID = 145013U;
static const uint32_t ACL_ERROR_GE_AIPP_BATCH_EMPTY = 145014U;
static const uint32_t ACL_ERROR_GE_AIPP_NOT_EXIST = 145015U;
static const uint32_t ACL_ERROR_GE_AIPP_MODE_INVALID = 145016U;
static const uint32_t ACL_ERROR_GE_OP_TASK_TYPE_INVALID = 145017U;
static const uint32_t ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID = 145018U;
static const uint32_t ACL_ERROR_GE_PLGMGR_PATH_INVALID = 145019U;
static const uint32_t ACL_ERROR_GE_FORMAT_INVALID = 145020U;
static const uint32_t ACL_ERROR_GE_SHAPE_INVALID = 145021U;
static const uint32_t ACL_ERROR_GE_DATATYPE_INVALID = 145022U;
static const uint32_t ACL_ERROR_GE_MEMORY_ALLOCATION = 245000U;
static const uint32_t ACL_ERROR_GE_MEMORY_OPERATE_FAILED = 245001U;
static const uint32_t ACL_ERROR_GE_INTERNAL_ERROR = 545000U;
static const uint32_t ACL_ERROR_GE_LOAD_MODEL = 545001U;
static const uint32_t ACL_ERROR_GE_EXEC_LOAD_MODEL_PARTITION_FAILED = 545002U;
static const uint32_t ACL_ERROR_GE_EXEC_LOAD_WEIGHT_PARTITION_FAILED = 545003U;
static const uint32_t ACL_ERROR_GE_EXEC_LOAD_TASK_PARTITION_FAILED = 545004U;
static const uint32_t ACL_ERROR_GE_EXEC_LOAD_KERNEL_PARTITION_FAILED = 545005U;
static const uint32_t ACL_ERROR_GE_EXEC_RELEASE_MODEL_DATA = 545006U;
static const uint32_t ACL_ERROR_GE_COMMAND_HANDLE = 545007U;
static const uint32_t ACL_ERROR_GE_GET_TENSOR_INFO = 545008U;
static const uint32_t ACL_ERROR_GE_UNLOAD_MODEL = 545009U;

#ifdef __cplusplus
} // namespace ge


+ 7
- 1
inc/external/acl/error_codes/rt_error_codes.h View File

@@ -44,6 +44,7 @@ static const int32_t ACL_ERROR_RT_STREAM_NO_CB_REG = 107015; // callbac
static const int32_t ACL_ERROR_RT_INVALID_MEMORY_TYPE = 107016; // invalid memory type
static const int32_t ACL_ERROR_RT_INVALID_HANDLE = 107017; // invalid handle
static const int32_t ACL_ERROR_RT_INVALID_MALLOC_TYPE = 107018; // invalid malloc type
static const int32_t ACL_ERROR_RT_WAIT_TIMEOUT = 107019; // wait timeout

static const int32_t ACL_ERROR_RT_FEATURE_NOT_SUPPORT = 207000; // feature not support
static const int32_t ACL_ERROR_RT_MEMORY_ALLOCATION = 207001; // memory allocation error
@@ -61,6 +62,7 @@ static const int32_t ACL_ERROR_RT_OVER_LIMIT = 207012; // over limit
static const int32_t ACL_ERROR_RT_QUEUE_EMPTY = 207013; // queue is empty
static const int32_t ACL_ERROR_RT_QUEUE_FULL = 207014; // queue is full
static const int32_t ACL_ERROR_RT_REPEATED_INIT = 207015; // repeated init
static const int32_t ACL_ERROR_RT_AIVEC_OVER_FLOW = 207016; // aivec over flow

static const int32_t ACL_ERROR_RT_INTERNAL_ERROR = 507000; // runtime internal error
static const int32_t ACL_ERROR_RT_TS_ERROR = 507001; // ts internel error
@@ -99,6 +101,11 @@ static const int32_t ACL_ERROR_RT_DEV_SETUP_ERROR = 507033; // devic
static const int32_t ACL_ERROR_RT_VECTOR_CORE_TIMEOUT = 507034; // vector core timeout
static const int32_t ACL_ERROR_RT_VECTOR_CORE_EXCEPTION = 507035; // vector core exception
static const int32_t ACL_ERROR_RT_VECTOR_CORE_TRAP_EXCEPTION = 507036; // vector core trap exception
static const int32_t ACL_ERROR_RT_CDQ_BATCH_ABNORMAL = 507037; // cdq alloc batch abnormal
static const int32_t ACL_ERROR_RT_DIE_MODE_CHANGE_ERROR = 507038; // can not change die mode
static const int32_t ACL_ERROR_RT_DIE_SET_ERROR = 507039; // single die mode can not set die
static const int32_t ACL_ERROR_RT_INVALID_DIEID = 507040; // invalid die id
static const int32_t ACL_ERROR_RT_DIE_MODE_NOT_SET = 507041; // die mode not set

static const int32_t ACL_ERROR_RT_DRV_INTERNAL_ERROR = 507899; // drv internal error
static const int32_t ACL_ERROR_RT_AICPU_INTERNAL_ERROR = 507900; // aicpu internal error
@@ -107,5 +114,4 @@ static const int32_t ACL_ERROR_RT_SOCKET_CLOSE = 507901; // hdc disconn
#ifdef __cplusplus
}
#endif

#endif // __INC_EXTERNEL_RT_ERROR_CODES_H__

+ 8
- 44
inc/external/ge/ge_api_error_codes.h View File

@@ -83,16 +83,15 @@ class GE_FUNC_VISIBILITY ErrorNoRegisterar {
};

// Code compose(4 byte), runtime: 2 bit, type: 2 bit, level: 3 bit, sysid: 8 bit, modid: 5 bit, value: 12 bit
#define GE_ERRORNO(runtime, type, level, sysid, modid, name, value, desc) \
constexpr ge::Status name = (static_cast<uint32_t>(0xFFU & (static_cast<uint32_t>(runtime))) << 30U) | \
(static_cast<uint32_t>(0xFFU & (static_cast<uint32_t>(type))) << 28U) | \
(static_cast<uint32_t>(0xFFU & (static_cast<uint32_t>(level))) << 25U) | \
(static_cast<uint32_t>(0xFFU & (static_cast<uint32_t>(sysid))) << 17U) | \
(static_cast<uint32_t>(0xFFU & (static_cast<uint32_t>(modid))) << 12U) | \
(static_cast<uint32_t>(0x0FFFU) & (static_cast<uint32_t>(value))); \
const ErrorNoRegisterar g_##name##_errorno(name, desc);
#define GE_ERRORNO(runtime, type, level, sysid, modid, name, value, desc) \
constexpr ge::Status(name) = (static_cast<uint32_t>(0xFFU & (static_cast<uint32_t>(runtime))) << 30U) | \
(static_cast<uint32_t>(0xFFU & (static_cast<uint32_t>(type))) << 28U) | \
(static_cast<uint32_t>(0xFFU & (static_cast<uint32_t>(level))) << 25U) | \
(static_cast<uint32_t>(0xFFU & (static_cast<uint32_t>(sysid))) << 17U) | \
(static_cast<uint32_t>(0xFFU & (static_cast<uint32_t>(modid))) << 12U) | \
(static_cast<uint32_t>(0x0FFFU) & (static_cast<uint32_t>(value)));

#define GE_ERRORNO_EXTERNAL(name, desc) const ErrorNoRegisterar g_##name##_errorno(name, desc);
#define GE_ERRORNO_EXTERNAL(name, desc) constexpr ErrorNoRegisterar g_errorno_##name(name, desc);

using Status = uint32_t;

@@ -100,41 +99,6 @@ using Status = uint32_t;
GE_ERRORNO(0, 0, 0, 0, 0, SUCCESS, 0, "success");
GE_ERRORNO(0b11, 0b11, 0b111, 0xFFU, 0b11111, FAILED, 0xFFFU, "failed"); /*lint !e401*/

GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_PARAM_INVALID, "Parameter invalid.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_NOT_INIT, "GE executor not initialized yet.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "Model file path invalid.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_ID_INVALID, "Model id invalid.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, "Data size of model invalid.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_ADDR_INVALID, "Model addr invalid.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_QUEUE_ID_INVALID, "Queue id of model invalid.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED, "The model loaded repeatedly.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID, "Dynamic input addr invalid.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID, "Dynamic input size invalid.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID, "Dynamic batch size invalid.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_AIPP_BATCH_EMPTY, "AIPP batch parameter empty.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_AIPP_NOT_EXIST, "AIPP parameter not exist.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_AIPP_MODE_INVALID, "AIPP mode invalid.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_OP_TASK_TYPE_INVALID, "Task type invalid.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID, "Kernel type invalid.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_PLGMGR_PATH_INVALID, "Plugin path is invalid.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_FORMAT_INVALID, "Format is invalid.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_SHAPE_INVALID, "Shape is invalid.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_DATATYPE_INVALID, "Datatype is invalid.");

GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_MEMORY_ALLOCATION, "Memory allocation error.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to operate memory.");

GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_INTERNAL_ERROR, "Internal error.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_LOAD_MODEL, "Load model error.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_MODEL_PARTITION_FAILED, "Failed to load model partition.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_WEIGHT_PARTITION_FAILED, "Failed to load weight partition.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_TASK_PARTITION_FAILED, "Failed to load task partition.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_KERNEL_PARTITION_FAILED, "Failed to load op kernel partition.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_RELEASE_MODEL_DATA, "Failed to release the model data.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_COMMAND_HANDLE, "Command handle error.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_GET_TENSOR_INFO, "Get tensor info error.");
GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_UNLOAD_MODEL, "Load model error.");

} // namespace ge

#endif // INC_EXTERNAL_GE_GE_API_ERROR_CODES_H_

+ 1
- 1
inc/external/runtime/rt_error_codes.h View File

@@ -62,6 +62,7 @@ static const int32_t ACL_ERROR_RT_OVER_LIMIT = 207012; // over limit
static const int32_t ACL_ERROR_RT_QUEUE_EMPTY = 207013; // queue is empty
static const int32_t ACL_ERROR_RT_QUEUE_FULL = 207014; // queue is full
static const int32_t ACL_ERROR_RT_REPEATED_INIT = 207015; // repeated init
static const int32_t ACL_ERROR_RT_AIVEC_OVER_FLOW = 207016; // aivec over flow

static const int32_t ACL_ERROR_RT_INTERNAL_ERROR = 507000; // runtime internal error
static const int32_t ACL_ERROR_RT_TS_ERROR = 507001; // ts internel error
@@ -113,5 +114,4 @@ static const int32_t ACL_ERROR_RT_SOCKET_CLOSE = 507901; // hdc disconn
#ifdef __cplusplus
}
#endif

#endif // __INC_EXTERNEL_RT_ERROR_CODES_H__

+ 8
- 8
inc/framework/common/debug/ge_log.h View File

@@ -40,7 +40,7 @@ enum TraceStatus { TRACE_INIT = 0, TRACE_RUNNING, TRACE_WAITING, TRACE_STOP };

class GE_FUNC_VISIBILITY GeLog {
public:
static const uint64_t GetTid() {
static uint64_t GetTid() {
#ifdef __GNUC__
const uint64_t tid = static_cast<uint64_t>(syscall(__NR_gettid));
#else
@@ -56,11 +56,11 @@ inline bool IsLogEnable(const int32_t module_name, const int32_t log_level) {
return (enable == 1);
}

#define GELOGE(ERROR_CODE, fmt, ...) \
do { \
dlog_error(GE_MODULE_NAME, "%lu %s: ErrorNo: %u(%s) %s" fmt, GeLog::GetTid(), &__FUNCTION__[0], ERROR_CODE, \
((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ErrorManager::GetInstance().GetLogHeader().c_str(), \
##__VA_ARGS__); \
#define GELOGE(ERROR_CODE, fmt, ...) \
do { \
dlog_error(GE_MODULE_NAME, "%lu %s: ErrorNo: %u(%s) %s" fmt, GeLog::GetTid(), &__FUNCTION__[0], (ERROR_CODE), \
((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ErrorManager::GetInstance().GetLogHeader().c_str(), \
##__VA_ARGS__); \
} while (false)

#define GELOGW(fmt, ...) \
@@ -91,7 +91,7 @@ inline bool IsLogEnable(const int32_t module_name, const int32_t log_level) {

#define GELOGT(VALUE, fmt, ...) \
do { \
TraceStatus stat = VALUE; \
TraceStatus stat = (VALUE); \
const char_t *const TraceStatStr[] = {"INIT", "RUNNING", "WAITING", "STOP"}; \
const int32_t idx = static_cast<int32_t>(stat); \
char_t *k = const_cast<char_t *>("status"); \
@@ -102,7 +102,7 @@ inline bool IsLogEnable(const int32_t module_name, const int32_t log_level) {

#define GE_LOG_ERROR(MOD_NAME, ERROR_CODE, fmt, ...) \
do { \
dlog_error(MOD_NAME, "%lu %s: ErrorNo: %u(%s) %s" fmt, GeLog::GetTid(), &__FUNCTION__[0], ERROR_CODE, \
dlog_error((MOD_NAME), "%lu %s: ErrorNo: %u(%s) %s" fmt, GeLog::GetTid(), &__FUNCTION__[0], (ERROR_CODE), \
((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ErrorManager::GetInstance().GetLogHeader().c_str(), \
##__VA_ARGS__); \
} while (false)


+ 1
- 1
inc/framework/common/fmk_error_codes.h View File

@@ -74,7 +74,7 @@ class GE_FUNC_VISIBILITY StatusFactory {

class GE_FUNC_VISIBILITY ErrorNoRegisterar {
public:
ErrorNoRegisterar(uint32_t err, const std::string &desc) {
ErrorNoRegisterar(const uint32_t err, const std::string &desc) {
StatusFactory::Instance()->RegisterErrorNo(err, desc);
}
~ErrorNoRegisterar() {}


+ 3
- 3
inc/framework/common/ge_types.h View File

@@ -40,8 +40,8 @@ enum FrameworkType {
CAFFE = 0,
MINDSPORE = 1,
TENSORFLOW = 3,
ANDROID_NN,
ONNX,
ANDROID_NN = 4,
ONNX = 5,
};

enum class GraphStage : int64_t { GRAPH_STAGE_FUZZ = 0, GRAPH_STAGE_RESERVED };
@@ -81,7 +81,7 @@ struct DataBuffer {
uint64_t length; // Data length
bool isDataSupportMemShare = false;
uint32_t placement = 0U;
DataBuffer(void *data_in, uint64_t data_len, bool is_support_mem_share, uint32_t placement = 0U)
DataBuffer(void *data_in, const uint64_t data_len, const bool is_support_mem_share, const uint32_t placement = 0U)
: data(data_in), length(data_len), isDataSupportMemShare(is_support_mem_share), placement(placement) {}

DataBuffer() : data(nullptr), length(0UL), isDataSupportMemShare(false) {}


+ 1
- 1
inc/framework/common/helper/model_helper.h View File

@@ -40,6 +40,7 @@ class GE_FUNC_VISIBILITY ModelHelper {
Status SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::string &output_file);
Status LoadModel(const ge::ModelData &model_data);
Status LoadRootModel(const ge::ModelData &model_data);
static void SetModelToGeModel(GeModelPtr &ge_model, Model &model);

GeModelPtr GetGeModel();
GeRootModelPtr GetGeRootModel();
@@ -67,7 +68,6 @@ class GE_FUNC_VISIBILITY ModelHelper {
Status GenerateGeModel(OmFileLoadHelper &om_load_helper);
Status GenerateGeRootModel(OmFileLoadHelper &om_load_helper);
Status LoadModelData(OmFileLoadHelper &om_load_helper);
void SetModelToGeModel(GeModelPtr &ge_model, Model &model) const;
Status LoadModelData(OmFileLoadHelper &om_load_helper, GeModelPtr &cur_model, const size_t mode_index) const;
Status LoadWeights(OmFileLoadHelper &om_load_helper);
Status LoadWeights(OmFileLoadHelper &om_load_helper, GeModelPtr &cur_model, const size_t mode_index) const;


+ 15
- 18
inc/framework/common/helper/om_file_helper.h View File

@@ -21,25 +21,22 @@
#include <vector>

#include "external/ge/ge_ir_build.h"
#include "framework/common/fmk_types.h"
#include "framework/common/types.h"
#include "framework/common/ge_types.h"

using ProcParam = struct PROC_PARAM;
using std::string;
using std::vector;

namespace ge {
struct ModelPartition {
ModelPartitionType type;
uint8_t *data = 0;
uint32_t size = 0;
uint8_t *data = nullptr;
uint32_t size = 0U;
};

struct OmFileContext {
std::vector<ModelPartition> partition_datas_;
std::vector<char> partition_table_;
uint32_t model_data_len_ = 0;
std::vector<char_t> partition_table_;
uint32_t model_data_len_ = 0U;
};

struct SaveParam {
@@ -55,13 +52,13 @@ class GE_FUNC_VISIBILITY OmFileLoadHelper {
public:
Status Init(const ge::ModelData &model);

Status Init(uint8_t *model_data, const uint32_t model_data_size);
Status Init(uint8_t *const model_data, const uint32_t model_data_size);

Status Init(uint8_t *model_data, const uint32_t model_data_size, uint32_t model_num);
Status Init(uint8_t *const model_data, const uint32_t model_data_size, const uint32_t model_num);

Status GetModelPartition(ModelPartitionType type, ModelPartition &partition);
Status GetModelPartition(const ModelPartitionType type, ModelPartition &partition);

Status GetModelPartition(ModelPartitionType type, ModelPartition &partition, size_t model_index);
Status GetModelPartition(const ModelPartitionType type, ModelPartition &partition, const size_t model_index);

OmFileContext context_;

@@ -70,9 +67,9 @@ class GE_FUNC_VISIBILITY OmFileLoadHelper {
private:
Status CheckModelValid(const ge::ModelData &model) const;

Status LoadModelPartitionTable(uint8_t *model_data, const uint32_t model_data_size);
Status LoadModelPartitionTable(uint8_t *const model_data, const uint32_t model_data_size);

Status LoadModelPartitionTable(uint8_t *model_data, const uint32_t model_data_size, uint32_t model_num);
Status LoadModelPartitionTable(uint8_t *const model_data, const uint32_t model_data_size, const uint32_t model_num);

bool is_inited_{false};
};
@@ -89,16 +86,16 @@ class GE_FUNC_VISIBILITY OmFileSaveHelper {

ModelPartitionTable *GetPartitionTable();

Status AddPartition(ModelPartition &partition);
Status AddPartition(const ModelPartition &partition);

Status AddPartition(ModelPartition &partition, size_t cur_index);
Status AddPartition(const ModelPartition &partition, const size_t cur_index);

const std::vector<ModelPartition> &GetModelPartitions() const;

Status SaveModel(const SaveParam &save_param, const char *target_file, ge::ModelBufferData &model,
bool is_offline = true);
Status SaveModel(const SaveParam &save_param, const char_t *const output_file, ge::ModelBufferData &model,
const bool is_offline = true);

Status SaveModelToFile(const char *output_file, ge::ModelBufferData &model, bool is_offline = true);
Status SaveModelToFile(const char_t *const output_file, ge::ModelBufferData &model, const bool is_offline = true);

std::vector<OmFileContext> model_contexts_;



+ 10
- 135
inc/framework/common/op/attr_value_util.h View File

@@ -34,143 +34,18 @@
#include <google/protobuf/map.h>
#include <unordered_map>
#include <string>
#include "external/graph/types.h"
#include "graph/debug/ge_attr_define.h"
#include "proto/om.pb.h"

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>;

GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, AttrDef &attr, OpDef *opdef);
// DEFINE_ADD_ATTR_VALUE
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const std::string &value, AttrDefMap *attrs);
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const char *value, AttrDefMap *attrs);
GE_FUNC_VISIBILITY void AddOpAttr(const char *key, const char *value, AttrDefMap *attrs);
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const uint32_t value, AttrDefMap *attrs);
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const int32_t value, AttrDefMap *attrs);
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const int64_t value, AttrDefMap *attrs);
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const float value, AttrDefMap *attrs);
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const double value, AttrDefMap *attrs);
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const bool value, AttrDefMap *attrs);

GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const AttrDef_ListValue &value, AttrDefMap *attrs);

// DEFINE_ADD_ATTR_VALUE
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const std::string &value, OpDef *opdef);
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const char *value, OpDef *opdef);
GE_FUNC_VISIBILITY void AddOpAttr(const char *key, const char *value, OpDef *opdef);
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const uint32_t value, OpDef *opdef);
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const int32_t value, OpDef *opdef);
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const int64_t value, OpDef *opdef);
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const float value, OpDef *opdef);
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const double value, OpDef *opdef);
GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const bool value, OpDef *opdef);

GE_FUNC_VISIBILITY void AddOpAttr(const std::string &key, const AttrDef_ListValue &value, OpDef *opdef);

GE_FUNC_VISIBILITY void AddOpBytesAttr(const std::string &key, const void *value, size_t size, OpDef *opdef);

// DEFINE_ADD_ATTR_VALUE_LIST
GE_FUNC_VISIBILITY void AddOpAttrList(const std::string &key, const double value, AttrDefMap *attrs);
GE_FUNC_VISIBILITY void AddOpAttrList(const std::string &key, const float value, AttrDefMap *attrs);
GE_FUNC_VISIBILITY void AddOpAttrList(const std::string &key, const uint32_t value, AttrDefMap *attrs);
GE_FUNC_VISIBILITY void AddOpAttrList(const std::string &key, const int32_t value, AttrDefMap *attrs);
GE_FUNC_VISIBILITY void AddOpAttrList(const std::string &key, const std::string value, AttrDefMap *attrs);
GE_FUNC_VISIBILITY void AddOpAttrList(const std::string &key, const double value, OpDef *opdef);
GE_FUNC_VISIBILITY void AddOpAttrList(const std::string &key, const float value, OpDef *opdef);
GE_FUNC_VISIBILITY void AddOpAttrList(const std::string &key, const uint32_t value, OpDef *opdef);
GE_FUNC_VISIBILITY void AddOpAttrList(const std::string &key, const int32_t value, OpDef *opdef);
GE_FUNC_VISIBILITY void AddOpAttrList(const std::string &key, const bool value, OpDef *opdef);
GE_FUNC_VISIBILITY void AddOpAttrList(const std::string &key, const int64_t value, OpDef *opdef);

GE_FUNC_VISIBILITY void AddOpAttrList(const std::string &key, const std::string &value, OpDef *opdef);

GE_FUNC_VISIBILITY bool GetOpAttr(const std::string &key, std::string *value, const OpDef *opdef);
GE_FUNC_VISIBILITY bool GetOpAttr(const std::string &key, int32_t *value, const OpDef *opdef);
GE_FUNC_VISIBILITY bool GetOpAttr(const std::string &key, int64_t *value, const OpDef *opdef);
GE_FUNC_VISIBILITY bool GetOpAttr(const std::string &key, uint32_t *value, const OpDef *opdef);
GE_FUNC_VISIBILITY bool GetOpAttr(const std::string &key, float *value, const OpDef *opdef);
GE_FUNC_VISIBILITY bool GetOpAttr(const std::string &key, double *value, const OpDef *opdef);
GE_FUNC_VISIBILITY bool GetOpAttr(const std::string &key, bool *value, const OpDef *opdef);
GE_FUNC_VISIBILITY bool GetOpAttr(const std::string &key, AttrDef_ListValue *value, const OpDef *opdef);

GE_FUNC_VISIBILITY uint32_t GetOpAttrListSize(const std::string &key, std::string value, const OpDef *opdef);
GE_FUNC_VISIBILITY uint32_t GetOpAttrListSize(const std::string &key, int32_t value, const OpDef *opdef);
GE_FUNC_VISIBILITY uint32_t GetOpAttrListSize(const std::string &key, int64_t value, const OpDef *opdef);
GE_FUNC_VISIBILITY uint32_t GetOpAttrListSize(const std::string &key, uint32_t value, const OpDef *opdef);
GE_FUNC_VISIBILITY uint32_t GetOpAttrListSize(const std::string &key, float value, const OpDef *opdef);
GE_FUNC_VISIBILITY uint32_t GetOpAttrListSize(const std::string &key, double value, const OpDef *opdef);
GE_FUNC_VISIBILITY uint32_t GetOpAttrListSize(const std::string &key, bool value, const OpDef *opdef);

GE_FUNC_VISIBILITY bool GetBytesAttr(const std::string &key, std::string *value, const OpDef *opdef);
GE_FUNC_VISIBILITY bool GetBytesAttr(const std::string &key, std::string *value, const ModelDef *model_def);

GE_FUNC_VISIBILITY void AddModelAttr(const std::string &key, const std::string &value, ModelDef *model_def);
GE_FUNC_VISIBILITY void AddModelAttr(const std::string &key, const char *value, ModelDef *model_def);
GE_FUNC_VISIBILITY void AddModelAttr(const char *key, const char *value, ModelDef *model_def);
GE_FUNC_VISIBILITY void AddModelAttr(const std::string &key, const uint32_t value, ModelDef *model_def);
GE_FUNC_VISIBILITY void AddModelAttr(const std::string &key, const int32_t value, ModelDef *model_def);
GE_FUNC_VISIBILITY void AddModelAttr(const std::string &key, const int64_t value, ModelDef *model_def);
GE_FUNC_VISIBILITY void AddModelAttr(const std::string &key, const float value, ModelDef *model_def);
GE_FUNC_VISIBILITY void AddModelAttr(const std::string &key, const double value, ModelDef *model_def);
GE_FUNC_VISIBILITY void AddModelAttr(const std::string &key, const bool value, ModelDef *model_def);
GE_FUNC_VISIBILITY void AddModelAttr(const std::string &key, const void *value, size_t size, ModelDef *model_def);
GE_FUNC_VISIBILITY void AddModelAttr(const std::string &key, const AttrDef_ListValue &value, ModelDef *model_def);

GE_FUNC_VISIBILITY void AddModelAttrList(const std::string &key, const double value, ModelDef *model_def);
GE_FUNC_VISIBILITY void AddModelAttrList(const std::string &key, const float value, ModelDef *model_def);
GE_FUNC_VISIBILITY void AddModelAttrList(const std::string &key, const uint32_t value, ModelDef *model_def);
GE_FUNC_VISIBILITY void AddModelAttrList(const std::string &key, const int32_t value, ModelDef *model_def);
GE_FUNC_VISIBILITY void AddModelAttrList(const std::string &key, const std::string &value, ModelDef *model_def);

GE_FUNC_VISIBILITY bool GetModelAttr(const std::string &key, std::string *value, const ModelDef *model_def);
GE_FUNC_VISIBILITY bool GetModelAttr(const std::string &key, int32_t *value, const ModelDef *model_def);
GE_FUNC_VISIBILITY bool GetModelAttr(const std::string &key, int64_t *value, const ModelDef *model_def);
GE_FUNC_VISIBILITY bool GetModelAttr(const std::string &key, uint32_t *value, const ModelDef *model_def);
GE_FUNC_VISIBILITY bool GetModelAttr(const std::string &key, float *value, const ModelDef *model_def);
GE_FUNC_VISIBILITY bool GetModelAttr(const std::string &key, double *value, const ModelDef *model_def);
GE_FUNC_VISIBILITY bool GetModelAttr(const std::string &key, bool *value, const ModelDef *model_def);
GE_FUNC_VISIBILITY bool GetModelAttr(const std::string &key, AttrDef_ListValue *value, const ModelDef *model_def);

GE_FUNC_VISIBILITY bool HasOpAttr(const OpDef *opdef, const std::string &attr_name);

GE_FUNC_VISIBILITY void SetAttrDef(const std::string &value, AttrDef *out);
GE_FUNC_VISIBILITY void SetAttrDef(const char *value, AttrDef *out);
GE_FUNC_VISIBILITY void SetAttrDef(const uint32_t value, AttrDef *out);
GE_FUNC_VISIBILITY void SetAttrDef(const int32_t value, AttrDef *out);
GE_FUNC_VISIBILITY void SetAttrDef(const float value, AttrDef *out);
GE_FUNC_VISIBILITY void SetAttrDef(const double value, AttrDef *out);
GE_FUNC_VISIBILITY void SetAttrDef(const bool value, AttrDef *out);
GE_FUNC_VISIBILITY void SetAttrList(const std::string &value, AttrDef *out);
GE_FUNC_VISIBILITY void SetAttrList(const bool value, AttrDef *out);
GE_FUNC_VISIBILITY void SetAttrList(const float value, AttrDef *out);
GE_FUNC_VISIBILITY void SetAttrList(const double value, AttrDef *out);
GE_FUNC_VISIBILITY void SetAttrList(const uint32_t value, AttrDef *out);

GE_FUNC_VISIBILITY bool GetAttrDefValue(const std::string &key, std::string *value, const AttrDefMap &attr);
GE_FUNC_VISIBILITY bool GetAttrDefValue(const std::string &key, int32_t *value, const AttrDefMap &attr);
GE_FUNC_VISIBILITY bool GetAttrDefValue(const std::string &key, int64_t *value, const AttrDefMap &attr);
GE_FUNC_VISIBILITY bool GetAttrDefValue(const std::string &key, uint32_t *value, const AttrDefMap &attr);
GE_FUNC_VISIBILITY bool GetAttrDefValue(const std::string &key, float *value, const AttrDefMap &attr);
GE_FUNC_VISIBILITY bool GetAttrDefValue(const std::string &key, double *value, const AttrDefMap &attr);
GE_FUNC_VISIBILITY bool GetAttrDefValue(const std::string &key, bool *value, const AttrDefMap &attr);
GE_FUNC_VISIBILITY bool GetAttrDefValue(const std::string &key, AttrDef_ListValue *value, const AttrDefMap &attr);
GE_FUNC_VISIBILITY bool GetAttrDefValue(const std::string &key, NamedAttrs *&value, AttrDefMap *attr);
GE_FUNC_VISIBILITY bool GetAttrDefValue(const std::string &key, const NamedAttrs *&value, const AttrDefMap &attr);

GE_FUNC_VISIBILITY bool GetAttrDefListValue(const std::string &key, int32_t idx, int32_t *value,
const AttrDefMap &attr);
GE_FUNC_VISIBILITY bool GetAttrDefListValue(const std::string &key, int32_t idx, uint32_t *value,
const AttrDefMap &attr);
GE_FUNC_VISIBILITY bool GetAttrDefListValue(const std::string &key, int32_t idx, float *value, const AttrDefMap &attr);
GE_FUNC_VISIBILITY bool GetAttrDefListValue(const std::string &key, int32_t idx, double *value, const AttrDefMap &attr);
GE_FUNC_VISIBILITY void SetAttrDef(const std::string &value, domi::AttrDef *const out);
GE_FUNC_VISIBILITY void SetAttrDef(const char *value, domi::AttrDef *const out);
GE_FUNC_VISIBILITY void SetAttrDef(const uint32_t value, domi::AttrDef *const out);
GE_FUNC_VISIBILITY void SetAttrDef(const int32_t value, domi::AttrDef *const out);
GE_FUNC_VISIBILITY void SetAttrDef(const int64_t value, domi::AttrDef *const out);
GE_FUNC_VISIBILITY void SetAttrDef(const float32_t value, domi::AttrDef *const out);
GE_FUNC_VISIBILITY void SetAttrDef(const float64_t value, domi::AttrDef *const out);
GE_FUNC_VISIBILITY void SetAttrDef(const bool value, domi::AttrDef *const out);
} // namespace ge

#endif // INC_FRAMEWORK_COMMON_OP_ATTR_VALUE_UTIL_H_
#endif // INC_FRAMEWORK_COMMON_OP_ATTR_VALUE_UTIL_H_

+ 8
- 41
inc/framework/common/op/ge_op_utils.h View File

@@ -31,7 +31,6 @@
#include "proto/insert_op.pb.h"

namespace ge {
using domi::Status;

// Add Sub Mul
GE_FUNC_VISIBILITY extern const uint32_t ADD_INPUT_NUM;
@@ -55,8 +54,8 @@ GE_FUNC_VISIBILITY extern const uint32_t SWITCH_DATA_INPUT;
GE_FUNC_VISIBILITY extern const uint32_t SWITCH_PRED_INPUT;

// Merge
GE_FUNC_VISIBILITY extern const uint32_t MERGE_DATA_OUTPUT;
GE_FUNC_VISIBILITY extern const uint32_t MERGE_INDEX_OUTPUT;
GE_FUNC_VISIBILITY extern const int32_t MERGE_DATA_OUTPUT;
GE_FUNC_VISIBILITY extern const int32_t MERGE_INDEX_OUTPUT;

// FunctionOp
GE_FUNC_VISIBILITY extern const uint32_t IF_COND_INPUT;
@@ -66,7 +65,7 @@ GE_FUNC_VISIBILITY extern const uint32_t FOR_DELTA_INPUT;
GE_FUNC_VISIBILITY extern const uint32_t FOR_DATA_INPUT;

GE_FUNC_VISIBILITY extern const int32_t NORMAL_TENSOR_SIZE;
/*lint -e148*/
class GE_FUNC_VISIBILITY OpUtils {
public:
///
@@ -95,8 +94,8 @@ class GE_FUNC_VISIBILITY OpUtils {
/// @param [out] aipp_params aipp parameters
/// @return enum of tagCCAippInputFormat
///
static Status ConvertAippParams(const NamedAttrs &aipp_attr, domi::AippOpParams *aipp_params);
static Status TransferDim(const std::vector<int64_t> &dim, std::vector<int64_t> &dim_vector);
static Status ConvertAippParams(const NamedAttrs &aipp_attr, domi::AippOpParams &aipp_params);
template <typename T>
static void SliceData(const std::vector<char *> &input, int64_t chunk_size, std::vector<char *> &output,
int64_t begin, int64_t out_dim, int64_t stride);
@@ -107,45 +106,13 @@ class GE_FUNC_VISIBILITY OpUtils {
static Status SetOutputSliceDataByDataType(void *data, int64_t data_size, const std::vector<int64_t> &input_dims,
const std::vector<int64_t> &begin, const std::vector<int64_t> &output_dims,
ge::GeTensor *output, const std::vector<int64_t> &stride);
static Status SetOutputSliceData(void *data, int64_t data_size, int32_t data_type,
static Status SetOutputSliceData(void *const data, const int64_t data_size, const int32_t data_type,
const std::vector<int64_t> &input_dims, const std::vector<int64_t> &begin,
const std::vector<int64_t> &output_dims, ge::GeTensor *const output,
const std::vector<int64_t> &output_dims, GeTensor *const output,
const std::vector<int64_t> &stride);

///
/// @ingroup domi_omg
/// @brief Convert the convolutional weight data from [h, w, c, k] to [k, c, h, w]
/// @param [in] input Weight data in HWCK format
/// @param [in] H value of H dimension
/// @param [in] W value of W dimension
/// @param [in] C value of C dimension
/// @param [in] K value of K dimension
/// @param [out] output Data pointer after conversion. The format is KCHW.
///
static void TransDataHWCK2KCHW(const void *input, int64_t h, int64_t w, int64_t c, int64_t k, void **output);
///
/// @ingroup domi_omg
/// @brief Converts the convolutional weight data from [k, c, h, w] to [h, w, c, k].
/// @param [in] input Weight data in HWCK format
/// @param [in] K value of K dimension
/// @param [in] C value of C dimension
/// @param [in] H value of H dimension
/// @param [in] W value of W dimension
/// @param [out] output Data pointer after conversion. The format is HWCK
///
static void TransDataKCHW2HWCK(const void *input, int64_t k, int64_t c, int64_t h, int64_t w, void *output);

static std::vector<ConstGeTensorPtr> GetWeights(const ge::Node &node);
static std::vector<ConstGeTensorPtr> GetWeights(ge::ConstNodePtr node);
static std::vector<GeTensorPtr> MutableWeights(const ge::Node &node);
static std::vector<GeTensorPtr> MutableWeights(const ge::NodePtr node);
static Status SetWeights(ge::Node &node, const std::vector<ge::GeTensorPtr> &weights);
static Status SetWeights(const ge::NodePtr node, const std::vector<ge::GeTensorPtr> &weights);
static Status GetShapeDataFromConstTensor(const ConstGeTensorPtr &tensor, const DataType type,
std::vector<int64_t> &dims);

private:
static uint32_t GetRealDimCnt(const GeTensorDesc &tensor_desc);
};
/*lint +e148*/
} // namespace ge
#endif // INC_FRAMEWORK_COMMON_OP_GE_OP_UTILS_H_

+ 5
- 3
inc/framework/common/op_types.h View File

@@ -20,6 +20,8 @@
#include <set>
#include <string>

#include "graph/types.h"

namespace ge {
class GE_FUNC_VISIBILITY OpTypeContainer {
public:
@@ -47,17 +49,17 @@ class GE_FUNC_VISIBILITY OpTypeContainer {

class GE_FUNC_VISIBILITY OpTypeRegistrar {
public:
explicit OpTypeRegistrar(const std::string &op_type) {
explicit OpTypeRegistrar(const std::string &op_type) noexcept {
OpTypeContainer::Instance()->Register(op_type);
}
~OpTypeRegistrar() {}
};

#define REGISTER_OPTYPE_DECLARE(var_name, str_name) \
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *var_name;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char_t *var_name;

#define REGISTER_OPTYPE_DEFINE(var_name, str_name) \
const char *var_name = str_name; \
const char_t *var_name = str_name; \
const OpTypeRegistrar g_##var_name##_reg(str_name);

#define IS_OPTYPE_EXISTING(str_name) (OpTypeContainer::Instance()->IsExisting(str_name))


+ 136
- 0
inc/framework/common/profiling_definitions.h View File

@@ -0,0 +1,136 @@
/**
* Copyright 2021 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 AIR_CXX_PROFILING_DEFINITIONS_H
#define AIR_CXX_PROFILING_DEFINITIONS_H
#include <string>
#include <iostream>
#include <atomic>
#include <mutex>
#include <unordered_map>
#include "graph/profiler.h"
namespace ge {
namespace profiling {
enum {
kInferShape,
kTiling,
kUpdateShape,
kConstPrepare,
kInitHybridExecuteArgs,
kInitInferShapeContext,
kDestroyInferShapeContext,
kResetSubgraphExecutor,
kCommitInferShapeTask,
kDeviceToHost,
kPrepareTask,
kLaunchTask,
kCommitTilingTask,
kAtomic,
kKernelLaunchPrepare,
kRtKernelLaunch,
kOpExecute,
kAllocMem,
kCopyH2D,
kProfilingIndexEnd
};

class ProfilingContext {
public:
static bool IsDumpToStdEnabled();
static ProfilingContext &GetInstance();
ProfilingContext();
~ProfilingContext();

/*
* 还有一种思路是`IsEnabled`只判断profiler_是否为空指针,不再设置单独的enabled标记位,这样可以少一个标记位。
* 但是这么做就意味着,profiler_实例在未使能profiling时,必须是空指针状态。
* 为了性能考虑,profiling机制在编译和加载时,就会调用`RegisterString`,向profiler_注册字符串,后续执行时,只会使用注册好的index了。
* 因此存在一种场景:编译时并未使能profiling(因为编译时间很长,使能profiling也无法真实反应执行时的耗时状态),
* 因此编译时注册字符串的动作并没有生效。在执行时,动态的打开了profiling,这种场景下,执行时无法拿到注册后字符串
*/
bool IsEnabled() const noexcept {
return enabled_ && profiler_ != nullptr;
}
void SetEnable() noexcept {
enabled_ = true;
}
void SetDisable() noexcept {
enabled_ = false;
}

void RecordCurrentThread(int64_t element, int64_t event, EventType et) {
if (IsEnabled()) {
profiler_->RecordCurrentThread(element, event, et);
}
}

const Profiler *GetProfiler() const {
return profiler_.get();
}

void Dump(std::ostream &out_stream) const {
if (IsEnabled()) {
profiler_->Dump(out_stream);
} else {
out_stream << "Profiling not enable, skip to dump" << std::endl;
}
}

void DumpToStdOut() const {
Dump(std::cout);
}

void Reset() {
if (IsEnabled()) {
profiler_->Reset();
}
}

int64_t RegisterString(const std::string &str);

private:
void RegisterString(int64_t index, const std::string &str);
void Init();

private:
bool enabled_;
int64_t str_index_;
std::unordered_map<std::string, int64_t> strings_to_index_;
std::mutex strings_to_index_mutex_;
std::unique_ptr<Profiler> profiler_;
};

class ScopeProfiler {
public:
ScopeProfiler(int64_t element, int64_t event) : element_(element), event_(event) {
ProfilingContext::GetInstance().RecordCurrentThread(element_, event, kEventStart);
}
~ScopeProfiler() {
ProfilingContext::GetInstance().RecordCurrentThread(element_, event_, kEventEnd);
}

private:
int64_t element_;
int64_t event_;
};
} // namespace profiling
} // namespace ge
#define PROFILING_START(element, event) \
profiling::ProfilingContext::GetInstance().RecordCurrentThread(element, event, profiling::kEventStart)
#define PROFILING_END(element, event) \
profiling::ProfilingContext::GetInstance().RecordCurrentThread(element, event, profiling::kEventEnd)
#define PROFILING_SCOPE(element, event) profiling::ScopeProfiler profiler(element, event)
#endif // AIR_CXX_PROFILING_DEFINITIONS_H

+ 2
- 2
inc/framework/common/scope_guard.h View File

@@ -25,9 +25,9 @@
/// MAKE_GUARD([&] { Release Resource 1 })
/// Acquire Resource 2
// MAKE_GUARD([&] { Release Resource 2 })
#define GE_MAKE_GUARD(var, callback) const ScopeGuard const_guard_##var(callback)
#define GE_MAKE_GUARD(var, callback) const ::ge::ScopeGuard const_guard_##var(callback)

#define GE_DISMISSABLE_GUARD(var, callback) ScopeGuard make_guard_##var(callback)
#define GE_DISMISSABLE_GUARD(var, callback) ::ge::ScopeGuard make_guard_##var(callback)
#define GE_DISMISS_GUARD(var) make_guard_##var.Dismiss()

namespace ge {


+ 28
- 241
inc/framework/common/types.h View File

@@ -53,23 +53,11 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string MODEL_
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string MODEL_ATTR_TASK_GEN_BASE_ADDR;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string MODEL_ATTR_TASK_GEN_WEIGHT_ADDR;
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string MODEL_ATTR_FUSION_MODEL_DEF;

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint64_t ALLOC_MEMORY_MAX_SIZE; // Max size of 8 GB.

template <typename K, typename V>
static std::pair<V, K> flip_pair(const std::pair<K, V> &p) {
return std::pair<V, K>(p.second, p.first);
}

template <typename K, typename V>
static std::map<V, K> flip_map(std::map<K, V> src) {
std::map<V, K> dst;
std::transform(src.begin(), src.end(), std::inserter(dst, dst.begin()), flip_pair<K, V>);
return dst;
}

REGISTER_OPTYPE_DECLARE(DATA, "Data");
REGISTER_OPTYPE_DECLARE(AIPPDATA, "AippData");
REGISTER_OPTYPE_DECLARE(QUEUE_DATA, "QueueData");
REGISTER_OPTYPE_DECLARE(CONVOLUTION, "Convolution");
REGISTER_OPTYPE_DECLARE(CORRELATION, "Correlation");
REGISTER_OPTYPE_DECLARE(CORRELATIONV2, "Correlation_V2");
@@ -516,30 +504,6 @@ REGISTER_OPTYPE_DECLARE(GETDYNAMICDIMS, "GetDynamicDims");
// profiling training trace node
REGISTER_OPTYPE_DECLARE(PROFILINGTRAININGTRACE, "ProfilingTrainingTrace");

enum InputMode { INPUT = 0, CONST_INPUT };

// Definition of the processing status enum of the process module
enum ModelProcessState {
INIT_STATE = 0, // init status
WAIT_EVENT_STATE, // Wait for the event status
IND_RSLT_STATE, // The model execution result is being output to the high level
STOPPED_STATE, // Model execution completed. The model enters this state after Model Manager::Stop
RESERVED_STATE, // reserved
};

// Indicates the enun definition of the execution mode of the access module
enum SysMode {
INFERENCE = 0, // Normal, that is, Inference mode
DEBUG, // Debug mode
TIME, // Model execution time mode, including the execution time of each OP
STOP, // STOP mode
RESET, // RESET mode
PERFORMANCE, // Impact of enabling the performance model: 1. The input data of the model is considered ready and does
// not need to be converted
ANDROID_DEBUG, // Exports Android platform computing data
RESERVED, // reserved
};

// @brief encryption type of the model file
enum ModelEncryptType {
UNENCRYPTED, // not encrypted
@@ -577,22 +541,22 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t MODEL_FIL
///
/// @brief model name length
///
static constexpr uint32_t MODEL_NAME_LENGTH = 32;
constexpr uint32_t MODEL_NAME_LENGTH = 32U;

///
/// @brief length of user-defined information
///
static constexpr uint32_t USER_DEFINE_INFO_LENGTH = 32;
constexpr uint32_t USER_DEFINE_INFO_LENGTH = 32U;

///
/// @brief length of the model file signature
///
static constexpr uint32_t MODEL_FILE_CHECKSUM_LENGTH = 64;
constexpr uint32_t MODEL_FILE_CHECKSUM_LENGTH = 64U;

///
/// @brief length of the reserved field in the model file header
///
static constexpr uint32_t MODEL_FILE_RESERVED_LENGTH = 75;
constexpr uint32_t MODEL_FILE_RESERVED_LENGTH = 75U;

// DATA node type
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DATA_TYPE;
@@ -617,7 +581,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OP_TYP
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string OP_CONF_DELIMITER;

// dim default size value
static const int32_t DIM_DEFAULT_SIZE = 4;
constexpr int32_t DIM_DEFAULT_SIZE = 4;

// dim extension default value
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const int32_t DIM_DEFAULT_VALUE;
@@ -650,34 +614,35 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t STREAM_SW

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_GLOBAL_STEP;

static const uint32_t PLATFORM_VERSION_LEN = 20;
constexpr uint32_t PLATFORM_VERSION_LEN = 20U;

// Definition of the file header of the model file
struct ModelFileHeader {
uint32_t magic = MODEL_FILE_MAGIC_NUM; // magic number of DOMI
uint32_t headsize = MODEL_FILE_HEAD_LEN; // length of the model header. The value is fixed at 256
uint32_t version = MODEL_VERSION; // version 1.0
uint8_t checksum[MODEL_FILE_CHECKSUM_LENGTH] = {0}; // signature
uint32_t length = 0; // Ciphertext length. In the non-encryption model, the length is the plaintext length.
uint8_t is_encrypt = ModelEncryptType::UNENCRYPTED; // whether encrypted 0:not encrypt, 1:encrypt
uint8_t is_checksum = ModelCheckType::CHECK; // whether to check the checksum
uint8_t modeltype = 0; // 0:IR model 1:standard model 2: OM Tiny model
uint8_t genmode = 0; // 0:offline generate 1:online generate
uint8_t name[MODEL_NAME_LENGTH] = {0}; // Model name, which contains 32 characters
uint32_t ops = 0; // Computing power (Kops)
uint8_t userdefineinfo[USER_DEFINE_INFO_LENGTH] = {0}; // User-defined information. The value contains 32 characters
uint32_t om_ir_version = 0;
uint32_t model_num = 0;
uint8_t platform_version[PLATFORM_VERSION_LEN] = {0};
uint8_t platform_type = {0};
uint8_t reserved[MODEL_FILE_RESERVED_LENGTH] = {0}; // Reserved field 75
uint32_t magic = MODEL_FILE_MAGIC_NUM; // magic number of DOMI
uint32_t headsize = MODEL_FILE_HEAD_LEN; // length of the model header. The value is fixed at 256
uint32_t version = MODEL_VERSION; // version 1.0
uint8_t checksum[MODEL_FILE_CHECKSUM_LENGTH] = {0U}; // signature
uint32_t length = 0U; // Ciphertext length. In the non-encryption model, the length is the plaintext length.
uint8_t is_encrypt =
static_cast<uint8_t>(ModelEncryptType::UNENCRYPTED); // whether encrypted 0:not encrypt, 1:encrypt
uint8_t is_checksum = static_cast<uint8_t>(ModelCheckType::CHECK); // whether to check the checksum
uint8_t modeltype = 0U; // 0:IR model 1:standard model 2: OM Tiny model
uint8_t genmode = 0U; // 0:offline generate 1:online generate
uint8_t name[MODEL_NAME_LENGTH] = {0U}; // Model name, which contains 32 characters
uint32_t ops = 0U; // Computing power (Kops)
uint8_t userdefineinfo[USER_DEFINE_INFO_LENGTH] = {0U}; // User-defined information. The value contains 32 characters
uint32_t om_ir_version = 0U;
uint32_t model_num = 0U;
uint8_t platform_version[PLATFORM_VERSION_LEN] = {0U};
uint8_t platform_type = {0U};
uint8_t reserved[MODEL_FILE_RESERVED_LENGTH] = {0U}; // Reserved field 75
};

static constexpr uint8_t TARGET_TYPE_LTTE_8BIT = 0;
static constexpr uint8_t TARGET_TYPE_MINI_8BIT = 1;
constexpr uint8_t TARGET_TYPE_LTTE_8BIT = 0U;
constexpr uint8_t TARGET_TYPE_MINI_8BIT = 1U;

// number of partitions in the current model
static constexpr uint32_t PARTITION_SIZE = 5;
constexpr uint32_t PARTITION_SIZE = 5U;

enum ModelPartitionType { MODEL_DEF = 0, WEIGHTS_DATA, TASK_INFO, TBE_KERNELS, CUST_AICPU_KERNELS };

@@ -694,20 +659,6 @@ struct ModelPartitionTable {

#define SIZE_OF_MODEL_PARTITION_TABLE(table) (sizeof(ModelPartitionTable) + sizeof(ModelPartitionMemInfo) * (table).num)

// Filter format
typedef enum tagDomiFilterFormat {
DOMI_FILTER_KCHW, // KCHW
DOMI_FILTER_HWCK, // HWCK
DOMI_FILTER_RESERVED
} domiFilterFormat_t;

// Const data trans type
typedef enum tagDomiConstDataTransType {
DOMI_CONST_DATA_NOT_CHANGE = 0, // No action is required
DOMI_CONST_DATA_TRANS_MATMUL, // The const input to MatMul and needs to be transposed
DOMI_CONST_DATA_RESERVED
} domiConstDataTransType_t;

// mode of activation
typedef enum tagDomiActivationMode {
DOMI_ACTIVATION_SIGMOID = 0, // sigmoid
@@ -727,170 +678,6 @@ typedef enum tagDomiActivationMode {
DOMI_ACTIVATION_RESERVED
} domiActivationMode_t;

// mode of batchnorm
typedef enum tagDomiBatchNormMode {
DOMI_BATCHNORM_PER_ACTIVATION = 0, // bnScale, bnBias tensor dims are 1xCxHxW
DOMI_BATCHNORM_SPATIAL, // bnScale, bnBias tensor dims are 1xCx1x1
DOMI_BATCHNORM_RESERVED
} domiBatchNormMode_t;

// eltwise mode
typedef enum tagDomiEltwiseMode {
DOMI_ELTWISE_PROD = 0, // prod
DOMI_ELTWISE_SUM, // sum
DOMI_ELTWISE_MAX, // max
DOMI_ELTWISE_RESERVED
} domiEltwiseMode_t;

// mode of padding
typedef enum tagDomiPaddingMode {
DOMI_PADDING_CEIL = 0, // Default padding mode
DOMI_PADDING_DIRECTASSIGN, // Default padding mode: NOTSET
DOMI_PADDING_VALID, // VALID padding mode
DOMI_PADDING_SAME, // Padding values of 0 are always used
DOMI_PADDING_CEIL_NEW, // Padding values of 0 are always used
DOMI_PADDING_VALID_NEW, // Padding values of 0 are always used
DOMI_PADDING_SAME_NEW, // Padding values of 0 are always used
DOMI_PADDING_RESERVED
} domiPaddingMode_t;

// algorithm of convolution forward
typedef enum tagDomiConvolutionFwdAlgo {
DOMI_CONVOLUTION_FWD_ALGO_GEMM = 0, // matrix gemm algo
DOMI_CONVOLUTION_FWD_ALGO_WINOGRAD, // Winograd Transform algo
DOMI_CONVOLUTION_FWD_ALGO_GEMM_ACCU_FLOAT32, // accumulate in L0c with FP32
DOMI_CONVOLUTION_FWD_ALGO_RESERVED
} domiConvolutionFwdAlgo_t;

typedef enum tagDomiFullConnectFwdAlgo {
DOMI_FULLCONNECT_FWD_ALGO_HALF = 0, // accumulate in L0c with FP16
DOMI_FULLCONNECT_FWD_ALGO_FLOAT32 // accumulate in L0c with FP32
} domiFullConnectFwdAlgo_t;

typedef enum tagDomiPooingFwdAlgo {
DOMI_POOLING_FWD_ALGO_HALF = 0, // accumulate in L0c with FP16
DOMI_POOLING_FWD_ALGO_FLOAT32 // accumulate in L0c with FP32
} domiPooingFwdAlgo_t;

// mode of convolution
typedef enum tagDomiConvolutionMode {
DOMI_CONV_CONVOLUTION = 0, // math convolution
DOMI_CONV_CROSS_CORRELATION, // cross-correlation convolution
DOMI_CONV_DECONVOLUTION, // deconvolution, also named transposed convolution
DOMI_CONV_MODE_DEPTHWISE, // depthwise convolution
DOMI_CONV_MODE_RESERVED
} domiConvolutionMode_t;

// softmax mode
typedef enum tagDomiSoftmaxMode {
DOMI_SOFTMAX_MODE_INSTANCE = 0, // compute the softmax over all C, H, W for each N
DOMI_SOFTMAX_MODE_CHANNEL, // compute the softmax over all C for each H, W, N
DOMI_SOFTMAX_MODE_HEIGHT, // compute the softmax over all H for each N, C, W
DOMI_SOFTMAX_MODE_WIDTH, // compute the softmax over all W for each N, C, H
DOMI_SOFTMAX_MODE_RESERVED
} domiSoftmaxMode_t;

// softmax algorithm
typedef enum tagDomiSoftmaxAlgo {
DOMI_SOFTMAX_FAST = 0, // straightforward implementation
DOMI_SOFTMAX_ACCURATE, // subtract max from every point to avoid overflow
DOMI_SOFTMAX_LOG, // perform the Log softmax operation to avoid overflow
DOMI_SOFTMAX_ACCURATE_FP32,
DOMI_SOFTMAX_RESERVED
} domiSoftmaxAlgo_t;

// algorithm of convolution backward
typedef enum tagDomiConvolutionBwdAlgo {
DOMI_CONVOLUTION_BWD_ALGO_GEMM = 0, // matrix gemm algo
DOMI_CONVOLUTION_BWD_ALGO_WINOGRAD, // Winograd Transform algo
DOMI_CONVOLUTION_BWD_ALGO_RESERVED
} domiConvolutionBwdAlgo_t;

// mode of pooling
typedef enum tagDomiPoolingMode {
DOMI_POOLING_MAX = 0, // max pooling
DOMI_POOLING_AVG, // average pooling
DOMI_POOLING_L2, // L2 pooling
DOMI_POOLING_RESERVED
} domiPoolingMode_t;

// propagate Nan
typedef enum tagDomiNanPropagation {
DOMI_NAN_NOT_PROPAGATE = 0, // Nan numbers are not propagated
DOMI_NAN_PROPAGATE, // Nan numbers are propagated
DOMI_NAN_PROPAGATE_RESERVED
} domiNanPropagation_t;

// mode of cropandresize
typedef enum tagDomiCropAndResizeMode {
DOMI_RESIZE_METHOD_BILINEAR = 0, // resize bilinear
DOMI_RESIZE_METHOD_NEAREST, // resize nearest
DOMI_RESIZE_RESERVED
} domiCropAndResizeMode_t;

// yolo version
typedef enum tagDomiYoloVersion { DOMI_YOLO_V2 = 1, DOMI_YOLO_V3, DOMI_YOLO_TRSERVED } domiYoloVersion_t;

typedef enum tagDomiRNNScopePassType {
DOMI_STATIC_BIDIRECTIONAL_RNN_GENERAL_PASS = 0,
DOMI_DYNAMIC_BIDIRECTIONAL_RNN_GENERAL_PASS,
DOMI_DYNAMIC_BIDIRECTIONAL_RNN_BIDAF_PASS
} domiRNNScopePassType;

// RNNDataLayout
typedef enum tagDomiRNNDataLayout {
DOMI_RNN_ND_TBX = 0, // data[max_time,batch_size,Xt]
DOMI_RNN_ND_BTX, // data[batch_size,max_time,Xt]
DOMI_RNN_5D_TX1BX, // data[max_time,Xt,1,batch_size,Xt]
DOMI_RNN_5D_BX1TX, // dataa[batch_size,Xt,1,max_time,Xt]
DOMI_RNN_4DTBX1,
DOMI_ENN_DL_RESERVED
} domiRNNDataLayout_t;

// RNNInputMode
typedef enum tagDomiRNNInputMode { DOMI_RNN_LINEAR_INPUT = 0, DOMI_RNN_SKIP_INPUT } domiRNNInputMode_t;

// RNNDirectionMode
typedef enum tagDomiRNNDirectionMode { DOMI_RNN_UNIDIRECTIONAL = 0, DOMI_RNN_BIDIRECTIONAL } domiDirectionMode_t;

typedef enum tagDomiPoolingCeilMode { DOMI_POOLING_FLOOR = 0, DOMI_POOLING_CEIL } domiPoolingCeilMode_t;

// RNNMode
typedef enum tagDomiRNNActivationMode {
DOMI_RNN_ACTIVATION_SIGMOID = 0, // sigmoid
DOMI_RNN_ACTIVATION_TANH, // tanh
DOMI_RNN_ACTIVATION_RELU, // ReLU
DOMI_RNN_ACTIVATION_RELU1, // ReLU1
DOMI_RNN_ACTIVATION_RELU6, // ReLU6
DOMI_RNN_ACTIVATION_RESERVED
} domiRNNActivationMode_t;

typedef enum tagDomiRNNLSTMOutMode {
DOMI_RNN_LSTM_OUT_SEPARATE = 0,
DOMI_RNN_LSTM_OUT_CONCAT,
DOMI_RNN_LSTM_OUT_RESERVED
} domiRNNLSTMOutPutMode_t;
typedef enum tagDomiRNNLSTMStateOutMode {
DOMI_RNN_LSTM_STATE_OUT_SEPARATE = 0,
DOMI_RNN_LSTM_STATE_OUT_CONCAT_ALL,
DOMI_RNN_LSTM_STATE_OUT_RESERVED
} domiRNNLSTMStateOutMode_t;

typedef enum tagDomiRNNMode {
DOMI_RNN_RELU = 0,
DOMI_RNN_TANH,
DOMI_LSTM,
DOMI_GRU,
DOMI_RNN_MODE_RESERVED
} domiRNNMode_t;

typedef enum tagDomiResizeBilinearMode {
DOMI_RESIZE_OUTPUT_DIM_BY_ZOOM_FACTOR = 0, // Output dimension specified by zoom factor
DOMI_RESIZE_OUTPUT_DIM_BY_SHRINK_FACTOR, // specified by shrink factor
DOMI_RESIZE_OUTPUT_DIM_EXPLICIT, // specified explicitly
DOMI_RESIZE_OUTPUT_DIM_RESERVED
} domiResizeOutputDimMode_t;

#pragma pack(1) // single-byte alignment
// DUMP file struct
struct FileHeader {


+ 93
- 93
inc/framework/common/util.h View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/

#ifndef INC_FRAMEWORK_COMMON_UTIL_H_
#define INC_FRAMEWORK_COMMON_UTIL_H_
#ifndef AIR_INC_FRAMEWORK_COMMON_UTIL_H_
#define AIR_INC_FRAMEWORK_COMMON_UTIL_H_

#include <climits>
#include <cmath>
@@ -24,13 +24,14 @@
#include <vector>

#include <google/protobuf/text_format.h>
#include "external/graph/types.h"
#include "framework/common/debug/log.h"
#include "framework/common/scope_guard.h"
#include "framework/common/ge_inner_error_codes.h"

#define GE_CHECK_POSITIVE_SIZE_RANGE(size) \
do { \
if (size <= 0) { \
if ((size) <= 0) { \
GELOGE(ge::FAILED, "param[%s] is not a positive number", #size); \
return PARAM_INVALID; \
} \
@@ -115,7 +116,7 @@
// Check if the parameter is null. If yes, return PARAM_INVALID and record the error
#define GE_CHECK_NOTNULL(val) \
do { \
if (val == nullptr) { \
if ((val) == nullptr) { \
REPORT_INNER_ERROR("E19999", "Param:%s is nullptr, check invalid", #val); \
GELOGE(ge::FAILED, "[Check][Param:%s]null is invalid.", #val); \
return ge::PARAM_INVALID; \
@@ -125,7 +126,7 @@
// Check if the parameter is null. If yes, just return and record the error
#define GE_CHECK_NOTNULL_JUST_RETURN(val) \
do { \
if (val == nullptr) { \
if ((val) == nullptr) { \
GELOGE(ge::FAILED, "param[%s] must not be null.", #val); \
return; \
} \
@@ -134,7 +135,7 @@
// Check whether the parameter is null. If so, execute the exec_expr expression and record the error log
#define GE_CHECK_NOTNULL_EXEC(val, exec_expr) \
do { \
if (val == nullptr) { \
if ((val) == nullptr) { \
GELOGE(ge::FAILED, "param[%s] must not be null.", #val); \
exec_expr; \
} \
@@ -143,7 +144,7 @@
// Check whether the parameter is null. If yes, return directly and record the error log
#define GE_RT_VOID_CHECK_NOTNULL(val) \
do { \
if (val == nullptr) { \
if ((val) == nullptr) { \
GELOGE(ge::FAILED, "param[%s] must not be null.", #val); \
return; \
} \
@@ -152,7 +153,7 @@
// Check if the parameter is null. If yes, return false and record the error log
#define GE_RT_FALSE_CHECK_NOTNULL(val) \
do { \
if (val == nullptr) { \
if ((val) == nullptr) { \
GELOGE(ge::FAILED, "param[%s] must not be null.", #val); \
return false; \
} \
@@ -161,7 +162,7 @@
// Check if the parameter is out of bounds
#define GE_CHECK_SIZE(size) \
do { \
if (size == 0) { \
if ((size) == 0) { \
GELOGE(ge::FAILED, "param[%s] is out of range", #size); \
return ge::PARAM_INVALID; \
} \
@@ -170,7 +171,7 @@
// Check if the value on the left is greater than or equal to the value on the right
#define GE_CHECK_GE(lhs, rhs) \
do { \
if (lhs < rhs) { \
if ((lhs) < (rhs)) { \
GELOGE(ge::FAILED, "param[%s] is less than[%s]", #lhs, #rhs); \
return ge::PARAM_INVALID; \
} \
@@ -179,7 +180,7 @@
// Check if the value on the left is less than or equal to the value on the right
#define GE_CHECK_LE(lhs, rhs) \
do { \
if (lhs > rhs) { \
if ((lhs) > (rhs)) { \
GELOGE(ge::FAILED, "param[%s] is greater than[%s]", #lhs, #rhs); \
return ge::PARAM_INVALID; \
} \
@@ -187,103 +188,36 @@

#define GE_DELETE_NEW_SINGLE(var) \
do { \
if (var != nullptr) { \
delete var; \
var = nullptr; \
if ((var) != nullptr) { \
delete (var); \
(var) = nullptr; \
} \
} while (false)

#define GE_DELETE_NEW_ARRAY(var) \
do { \
if (var != nullptr) { \
delete[] var; \
var = nullptr; \
if ((var) != nullptr) { \
delete[](var); \
(var) = nullptr; \
} \
} while (false)

#define GE_FREE_RT_LOG(addr) \
do { \
if (addr != nullptr) { \
if ((addr) != nullptr) { \
const rtError_t error = rtFree(addr); \
if (error != RT_ERROR_NONE) { \
GELOGE(RT_FAILED, "Call rtFree failed, error: %#x", error); \
} \
addr = nullptr; \
(addr) = nullptr; \
} \
} while (false)

/**
* @ingroup domi_common
* @brief version of om.proto file
*/
static constexpr int32_t OM_PROTO_VERSION = 2;

/**
* Finding an Integer Ceiling Value Without Precision Loss
*/
#define CEIL(N, n) (((N) + (n)-1) / (n))

namespace ge {
using google::protobuf::Message;

///
/// @ingroup domi_common
/// @brief Reads the proto structure from an array.
/// @param [in] data proto data to be read
/// @param [in] size proto data size
/// @param [out] proto Memory for storing the proto file
/// @return true success
/// @return false fail
///
GE_FUNC_VISIBILITY bool ReadProtoFromArray(const void *data, int32_t size, Message *proto);

///
/// @ingroup domi_proto
/// @brief Reads the proto file in the text format.
/// @param [in] file path of proto file
/// @param [out] message Memory for storing the proto file
/// @return true success
/// @return false fail
///
GE_FUNC_VISIBILITY bool ReadProtoFromText(const char *file, google::protobuf::Message *message);

///
/// @ingroup: domi_common
/// @brief: get length of file
/// @param [in] input_file: path of file
/// @return long: File length. If the file length fails to be obtained, the value -1 is returned.
///
GE_FUNC_VISIBILITY extern long GetFileLength(const std::string &input_file);

///
/// @ingroup domi_common
/// @brief Reads all data from a binary file.
/// @param [in] file_name path of file
/// @param [out] buffer Output memory address, which needs to be released by the caller.
/// @param [out] length Output memory size
/// @return false fail
/// @return true success
///
GE_FUNC_VISIBILITY bool ReadBytesFromBinaryFile(const char *const file_name, char **buffer, int32_t &length);

GE_FUNC_VISIBILITY bool ReadBytesFromBinaryFile(const char *file_name, std::vector<char> &buffer);

///
/// @ingroup domi_common
/// @brief Recursively Creating a Directory
/// @param [in] directory_path Path, which can be a multi-level directory.
/// @return 0 success
/// @return -1 fail
///
GE_FUNC_VISIBILITY extern int32_t CreateDirectory(const std::string &directory_path);

///
/// @ingroup domi_common
/// @brief Obtains the current time string.
/// @return Time character string in the format : %Y%m%d%H%M%S, eg: 20171011083555
///
GE_FUNC_VISIBILITY std::string CurrentTimeInStr();

///
/// @ingroup domi_common
/// @brief onverts Vector of a number to a string.
@@ -294,7 +228,7 @@ template <typename T>
GE_FUNC_VISIBILITY std::string ToString(std::vector<T> &v) {
std::stringstream ss;
ss << "[";
for (T x : v) {
for (const T x : v) {
ss << x;
ss << ", ";
}
@@ -314,7 +248,7 @@ template <typename T>
GE_FUNC_VISIBILITY std::string ToString(const google::protobuf::RepeatedField<T> &rpd_field) {
std::stringstream ss;
ss << "[";
for (T x : rpd_field) {
for (const T x : rpd_field) {
ss << x;
ss << ", ";
}
@@ -343,6 +277,72 @@ GE_FUNC_VISIBILITY std::string ToString(const google::protobuf::RepeatedPtrField
return str_ret;
}

namespace ge {
/**
* @ingroup domi_common
* @brief version of om.proto file
*/
constexpr int32_t OM_PROTO_VERSION = 2;

///
/// @ingroup domi_common
/// @brief Reads the proto structure from an array.
/// @param [in] data proto data to be read
/// @param [in] size proto data size
/// @param [out] proto Memory for storing the proto file
/// @return true success
/// @return false fail
///
GE_FUNC_VISIBILITY bool ReadProtoFromArray(const void *const data, const int32_t size,
google::protobuf::Message *const proto);

///
/// @ingroup domi_proto
/// @brief Reads the proto file in the text format.
/// @param [in] file path of proto file
/// @param [out] message Memory for storing the proto file
/// @return true success
/// @return false fail
///
GE_FUNC_VISIBILITY bool ReadProtoFromText(const char_t *const file, google::protobuf::Message *const message);

///
/// @ingroup: domi_common
/// @brief: get length of file
/// @param [in] input_file: path of file
/// @return int64_t: File length. If the file length fails to be obtained, the value -1 is returned.
///
GE_FUNC_VISIBILITY extern int64_t GetFileLength(const std::string &input_file);

///
/// @ingroup domi_common
/// @brief Reads all data from a binary file.
/// @param [in] file_name path of file
/// @param [out] buffer Output memory address, which needs to be released by the caller.
/// @param [out] length Output memory size
/// @return false fail
/// @return true success
///
GE_FUNC_VISIBILITY bool ReadBytesFromBinaryFile(const char_t *const file_name, char_t **const buffer, int32_t &length);

GE_FUNC_VISIBILITY bool ReadBytesFromBinaryFile(const char_t *file_name, std::vector<char_t> &buffer);

///
/// @ingroup domi_common
/// @brief Recursively Creating a Directory
/// @param [in] directory_path Path, which can be a multi-level directory.
/// @return 0 success
/// @return -1 fail
///
GE_FUNC_VISIBILITY extern int32_t CreateDirectory(const std::string &directory_path);

///
/// @ingroup domi_common
/// @brief Obtains the current time string.
/// @return Time character string in the format : %Y%m%d%H%M%S, eg: 20171011083555
///
GE_FUNC_VISIBILITY std::string CurrentTimeInStr();

///
/// @ingroup domi_common
/// @brief Obtains the absolute time (timestamp) of the current system.
@@ -366,7 +366,7 @@ GE_FUNC_VISIBILITY uint32_t GetCurrentSecondTimestap();
/// @param [in] b
/// @return false: true: The result is within the normal int64 range.
///
GE_FUNC_VISIBILITY bool CheckInt64MulOverflow(int64_t a, int64_t b);
GE_FUNC_VISIBILITY bool CheckInt64MulOverflow(const int64_t a, const int64_t b);

///
/// @ingroup domi_common
@@ -374,7 +374,7 @@ GE_FUNC_VISIBILITY bool CheckInt64MulOverflow(int64_t a, int64_t b);
/// @param [in] path of input file
/// @param [out] Absolute path of a file. If the absolute path cannot be obtained, an empty string is returned
///
GE_FUNC_VISIBILITY std::string RealPath(const char *path);
GE_FUNC_VISIBILITY std::string RealPath(const char_t *path);

///
/// @ingroup domi_common
@@ -401,7 +401,7 @@ GE_FUNC_VISIBILITY bool CheckOutputPathValid(const std::string &file_path, const
/// @param [in] str file path
/// @param [out] result
///
GE_FUNC_VISIBILITY bool ValidateStr(const std::string &str, const std::string &mode);
GE_FUNC_VISIBILITY bool ValidateStr(const std::string &file_path, const std::string &mode);

///
/// @ingroup domi_common
@@ -411,7 +411,7 @@ GE_FUNC_VISIBILITY bool ValidateStr(const std::string &str, const std::string &m
/// @return 0 success
/// @return -1 fail
///
GE_FUNC_VISIBILITY Status CheckPath(const char *path, size_t length);
GE_FUNC_VISIBILITY Status CheckPath(const char_t *path, size_t length);
} // namespace ge

#endif // INC_FRAMEWORK_COMMON_UTIL_H_
#endif // AIR_INC_FRAMEWORK_COMMON_UTIL_H_

+ 13
- 0
inc/framework/executor/ge_executor.h View File

@@ -32,6 +32,7 @@
namespace ge {
class SingleOp;
class DynamicSingleOp;
class GeRootModel;

struct RunModelData {
uint32_t index; // Data index
@@ -227,6 +228,18 @@ class GE_FUNC_VISIBILITY GeExecutor {

///
/// @ingroup ge
/// @brief Load task list from ModelData with queue.
/// @param [out] model_id: model id allocate from manager.
/// @param [in] root_model: Instance of GeRootModel.
/// @param [in] input_queue_ids: input queue ids create from user.
/// @param [in] output_queue_ids: input queue ids create from user.
/// @return: 0 for success / others for fail
///
Status LoadModelWithQ(uint32_t &model_id, const std::shared_ptr<GeRootModel> &root_model,
const std::vector<uint32_t> &input_queue_ids, const std::vector<uint32_t> &output_queue_ids);

///
/// @ingroup ge
/// @brief Synchronous execution of offline model(Do not create thread)
/// @param [in] uint32_t model_id: Model ID to execute
/// @param [in] void* stream: stream to execute


+ 2
- 2
inc/framework/generator/ge_generator.h View File

@@ -120,9 +120,9 @@ class GE_FUNC_VISIBILITY GeGenerator {
GraphStage graph_stage = GraphStage::GRAPH_STAGE_RESERVED);
bool CheckNoAicore(const ComputeGraphPtr &graph);
void RemoveConst(const std::vector<GeTensor> &inputs, std::vector<GeTensor> &outputs);
Status CheckForSingleOp(OpDescPtr &op_desc, const std::vector<GeTensor> &inputs,
Status CheckForSingleOp(const OpDescPtr &op_desc, const std::vector<GeTensor> &inputs,
const std::vector<GeTensor> &outputs);
Status InferFormatForSingleOp(OpDescPtr &op_desc, Graph &graph);
Status InferFormatForSingleOp(const OpDescPtr &op_desc, const Graph &graph);

using GeRootModelPtr = std::shared_ptr<ge::GeRootModel>;
Status SetModelNameForDump(const GeRootModelPtr &ge_root_model);


+ 0
- 4
inc/framework/memory/memory_api.h View File

@@ -17,11 +17,7 @@
#ifndef INC_FRAMEWORK_MEMORY_MEMORY_API_H_
#define INC_FRAMEWORK_MEMORY_MEMORY_API_H_

#include <string>
#include <vector>

#include "external/ge/ge_api_error_codes.h"
#include "graph/types.h"
#include "runtime/mem.h"

namespace ge {


+ 1
- 1
inc/framework/memory/memory_assigner.h View File

@@ -33,7 +33,7 @@ class GE_FUNC_VISIBILITY MemoryAssigner {

MemoryAssigner &operator=(const MemoryAssigner &) = delete;

Status AssignMemory(bool is_loop_graph, std::map<uint64_t, size_t> &mem_offset, size_t &zero_copy_mem_size);
Status AssignMemory(std::map<uint64_t, size_t> &mem_offset, size_t &zero_copy_mem_size);

private:
ge::ComputeGraphPtr compute_graph_;


+ 0
- 35
inc/framework/omg/model_tool.h View File

@@ -1,35 +0,0 @@
/**
* Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
*
* 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_FRAMEWORK_OMG_MODEL_TOOL_H_
#define INC_FRAMEWORK_OMG_MODEL_TOOL_H_

#include <memory>
#include <string>

#include "framework/common/debug/ge_log.h"
#include "proto/ge_ir.pb.h"

namespace ge {
class GE_FUNC_VISIBILITY ModelTool {
public:
static Status GetModelInfoFromOm(const char *model_file, ge::proto::ModelDef &model_def, uint32_t &modeldef_size);

static Status GetModelInfoFromPbtxt(const char *model_file, ge::proto::ModelDef &model_def);
};
} // namespace ge

#endif // INC_FRAMEWORK_OMG_MODEL_TOOL_H_

+ 1
- 1
inc/framework/omg/omg.h View File

@@ -64,7 +64,7 @@ GE_FUNC_VISIBILITY Status InitDomiOmgContext(const std::string &input_shape, con
GE_FUNC_VISIBILITY Status ParseGraph(ge::Graph &graph, const std::map<std::string, std::string> &atc_params,
const char *model_file, const char *weights_file, domi::FrameworkType type,
const char *op_conf = nullptr, const char *target = nullptr,
RunMode run_mode = GEN_OM_MODEL, bool is_dynamic_input = false);
RunMode run_mode = RunMode::GEN_OM_MODEL, bool is_dynamic_input = false);

/**
* @ingroup domi_omg


+ 6
- 34
inc/framework/omg/omg_inner_types.h View File

@@ -31,12 +31,7 @@
using domi::DOMI_TENSOR_ND;
using domi::DOMI_TENSOR_RESERVED;
using domi::domiTensorFormat_t;
using domi::FRAMEWORK_RESERVED;
using domi::FrameworkType;
using std::map;
using std::string;
using std::unordered_map;
using std::vector;

namespace ge {
/**
@@ -51,36 +46,13 @@ enum RunMode {
DISPLAY_OM_INFO = 6 // display model info
};

///
/// @ingroup domi_omg
/// @brief high-precision mode
///
enum HighPrecisionMode {
// the FP16 high-precision function is disabled in common mode
HIGH_PRECISION_DEFAULT = 0,

// high-precision mode, enabling FP16 high-precision mode (Convolution/FullConnect/AvgPooling are involved)
HIGH_PRECISION_FP16 = 1
};

///
/// @ingroup domi_omg
/// @brief description buffer data
///
struct OMGBufferData {
void *data;
uint32_t length;
};

struct OmgContext {
OmgContext() {
format = DOMI_TENSOR_ND;
}
domiTensorFormat_t format;
OmgContext() : format(domi::DOMI_TENSOR_ND) {}
domi::domiTensorFormat_t format;

// format of the input specified by the command line
std::unordered_map<std::string, domiTensorFormat_t> input_nodes_format_map;
std::vector<domiTensorFormat_t> output_formats;
std::unordered_map<std::string, domi::domiTensorFormat_t> input_nodes_format_map;
std::vector<domi::domiTensorFormat_t> output_formats;

// user-designate input dims
std::vector<std::pair<std::string, std::vector<int64_t>>> user_input_dims;
@@ -107,9 +79,9 @@ struct OmgContext {
// net data nodes tensor names(caffe or onnx)
std::vector<std::string> data_tensor_names;
// preferential format used by the entire network
domiTensorFormat_t net_format = DOMI_TENSOR_RESERVED;
domi::domiTensorFormat_t net_format = domi::DOMI_TENSOR_RESERVED;
domi::FrameworkType type = domi::FRAMEWORK_RESERVED;
RunMode run_mode = ONLY_PRE_CHECK;
RunMode run_mode = RunMode::ONLY_PRE_CHECK;
bool train_flag = false;

std::string output_type;


+ 4
- 4
inc/framework/omg/parser/op_parser.h View File

@@ -50,7 +50,7 @@ class GE_FUNC_VISIBILITY OpParser {
* @return SUCCESS
* @return FAILED
*/
virtual domi::Status ParseParams(const Message *op_src, ge::OpDescPtr &op_desc) = 0;
virtual domi::Status ParseParams(const google::protobuf::Message *op_src, ge::OpDescPtr &op_desc) = 0;

/**
* @ingroup domi_omg
@@ -60,7 +60,7 @@ class GE_FUNC_VISIBILITY OpParser {
* @return SUCCESS
* @return FAILED
*/
virtual domi::Status ParseParams(const Message *op_src, ge::Operator &op_dest) = 0;
virtual domi::Status ParseParams(const google::protobuf::Message *op_src, ge::Operator &op_dest) = 0;

/**
* @ingroup domi_omg
@@ -70,7 +70,7 @@ class GE_FUNC_VISIBILITY OpParser {
* @return SUCCESS
* @return FAILED
*/
virtual domi::Status ParseWeights(const Message *op_src, ge::NodePtr &node) = 0;
virtual domi::Status ParseWeights(const google::protobuf::Message *op_src, ge::NodePtr &node) = 0;

/**
* @ingroup domi_omg
@@ -80,7 +80,7 @@ class GE_FUNC_VISIBILITY OpParser {
* @return SUCCESS
* @return FAILED
*/
virtual domi::Status GetFormat(const Message *op_src, domi::domiTensorFormat_t &format) {
virtual domi::Status GetFormat(const google::protobuf::Message *op_src, domi::domiTensorFormat_t &format) {
(void)op_src;
// Indicates that the op does not provide a value for format
format = domi::DOMI_TENSOR_RESERVED;


+ 3
- 3
inc/framework/omg/parser/parser_inner_ctx.h View File

@@ -29,8 +29,8 @@
namespace ge {
struct ParserContext {
// format of the input specified by the command line
std::unordered_map<std::string, domiTensorFormat_t> input_nodes_format_map;
std::vector<domiTensorFormat_t> output_formats;
std::unordered_map<std::string, domi::domiTensorFormat_t> input_nodes_format_map;
std::vector<domi::domiTensorFormat_t> output_formats;
// user-designate input dims
std::vector<std::pair<std::string, std::vector<int64_t>>> user_input_dims;
std::map<std::string, std::vector<int64_t>> input_dims;
@@ -58,7 +58,7 @@ struct ParserContext {
bool train_flag = false;
domi::domiTensorFormat_t format = domi::DOMI_TENSOR_ND;
domi::FrameworkType type = domi::FRAMEWORK_RESERVED;
RunMode run_mode = GEN_OM_MODEL;
RunMode run_mode = RunMode::GEN_OM_MODEL;
// save caffe custom proto path, used by caffe parse
std::string custom_proto_path;
// save caffe proto path, used by caffe parse


+ 1
- 3
inc/framework/omg/version.h View File

@@ -19,8 +19,6 @@

#include <memory>
#include <set>
#include <string>
#include <vector>

#include "framework/common/debug/log.h"
#include "framework/common/string_util.h"
@@ -34,7 +32,7 @@ class GE_FUNC_VISIBILITY PlatformVersionManager {
static Status GetPlatformVersion(std::string &ver) {
ver = "1.11.z";
const std::vector<std::string> version_splits = StringUtils::Split(ver, '.');
GE_IF_BOOL_EXEC(version_splits.size() < 3, GELOGW("Read platform version error!"); return FAILED;);
GE_IF_BOOL_EXEC(version_splits.size() < 3U, GELOGW("Read platform version error!"); return FAILED;);

GELOGI("Read current platform version: %s.", ver.c_str());
return SUCCESS;


+ 1
- 1
metadef

@@ -1 +1 @@
Subproject commit 1d99928bfcb02e45acc7db73e3ee57304ff1131a
Subproject commit 238e5308bf0191ac4598984ad6de80fa4a0cff4d

+ 9
- 7
third_party/fwkacllib/inc/cce/fwk_adpt_struct.h View File

@@ -21,7 +21,7 @@

namespace aicpu {
namespace FWKAdapter {
using char_t = char;
// API RETURN CODE
enum FWKAdptAPIRetCode {
FWK_ADPT_SUCCESS = 0, // success
@@ -63,6 +63,8 @@ enum FWKTaskExtInfoType {
FWK_ADPT_EXT_BITMAP,
FWK_ADPT_EXT_TOPIC_TYPE,
FWK_ADPT_EXT_ASYNCWAIT,
FWK_ADPT_EXT_UNKNOWN_SHAPE_INPUT_INDEX,
FWK_ADPT_EXT_UNKNOWN_SHAPE_OUTPUT_INDEX,
FWK_ADPT_EXT_INVALID
};

@@ -113,7 +115,7 @@ struct StrFWKKernel {
typedef StrFWKKernel FWKOperateParam;

// Extent info ShapeAndType
const uint32_t kMaxShapeDims = 8;
const uint32_t kMaxShapeDims = 8U;
#pragma pack(push, 1)
struct ShapeAndType {
int32_t type;
@@ -122,13 +124,13 @@ struct ShapeAndType {
#pragma pack(pop)

// Extend info structure for extInfoAddr
const uint32_t kExtInfoHeadSize = 8;
const uint32_t kExtInfoHeadSize = 8U;

#pragma pack(push, 1)
struct ExtInfo {
int32_t infoType; // extend type
uint32_t infoLen; // length for infoMsg
char infoMsg[0]; // extend value
char_t infoMsg[0]; // extend value
};
#pragma pack(pop)

@@ -143,9 +145,9 @@ struct ResultSummary {

#pragma pack(push, 1)
struct AsyncWait {
uint8_t waitType; // wait type, FWK_ADPT_WAIT_TYPE_EVENT: event wait
uint32_t waitId; // wait id, GE refresh
uint32_t timeOut; // reserved
uint8_t waitType; // wait type, FWk_ADPT_WAIT_TPYE_EVENT: event wait
uint32_t waitId; // wait id, GE refresh
uint32_t timeOut; // reserved
uint64_t reserved;
};
#pragma pack(pop)


+ 3
- 0
third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_linux.h View File

@@ -79,6 +79,9 @@ typedef long LONG;
#define MMPA_THREAD_SCHED_OTHER SCHED_OTHER
#define MMPA_THREAD_MIN_STACK_SIZE PTHREAD_STACK_MIN

#define MMPA_PATH_SEPARATOR_STR "/"
#define MMPA_PATH_SEPARATOR_CHAR '/'

#define MM_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER

#define MMPA_MAX_NI 19


+ 86
- 83
third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_win.h View File

@@ -1,83 +1,86 @@
/**
* 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 MMPA_TYPEDEF_WIN_H
#define MMPA_TYPEDEF_WIN_H

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif // __cpluscplus
#endif // __cpluscplus

#ifndef FALSE
#define FALSE 0
#endif

#ifndef TRUE
#define TRUE 1
#endif

#define EN_OK 0
#define EN_ERR 1
#define EN_ERROR (-1)
#define EN_INVALID_PARAM (-2)
#define EN_TIMEOUT (-3)

#define HANDLE_INVALID_VALUE (-1)
#define INVALID_SOCKET_HANDLE INVALID_SOCKET
#define MMPA_MEM_MAX_LEN (0x7fffffff)
#define MMPA_PROCESS_ERROR (0x7fffffff)

#define MMPA_ONE_THOUSAND 1000
#define MMPA_COMPUTER_BEGIN_YEAR 1900
#define SUMMER_TIME_OR_NOT (-1)
#define MMPA_ZERO 0
#define MMPA_VALUE_ONE 1
#define MMPA_SOCKET_MAIN_EDITION 2
#define MMPA_SOCKET_SECOND_EDITION 0
#define MMPA_PIPE_BUF_SIZE 1024
#define MMPA_MAX_SCANDIR_COUNT 1024
#define MAX_IOVEC_SIZE 32
#define MMPA_PIPE_COUNT 2
#define MMPA_THREADNAME_SIZE 16
#define MMPA_MIN_OS_NAME_SIZE (MAX_COMPUTERNAME_LENGTH + 1)
#define MMPA_MIN_OS_VERSION_SIZE 64

#define MMPA_MAX_NI 19
#define MMPA_MIDDLE_NI 5
#define MMPA_LOW_NI (-5)
#define MMPA_MIN_NI (-20)
#define MMPA_MAX_FILE 128

#define MMPA_MAX_THREAD_PIO 99
#define MMPA_MIDDLE_THREAD_PIO 66
#define MMPA_LOW_THREAD_PIO 33
#define MMPA_MIN_THREAD_PIO 1

#define MMPA_THREAD_SCHED_RR 0
#define MMPA_THREAD_SCHED_FIFO 0
#define MMPA_THREAD_SCHED_OTHER 0
#define MMPA_THREAD_MIN_STACK_SIZE 0

#define MM_MUTEX_INITIALIZER NULL

#ifdef __cplusplus
#if __cplusplus
}
#endif // __cpluscplus
#endif // __cpluscplus
#endif // _MMPA_TYPEDEF_WIN_H_
/**
* 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 MMPA_TYPEDEF_WIN_H
#define MMPA_TYPEDEF_WIN_H
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif // __cpluscplus
#endif // __cpluscplus
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#define EN_OK 0
#define EN_ERR 1
#define EN_ERROR (-1)
#define EN_INVALID_PARAM (-2)
#define EN_TIMEOUT (-3)
#define HANDLE_INVALID_VALUE (-1)
#define INVALID_SOCKET_HANDLE INVALID_SOCKET
#define MMPA_MEM_MAX_LEN (0x7fffffff)
#define MMPA_PROCESS_ERROR (0x7fffffff)
#define MMPA_ONE_THOUSAND 1000
#define MMPA_COMPUTER_BEGIN_YEAR 1900
#define SUMMER_TIME_OR_NOT (-1)
#define MMPA_ZERO 0
#define MMPA_VALUE_ONE 1
#define MMPA_SOCKET_MAIN_EDITION 2
#define MMPA_SOCKET_SECOND_EDITION 0
#define MMPA_PIPE_BUF_SIZE 1024
#define MMPA_MAX_SCANDIR_COUNT 1024
#define MAX_IOVEC_SIZE 32
#define MMPA_PIPE_COUNT 2
#define MMPA_THREADNAME_SIZE 16
#define MMPA_MIN_OS_NAME_SIZE (MAX_COMPUTERNAME_LENGTH + 1)
#define MMPA_MIN_OS_VERSION_SIZE 64
#define MMPA_MAX_NI 19
#define MMPA_MIDDLE_NI 5
#define MMPA_LOW_NI (-5)
#define MMPA_MIN_NI (-20)
#define MMPA_MAX_FILE 128
#define MMPA_PATH_SEPARATOR_STR "\\"
#define MMPA_PATH_SEPARATOR_CHAR '\\'
#define MMPA_MAX_THREAD_PIO 99
#define MMPA_MIDDLE_THREAD_PIO 66
#define MMPA_LOW_THREAD_PIO 33
#define MMPA_MIN_THREAD_PIO 1
#define MMPA_THREAD_SCHED_RR 0
#define MMPA_THREAD_SCHED_FIFO 0
#define MMPA_THREAD_SCHED_OTHER 0
#define MMPA_THREAD_MIN_STACK_SIZE 0
#define MM_MUTEX_INITIALIZER NULL
#ifdef __cplusplus
#if __cplusplus
}
#endif // __cpluscplus
#endif // __cpluscplus
#endif // _MMPA_TYPEDEF_WIN_H_

+ 42
- 0
third_party/fwkacllib/inc/ops/array_ops.h View File

@@ -201,6 +201,48 @@ REG_OP(Unique)
.OP_END_FACTORY_REG(Unique)

/**
*@brief Finds unique elements in a N-D tensor. \n

*@par Inputs:
*Inputs "x" and "axis" are N-D vectors.
* @li x: A N-D tensor. \n

*@par Attributes:
*sorted: An optional attr of type int, default to 1.
*axis: An optional attr of type int, default to -1000.
*return_idx: An optional attr of type bool, default to false.
*return_inverse: An optional attr of type bool, default to false.
*return_counts: An optional attr of type bool, default to false.\n

*@par Outputs:
*@li y: "x" in the unique output "y".
*@li idx: A tensor the same size as "x". The index of each value of "x".
*@li inverse_idx: A tensor the same size as "x". The index of each value of "y".
*@li count: A tensor the same size as "x". The index of each value of "y". \n

*@attention Constraints:
*UniqueV2 runs on the Ascend AI CPU, which delivers poor performance. \n

*@par Third-party framework compatibility
*Compatible with the Pytorch operator unique.
*/

REG_OP(UniqueV2)
.INPUT(x, TensorType({ DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, \
DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_STRING }))
.OUTPUT(y, TensorType({ DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, \
DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_STRING }))
.OUTPUT(idx, TensorType({ DT_INT64 }))
.OUTPUT(inverse_idx, TensorType({ DT_INT64 }))
.OUTPUT(count, TensorType({ DT_INT64 }))
.ATTR(sorted, Int, 1)
.ATTR(axis, Int, -1000)
.ATTR(return_idx, Bool, false)
.ATTR(return_inverse, Bool, false)
.ATTR(return_counts, Bool, false)
.OP_END_FACTORY_REG(UniqueV2)

/**
*@brief Finds unique elements in a 1D tensor. \n

*@par Inputs:


+ 6
- 0
third_party/fwkacllib/inc/ops/elewise_calculation_ops.h View File

@@ -3821,6 +3821,10 @@ REG_OP(CosineSimilarity)
* @li max_grad_norm: A Tensor. Datatype is same as exp_avg. Shape (1, ).\n
* @li global_grad_norm: A Tensor. Datatype is same as exp_avg. Shape (1, ).\n
* @li weight_decay: A Tensor. Datatype is same as exp_avg. Shape (1, ).\n
* @li step_size: A Optional Tensor. Datatype is same as exp_avg. Shape (1, ).\n

* @par Attributes:
* @li adam_mode: An optional bool. Defaults to "adam". \n

*@par Outputs:
*three inputs, including:
@@ -3840,9 +3844,11 @@ REG_OP(ApplyAdamV2)
.INPUT(max_grad_norm, TensorType({ DT_FLOAT, DT_FLOAT16 }))
.INPUT(global_grad_norm, TensorType({ DT_FLOAT, DT_FLOAT16 }))
.INPUT(weight_decay, TensorType({ DT_FLOAT, DT_FLOAT16 }))
.OPTIONAL_INPUT(step_size, TensorType({ DT_FLOAT, DT_FLOAT16 }))
.OUTPUT(var, TensorType({ DT_FLOAT, DT_FLOAT16 }))
.OUTPUT(m, TensorType({ DT_FLOAT, DT_FLOAT16 }))
.OUTPUT(v, TensorType({ DT_FLOAT, DT_FLOAT16 }))
.ATTR(adam_mode, String, "adam")
.OP_END_FACTORY_REG(ApplyAdamV2)
} // namespace ge



+ 33
- 1
third_party/fwkacllib/inc/ops/nn_detect_ops.h View File

@@ -2076,7 +2076,7 @@ REG_OP(GIoUGrad)
* trans: An optional attr, true for 'xyxyt', false for 'xywht'.

*@par Outputs:
* overlaps: A 3D Tensor of type float16 or float32 with shape [B, N, K].
* overlaps: A 3D Tensor of type float32 with shape [B, N, K].

*@attention Constraints:
* In each batch, the invalid box cannot appear before the valid box.
@@ -2087,6 +2087,38 @@ REG_OP(RotatedOverlaps)
.OUTPUT(overlaps, TensorType({DT_FLOAT}))
.ATTR(trans, Bool, false)
.OP_END_FACTORY_REG(RotatedOverlaps)

/**
*@brief RotatedIou . \n

*@par Inputs:
*@li boxes : data of grad increment, a 3D Tensor of type float32 with
* shape (B, 5, N). "N" indicates the number of boxes, and the value
* "5" refers to [x1, y1, x2, y2, theta] or [x, y, w, h, theta].
*@li query_boxes: Bounding boxes, a 3D Tensor of type float32 with
* shape (B, 5, K). "K" indicates the number of boxes, and the value
* "5" refers to [x1, y1, x2, y2, theta] or [x, y, w, h, theta].

*@par Attributes:
*@li trans: An optional attr, true for 'xyxyt', false for 'xywht'.
*@li mode: An optional attr, a character string with the value range of ['iou', 'iof'],
* only support 'iou' now.
*@li is_cross: Cross calculation when it is True, and one-to-one calculation when it is False.

*@par Outputs:
* iou: A 3D Tensor of float32 with shape [B, N, K].

*@attention Constraints:
* In each batch, the invalid box cannot appear before the valid box.
*/
REG_OP(RotatedIou)
.INPUT(boxes, TensorType({DT_FLOAT}))
.INPUT(query_boxes, TensorType({DT_FLOAT}))
.OUTPUT(iou, TensorType({DT_FLOAT}))
.ATTR(trans, Bool, false)
.ATTR(mode, String, "iou")
.ATTR(is_cross, Bool, true)
.OP_END_FACTORY_REG(RotatedIou)
} // namespace ge

#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_DETECT_OPS_H_


+ 30
- 0
third_party/fwkacllib/inc/ops/nn_norm_ops.h View File

@@ -1644,6 +1644,36 @@ REG_OP(NormalizeBatch)
.REQUIRED_ATTR(normalize_type, String)
.ATTR(epsilon, Float, 0.00001)
.OP_END_FACTORY_REG(NormalizeBatch)

/**
*@brief GroupNorm and Reul operator
* calculating: x, gamma, beta
* y = relu(gamma*((x - mean) / np.sqrt(variance + 0.001)) + beta)

*@par Inputs:
*Three inputs, including:
* @li x: A Tensor. Must be one of the following types: float16, float32.
* @li gamma: A Tensor. Must be one of the following types: float16, float32.
* @li beta: A Tensor. Must be one of the following types: float16, float32 . \n

*@par Attributes:
* @li num_groups: A require attribute, the type is int32.
* @li eps: A optional attribute, the type is float32. Defaults to 0.00001. \n

*@par Outputs:
*One outputs, including:
* @li y: A Tensor. Must be one of the following types: float16, float32.
*@par Restrictions:
*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use/
*/
REG_OP(GroupNormRelu)
.INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16}))
.INPUT(gamma, TensorType({DT_FLOAT, DT_FLOAT16}))
.INPUT(beta, TensorType({DT_FLOAT, DT_FLOAT16}))
.OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16}))
.REQUIRED_ATTR(num_groups, Int)
.ATTR(eps, Float, 0.00001)
.OP_END_FACTORY_REG(GroupNormRelu)
} // namespace ge

#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_NORM_OPS_H_

+ 15
- 0
third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h View File

@@ -159,7 +159,22 @@ REG_OP(FastGelu)
.INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
.OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
.OP_END_FACTORY_REG(FastGelu)
/**
*@brief Computes the for the fast_gelu_v2 of "x" . \n

*@par Inputs:
*One input, including:
*x: A Tensor. Must be one of the following types: float16, float32

*@par Outputs:
*y: A Tensor. Has the same type as "x".
*@par Third-party framework compatibility
*Compatible with the TensorFlow operator FastGeluV2
*/
REG_OP(FastGeluV2)
.INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
.OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
.OP_END_FACTORY_REG(FastGeluV2)
/**
*@brief Computes the gradient for the fast_gelu of "x" . \n



+ 1
- 0
third_party/fwkacllib/inc/ops/ocr_ops.h View File

@@ -81,6 +81,7 @@ REG_OP(OCRRecognitionPreHandle)
.OUTPUT(imgs, TensorType({DT_UINT8}))
.OUTPUT(imgs_relation, TensorType({DT_INT32}))
.OUTPUT(imgs_lang, TensorType({DT_INT32}))
.OUTPUT(imgs_piece_fillers, TensorType({DT_INT32}))
.ATTR(batch_size, Int, 8)
.ATTR(data_format, String, "NHWC")
.ATTR(pad_mode, String, "REPLICATE")


+ 37
- 0
third_party/fwkacllib/inc/ops/reduce_ops.h View File

@@ -1326,6 +1326,43 @@ REG_OP(ReduceMeanVariance)
.ATTR(axes, ListInt, {})
.ATTR(keep_dims, Bool, true)
.OP_END_FACTORY_REG(ReduceMeanVariance)

/**
* @brief Calculates the standard deviation or the variance of Tensors with the average value.

* @par Inputs:
* Two inputs, including:
* @li x: A Tensor. Must be one of the following types: float16, float32. \n
* @li mean: A Tensor. It's the mean of X. Has the same shape and type as "x" \n

* @par Attributes:
* Four Attributes, including:
* @li dim: An listint. \n
* @li if_std: An optional bool. Defaults to "False"
* If "True", Calculate the standard deviation
* If "False", Calculate the variance
* @li unbiased: An optional bool. Defaults to "True".
* If "True", Use Bessel Correction.
* If "False", Do not use Bessel Correction. \n
* @li keepdim: An optional bool. Defaults to "False".
* If "True", Keep the original tensor dimension.
* If "False", Do not keep the original tensor dimension. \n

* @par Outputs:
* @li output_var: A Tensor. It's the standard deviation or the variance of X. Has the same type as "x".

* @par Third-party framework compatibility
* Compatible with the Pytorch operator Var_mean.
*/
REG_OP(ReduceStdV2Update)
.INPUT(x, TensorType({DT_FLOAT,DT_FLOAT16}))
.INPUT(mean, TensorType({DT_FLOAT,DT_FLOAT16}))
.OUTPUT(output_var, TensorType({DT_FLOAT,DT_FLOAT16}))
.REQUIRED_ATTR(dim, ListInt)
.ATTR(if_std, Bool, false)
.ATTR(unbiased, Bool, true)
.ATTR(keepdim, Bool, false)
.OP_END_FACTORY_REG(ReduceStdV2Update)
} //namespace ge

#endif // OPS_BUILT_IN_OP_PROTO_INC_REDUCE_OPS_H_

+ 2
- 2
third_party/fwkacllib/inc/runtime/base.h View File

@@ -98,11 +98,11 @@ typedef struct rtExceptionInfo {
uint32_t tid;
uint32_t deviceid;
uint32_t retcode;
} rtExceptionInfo;
} rtExceptionInfo_t;

typedef void (*rtErrorCallback)(rtExceptionType);

typedef void (*rtTaskFailCallback)(rtExceptionInfo *exceptionInfo);
typedef void (*rtTaskFailCallback)(rtExceptionInfo_t *exceptionInfo);

typedef void (*rtDeviceStateCallback)(uint32_t devId, bool isOpen);



+ 1
- 1
third_party/fwkacllib/inc/runtime/context.h View File

@@ -140,7 +140,7 @@ RTS_API rtError_t rtSetGroup(int32_t groupId);
* @param [in] groupid count
* @return RT_ERROR_NONE for ok, errno for failed
*/
RTS_API rtError_t rtGetGroupInfo(int32_t groupId, rtGroupInfo_t *groupInfo, uint32_t count);
RTS_API rtError_t rtGetGroupInfo(int32_t groupId, rtGroupInfo_t *groupInfo, uint32_t cnt);

/**
* @ingroup


+ 3
- 3
third_party/fwkacllib/inc/runtime/dev.h View File

@@ -94,11 +94,11 @@ typedef enum tagGetDevMsgType {
/**
* @ingroup dvrt_dev
* @brief get total device number.
* @param [in|out] count the device number
* @param [in|out] cnt the device number
* @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
*/
RTS_API rtError_t rtGetDeviceCount(int32_t *count);
RTS_API rtError_t rtGetDeviceCount(int32_t *cnt);
/**
* @ingroup dvrt_dev
* @brief get device ids
@@ -338,7 +338,7 @@ RTS_API rtError_t rtSetTSDevice(uint32_t tsId);
* @return RT_ERROR_NONE for ok
* @return RT_ERROR_DRV_ERR for can not get run mode
*/
RTS_API rtError_t rtGetRunMode(rtRunMode *mode);
RTS_API rtError_t rtGetRunMode(rtRunMode *runMode);

/**
* @ingroup dvrt_dev


+ 2
- 2
third_party/fwkacllib/inc/runtime/dvfsprofile.h View File

@@ -23,11 +23,11 @@ typedef enum dvfsProfileMode {
/**
* @ingroup dvrt_dvfsprofile
* @brief Set the performance mode of the device
* @param [in] mode dvfsProfileMode
* @param [in] profMode dvfsProfileMode
* @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
*/
RTS_API rtError_t rtSetDvfsProfile(DvfsProfileMode mode);
RTS_API rtError_t rtSetDvfsProfile(DvfsProfileMode profMode);

/**
* @ingroup dvrt_dvfsprofile


+ 4
- 4
third_party/fwkacllib/inc/runtime/kernel.h View File

@@ -519,13 +519,13 @@ RTS_API rtError_t rtConfigureCall(uint32_t numBlocks, rtSmDesc_t *smDesc, rtStre
/**
* @ingroup rt_kernel
* @brief setup argment for next rtLaunch in current thread
* @param [in] arg argment address for kernel function
* @param [in] args argment address for kernel function
* @param [in] size argment size
* @param [in] offset argment table offset
* @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
*/
RTS_API rtError_t rtSetupArgument(const void *arg, uint32_t size, uint32_t offset);
RTS_API rtError_t rtSetupArgument(const void *args, uint32_t size, uint32_t offset);

/**
* @ingroup rt_kernel
@@ -544,11 +544,11 @@ RTS_API rtError_t rtLaunch(const void *stubFunc);
* @param [in] ptr host memory
* @param [in] size host memory size
* @param [in] flag reserved. set to 0
* @param [out] arg returned arg. used for next kernel's arg.
* @param [out] args returned arg. used for next kernel's arg.
* @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
*/
RTS_API rtError_t rtKernelConfigTransArg(const void *ptr, uint64_t size, uint32_t flag, void **arg);
RTS_API rtError_t rtKernelConfigTransArg(const void *ptr, uint64_t size, uint32_t flag, void **args);

/**
* @ingroup rt_kernel


+ 16
- 16
third_party/fwkacllib/inc/runtime/rt_mem_queue.h View File

@@ -222,24 +222,24 @@ RTS_API rtError_t rtMemQueueInit(int32_t devId);

/**
* @ingroup rt_mem_queue
* @brief enqueu mbuf
* @brief enqueue memBuf
* @param [in] devId the logical device id
* @param [in] qid queue id
* @param [in] mbuf enqueue mbuf
* @param [in] memBuf enqueue memBuf
* @return RT_ERROR_NONE for ok
*/
RTS_API rtError_t rtMemQueueEnQueue(int32_t devId, uint32_t qid, void *mbuf);
RTS_API rtError_t rtMemQueueEnQueue(int32_t devId, uint32_t qid, void *memBuf);


/**
* @ingroup rt_mem_queue
* @brief enqueu mbuf
* @brief dequeue memBuf
* @param [in] devId the logical device id
* @param [in] qid queue id
* @param [out] mbuf dequeue mbuf
* @param [out] memBuf dequeue memBuf
* @return RT_ERROR_NONE for ok
*/
RTS_API rtError_t rtMemQueueDeQueue(int32_t devId, uint32_t qid, void **mbuf);
RTS_API rtError_t rtMemQueueDeQueue(int32_t devId, uint32_t qid, void **memBuf);

/**
* @ingroup rt_mem_queue
@@ -350,47 +350,47 @@ RTS_API rtError_t rtMbufInit(rtMemBuffCfg_t *cfg);
/**
* @ingroup rt_mem_queue
* @brief alloc buff
* @param [out] buff: buff addr alloced
* @param [out] memBuf: buff addr alloced
* @param [in] size: The amount of memory space requested
* @return RT_ERROR_NONE for ok
*/
RTS_API rtError_t rtMbufAlloc(rtMbufPtr_t *mbuf, uint64_t size);
RTS_API rtError_t rtMbufAlloc(rtMbufPtr_t *memBuf, uint64_t size);

/**
* @ingroup rt_mem_queue
* @brief free buff
* @param [in] buff: buff addr to be freed
* @param [in] memBuf: buff addr to be freed
* @return RT_ERROR_NONE for ok
*/
RTS_API rtError_t rtMbufFree(rtMbufPtr_t mbuf);
RTS_API rtError_t rtMbufFree(rtMbufPtr_t memBuf);

/**
* @ingroup rt_mem_queue
* @brief get Data addr of Mbuf
* @param [in] mbuf: Mbuf addr
* @param [in] memBuf: Mbuf addr
* @param [out] buf: Mbuf data addr
* @return RT_ERROR_NONE for ok
*/
RTS_API rtError_t rtMbufGetBuffAddr(rtMbufPtr_t mbuf, void **buf);
RTS_API rtError_t rtMbufGetBuffAddr(rtMbufPtr_t memBuf, void **buf);

/**
* @ingroup rt_mem_queue
* @brief get total Buffer size of Mbuf
* @param [in] mbuf: Mbuf addr
* @param [in] memBuf: Mbuf addr
* @param [out] totalSize: total buffer size of Mbuf
* @return RT_ERROR_NONE for ok
*/
RTS_API rtError_t rtMbufGetBuffSize(rtMbufPtr_t mbuf, uint64_t *totalSize);
RTS_API rtError_t rtMbufGetBuffSize(rtMbufPtr_t memBuf, uint64_t *totalSize);

/**
* @ingroup rt_mem_queue
* @brief Get the address and length of its user_data from the specified Mbuf
* @param [in] mbuf: Mbuf addr
* @param [in] memBuf: Mbuf addr
* @param [out] priv: address of its user_data
* @param [out] size: length of its user_data
* @return RT_ERROR_NONE for ok
*/
RTS_API rtError_t rtMbufGetPrivInfo (rtMbufPtr_t mbuf, void **priv, uint64_t *size);
RTS_API rtError_t rtMbufGetPrivInfo (rtMbufPtr_t memBuf, void **priv, uint64_t *size);

// mem group
typedef struct {


+ 1
- 0
third_party/fwkacllib/inc/runtime/rt_model.h View File

@@ -44,6 +44,7 @@ typedef enum tagModelTaskType {
RT_MODEL_TASK_PROFILER_TRACE_EX,
RT_MODEL_TASK_FFTS_TASK,
RT_MODEL_TASK_FFTS_PLUS_TASK,
RT_MODEL_TASK_DSA_TASK,
} rtModelTaskType_t;

typedef enum tagModelStreamType {


+ 31
- 0
third_party/fwkacllib/inc/runtime/rt_stars_define.h View File

@@ -32,6 +32,37 @@ typedef struct tagStarsSqeHeader {
uint16_t taskId;
} rtStarsSqeHeader_t;

typedef struct tagStarsDsaSqe {
// 0-7 bytes
rtStarsSqeHeader_t sqeHeader;
// 8-11 bytes
uint32_t start : 1;
uint32_t functionType : 3;
uint32_t dataType : 3;
uint32_t algoType : 3;
uint32_t paramVldBitmap : 5;
uint32_t paramAddrValBitmap : 7;
uint32_t reserved0 : 10;
// 12-15 bytes
uint16_t sqeIndex;
uint8_t kernelCredit;
uint8_t reserved1;
// 16-31 bytes
uint32_t dsaCfgResultAddrLow;
uint32_t dsaCfgResultAddrHigh;
uint32_t dsaCfgStateAddrLow;
uint32_t dsaCfgStateAddrHigh;
// 32-47 bytes
uint32_t dsaCfgParamAddrLow;
uint32_t dsaCfgParamAddrHigh;
uint32_t dsaCfgSeedLow;
uint32_t dsaCfgSeedHigh;
// 48-63 bytes
uint32_t dsaCfgNumberLow;
uint32_t dsaCfgNumberHigh;
uint32_t reserved2[2];
} rtStarsDsaSqe_t;

// ffts+ type
typedef enum tagFftsPlusType {
RT_FFTS_PLUS_TYPE_RES1 = 2, // Reserved


+ 21
- 16
third_party/fwkacllib/inc/toolchain/prof_acl_api.h View File

@@ -1,17 +1,8 @@
/**
* 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.
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved.
* Description: handle perf data
* Author: xp
* Create: 2019-10-13
*/

#ifndef MSPROFILER_API_PROF_ACL_API_H_
@@ -25,6 +16,7 @@
#define PROF_L2CACHE 0x00000010ULL
#define PROF_HCCL_TRACE 0x00000020ULL
#define PROF_TRAINING_TRACE 0x00000040ULL
#define PROF_MSPROFTX 0x00000080ULL

// system profilinig switch
#define PROF_CPU 0x00010000ULL
@@ -42,11 +34,13 @@
#define PROF_SCHEDULE_TRACE 0x0000010000000ULL
#define PROF_AIVECTORCORE_METRICS 0x0000020000000ULL
#define PROF_SUBTASK_TIME 0x0000040000000ULL

#define PROF_TASK_TRACE 0x0000005000062ULL
#define PROF_OP_DETAIL 0x0000080000000ULL

#define PROF_MODEL_LOAD 0x8000000000000000ULL

#define PROF_TASK_TRACE (PROF_MODEL_EXECUTE | PROF_RUNTIME_TRACE | PROF_TRAINING_TRACE | \
PROF_HCCL_TRACE | PROF_TASK_TIME)

// DataTypeConfig MASK
#define PROF_ACL_API_MASK 0x00000001ULL
#define PROF_TASK_TIME_MASK 0x00000002ULL
@@ -55,6 +49,7 @@
#define PROF_L2CACHE_MASK 0x00000010ULL
#define PROF_HCCL_TRACE_MASK 0x00000020ULL
#define PROF_TRAINING_TRACE_MASK 0x00000040ULL
#define PROF_MSPROFTX_MASK 0x00000080ULL

// system profilinig mask
#define PROF_CPU_MASK 0x00010000ULL
@@ -72,6 +67,7 @@
#define PROF_SCHEDULE_TRACE_MASK 0x0000010000000ULL
#define PROF_AIVECTORCORE_METRICS_MASK 0x0000020000000ULL
#define PROF_SUBTASK_TIME_MASK 0x0000040000000ULL
#define PROF_OP_DETAIL_MASK 0x0000080000000ULL

#define PROF_MODEL_LOAD_MASK 0x8000000000000000ULL

@@ -135,6 +131,15 @@ MSVP_PROF_API Status aclgrphProfGraphUnSubscribe(const uint32_t graphId);
* @retval 0 for failed
*/
MSVP_PROF_API size_t aclprofGetGraphId(const void *opInfo, size_t opInfoLen, uint32_t index);

/**
* @ingroup AscendCL
* @brief set stamp pay load
*
*
* @retval void
*/
MSVP_PROF_API int aclprofSetStampPayload(void *stamp, const int32_t type, void *value);
#ifdef __cplusplus
}
#endif


+ 7
- 15
third_party/fwkacllib/inc/toolchain/prof_callback.h View File

@@ -1,17 +1,8 @@
/**
* 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.
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved.
* Description: handle perf data
* Author: xp
* Create: 2019-10-13
*/

#ifndef MSPROFILER_PROF_CALLBACK_H_
@@ -76,7 +67,8 @@ enum MsprofReporterModuleId {
MSPROF_MODULE_HCCL, // HCCL
MSPROF_MODULE_ACL, // AclModule
MSPROF_MODULE_FRAMEWORK, // Framework
MSPROF_MODULE_RUNTIME // runtime
MSPROF_MODULE_RUNTIME, // runtime
MSPROF_MODULE_MSPROF // msprofTx
};

/**


Loading…
Cancel
Save