1be168c0dSopenharmony_ciFrom cff83709eb00161cfb61ad93346828bde2d9a2e8 Mon Sep 17 00:00:00 2001 2be168c0dSopenharmony_ciFrom: chengfeng27 <chengfeng27@huawei.com> 3be168c0dSopenharmony_ciDate: Fri, 29 Mar 2024 14:19:14 +0800 4be168c0dSopenharmony_ciSubject: [PATCH] add mindir ops third phase 5be168c0dSopenharmony_ci 6be168c0dSopenharmony_ci--- 7be168c0dSopenharmony_ci mindspore/lite/mindir/include/mindir.h | 134 +- 8be168c0dSopenharmony_ci mindspore/lite/mindir/include/mindir_types.h | 27 + 9be168c0dSopenharmony_ci mindspore/lite/mindir/src/mindir.cc | 1147 +++++++++++++++++- 10be168c0dSopenharmony_ci 3 files changed, 1303 insertions(+), 5 deletions(-) 11be168c0dSopenharmony_ci 12be168c0dSopenharmony_cidiff --git a/mindspore/lite/mindir/include/mindir.h b/mindspore/lite/mindir/include/mindir.h 13be168c0dSopenharmony_ciindex 4f633493..7eb3a744 100644 14be168c0dSopenharmony_ci--- a/mindspore/lite/mindir/include/mindir.h 15be168c0dSopenharmony_ci+++ b/mindspore/lite/mindir/include/mindir.h 16be168c0dSopenharmony_ci@@ -270,11 +270,13 @@ bool MindIR_PReLUFusion_GetChannelShared(ConstPrimitivePtr primitive); 17be168c0dSopenharmony_ci void MindIR_PReLUFusion_SetChannelShared(PrimitivePtr *primitive, bool channel_shared); 18be168c0dSopenharmony_ci 19be168c0dSopenharmony_ci // ********** QuantDTypeCast ********** 20be168c0dSopenharmony_ci-PrimitivePtr MindIR_QuantDTypeCast_CreatePrimitive(int64_t src_t, int64_t dst_t); 21be168c0dSopenharmony_ci+PrimitivePtr MindIR_QuantDTypeCast_CreatePrimitive(int64_t src_t, int64_t dst_t, int64_t axis); 22be168c0dSopenharmony_ci int64_t MindIR_QuantDTypeCast_GetSrcT(ConstPrimitivePtr primitive); 23be168c0dSopenharmony_ci void MindIR_QuantDTypeCast_SetSrcT(PrimitivePtr *primitive, int64_t src_t); 24be168c0dSopenharmony_ci int64_t MindIR_QuantDTypeCast_GetDstT(ConstPrimitivePtr primitive); 25be168c0dSopenharmony_ci void MindIR_QuantDTypeCast_SetDstT(PrimitivePtr *primitive, int64_t dst_t); 26be168c0dSopenharmony_ci+int64_t MindIR_QuantDTypeCast_GetAxis(ConstPrimitivePtr primitive); 27be168c0dSopenharmony_ci+void MindIR_QuantDTypeCast_SetAxis(PrimitivePtr *primitive, int64_t axis); 28be168c0dSopenharmony_ci 29be168c0dSopenharmony_ci // ********** ReduceFusion ********** 30be168c0dSopenharmony_ci PrimitivePtr MindIR_ReduceFusion_CreatePrimitive(bool keep_dims, ReduceMode mode, bool reduce_to_end, float coeff); 31be168c0dSopenharmony_ci@@ -534,6 +536,136 @@ void MindIR_Clip_SetMax(PrimitivePtr *primitive, float max); 32be168c0dSopenharmony_ci float MindIR_Clip_GetMin(ConstPrimitivePtr primitive); 33be168c0dSopenharmony_ci void MindIR_Clip_SetMin(PrimitivePtr *primitive, float min); 34be168c0dSopenharmony_ci 35be168c0dSopenharmony_ci+// ********** All ********** 36be168c0dSopenharmony_ci+PrimitivePtr MindIR_All_CreatePrimitive(int64_t keep_dims); 37be168c0dSopenharmony_ci+int64_t MindIR_All_GetKeepDims(ConstPrimitivePtr primitive); 38be168c0dSopenharmony_ci+void MindIR_All_SetKeepDims(PrimitivePtr *primitive, int64_t keep_dims); 39be168c0dSopenharmony_ci+ 40be168c0dSopenharmony_ci+// ********** Assert ********** 41be168c0dSopenharmony_ci+PrimitivePtr MindIR_Assert_CreatePrimitive(int64_t summarize); 42be168c0dSopenharmony_ci+int64_t MindIR_Assert_GetSummarize(ConstPrimitivePtr primitive); 43be168c0dSopenharmony_ci+void MindIR_Assert_SetSummarize(PrimitivePtr *primitive, int64_t summarize); 44be168c0dSopenharmony_ci+ 45be168c0dSopenharmony_ci+// ********** LogicalAnd ********** 46be168c0dSopenharmony_ci+PrimitivePtr MindIR_LogicalAnd_CreatePrimitive(); 47be168c0dSopenharmony_ci+ 48be168c0dSopenharmony_ci+// ********** LogicalNot ********** 49be168c0dSopenharmony_ci+PrimitivePtr MindIR_LogicalNot_CreatePrimitive(); 50be168c0dSopenharmony_ci+ 51be168c0dSopenharmony_ci+// ********** Cos ********** 52be168c0dSopenharmony_ci+PrimitivePtr MindIR_Cos_CreatePrimitive(); 53be168c0dSopenharmony_ci+ 54be168c0dSopenharmony_ci+// ********** Mod ********** 55be168c0dSopenharmony_ci+PrimitivePtr MindIR_Mod_CreatePrimitive(); 56be168c0dSopenharmony_ci+ 57be168c0dSopenharmony_ci+// ********** Neg ********** 58be168c0dSopenharmony_ci+PrimitivePtr MindIR_Neg_CreatePrimitive(); 59be168c0dSopenharmony_ci+ 60be168c0dSopenharmony_ci+// ********** Reciprocal ********** 61be168c0dSopenharmony_ci+PrimitivePtr MindIR_Reciprocal_CreatePrimitive(); 62be168c0dSopenharmony_ci+ 63be168c0dSopenharmony_ci+// ********** Sin ********** 64be168c0dSopenharmony_ci+PrimitivePtr MindIR_Sin_CreatePrimitive(); 65be168c0dSopenharmony_ci+ 66be168c0dSopenharmony_ci+// ********** Where ********** 67be168c0dSopenharmony_ci+PrimitivePtr MindIR_Where_CreatePrimitive(); 68be168c0dSopenharmony_ci+ 69be168c0dSopenharmony_ci+// ********** Log ********** 70be168c0dSopenharmony_ci+PrimitivePtr MindIR_Log_CreatePrimitive(); 71be168c0dSopenharmony_ci+ 72be168c0dSopenharmony_ci+// ********** LogicalOr ********** 73be168c0dSopenharmony_ci+PrimitivePtr MindIR_LogicalOr_CreatePrimitive(); 74be168c0dSopenharmony_ci+ 75be168c0dSopenharmony_ci+// ********** SparseToDense ********** 76be168c0dSopenharmony_ci+PrimitivePtr MindIR_SparseToDense_CreatePrimitive(); 77be168c0dSopenharmony_ci+ 78be168c0dSopenharmony_ci+// ********** Minimum ********** 79be168c0dSopenharmony_ci+PrimitivePtr MindIR_Minimum_CreatePrimitive(); 80be168c0dSopenharmony_ci+ 81be168c0dSopenharmony_ci+// ********** SpaceToDepth ********** 82be168c0dSopenharmony_ci+PrimitivePtr MindIR_SpaceToDepth_CreatePrimitive(int64_t block_size, Format format); 83be168c0dSopenharmony_ci+int64_t MindIR_SpaceToDepth_GetBlockSize(ConstPrimitivePtr primitive); 84be168c0dSopenharmony_ci+void MindIR_SpaceToDepth_SetBlockSize(PrimitivePtr *primitive, int64_t block_size); 85be168c0dSopenharmony_ci+Format MindIR_SpaceToDepth_GetFormat(ConstPrimitivePtr primitive); 86be168c0dSopenharmony_ci+void MindIR_SpaceToDepth_SetFormat(PrimitivePtr *primitive, Format format); 87be168c0dSopenharmony_ci+ 88be168c0dSopenharmony_ci+// ********** Round ********** 89be168c0dSopenharmony_ci+PrimitivePtr MindIR_Round_CreatePrimitive(); 90be168c0dSopenharmony_ci+ 91be168c0dSopenharmony_ci+// ********** Ceil ********** 92be168c0dSopenharmony_ci+PrimitivePtr MindIR_Ceil_CreatePrimitive(); 93be168c0dSopenharmony_ci+ 94be168c0dSopenharmony_ci+// ********** Floor ********** 95be168c0dSopenharmony_ci+PrimitivePtr MindIR_Floor_CreatePrimitive(); 96be168c0dSopenharmony_ci+ 97be168c0dSopenharmony_ci+// ********** L2NormalizeFusion ********** 98be168c0dSopenharmony_ci+PrimitivePtr MindIR_L2NormalizeFusion_CreatePrimitive(const std::vector<int64_t>& axis, float epsilon, ActivationType activation_type); 99be168c0dSopenharmony_ci+std::vector<int64_t> MindIR_L2NormalizeFusion_GetAxis(ConstPrimitivePtr primitive); 100be168c0dSopenharmony_ci+void MindIR_L2NormalizeFusion_SetAxis(PrimitivePtr *primitive, const std::vector<int64_t>& axis); 101be168c0dSopenharmony_ci+float MindIR_L2NormalizeFusion_GetEpsilon(ConstPrimitivePtr primitive); 102be168c0dSopenharmony_ci+void MindIR_L2NormalizeFusion_SetEpsilon(PrimitivePtr *primitive, float epsilon); 103be168c0dSopenharmony_ci+ActivationType MindIR_L2NormalizeFusion_GetActivationType(ConstPrimitivePtr primitive); 104be168c0dSopenharmony_ci+void MindIR_L2NormalizeFusion_SetActivationType(PrimitivePtr *primitive, ActivationType activation_type); 105be168c0dSopenharmony_ci+ 106be168c0dSopenharmony_ci+// ********** LRN ********** 107be168c0dSopenharmony_ci+PrimitivePtr MindIR_LRN_CreatePrimitive(int64_t depth_radius, float bias, float alpha, float beta, std::string norm_region); 108be168c0dSopenharmony_ci+int64_t MindIR_LRN_GetDepthRadius(ConstPrimitivePtr primitive); 109be168c0dSopenharmony_ci+void MindIR_LRN_SetDepthRadius(PrimitivePtr *primitive, int64_t depth_radius); 110be168c0dSopenharmony_ci+float MindIR_LRN_GetBias(ConstPrimitivePtr primitive); 111be168c0dSopenharmony_ci+void MindIR_LRN_SetBias(PrimitivePtr *primitive, float bias); 112be168c0dSopenharmony_ci+float MindIR_LRN_GetAlpha(ConstPrimitivePtr primitive); 113be168c0dSopenharmony_ci+void MindIR_LRN_SetAlpha(PrimitivePtr *primitive, float alpha); 114be168c0dSopenharmony_ci+float MindIR_LRN_GetBeta(ConstPrimitivePtr primitive); 115be168c0dSopenharmony_ci+void MindIR_LRN_SetBeta(PrimitivePtr *primitive, float beta); 116be168c0dSopenharmony_ci+std::string MindIR_LRN_GetNormRegion(ConstPrimitivePtr primitive); 117be168c0dSopenharmony_ci+void MindIR_LRN_SetNormRegion(PrimitivePtr *primitive, std::string norm_region); 118be168c0dSopenharmony_ci+ 119be168c0dSopenharmony_ci+// ********** LogSoftmax ********** 120be168c0dSopenharmony_ci+PrimitivePtr MindIR_LogSoftmax_CreatePrimitive(int64_t axis); 121be168c0dSopenharmony_ci+int64_t MindIR_LogSoftmax_GetAxis(ConstPrimitivePtr primitive); 122be168c0dSopenharmony_ci+void MindIR_LogSoftmax_SetAxis(PrimitivePtr *primitive, int64_t axis); 123be168c0dSopenharmony_ci+ 124be168c0dSopenharmony_ci+// ********** Crop ********** 125be168c0dSopenharmony_ci+PrimitivePtr MindIR_Crop_CreatePrimitive(int64_t axis, const std::vector<int64_t>& offsets); 126be168c0dSopenharmony_ci+int64_t MindIR_Crop_GetAxis(ConstPrimitivePtr primitive); 127be168c0dSopenharmony_ci+void MindIR_Crop_SetAxis(PrimitivePtr *primitive, int64_t axis); 128be168c0dSopenharmony_ci+std::vector<int64_t> MindIR_Crop_GetOffsets(ConstPrimitivePtr primitive); 129be168c0dSopenharmony_ci+void MindIR_Crop_SetOffsets(PrimitivePtr *primitive, const std::vector<int64_t>& offsets); 130be168c0dSopenharmony_ci+ 131be168c0dSopenharmony_ci+// ********** DetectionPostProcess ********** 132be168c0dSopenharmony_ci+PrimitivePtr MindIR_DetectionPostProcess_CreatePrimitive(Format format, int64_t input_size, const std::vector<float>& scale, float nms_iou_threshold, float nms_score_threshold, int64_t max_detections, int64_t detections_per_class, int64_t max_classes_per_detection, int64_t num_classes, bool use_regular_nms, bool out_quantized); 133be168c0dSopenharmony_ci+Format MindIR_DetectionPostProcess_GetFormat(ConstPrimitivePtr primitive); 134be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetFormat(PrimitivePtr *primitive, Format format); 135be168c0dSopenharmony_ci+int64_t MindIR_DetectionPostProcess_GetInputSize(ConstPrimitivePtr primitive); 136be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetInputSize(PrimitivePtr *primitive, int64_t input_size); 137be168c0dSopenharmony_ci+std::vector<float> MindIR_DetectionPostProcess_GetScale(ConstPrimitivePtr primitive); 138be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetScale(PrimitivePtr *primitive, const std::vector<float>& scale); 139be168c0dSopenharmony_ci+float MindIR_DetectionPostProcess_GetNmsIouThreshold(ConstPrimitivePtr primitive); 140be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetNmsIouThreshold(PrimitivePtr *primitive, float nms_iou_threshold); 141be168c0dSopenharmony_ci+float MindIR_DetectionPostProcess_GetNmsScoreThreshold(ConstPrimitivePtr primitive); 142be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetNmsScoreThreshold(PrimitivePtr *primitive, float nms_score_threshold); 143be168c0dSopenharmony_ci+int64_t MindIR_DetectionPostProcess_GetMaxDetections(ConstPrimitivePtr primitive); 144be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetMaxDetections(PrimitivePtr *primitive, int64_t max_detections); 145be168c0dSopenharmony_ci+int64_t MindIR_DetectionPostProcess_GetDetectionsPerClass(ConstPrimitivePtr primitive); 146be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetDetectionsPerClass(PrimitivePtr *primitive, int64_t detections_per_class); 147be168c0dSopenharmony_ci+int64_t MindIR_DetectionPostProcess_GetMaxClassesPerDetection(ConstPrimitivePtr primitive); 148be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetMaxClassesPerDetection(PrimitivePtr *primitive, int64_t max_classes_per_detection); 149be168c0dSopenharmony_ci+int64_t MindIR_DetectionPostProcess_GetNumClasses(ConstPrimitivePtr primitive); 150be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetNumClasses(PrimitivePtr *primitive, int64_t num_classes); 151be168c0dSopenharmony_ci+bool MindIR_DetectionPostProcess_GetUseRegularNms(ConstPrimitivePtr primitive); 152be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetUseRegularNms(PrimitivePtr *primitive, bool use_regular_nms); 153be168c0dSopenharmony_ci+bool MindIR_DetectionPostProcess_GetOutQuantized(ConstPrimitivePtr primitive); 154be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetOutQuantized(PrimitivePtr *primitive, bool out_quantized); 155be168c0dSopenharmony_ci+ 156be168c0dSopenharmony_ci+// ********** ScatterNd ********** 157be168c0dSopenharmony_ci+PrimitivePtr MindIR_ScatterNd_CreatePrimitive(); 158be168c0dSopenharmony_ci+ 159be168c0dSopenharmony_ci+// ********** Rank ********** 160be168c0dSopenharmony_ci+PrimitivePtr MindIR_Rank_CreatePrimitive(); 161be168c0dSopenharmony_ci+ 162be168c0dSopenharmony_ci+// ********** GatherNd ********** 163be168c0dSopenharmony_ci+PrimitivePtr MindIR_GatherNd_CreatePrimitive(); 164be168c0dSopenharmony_ci+ 165be168c0dSopenharmony_ci // ********** Custom ********** 166be168c0dSopenharmony_ci std::vector<const mindspore::schema::Attribute *> MindIR_Custom_GetAttr(ConstPrimitivePtr primitive); 167be168c0dSopenharmony_ci std::string MindIR_Attribute_GetName(const mindspore::schema::Attribute &attr); 168be168c0dSopenharmony_cidiff --git a/mindspore/lite/mindir/include/mindir_types.h b/mindspore/lite/mindir/include/mindir_types.h 169be168c0dSopenharmony_ciindex 3ee6aca1..5744441a 100644 170be168c0dSopenharmony_ci--- a/mindspore/lite/mindir/include/mindir_types.h 171be168c0dSopenharmony_ci+++ b/mindspore/lite/mindir/include/mindir_types.h 172be168c0dSopenharmony_ci@@ -56,28 +56,36 @@ enum NodeType : uint32_t { 173be168c0dSopenharmony_ci NODE_TYPE_ABS = 1, 174be168c0dSopenharmony_ci NODE_TYPE_ACTIVATION = 2, 175be168c0dSopenharmony_ci NODE_TYPE_ADD_FUSION = 5, 176be168c0dSopenharmony_ci+ NODE_TYPE_ALL = 9, 177be168c0dSopenharmony_ci NODE_TYPE_ARGMAX_FUSION = 11, 178be168c0dSopenharmony_ci+ NODE_TYPE_ASSERT = 13, 179be168c0dSopenharmony_ci NODE_TYPE_AVG_POOL_FUSION = 17, 180be168c0dSopenharmony_ci NODE_TYPE_BATCH_TO_SPACE_ND = 22, 181be168c0dSopenharmony_ci NODE_TYPE_BIAS_ADD = 23, 182be168c0dSopenharmony_ci NODE_TYPE_BROADCAST_TO = 27, 183be168c0dSopenharmony_ci NODE_TYPE_CAST = 28, 184be168c0dSopenharmony_ci+ NODE_TYPE_CEIL = 29, 185be168c0dSopenharmony_ci NODE_TYPE_CLIP = 30, 186be168c0dSopenharmony_ci NODE_TYPE_CONCAT = 31, 187be168c0dSopenharmony_ci NODE_TYPE_CONV2D_FUSION = 35, 188be168c0dSopenharmony_ci NODE_TYPE_CONV2D_TRANSPOSE_FUSION = 36, 189be168c0dSopenharmony_ci+ NODE_TYPE_COS = 37, 190be168c0dSopenharmony_ci NODE_TYPE_CONSTANT_OF_SHAPE = 38, 191be168c0dSopenharmony_ci+ NODE_TYPE_CROP = 39, 192be168c0dSopenharmony_ci NODE_TYPE_DEPTH_TO_SPACE = 45, 193be168c0dSopenharmony_ci+ NODE_TYPE_DETECTION_POST_PROCESS = 46, 194be168c0dSopenharmony_ci NODE_TYPE_DIV_FUSION = 47, 195be168c0dSopenharmony_ci NODE_TYPE_ELTWISE = 52, 196be168c0dSopenharmony_ci NODE_TYPE_EQUAL = 53, 197be168c0dSopenharmony_ci NODE_TYPE_EXPFUSION = 55, 198be168c0dSopenharmony_ci NODE_TYPE_EXPAND_DIMS = 56, 199be168c0dSopenharmony_ci NODE_TYPE_FLATTEN = 61, 200be168c0dSopenharmony_ci+ NODE_TYPE_FLOOR = 63, 201be168c0dSopenharmony_ci NODE_TYPE_FILL = 66, 202be168c0dSopenharmony_ci NODE_TYPE_FULL_CONNECTION = 67, 203be168c0dSopenharmony_ci NODE_TYPE_FUSED_BATCH_NORM = 68, 204be168c0dSopenharmony_ci NODE_TYPE_GATHER = 69, 205be168c0dSopenharmony_ci+ NODE_TYPE_GATHER_ND = 70, 206be168c0dSopenharmony_ci NODE_TYPE_GREATER = 71, 207be168c0dSopenharmony_ci NODE_TYPE_GREATER_EQUAL = 72, 208be168c0dSopenharmony_ci NODE_TYPE_INSTANCE_NORM = 74, 209be168c0dSopenharmony_ci@@ -85,28 +93,44 @@ enum NodeType : uint32_t { 210be168c0dSopenharmony_ci NODE_TYPE_LEAKY_RELU = 76, 211be168c0dSopenharmony_ci NODE_TYPE_LESS = 77, 212be168c0dSopenharmony_ci NODE_TYPE_LESS_EQUAL = 78, 213be168c0dSopenharmony_ci+ NODE_TYPE_LOG = 79, 214be168c0dSopenharmony_ci+ NODE_TYPE_LOGICAL_AND = 81, 215be168c0dSopenharmony_ci+ NODE_TYPE_LOGICAL_NOT = 82, 216be168c0dSopenharmony_ci+ NODE_TYPE_LOGICAL_OR = 83, 217be168c0dSopenharmony_ci+ NODE_TYPE_L_R_N = 85, 218be168c0dSopenharmony_ci NODE_TYPE_LSTM = 87, 219be168c0dSopenharmony_ci+ NODE_TYPE_L2_NORMALIZE_FUSION = 88, 220be168c0dSopenharmony_ci NODE_TYPE_MATMUL_FUSION = 89, 221be168c0dSopenharmony_ci NODE_TYPE_MAXIMUM = 90, 222be168c0dSopenharmony_ci NODE_TYPE_MAX_POOL_FUSION = 92, 223be168c0dSopenharmony_ci+ NODE_TYPE_MINIMUM = 96, 224be168c0dSopenharmony_ci+ NODE_TYPE_MOD = 98, 225be168c0dSopenharmony_ci NODE_TYPE_MUL_FUSION = 99, 226be168c0dSopenharmony_ci+ NODE_TYPE_NEG = 101, 227be168c0dSopenharmony_ci NODE_TYPE_NOT_EQUAL = 103, 228be168c0dSopenharmony_ci NODE_TYPE_ONE_HOT = 105, 229be168c0dSopenharmony_ci NODE_TYPE_PAD_FUSION = 107, 230be168c0dSopenharmony_ci NODE_TYPE_POW_FUSION = 110, 231be168c0dSopenharmony_ci NODE_TYPE_PRELU_FUSION = 112, 232be168c0dSopenharmony_ci NODE_TYPE_QUANT_DTYPE_CAST = 113, 233be168c0dSopenharmony_ci+ NODE_TYPE_RANK = 114, 234be168c0dSopenharmony_ci NODE_TYPE_RANGE = 115, 235be168c0dSopenharmony_ci+ NODE_TYPE_RECIPROCAL = 116, 236be168c0dSopenharmony_ci NODE_TYPE_REAL_DIV = 117, 237be168c0dSopenharmony_ci NODE_TYPE_REDUCE_FUSION = 118, 238be168c0dSopenharmony_ci NODE_TYPE_RESHAPE = 119, 239be168c0dSopenharmony_ci NODE_TYPE_RESIZE = 120, 240be168c0dSopenharmony_ci+ NODE_TYPE_ROUND = 125, 241be168c0dSopenharmony_ci NODE_TYPE_RSQRT = 126, 242be168c0dSopenharmony_ci NODE_TYPE_SCALE_FUSION = 127, 243be168c0dSopenharmony_ci+ NODE_TYPE_SCATTER_ND = 128, 244be168c0dSopenharmony_ci NODE_TYPE_SHAPE = 130, 245be168c0dSopenharmony_ci+ NODE_TYPE_SIN = 133, 246be168c0dSopenharmony_ci NODE_TYPE_SLICE_FUSION = 135, 247be168c0dSopenharmony_ci NODE_TYPE_SOFTMAX = 138, 248be168c0dSopenharmony_ci NODE_TYPE_SPACE_TO_BATCH_ND = 141, 249be168c0dSopenharmony_ci+ NODE_TYPE_SPACE_TO_DEPTH = 142, 250be168c0dSopenharmony_ci+ NODE_TYPE_SPARSE_TO_DENSE = 144, 251be168c0dSopenharmony_ci NODE_TYPE_SPLIT = 145, 252be168c0dSopenharmony_ci NODE_TYPE_SQRT = 146, 253be168c0dSopenharmony_ci NODE_TYPE_SQUEEZE = 147, 254be168c0dSopenharmony_ci@@ -120,8 +144,10 @@ enum NodeType : uint32_t { 255be168c0dSopenharmony_ci NODE_TYPE_TRANSPOSE = 162, 256be168c0dSopenharmony_ci NODE_TYPE_UNSQUEEZE = 165, 257be168c0dSopenharmony_ci NODE_TYPE_UNSTACK = 166, 258be168c0dSopenharmony_ci+ NODE_TYPE_WHERE = 168, 259be168c0dSopenharmony_ci NODE_TYPE_SELECT = 170, 260be168c0dSopenharmony_ci NODE_TYPE_ERF = 178, 261be168c0dSopenharmony_ci+ NODE_TYPE_LOG_SOFTMAX = 189, 262be168c0dSopenharmony_ci NODE_TYPE_CUSTOM = 191, 263be168c0dSopenharmony_ci }; 264be168c0dSopenharmony_ci 265be168c0dSopenharmony_ci@@ -179,6 +205,7 @@ enum ReduceMode : int8_t { 266be168c0dSopenharmony_ci REDUCE_MODE_SUM_SQUARE = 5, 267be168c0dSopenharmony_ci REDUCE_MODE_ASUM = 6, 268be168c0dSopenharmony_ci REDUCE_MODE_ALL = 7, 269be168c0dSopenharmony_ci+ REDUCE_MODE_L2 = 8, 270be168c0dSopenharmony_ci }; 271be168c0dSopenharmony_ci 272be168c0dSopenharmony_ci enum PoolMode : int8_t { 273be168c0dSopenharmony_cidiff --git a/mindspore/lite/mindir/src/mindir.cc b/mindspore/lite/mindir/src/mindir.cc 274be168c0dSopenharmony_ciindex 36056c59..7041498a 100644 275be168c0dSopenharmony_ci--- a/mindspore/lite/mindir/src/mindir.cc 276be168c0dSopenharmony_ci+++ b/mindspore/lite/mindir/src/mindir.cc 277be168c0dSopenharmony_ci@@ -2896,9 +2896,9 @@ void MindIR_PReLUFusion_SetChannelShared(PrimitivePtr *primitive, bool channel_s 278be168c0dSopenharmony_ci } 279be168c0dSopenharmony_ci 280be168c0dSopenharmony_ci // ********** QuantDTypeCast ********** 281be168c0dSopenharmony_ci-PrimitivePtr MindIR_QuantDTypeCast_CreatePrimitive(int64_t src_t, int64_t dst_t) { 282be168c0dSopenharmony_ci+PrimitivePtr MindIR_QuantDTypeCast_CreatePrimitive(int64_t src_t, int64_t dst_t, int64_t axis) { 283be168c0dSopenharmony_ci flatbuffers::FlatBufferBuilder fbb; 284be168c0dSopenharmony_ci- auto ops_offset = schema::CreateQuantDTypeCast(fbb, src_t, dst_t); 285be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateQuantDTypeCast(fbb, src_t, dst_t, axis); 286be168c0dSopenharmony_ci auto prim_offset = 287be168c0dSopenharmony_ci schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_QUANT_DTYPE_CAST), ops_offset.o); 288be168c0dSopenharmony_ci fbb.Finish(prim_offset); 289be168c0dSopenharmony_ci@@ -2926,7 +2926,7 @@ void MindIR_QuantDTypeCast_SetSrcT(PrimitivePtr *primitive, int64_t src_t) { 290be168c0dSopenharmony_ci auto value = prim->value_as_QuantDTypeCast(); 291be168c0dSopenharmony_ci if (prim != nullptr && value != nullptr) { 292be168c0dSopenharmony_ci flatbuffers::FlatBufferBuilder fbb; 293be168c0dSopenharmony_ci- auto ops_offset = schema::CreateQuantDTypeCast(fbb, src_t, value->dst_t()); 294be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateQuantDTypeCast(fbb, src_t, value->dst_t(), value->axis()); 295be168c0dSopenharmony_ci auto prim_offset = 296be168c0dSopenharmony_ci schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_QUANT_DTYPE_CAST), ops_offset.o); 297be168c0dSopenharmony_ci fbb.Finish(prim_offset); 298be168c0dSopenharmony_ci@@ -2956,7 +2956,38 @@ void MindIR_QuantDTypeCast_SetDstT(PrimitivePtr *primitive, int64_t dst_t) { 299be168c0dSopenharmony_ci auto value = prim->value_as_QuantDTypeCast(); 300be168c0dSopenharmony_ci if (prim != nullptr && value != nullptr) { 301be168c0dSopenharmony_ci flatbuffers::FlatBufferBuilder fbb; 302be168c0dSopenharmony_ci- auto ops_offset = schema::CreateQuantDTypeCast(fbb, value->src_t(), dst_t); 303be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateQuantDTypeCast(fbb, value->src_t(), dst_t, value->axis()); 304be168c0dSopenharmony_ci+ auto prim_offset = 305be168c0dSopenharmony_ci+ schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_QUANT_DTYPE_CAST), ops_offset.o); 306be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 307be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, prim); 308be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 309be168c0dSopenharmony_ci+ *primitive = ret_value; 310be168c0dSopenharmony_ci+ } 311be168c0dSopenharmony_ci+ } 312be168c0dSopenharmony_ci+} 313be168c0dSopenharmony_ci+ 314be168c0dSopenharmony_ci+int64_t MindIR_QuantDTypeCast_GetAxis(ConstPrimitivePtr primitive) { 315be168c0dSopenharmony_ci+ if (primitive != nullptr) { 316be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 317be168c0dSopenharmony_ci+ auto value = prim->value_as_QuantDTypeCast(); 318be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 319be168c0dSopenharmony_ci+ return value->axis(); 320be168c0dSopenharmony_ci+ } else { 321be168c0dSopenharmony_ci+ return 0; 322be168c0dSopenharmony_ci+ } 323be168c0dSopenharmony_ci+ } else { 324be168c0dSopenharmony_ci+ return 0; 325be168c0dSopenharmony_ci+ } 326be168c0dSopenharmony_ci+} 327be168c0dSopenharmony_ci+ 328be168c0dSopenharmony_ci+void MindIR_QuantDTypeCast_SetAxis(PrimitivePtr *primitive, int64_t axis) { 329be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 330be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 331be168c0dSopenharmony_ci+ auto value = prim->value_as_QuantDTypeCast(); 332be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 333be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 334be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateQuantDTypeCast(fbb, value->src_t(), value->dst_t(), axis); 335be168c0dSopenharmony_ci auto prim_offset = 336be168c0dSopenharmony_ci schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_QUANT_DTYPE_CAST), ops_offset.o); 337be168c0dSopenharmony_ci fbb.Finish(prim_offset); 338be168c0dSopenharmony_ci@@ -5518,6 +5549,1114 @@ void MindIR_Clip_SetMin(PrimitivePtr *primitive, float min) { 339be168c0dSopenharmony_ci } 340be168c0dSopenharmony_ci } 341be168c0dSopenharmony_ci 342be168c0dSopenharmony_ci+// ********** All ********** 343be168c0dSopenharmony_ci+PrimitivePtr MindIR_All_CreatePrimitive(int64_t keep_dims) { 344be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 345be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateAll(fbb, keep_dims); 346be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_ALL), ops_offset.o); 347be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 348be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 349be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 350be168c0dSopenharmony_ci+ return ret_value; 351be168c0dSopenharmony_ci+} 352be168c0dSopenharmony_ci+ 353be168c0dSopenharmony_ci+int64_t MindIR_All_GetKeepDims(ConstPrimitivePtr primitive) { 354be168c0dSopenharmony_ci+ if (primitive != nullptr) { 355be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 356be168c0dSopenharmony_ci+ auto value = prim->value_as_All(); 357be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 358be168c0dSopenharmony_ci+ return value->keep_dims(); 359be168c0dSopenharmony_ci+ } else { 360be168c0dSopenharmony_ci+ return 0; 361be168c0dSopenharmony_ci+ } 362be168c0dSopenharmony_ci+ } else { 363be168c0dSopenharmony_ci+ return 0; 364be168c0dSopenharmony_ci+ } 365be168c0dSopenharmony_ci+} 366be168c0dSopenharmony_ci+ 367be168c0dSopenharmony_ci+void MindIR_All_SetKeepDims(PrimitivePtr *primitive, int64_t keep_dims) { 368be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 369be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 370be168c0dSopenharmony_ci+ auto value = prim->value_as_All(); 371be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 372be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 373be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateAll(fbb, keep_dims); 374be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_ALL), ops_offset.o); 375be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 376be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, prim); 377be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 378be168c0dSopenharmony_ci+ *primitive = ret_value; 379be168c0dSopenharmony_ci+ } 380be168c0dSopenharmony_ci+ } 381be168c0dSopenharmony_ci+} 382be168c0dSopenharmony_ci+ 383be168c0dSopenharmony_ci+// ********** Assert ********** 384be168c0dSopenharmony_ci+PrimitivePtr MindIR_Assert_CreatePrimitive(int64_t summarize) { 385be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 386be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateAssert(fbb, summarize); 387be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_ASSERT), ops_offset.o); 388be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 389be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 390be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 391be168c0dSopenharmony_ci+ return ret_value; 392be168c0dSopenharmony_ci+} 393be168c0dSopenharmony_ci+ 394be168c0dSopenharmony_ci+int64_t MindIR_Assert_GetSummarize(ConstPrimitivePtr primitive) { 395be168c0dSopenharmony_ci+ if (primitive != nullptr) { 396be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 397be168c0dSopenharmony_ci+ auto value = prim->value_as_Assert(); 398be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 399be168c0dSopenharmony_ci+ return value->summarize(); 400be168c0dSopenharmony_ci+ } else { 401be168c0dSopenharmony_ci+ return 0; 402be168c0dSopenharmony_ci+ } 403be168c0dSopenharmony_ci+ } else { 404be168c0dSopenharmony_ci+ return 0; 405be168c0dSopenharmony_ci+ } 406be168c0dSopenharmony_ci+} 407be168c0dSopenharmony_ci+ 408be168c0dSopenharmony_ci+void MindIR_Assert_SetSummarize(PrimitivePtr *primitive, int64_t summarize) { 409be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 410be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 411be168c0dSopenharmony_ci+ auto value = prim->value_as_Assert(); 412be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 413be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 414be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateAssert(fbb, summarize); 415be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_ASSERT), ops_offset.o); 416be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 417be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, prim); 418be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 419be168c0dSopenharmony_ci+ *primitive = ret_value; 420be168c0dSopenharmony_ci+ } 421be168c0dSopenharmony_ci+ } 422be168c0dSopenharmony_ci+} 423be168c0dSopenharmony_ci+ 424be168c0dSopenharmony_ci+// ********** LogicalAnd ********** 425be168c0dSopenharmony_ci+PrimitivePtr MindIR_LogicalAnd_CreatePrimitive() { 426be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 427be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateLogicalAnd(fbb); 428be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_LOGICAL_AND), ops_offset.o); 429be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 430be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 431be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 432be168c0dSopenharmony_ci+ return ret_value; 433be168c0dSopenharmony_ci+} 434be168c0dSopenharmony_ci+ 435be168c0dSopenharmony_ci+// ********** LogicalNot ********** 436be168c0dSopenharmony_ci+PrimitivePtr MindIR_LogicalNot_CreatePrimitive() { 437be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 438be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateLogicalNot(fbb); 439be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_LOGICAL_NOT), ops_offset.o); 440be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 441be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 442be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 443be168c0dSopenharmony_ci+ return ret_value; 444be168c0dSopenharmony_ci+} 445be168c0dSopenharmony_ci+ 446be168c0dSopenharmony_ci+// ********** Cos ********** 447be168c0dSopenharmony_ci+PrimitivePtr MindIR_Cos_CreatePrimitive() { 448be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 449be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateCos(fbb); 450be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_COS), ops_offset.o); 451be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 452be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 453be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 454be168c0dSopenharmony_ci+ return ret_value; 455be168c0dSopenharmony_ci+} 456be168c0dSopenharmony_ci+ 457be168c0dSopenharmony_ci+// ********** Mod ********** 458be168c0dSopenharmony_ci+PrimitivePtr MindIR_Mod_CreatePrimitive() { 459be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 460be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateMod(fbb); 461be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_MOD), ops_offset.o); 462be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 463be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 464be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 465be168c0dSopenharmony_ci+ return ret_value; 466be168c0dSopenharmony_ci+} 467be168c0dSopenharmony_ci+ 468be168c0dSopenharmony_ci+// ********** Neg ********** 469be168c0dSopenharmony_ci+PrimitivePtr MindIR_Neg_CreatePrimitive() { 470be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 471be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateNeg(fbb); 472be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_NEG), ops_offset.o); 473be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 474be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 475be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 476be168c0dSopenharmony_ci+ return ret_value; 477be168c0dSopenharmony_ci+} 478be168c0dSopenharmony_ci+ 479be168c0dSopenharmony_ci+// ********** Reciprocal ********** 480be168c0dSopenharmony_ci+PrimitivePtr MindIR_Reciprocal_CreatePrimitive() { 481be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 482be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateReciprocal(fbb); 483be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_RECIPROCAL), ops_offset.o); 484be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 485be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 486be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 487be168c0dSopenharmony_ci+ return ret_value; 488be168c0dSopenharmony_ci+} 489be168c0dSopenharmony_ci+ 490be168c0dSopenharmony_ci+// ********** Sin ********** 491be168c0dSopenharmony_ci+PrimitivePtr MindIR_Sin_CreatePrimitive() { 492be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 493be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateSin(fbb); 494be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_SIN), ops_offset.o); 495be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 496be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 497be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 498be168c0dSopenharmony_ci+ return ret_value; 499be168c0dSopenharmony_ci+} 500be168c0dSopenharmony_ci+ 501be168c0dSopenharmony_ci+// ********** Where ********** 502be168c0dSopenharmony_ci+PrimitivePtr MindIR_Where_CreatePrimitive() { 503be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 504be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateWhere(fbb); 505be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_WHERE), ops_offset.o); 506be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 507be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 508be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 509be168c0dSopenharmony_ci+ return ret_value; 510be168c0dSopenharmony_ci+} 511be168c0dSopenharmony_ci+ 512be168c0dSopenharmony_ci+// ********** Log ********** 513be168c0dSopenharmony_ci+PrimitivePtr MindIR_Log_CreatePrimitive() { 514be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 515be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateLog(fbb); 516be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_LOG), ops_offset.o); 517be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 518be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 519be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 520be168c0dSopenharmony_ci+ return ret_value; 521be168c0dSopenharmony_ci+} 522be168c0dSopenharmony_ci+ 523be168c0dSopenharmony_ci+// ********** LogicalOr ********** 524be168c0dSopenharmony_ci+PrimitivePtr MindIR_LogicalOr_CreatePrimitive() { 525be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 526be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateLogicalOr(fbb); 527be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_LOGICAL_OR), ops_offset.o); 528be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 529be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 530be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 531be168c0dSopenharmony_ci+ return ret_value; 532be168c0dSopenharmony_ci+} 533be168c0dSopenharmony_ci+ 534be168c0dSopenharmony_ci+// ********** SparseToDense ********** 535be168c0dSopenharmony_ci+PrimitivePtr MindIR_SparseToDense_CreatePrimitive() { 536be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 537be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateSparseToDense(fbb); 538be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_SPARSE_TO_DENSE), ops_offset.o); 539be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 540be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 541be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 542be168c0dSopenharmony_ci+ return ret_value; 543be168c0dSopenharmony_ci+} 544be168c0dSopenharmony_ci+ 545be168c0dSopenharmony_ci+// ********** Minimum ********** 546be168c0dSopenharmony_ci+PrimitivePtr MindIR_Minimum_CreatePrimitive() { 547be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 548be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateMinimum(fbb); 549be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_MINIMUM), ops_offset.o); 550be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 551be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 552be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 553be168c0dSopenharmony_ci+ return ret_value; 554be168c0dSopenharmony_ci+} 555be168c0dSopenharmony_ci+ 556be168c0dSopenharmony_ci+// ********** SpaceToDepth ********** 557be168c0dSopenharmony_ci+PrimitivePtr MindIR_SpaceToDepth_CreatePrimitive(int64_t block_size, Format format) { 558be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 559be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateSpaceToDepth(fbb, block_size, static_cast<schema::Format>(format)); 560be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_SPACE_TO_DEPTH), ops_offset.o); 561be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 562be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 563be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 564be168c0dSopenharmony_ci+ return ret_value; 565be168c0dSopenharmony_ci+} 566be168c0dSopenharmony_ci+ 567be168c0dSopenharmony_ci+int64_t MindIR_SpaceToDepth_GetBlockSize(ConstPrimitivePtr primitive) { 568be168c0dSopenharmony_ci+ if (primitive != nullptr) { 569be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 570be168c0dSopenharmony_ci+ auto value = prim->value_as_SpaceToDepth(); 571be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 572be168c0dSopenharmony_ci+ return value->block_size(); 573be168c0dSopenharmony_ci+ } else { 574be168c0dSopenharmony_ci+ return 0; 575be168c0dSopenharmony_ci+ } 576be168c0dSopenharmony_ci+ } else { 577be168c0dSopenharmony_ci+ return 0; 578be168c0dSopenharmony_ci+ } 579be168c0dSopenharmony_ci+} 580be168c0dSopenharmony_ci+ 581be168c0dSopenharmony_ci+void MindIR_SpaceToDepth_SetBlockSize(PrimitivePtr *primitive, int64_t block_size) { 582be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 583be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 584be168c0dSopenharmony_ci+ auto value = prim->value_as_SpaceToDepth(); 585be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 586be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 587be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateSpaceToDepth(fbb, block_size, static_cast<schema::Format>(value->format())); 588be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_SPACE_TO_DEPTH), ops_offset.o); 589be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 590be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 591be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 592be168c0dSopenharmony_ci+ free(*primitive); 593be168c0dSopenharmony_ci+ *primitive = ret_value; 594be168c0dSopenharmony_ci+ } 595be168c0dSopenharmony_ci+ } 596be168c0dSopenharmony_ci+} 597be168c0dSopenharmony_ci+ 598be168c0dSopenharmony_ci+Format MindIR_SpaceToDepth_GetFormat(ConstPrimitivePtr primitive) { 599be168c0dSopenharmony_ci+ if (primitive != nullptr) { 600be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 601be168c0dSopenharmony_ci+ auto value = prim->value_as_SpaceToDepth(); 602be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 603be168c0dSopenharmony_ci+ return static_cast<Format>(value->format()); 604be168c0dSopenharmony_ci+ } else { 605be168c0dSopenharmony_ci+ Format en = static_cast<Format>(0); 606be168c0dSopenharmony_ci+ return en; 607be168c0dSopenharmony_ci+ } 608be168c0dSopenharmony_ci+ } else { 609be168c0dSopenharmony_ci+ Format en = static_cast<Format>(0); 610be168c0dSopenharmony_ci+ return en; 611be168c0dSopenharmony_ci+ } 612be168c0dSopenharmony_ci+} 613be168c0dSopenharmony_ci+ 614be168c0dSopenharmony_ci+void MindIR_SpaceToDepth_SetFormat(PrimitivePtr *primitive, Format format) { 615be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 616be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 617be168c0dSopenharmony_ci+ auto value = prim->value_as_SpaceToDepth(); 618be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 619be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 620be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateSpaceToDepth(fbb, value->block_size(), static_cast<schema::Format>(format)); 621be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_SPACE_TO_DEPTH), ops_offset.o); 622be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 623be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 624be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 625be168c0dSopenharmony_ci+ free(*primitive); 626be168c0dSopenharmony_ci+ *primitive = ret_value; 627be168c0dSopenharmony_ci+ } 628be168c0dSopenharmony_ci+ } 629be168c0dSopenharmony_ci+} 630be168c0dSopenharmony_ci+ 631be168c0dSopenharmony_ci+// ********** Round ********** 632be168c0dSopenharmony_ci+PrimitivePtr MindIR_Round_CreatePrimitive() { 633be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 634be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateRound(fbb); 635be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_ROUND), ops_offset.o); 636be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 637be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 638be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 639be168c0dSopenharmony_ci+ return ret_value; 640be168c0dSopenharmony_ci+} 641be168c0dSopenharmony_ci+ 642be168c0dSopenharmony_ci+// ********** Ceil ********** 643be168c0dSopenharmony_ci+PrimitivePtr MindIR_Ceil_CreatePrimitive() { 644be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 645be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateCeil(fbb); 646be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_CEIL), ops_offset.o); 647be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 648be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 649be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 650be168c0dSopenharmony_ci+ return ret_value; 651be168c0dSopenharmony_ci+} 652be168c0dSopenharmony_ci+ 653be168c0dSopenharmony_ci+// ********** Floor ********** 654be168c0dSopenharmony_ci+PrimitivePtr MindIR_Floor_CreatePrimitive() { 655be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 656be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateFloor(fbb); 657be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_FLOOR), ops_offset.o); 658be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 659be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 660be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 661be168c0dSopenharmony_ci+ return ret_value; 662be168c0dSopenharmony_ci+} 663be168c0dSopenharmony_ci+ 664be168c0dSopenharmony_ci+// ********** L2NormalizeFusion ********** 665be168c0dSopenharmony_ci+PrimitivePtr MindIR_L2NormalizeFusion_CreatePrimitive(const std::vector<int64_t> &axis, float epsilon, ActivationType activation_type) { 666be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 667be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateL2NormalizeFusion(fbb, fbb.CreateVector(axis.data(), axis.size()), epsilon, static_cast<schema::ActivationType>(activation_type)); 668be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_L2_NORMALIZE_FUSION), ops_offset.o); 669be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 670be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 671be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 672be168c0dSopenharmony_ci+ return ret_value; 673be168c0dSopenharmony_ci+} 674be168c0dSopenharmony_ci+ 675be168c0dSopenharmony_ci+std::vector<int64_t> MindIR_L2NormalizeFusion_GetAxis(ConstPrimitivePtr primitive) { 676be168c0dSopenharmony_ci+ if (primitive != nullptr) { 677be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 678be168c0dSopenharmony_ci+ auto value = prim->value_as_L2NormalizeFusion(); 679be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 680be168c0dSopenharmony_ci+ std::vector<int64_t> result; 681be168c0dSopenharmony_ci+ auto src = value->axis(); 682be168c0dSopenharmony_ci+ result.resize(src->size()); 683be168c0dSopenharmony_ci+ std::transform(src->begin(), src->end(), result.begin(), [](int64_t item) { return item; }); 684be168c0dSopenharmony_ci+ return result; 685be168c0dSopenharmony_ci+ } else { 686be168c0dSopenharmony_ci+ return {}; 687be168c0dSopenharmony_ci+ } 688be168c0dSopenharmony_ci+ } else { 689be168c0dSopenharmony_ci+ return {}; 690be168c0dSopenharmony_ci+ } 691be168c0dSopenharmony_ci+} 692be168c0dSopenharmony_ci+ 693be168c0dSopenharmony_ci+void MindIR_L2NormalizeFusion_SetAxis(PrimitivePtr *primitive, const std::vector<int64_t> &axis) { 694be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 695be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 696be168c0dSopenharmony_ci+ auto value = prim->value_as_L2NormalizeFusion(); 697be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 698be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 699be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateL2NormalizeFusion(fbb, fbb.CreateVector(axis.data(), axis.size()), value->epsilon(), static_cast<schema::ActivationType>(value->activation_type())); 700be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_L2_NORMALIZE_FUSION), ops_offset.o); 701be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 702be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 703be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 704be168c0dSopenharmony_ci+ free(*primitive); 705be168c0dSopenharmony_ci+ *primitive = ret_value; 706be168c0dSopenharmony_ci+ } 707be168c0dSopenharmony_ci+ } 708be168c0dSopenharmony_ci+} 709be168c0dSopenharmony_ci+ 710be168c0dSopenharmony_ci+float MindIR_L2NormalizeFusion_GetEpsilon(ConstPrimitivePtr primitive) { 711be168c0dSopenharmony_ci+ if (primitive != nullptr) { 712be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 713be168c0dSopenharmony_ci+ auto value = prim->value_as_L2NormalizeFusion(); 714be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 715be168c0dSopenharmony_ci+ return value->epsilon(); 716be168c0dSopenharmony_ci+ } else { 717be168c0dSopenharmony_ci+ return .0; 718be168c0dSopenharmony_ci+ } 719be168c0dSopenharmony_ci+ } else { 720be168c0dSopenharmony_ci+ return .0; 721be168c0dSopenharmony_ci+ } 722be168c0dSopenharmony_ci+} 723be168c0dSopenharmony_ci+ 724be168c0dSopenharmony_ci+void MindIR_L2NormalizeFusion_SetEpsilon(PrimitivePtr *primitive, float epsilon) { 725be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 726be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 727be168c0dSopenharmony_ci+ auto value = prim->value_as_L2NormalizeFusion(); 728be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 729be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 730be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateL2NormalizeFusion(fbb, fbb.CreateVector(value->axis()->data(), value->axis()->size()), epsilon, static_cast<schema::ActivationType>(value->activation_type())); 731be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_L2_NORMALIZE_FUSION), ops_offset.o); 732be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 733be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 734be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 735be168c0dSopenharmony_ci+ free(*primitive); 736be168c0dSopenharmony_ci+ *primitive = ret_value; 737be168c0dSopenharmony_ci+ } 738be168c0dSopenharmony_ci+ } 739be168c0dSopenharmony_ci+} 740be168c0dSopenharmony_ci+ 741be168c0dSopenharmony_ci+ActivationType MindIR_L2NormalizeFusion_GetActivationType(ConstPrimitivePtr primitive) { 742be168c0dSopenharmony_ci+ if (primitive != nullptr) { 743be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 744be168c0dSopenharmony_ci+ auto value = prim->value_as_L2NormalizeFusion(); 745be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 746be168c0dSopenharmony_ci+ return static_cast<ActivationType>(value->activation_type()); 747be168c0dSopenharmony_ci+ } else { 748be168c0dSopenharmony_ci+ ActivationType en = static_cast<ActivationType>(0); 749be168c0dSopenharmony_ci+ return en; 750be168c0dSopenharmony_ci+ } 751be168c0dSopenharmony_ci+ } else { 752be168c0dSopenharmony_ci+ ActivationType en = static_cast<ActivationType>(0); 753be168c0dSopenharmony_ci+ return en; 754be168c0dSopenharmony_ci+ } 755be168c0dSopenharmony_ci+} 756be168c0dSopenharmony_ci+ 757be168c0dSopenharmony_ci+void MindIR_L2NormalizeFusion_SetActivationType(PrimitivePtr *primitive, ActivationType activation_type) { 758be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 759be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 760be168c0dSopenharmony_ci+ auto value = prim->value_as_L2NormalizeFusion(); 761be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 762be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 763be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateL2NormalizeFusion(fbb, fbb.CreateVector(value->axis()->data(), value->axis()->size()), value->epsilon(), static_cast<schema::ActivationType>(activation_type)); 764be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_L2_NORMALIZE_FUSION), ops_offset.o); 765be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 766be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 767be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 768be168c0dSopenharmony_ci+ free(*primitive); 769be168c0dSopenharmony_ci+ *primitive = ret_value; 770be168c0dSopenharmony_ci+ } 771be168c0dSopenharmony_ci+ } 772be168c0dSopenharmony_ci+} 773be168c0dSopenharmony_ci+ 774be168c0dSopenharmony_ci+// ********** LRN ********** 775be168c0dSopenharmony_ci+PrimitivePtr MindIR_LRN_CreatePrimitive(int64_t depth_radius, float bias, float alpha, float beta, std::string norm_region) { 776be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 777be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateLRN(fbb, depth_radius, bias, alpha, beta, fbb.CreateString(norm_region)); 778be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_L_R_N), ops_offset.o); 779be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 780be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 781be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 782be168c0dSopenharmony_ci+ return ret_value; 783be168c0dSopenharmony_ci+} 784be168c0dSopenharmony_ci+ 785be168c0dSopenharmony_ci+int64_t MindIR_LRN_GetDepthRadius(ConstPrimitivePtr primitive) { 786be168c0dSopenharmony_ci+ if (primitive != nullptr) { 787be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 788be168c0dSopenharmony_ci+ auto value = prim->value_as_LRN(); 789be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 790be168c0dSopenharmony_ci+ return value->depth_radius(); 791be168c0dSopenharmony_ci+ } else { 792be168c0dSopenharmony_ci+ return 0; 793be168c0dSopenharmony_ci+ } 794be168c0dSopenharmony_ci+ } else { 795be168c0dSopenharmony_ci+ return 0; 796be168c0dSopenharmony_ci+ } 797be168c0dSopenharmony_ci+} 798be168c0dSopenharmony_ci+ 799be168c0dSopenharmony_ci+void MindIR_LRN_SetDepthRadius(PrimitivePtr *primitive, int64_t depth_radius) { 800be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 801be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 802be168c0dSopenharmony_ci+ auto value = prim->value_as_LRN(); 803be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 804be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 805be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateLRN(fbb, depth_radius, value->bias(), value->alpha(), value->beta(), fbb.CreateString(std::string(value->norm_region()->c_str(), value->norm_region()->size()))); 806be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_L_R_N), ops_offset.o); 807be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 808be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 809be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 810be168c0dSopenharmony_ci+ free(*primitive); 811be168c0dSopenharmony_ci+ *primitive = ret_value; 812be168c0dSopenharmony_ci+ } 813be168c0dSopenharmony_ci+ } 814be168c0dSopenharmony_ci+} 815be168c0dSopenharmony_ci+ 816be168c0dSopenharmony_ci+float MindIR_LRN_GetBias(ConstPrimitivePtr primitive) { 817be168c0dSopenharmony_ci+ if (primitive != nullptr) { 818be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 819be168c0dSopenharmony_ci+ auto value = prim->value_as_LRN(); 820be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 821be168c0dSopenharmony_ci+ return value->bias(); 822be168c0dSopenharmony_ci+ } else { 823be168c0dSopenharmony_ci+ return .0; 824be168c0dSopenharmony_ci+ } 825be168c0dSopenharmony_ci+ } else { 826be168c0dSopenharmony_ci+ return .0; 827be168c0dSopenharmony_ci+ } 828be168c0dSopenharmony_ci+} 829be168c0dSopenharmony_ci+ 830be168c0dSopenharmony_ci+void MindIR_LRN_SetBias(PrimitivePtr *primitive, float bias) { 831be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 832be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 833be168c0dSopenharmony_ci+ auto value = prim->value_as_LRN(); 834be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 835be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 836be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateLRN(fbb, value->depth_radius(), bias, value->alpha(), value->beta(), fbb.CreateString(std::string(value->norm_region()->c_str(), value->norm_region()->size()))); 837be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_L_R_N), ops_offset.o); 838be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 839be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 840be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 841be168c0dSopenharmony_ci+ free(*primitive); 842be168c0dSopenharmony_ci+ *primitive = ret_value; 843be168c0dSopenharmony_ci+ } 844be168c0dSopenharmony_ci+ } 845be168c0dSopenharmony_ci+} 846be168c0dSopenharmony_ci+ 847be168c0dSopenharmony_ci+float MindIR_LRN_GetAlpha(ConstPrimitivePtr primitive) { 848be168c0dSopenharmony_ci+ if (primitive != nullptr) { 849be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 850be168c0dSopenharmony_ci+ auto value = prim->value_as_LRN(); 851be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 852be168c0dSopenharmony_ci+ return value->alpha(); 853be168c0dSopenharmony_ci+ } else { 854be168c0dSopenharmony_ci+ return .0; 855be168c0dSopenharmony_ci+ } 856be168c0dSopenharmony_ci+ } else { 857be168c0dSopenharmony_ci+ return .0; 858be168c0dSopenharmony_ci+ } 859be168c0dSopenharmony_ci+} 860be168c0dSopenharmony_ci+ 861be168c0dSopenharmony_ci+void MindIR_LRN_SetAlpha(PrimitivePtr *primitive, float alpha) { 862be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 863be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 864be168c0dSopenharmony_ci+ auto value = prim->value_as_LRN(); 865be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 866be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 867be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateLRN(fbb, value->depth_radius(), value->bias(), alpha, value->beta(), fbb.CreateString(std::string(value->norm_region()->c_str(), value->norm_region()->size()))); 868be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_L_R_N), ops_offset.o); 869be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 870be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 871be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 872be168c0dSopenharmony_ci+ free(*primitive); 873be168c0dSopenharmony_ci+ *primitive = ret_value; 874be168c0dSopenharmony_ci+ } 875be168c0dSopenharmony_ci+ } 876be168c0dSopenharmony_ci+} 877be168c0dSopenharmony_ci+ 878be168c0dSopenharmony_ci+float MindIR_LRN_GetBeta(ConstPrimitivePtr primitive) { 879be168c0dSopenharmony_ci+ if (primitive != nullptr) { 880be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 881be168c0dSopenharmony_ci+ auto value = prim->value_as_LRN(); 882be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 883be168c0dSopenharmony_ci+ return value->beta(); 884be168c0dSopenharmony_ci+ } else { 885be168c0dSopenharmony_ci+ return .0; 886be168c0dSopenharmony_ci+ } 887be168c0dSopenharmony_ci+ } else { 888be168c0dSopenharmony_ci+ return .0; 889be168c0dSopenharmony_ci+ } 890be168c0dSopenharmony_ci+} 891be168c0dSopenharmony_ci+ 892be168c0dSopenharmony_ci+void MindIR_LRN_SetBeta(PrimitivePtr *primitive, float beta) { 893be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 894be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 895be168c0dSopenharmony_ci+ auto value = prim->value_as_LRN(); 896be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 897be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 898be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateLRN(fbb, value->depth_radius(), value->bias(), value->alpha(), beta, fbb.CreateString(std::string(value->norm_region()->c_str(), value->norm_region()->size()))); 899be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_L_R_N), ops_offset.o); 900be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 901be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 902be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 903be168c0dSopenharmony_ci+ free(*primitive); 904be168c0dSopenharmony_ci+ *primitive = ret_value; 905be168c0dSopenharmony_ci+ } 906be168c0dSopenharmony_ci+ } 907be168c0dSopenharmony_ci+} 908be168c0dSopenharmony_ci+ 909be168c0dSopenharmony_ci+std::string MindIR_LRN_GetNormRegion(ConstPrimitivePtr primitive) { 910be168c0dSopenharmony_ci+ if (primitive != nullptr) { 911be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 912be168c0dSopenharmony_ci+ auto value = prim->value_as_LRN(); 913be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 914be168c0dSopenharmony_ci+ return std::string(value->norm_region()->c_str(),value->norm_region()->size()); 915be168c0dSopenharmony_ci+ } else { 916be168c0dSopenharmony_ci+ return nullptr; 917be168c0dSopenharmony_ci+ } 918be168c0dSopenharmony_ci+ } else { 919be168c0dSopenharmony_ci+ return nullptr; 920be168c0dSopenharmony_ci+ } 921be168c0dSopenharmony_ci+} 922be168c0dSopenharmony_ci+ 923be168c0dSopenharmony_ci+void MindIR_LRN_SetNormRegion(PrimitivePtr *primitive, std::string norm_region) { 924be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 925be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 926be168c0dSopenharmony_ci+ auto value = prim->value_as_LRN(); 927be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 928be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 929be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateLRN(fbb, value->depth_radius(), value->bias(), value->alpha(), value->beta(), fbb.CreateString(norm_region)); 930be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_L_R_N), ops_offset.o); 931be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 932be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 933be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 934be168c0dSopenharmony_ci+ free(*primitive); 935be168c0dSopenharmony_ci+ *primitive = ret_value; 936be168c0dSopenharmony_ci+ } 937be168c0dSopenharmony_ci+ } 938be168c0dSopenharmony_ci+} 939be168c0dSopenharmony_ci+ 940be168c0dSopenharmony_ci+// ********** LogSoftmax ********** 941be168c0dSopenharmony_ci+PrimitivePtr MindIR_LogSoftmax_CreatePrimitive(int64_t axis) { 942be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 943be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateLogSoftmax(fbb, axis); 944be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_LOG_SOFTMAX), ops_offset.o); 945be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 946be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 947be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 948be168c0dSopenharmony_ci+ return ret_value; 949be168c0dSopenharmony_ci+} 950be168c0dSopenharmony_ci+ 951be168c0dSopenharmony_ci+int64_t MindIR_LogSoftmax_GetAxis(ConstPrimitivePtr primitive) { 952be168c0dSopenharmony_ci+ if (primitive != nullptr) { 953be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 954be168c0dSopenharmony_ci+ auto value = prim->value_as_LogSoftmax(); 955be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 956be168c0dSopenharmony_ci+ return value->axis(); 957be168c0dSopenharmony_ci+ } else { 958be168c0dSopenharmony_ci+ return 0; 959be168c0dSopenharmony_ci+ } 960be168c0dSopenharmony_ci+ } else { 961be168c0dSopenharmony_ci+ return 0; 962be168c0dSopenharmony_ci+ } 963be168c0dSopenharmony_ci+} 964be168c0dSopenharmony_ci+ 965be168c0dSopenharmony_ci+void MindIR_LogSoftmax_SetAxis(PrimitivePtr *primitive, int64_t axis) { 966be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 967be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 968be168c0dSopenharmony_ci+ auto value = prim->value_as_LogSoftmax(); 969be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 970be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 971be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateLogSoftmax(fbb, axis); 972be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_LOG_SOFTMAX), ops_offset.o); 973be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 974be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 975be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 976be168c0dSopenharmony_ci+ free(*primitive); 977be168c0dSopenharmony_ci+ *primitive = ret_value; 978be168c0dSopenharmony_ci+ } 979be168c0dSopenharmony_ci+ } 980be168c0dSopenharmony_ci+} 981be168c0dSopenharmony_ci+ 982be168c0dSopenharmony_ci+// ********** Crop ********** 983be168c0dSopenharmony_ci+PrimitivePtr MindIR_Crop_CreatePrimitive(int64_t axis, const std::vector<int64_t> &offsets) { 984be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 985be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateCrop(fbb, axis, fbb.CreateVector(offsets.data(), offsets.size())); 986be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_CROP), ops_offset.o); 987be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 988be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 989be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 990be168c0dSopenharmony_ci+ return ret_value; 991be168c0dSopenharmony_ci+} 992be168c0dSopenharmony_ci+ 993be168c0dSopenharmony_ci+int64_t MindIR_Crop_GetAxis(ConstPrimitivePtr primitive) { 994be168c0dSopenharmony_ci+ if (primitive != nullptr) { 995be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 996be168c0dSopenharmony_ci+ auto value = prim->value_as_Crop(); 997be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 998be168c0dSopenharmony_ci+ return value->axis(); 999be168c0dSopenharmony_ci+ } else { 1000be168c0dSopenharmony_ci+ return 0; 1001be168c0dSopenharmony_ci+ } 1002be168c0dSopenharmony_ci+ } else { 1003be168c0dSopenharmony_ci+ return 0; 1004be168c0dSopenharmony_ci+ } 1005be168c0dSopenharmony_ci+} 1006be168c0dSopenharmony_ci+ 1007be168c0dSopenharmony_ci+void MindIR_Crop_SetAxis(PrimitivePtr *primitive, int64_t axis) { 1008be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 1009be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 1010be168c0dSopenharmony_ci+ auto value = prim->value_as_Crop(); 1011be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1012be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1013be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateCrop(fbb, axis, fbb.CreateVector(value->offsets()->data(), value->offsets()->size())); 1014be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_CROP), ops_offset.o); 1015be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1016be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1017be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1018be168c0dSopenharmony_ci+ free(*primitive); 1019be168c0dSopenharmony_ci+ *primitive = ret_value; 1020be168c0dSopenharmony_ci+ } 1021be168c0dSopenharmony_ci+ } 1022be168c0dSopenharmony_ci+} 1023be168c0dSopenharmony_ci+ 1024be168c0dSopenharmony_ci+std::vector<int64_t> MindIR_Crop_GetOffsets(ConstPrimitivePtr primitive) { 1025be168c0dSopenharmony_ci+ if (primitive != nullptr) { 1026be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 1027be168c0dSopenharmony_ci+ auto value = prim->value_as_Crop(); 1028be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1029be168c0dSopenharmony_ci+ std::vector<int64_t> result; 1030be168c0dSopenharmony_ci+ auto src = value->offsets(); 1031be168c0dSopenharmony_ci+ result.resize(src->size()); 1032be168c0dSopenharmony_ci+ std::transform(src->begin(), src->end(), result.begin(), [](int64_t item) { return item; }); 1033be168c0dSopenharmony_ci+ return result; 1034be168c0dSopenharmony_ci+ } else { 1035be168c0dSopenharmony_ci+ return {}; 1036be168c0dSopenharmony_ci+ } 1037be168c0dSopenharmony_ci+ } else { 1038be168c0dSopenharmony_ci+ return {}; 1039be168c0dSopenharmony_ci+ } 1040be168c0dSopenharmony_ci+} 1041be168c0dSopenharmony_ci+ 1042be168c0dSopenharmony_ci+void MindIR_Crop_SetOffsets(PrimitivePtr *primitive, const std::vector<int64_t> &offsets) { 1043be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 1044be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 1045be168c0dSopenharmony_ci+ auto value = prim->value_as_Crop(); 1046be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1047be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1048be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateCrop(fbb, value->axis(), fbb.CreateVector(offsets.data(), offsets.size())); 1049be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_CROP), ops_offset.o); 1050be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1051be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1052be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1053be168c0dSopenharmony_ci+ free(*primitive); 1054be168c0dSopenharmony_ci+ *primitive = ret_value; 1055be168c0dSopenharmony_ci+ } 1056be168c0dSopenharmony_ci+ } 1057be168c0dSopenharmony_ci+} 1058be168c0dSopenharmony_ci+ 1059be168c0dSopenharmony_ci+// ********** DetectionPostProcess ********** 1060be168c0dSopenharmony_ci+PrimitivePtr MindIR_DetectionPostProcess_CreatePrimitive(Format format, int64_t input_size, const std::vector<float> &scale, float nms_iou_threshold, float nms_score_threshold, int64_t max_detections, int64_t detections_per_class, int64_t max_classes_per_detection, int64_t num_classes, bool use_regular_nms, bool out_quantized) { 1061be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1062be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateDetectionPostProcess(fbb, static_cast<schema::Format>(format), input_size, fbb.CreateVector(scale.data(), scale.size()), nms_iou_threshold, nms_score_threshold, max_detections, detections_per_class, max_classes_per_detection, num_classes, use_regular_nms, out_quantized); 1063be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_DETECTION_POST_PROCESS), ops_offset.o); 1064be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1065be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1066be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1067be168c0dSopenharmony_ci+ return ret_value; 1068be168c0dSopenharmony_ci+} 1069be168c0dSopenharmony_ci+ 1070be168c0dSopenharmony_ci+Format MindIR_DetectionPostProcess_GetFormat(ConstPrimitivePtr primitive) { 1071be168c0dSopenharmony_ci+ if (primitive != nullptr) { 1072be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 1073be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1074be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1075be168c0dSopenharmony_ci+ return static_cast<Format>(value->format()); 1076be168c0dSopenharmony_ci+ } else { 1077be168c0dSopenharmony_ci+ Format en = static_cast<Format>(0); 1078be168c0dSopenharmony_ci+ return en; 1079be168c0dSopenharmony_ci+ } 1080be168c0dSopenharmony_ci+ } else { 1081be168c0dSopenharmony_ci+ Format en = static_cast<Format>(0); 1082be168c0dSopenharmony_ci+ return en; 1083be168c0dSopenharmony_ci+ } 1084be168c0dSopenharmony_ci+} 1085be168c0dSopenharmony_ci+ 1086be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetFormat(PrimitivePtr *primitive, Format format) { 1087be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 1088be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 1089be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1090be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1091be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1092be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateDetectionPostProcess(fbb, static_cast<schema::Format>(format), value->input_size(), fbb.CreateVector(value->scale()->data(), value->scale()->size()), value->nms_iou_threshold(), value->nms_score_threshold(), value->max_detections(), value->detections_per_class(), value->max_classes_per_detection(), value->num_classes(), value->use_regular_nms(), value->out_quantized()); 1093be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_DETECTION_POST_PROCESS), ops_offset.o); 1094be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1095be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1096be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1097be168c0dSopenharmony_ci+ free(*primitive); 1098be168c0dSopenharmony_ci+ *primitive = ret_value; 1099be168c0dSopenharmony_ci+ } 1100be168c0dSopenharmony_ci+ } 1101be168c0dSopenharmony_ci+} 1102be168c0dSopenharmony_ci+ 1103be168c0dSopenharmony_ci+int64_t MindIR_DetectionPostProcess_GetInputSize(ConstPrimitivePtr primitive) { 1104be168c0dSopenharmony_ci+ if (primitive != nullptr) { 1105be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 1106be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1107be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1108be168c0dSopenharmony_ci+ return value->input_size(); 1109be168c0dSopenharmony_ci+ } else { 1110be168c0dSopenharmony_ci+ return 0; 1111be168c0dSopenharmony_ci+ } 1112be168c0dSopenharmony_ci+ } else { 1113be168c0dSopenharmony_ci+ return 0; 1114be168c0dSopenharmony_ci+ } 1115be168c0dSopenharmony_ci+} 1116be168c0dSopenharmony_ci+ 1117be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetInputSize(PrimitivePtr *primitive, int64_t input_size) { 1118be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 1119be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 1120be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1121be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1122be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1123be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateDetectionPostProcess(fbb, static_cast<schema::Format>(value->format()), input_size, fbb.CreateVector(value->scale()->data(), value->scale()->size()), value->nms_iou_threshold(), value->nms_score_threshold(), value->max_detections(), value->detections_per_class(), value->max_classes_per_detection(), value->num_classes(), value->use_regular_nms(), value->out_quantized()); 1124be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_DETECTION_POST_PROCESS), ops_offset.o); 1125be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1126be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1127be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1128be168c0dSopenharmony_ci+ free(*primitive); 1129be168c0dSopenharmony_ci+ *primitive = ret_value; 1130be168c0dSopenharmony_ci+ } 1131be168c0dSopenharmony_ci+ } 1132be168c0dSopenharmony_ci+} 1133be168c0dSopenharmony_ci+ 1134be168c0dSopenharmony_ci+std::vector<float> MindIR_DetectionPostProcess_GetScale(ConstPrimitivePtr primitive) { 1135be168c0dSopenharmony_ci+ if (primitive != nullptr) { 1136be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 1137be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1138be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1139be168c0dSopenharmony_ci+ std::vector<float> result; 1140be168c0dSopenharmony_ci+ auto src = value->scale(); 1141be168c0dSopenharmony_ci+ result.resize(src->size()); 1142be168c0dSopenharmony_ci+ std::transform(src->begin(), src->end(), result.begin(), [](float item) { return item; }); 1143be168c0dSopenharmony_ci+ return result; 1144be168c0dSopenharmony_ci+ } else { 1145be168c0dSopenharmony_ci+ return {}; 1146be168c0dSopenharmony_ci+ } 1147be168c0dSopenharmony_ci+ } else { 1148be168c0dSopenharmony_ci+ return {}; 1149be168c0dSopenharmony_ci+ } 1150be168c0dSopenharmony_ci+} 1151be168c0dSopenharmony_ci+ 1152be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetScale(PrimitivePtr *primitive, const std::vector<float> &scale) { 1153be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 1154be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 1155be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1156be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1157be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1158be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateDetectionPostProcess(fbb, static_cast<schema::Format>(value->format()), value->input_size(), fbb.CreateVector(scale.data(), scale.size()), value->nms_iou_threshold(), value->nms_score_threshold(), value->max_detections(), value->detections_per_class(), value->max_classes_per_detection(), value->num_classes(), value->use_regular_nms(), value->out_quantized()); 1159be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_DETECTION_POST_PROCESS), ops_offset.o); 1160be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1161be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1162be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1163be168c0dSopenharmony_ci+ free(*primitive); 1164be168c0dSopenharmony_ci+ *primitive = ret_value; 1165be168c0dSopenharmony_ci+ } 1166be168c0dSopenharmony_ci+ } 1167be168c0dSopenharmony_ci+} 1168be168c0dSopenharmony_ci+ 1169be168c0dSopenharmony_ci+float MindIR_DetectionPostProcess_GetNmsIouThreshold(ConstPrimitivePtr primitive) { 1170be168c0dSopenharmony_ci+ if (primitive != nullptr) { 1171be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 1172be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1173be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1174be168c0dSopenharmony_ci+ return value->nms_iou_threshold(); 1175be168c0dSopenharmony_ci+ } else { 1176be168c0dSopenharmony_ci+ return .0; 1177be168c0dSopenharmony_ci+ } 1178be168c0dSopenharmony_ci+ } else { 1179be168c0dSopenharmony_ci+ return .0; 1180be168c0dSopenharmony_ci+ } 1181be168c0dSopenharmony_ci+} 1182be168c0dSopenharmony_ci+ 1183be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetNmsIouThreshold(PrimitivePtr *primitive, float nms_iou_threshold) { 1184be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 1185be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 1186be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1187be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1188be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1189be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateDetectionPostProcess(fbb, static_cast<schema::Format>(value->format()), value->input_size(), fbb.CreateVector(value->scale()->data(), value->scale()->size()), nms_iou_threshold, value->nms_score_threshold(), value->max_detections(), value->detections_per_class(), value->max_classes_per_detection(), value->num_classes(), value->use_regular_nms(), value->out_quantized()); 1190be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_DETECTION_POST_PROCESS), ops_offset.o); 1191be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1192be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1193be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1194be168c0dSopenharmony_ci+ free(*primitive); 1195be168c0dSopenharmony_ci+ *primitive = ret_value; 1196be168c0dSopenharmony_ci+ } 1197be168c0dSopenharmony_ci+ } 1198be168c0dSopenharmony_ci+} 1199be168c0dSopenharmony_ci+ 1200be168c0dSopenharmony_ci+float MindIR_DetectionPostProcess_GetNmsScoreThreshold(ConstPrimitivePtr primitive) { 1201be168c0dSopenharmony_ci+ if (primitive != nullptr) { 1202be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 1203be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1204be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1205be168c0dSopenharmony_ci+ return value->nms_score_threshold(); 1206be168c0dSopenharmony_ci+ } else { 1207be168c0dSopenharmony_ci+ return .0; 1208be168c0dSopenharmony_ci+ } 1209be168c0dSopenharmony_ci+ } else { 1210be168c0dSopenharmony_ci+ return .0; 1211be168c0dSopenharmony_ci+ } 1212be168c0dSopenharmony_ci+} 1213be168c0dSopenharmony_ci+ 1214be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetNmsScoreThreshold(PrimitivePtr *primitive, float nms_score_threshold) { 1215be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 1216be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 1217be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1218be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1219be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1220be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateDetectionPostProcess(fbb, static_cast<schema::Format>(value->format()), value->input_size(), fbb.CreateVector(value->scale()->data(), value->scale()->size()), value->nms_iou_threshold(), nms_score_threshold, value->max_detections(), value->detections_per_class(), value->max_classes_per_detection(), value->num_classes(), value->use_regular_nms(), value->out_quantized()); 1221be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_DETECTION_POST_PROCESS), ops_offset.o); 1222be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1223be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1224be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1225be168c0dSopenharmony_ci+ free(*primitive); 1226be168c0dSopenharmony_ci+ *primitive = ret_value; 1227be168c0dSopenharmony_ci+ } 1228be168c0dSopenharmony_ci+ } 1229be168c0dSopenharmony_ci+} 1230be168c0dSopenharmony_ci+ 1231be168c0dSopenharmony_ci+int64_t MindIR_DetectionPostProcess_GetMaxDetections(ConstPrimitivePtr primitive) { 1232be168c0dSopenharmony_ci+ if (primitive != nullptr) { 1233be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 1234be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1235be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1236be168c0dSopenharmony_ci+ return value->max_detections(); 1237be168c0dSopenharmony_ci+ } else { 1238be168c0dSopenharmony_ci+ return 0; 1239be168c0dSopenharmony_ci+ } 1240be168c0dSopenharmony_ci+ } else { 1241be168c0dSopenharmony_ci+ return 0; 1242be168c0dSopenharmony_ci+ } 1243be168c0dSopenharmony_ci+} 1244be168c0dSopenharmony_ci+ 1245be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetMaxDetections(PrimitivePtr *primitive, int64_t max_detections) { 1246be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 1247be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 1248be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1249be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1250be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1251be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateDetectionPostProcess(fbb, static_cast<schema::Format>(value->format()), value->input_size(), fbb.CreateVector(value->scale()->data(), value->scale()->size()), value->nms_iou_threshold(), value->nms_score_threshold(), max_detections, value->detections_per_class(), value->max_classes_per_detection(), value->num_classes(), value->use_regular_nms(), value->out_quantized()); 1252be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_DETECTION_POST_PROCESS), ops_offset.o); 1253be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1254be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1255be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1256be168c0dSopenharmony_ci+ free(*primitive); 1257be168c0dSopenharmony_ci+ *primitive = ret_value; 1258be168c0dSopenharmony_ci+ } 1259be168c0dSopenharmony_ci+ } 1260be168c0dSopenharmony_ci+} 1261be168c0dSopenharmony_ci+ 1262be168c0dSopenharmony_ci+int64_t MindIR_DetectionPostProcess_GetDetectionsPerClass(ConstPrimitivePtr primitive) { 1263be168c0dSopenharmony_ci+ if (primitive != nullptr) { 1264be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 1265be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1266be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1267be168c0dSopenharmony_ci+ return value->detections_per_class(); 1268be168c0dSopenharmony_ci+ } else { 1269be168c0dSopenharmony_ci+ return 0; 1270be168c0dSopenharmony_ci+ } 1271be168c0dSopenharmony_ci+ } else { 1272be168c0dSopenharmony_ci+ return 0; 1273be168c0dSopenharmony_ci+ } 1274be168c0dSopenharmony_ci+} 1275be168c0dSopenharmony_ci+ 1276be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetDetectionsPerClass(PrimitivePtr *primitive, int64_t detections_per_class) { 1277be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 1278be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 1279be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1280be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1281be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1282be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateDetectionPostProcess(fbb, static_cast<schema::Format>(value->format()), value->input_size(), fbb.CreateVector(value->scale()->data(), value->scale()->size()), value->nms_iou_threshold(), value->nms_score_threshold(), value->max_detections(), detections_per_class, value->max_classes_per_detection(), value->num_classes(), value->use_regular_nms(), value->out_quantized()); 1283be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_DETECTION_POST_PROCESS), ops_offset.o); 1284be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1285be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1286be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1287be168c0dSopenharmony_ci+ free(*primitive); 1288be168c0dSopenharmony_ci+ *primitive = ret_value; 1289be168c0dSopenharmony_ci+ } 1290be168c0dSopenharmony_ci+ } 1291be168c0dSopenharmony_ci+} 1292be168c0dSopenharmony_ci+ 1293be168c0dSopenharmony_ci+int64_t MindIR_DetectionPostProcess_GetMaxClassesPerDetection(ConstPrimitivePtr primitive) { 1294be168c0dSopenharmony_ci+ if (primitive != nullptr) { 1295be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 1296be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1297be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1298be168c0dSopenharmony_ci+ return value->max_classes_per_detection(); 1299be168c0dSopenharmony_ci+ } else { 1300be168c0dSopenharmony_ci+ return 0; 1301be168c0dSopenharmony_ci+ } 1302be168c0dSopenharmony_ci+ } else { 1303be168c0dSopenharmony_ci+ return 0; 1304be168c0dSopenharmony_ci+ } 1305be168c0dSopenharmony_ci+} 1306be168c0dSopenharmony_ci+ 1307be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetMaxClassesPerDetection(PrimitivePtr *primitive, int64_t max_classes_per_detection) { 1308be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 1309be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 1310be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1311be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1312be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1313be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateDetectionPostProcess(fbb, static_cast<schema::Format>(value->format()), value->input_size(), fbb.CreateVector(value->scale()->data(), value->scale()->size()), value->nms_iou_threshold(), value->nms_score_threshold(), value->max_detections(), value->detections_per_class(), max_classes_per_detection, value->num_classes(), value->use_regular_nms(), value->out_quantized()); 1314be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_DETECTION_POST_PROCESS), ops_offset.o); 1315be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1316be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1317be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1318be168c0dSopenharmony_ci+ free(*primitive); 1319be168c0dSopenharmony_ci+ *primitive = ret_value; 1320be168c0dSopenharmony_ci+ } 1321be168c0dSopenharmony_ci+ } 1322be168c0dSopenharmony_ci+} 1323be168c0dSopenharmony_ci+ 1324be168c0dSopenharmony_ci+int64_t MindIR_DetectionPostProcess_GetNumClasses(ConstPrimitivePtr primitive) { 1325be168c0dSopenharmony_ci+ if (primitive != nullptr) { 1326be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 1327be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1328be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1329be168c0dSopenharmony_ci+ return value->num_classes(); 1330be168c0dSopenharmony_ci+ } else { 1331be168c0dSopenharmony_ci+ return 0; 1332be168c0dSopenharmony_ci+ } 1333be168c0dSopenharmony_ci+ } else { 1334be168c0dSopenharmony_ci+ return 0; 1335be168c0dSopenharmony_ci+ } 1336be168c0dSopenharmony_ci+} 1337be168c0dSopenharmony_ci+ 1338be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetNumClasses(PrimitivePtr *primitive, int64_t num_classes) { 1339be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 1340be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 1341be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1342be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1343be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1344be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateDetectionPostProcess(fbb, static_cast<schema::Format>(value->format()), value->input_size(), fbb.CreateVector(value->scale()->data(), value->scale()->size()), value->nms_iou_threshold(), value->nms_score_threshold(), value->max_detections(), value->detections_per_class(), value->max_classes_per_detection(), num_classes, value->use_regular_nms(), value->out_quantized()); 1345be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_DETECTION_POST_PROCESS), ops_offset.o); 1346be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1347be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1348be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1349be168c0dSopenharmony_ci+ free(*primitive); 1350be168c0dSopenharmony_ci+ *primitive = ret_value; 1351be168c0dSopenharmony_ci+ } 1352be168c0dSopenharmony_ci+ } 1353be168c0dSopenharmony_ci+} 1354be168c0dSopenharmony_ci+ 1355be168c0dSopenharmony_ci+bool MindIR_DetectionPostProcess_GetUseRegularNms(ConstPrimitivePtr primitive) { 1356be168c0dSopenharmony_ci+ if (primitive != nullptr) { 1357be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 1358be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1359be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1360be168c0dSopenharmony_ci+ return value->use_regular_nms(); 1361be168c0dSopenharmony_ci+ } else { 1362be168c0dSopenharmony_ci+ return false; 1363be168c0dSopenharmony_ci+ } 1364be168c0dSopenharmony_ci+ } else { 1365be168c0dSopenharmony_ci+ return false; 1366be168c0dSopenharmony_ci+ } 1367be168c0dSopenharmony_ci+} 1368be168c0dSopenharmony_ci+ 1369be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetUseRegularNms(PrimitivePtr *primitive, bool use_regular_nms) { 1370be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 1371be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 1372be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1373be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1374be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1375be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateDetectionPostProcess(fbb, static_cast<schema::Format>(value->format()), value->input_size(), fbb.CreateVector(value->scale()->data(), value->scale()->size()), value->nms_iou_threshold(), value->nms_score_threshold(), value->max_detections(), value->detections_per_class(), value->max_classes_per_detection(), value->num_classes(), use_regular_nms, value->out_quantized()); 1376be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_DETECTION_POST_PROCESS), ops_offset.o); 1377be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1378be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1379be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1380be168c0dSopenharmony_ci+ free(*primitive); 1381be168c0dSopenharmony_ci+ *primitive = ret_value; 1382be168c0dSopenharmony_ci+ } 1383be168c0dSopenharmony_ci+ } 1384be168c0dSopenharmony_ci+} 1385be168c0dSopenharmony_ci+ 1386be168c0dSopenharmony_ci+bool MindIR_DetectionPostProcess_GetOutQuantized(ConstPrimitivePtr primitive) { 1387be168c0dSopenharmony_ci+ if (primitive != nullptr) { 1388be168c0dSopenharmony_ci+ auto prim = static_cast<const schema::Primitive *>(primitive); 1389be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1390be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1391be168c0dSopenharmony_ci+ return value->out_quantized(); 1392be168c0dSopenharmony_ci+ } else { 1393be168c0dSopenharmony_ci+ return false; 1394be168c0dSopenharmony_ci+ } 1395be168c0dSopenharmony_ci+ } else { 1396be168c0dSopenharmony_ci+ return false; 1397be168c0dSopenharmony_ci+ } 1398be168c0dSopenharmony_ci+} 1399be168c0dSopenharmony_ci+ 1400be168c0dSopenharmony_ci+void MindIR_DetectionPostProcess_SetOutQuantized(PrimitivePtr *primitive, bool out_quantized) { 1401be168c0dSopenharmony_ci+ if (primitive != nullptr && *primitive != nullptr) { 1402be168c0dSopenharmony_ci+ auto prim = static_cast<schema::Primitive *>(*primitive); 1403be168c0dSopenharmony_ci+ auto value = prim->value_as_DetectionPostProcess(); 1404be168c0dSopenharmony_ci+ if (prim != nullptr && value != nullptr) { 1405be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1406be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateDetectionPostProcess(fbb, static_cast<schema::Format>(value->format()), value->input_size(), fbb.CreateVector(value->scale()->data(), value->scale()->size()), value->nms_iou_threshold(), value->nms_score_threshold(), value->max_detections(), value->detections_per_class(), value->max_classes_per_detection(), value->num_classes(), value->use_regular_nms(), out_quantized); 1407be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_DETECTION_POST_PROCESS), ops_offset.o); 1408be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1409be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1410be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1411be168c0dSopenharmony_ci+ free(*primitive); 1412be168c0dSopenharmony_ci+ *primitive = ret_value; 1413be168c0dSopenharmony_ci+ } 1414be168c0dSopenharmony_ci+ } 1415be168c0dSopenharmony_ci+} 1416be168c0dSopenharmony_ci+ 1417be168c0dSopenharmony_ci+// ********** ScatterNd ********** 1418be168c0dSopenharmony_ci+PrimitivePtr MindIR_ScatterNd_CreatePrimitive() { 1419be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1420be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateScatterNd(fbb); 1421be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_SCATTER_ND), ops_offset.o); 1422be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1423be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1424be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1425be168c0dSopenharmony_ci+ return ret_value; 1426be168c0dSopenharmony_ci+} 1427be168c0dSopenharmony_ci+ 1428be168c0dSopenharmony_ci+// ********** Rank ********** 1429be168c0dSopenharmony_ci+PrimitivePtr MindIR_Rank_CreatePrimitive() { 1430be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1431be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateRank(fbb); 1432be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_RANK), ops_offset.o); 1433be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1434be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1435be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1436be168c0dSopenharmony_ci+ return ret_value; 1437be168c0dSopenharmony_ci+} 1438be168c0dSopenharmony_ci+ 1439be168c0dSopenharmony_ci+// ********** GatherNd ********** 1440be168c0dSopenharmony_ci+PrimitivePtr MindIR_GatherNd_CreatePrimitive() { 1441be168c0dSopenharmony_ci+ flatbuffers::FlatBufferBuilder fbb; 1442be168c0dSopenharmony_ci+ auto ops_offset = schema::CreateGatherNd(fbb); 1443be168c0dSopenharmony_ci+ auto prim_offset = schema::CreatePrimitive(fbb, static_cast<schema::PrimitiveType>(NODE_TYPE_GATHER_ND), ops_offset.o); 1444be168c0dSopenharmony_ci+ fbb.Finish(prim_offset); 1445be168c0dSopenharmony_ci+ auto new_addr = MindIRMemoryManager::GetInstance()->CreatePrimitiveFromBuilder(fbb, nullptr); 1446be168c0dSopenharmony_ci+ auto ret_value = flatbuffers::GetMutableRoot<schema::Primitive>(new_addr); 1447be168c0dSopenharmony_ci+ return ret_value; 1448be168c0dSopenharmony_ci+} 1449be168c0dSopenharmony_ci+ 1450be168c0dSopenharmony_ci // ********** Custom ********** 1451be168c0dSopenharmony_ci std::vector<const mindspore::schema::Attribute *> MindIR_Custom_GetAttr(ConstPrimitivePtr primitive) { 1452be168c0dSopenharmony_ci if (primitive == nullptr) { 1453be168c0dSopenharmony_ci-- 1454be168c0dSopenharmony_ci2.17.1 1455be168c0dSopenharmony_ci 1456