You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dnn_struct_base.hpp 19 kB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  1. /**
  2. * Copyright 2019-2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef DNN_STRUCT_BASE_HPP__
  17. #define DNN_STRUCT_BASE_HPP__
  18. #include "cce/cce_def.hpp"
  19. namespace cce {
  20. /**
  21. * @ingroup dnn
  22. * @brief max number of dimensions
  23. */
  24. #define CC_DIM_MAX (8)
  25. /**
  26. * @ingroup dnn
  27. * @brief max number of dimensions when use NC1HWC0 format
  28. */
  29. #define CC_REALDIM_MAX (4)
  30. /**
  31. * @ingroup dnn
  32. * @brief max input count of MscnnBoxOutput
  33. */
  34. #define CC_MAX_INPUT_CNT (10)
  35. /**
  36. * @ingroup dnn
  37. * @brief image dimensions of aipp input
  38. */
  39. #define CC_AIPP_IMG_DIM (2)
  40. /**
  41. * @ingroup dnn
  42. * @brief image channel number of aipp input
  43. */
  44. #define CC_AIPP_IMG_CHN_NUM (4)
  45. /**
  46. * @ingroup dnn
  47. * @brief element number of aipp color space convertion matrix
  48. */
  49. #define CC_AIPP_CSC_MATRIX_DIM (9)
  50. /**
  51. * @ingroup dnn
  52. * @brief element number of aipp color space convertion bias
  53. */
  54. #define CC_AIPP_CSC_BIAS_DIM (3)
  55. /**
  56. * @ingroup dnn
  57. * @brief parameter number of op exp/log/pow
  58. */
  59. #define PARAM_CNT_THREE (3)
  60. /**
  61. * @ingroup dnn
  62. * @brief parameter number of op nonmaxsuppression
  63. */
  64. #define PARAM_CNT_TWO (2)
  65. #define DIMCNT_NUMBER_ONE (1)
  66. #define DIMCNT_NUMBER_TWO (2)
  67. #define DIMCNT_NUMBER_FOUR (4)
  68. #define COMMON_FORMAT_NCHW_N_INDEX (0)
  69. #define COMMON_FORMAT_NCHW_C_INDEX (1)
  70. #define COMMON_FORMAT_NCHW_H_INDEX (2)
  71. #define COMMON_FORMAT_NCHW_W_INDEX (3)
  72. /**
  73. * @ingroup dnn
  74. * @brief parameter number of op upsample
  75. */
  76. #define UPSAMPLE_SCAL_DEFAULT_TWO (2)
  77. #define UPSAMPLE_ILLEGAL_VALUE_1 (1)
  78. /**
  79. * @ingroup dnn
  80. * @brief struct define of StridedSlice required params.
  81. */
  82. typedef struct tagCcStridedSlice {
  83. uint32_t dimCnt;
  84. int32_t begin[CC_DIM_MAX];
  85. int32_t end[CC_DIM_MAX];
  86. int32_t strides[CC_DIM_MAX];
  87. } ccStridedSlice_t;
  88. /**
  89. * @ingroup dnn
  90. * @brief struct define of Strided_slice attrs
  91. */
  92. typedef struct tagCcStridedSliceAttrs {
  93. uint32_t beginMask;
  94. uint32_t endMask;
  95. uint32_t ellipsisMask;
  96. uint32_t newAxisMask;
  97. uint32_t shrinkAxisMask;
  98. } ccStridedSliceAttrs_t;
  99. /**
  100. * @ingroup dnn
  101. * @brief params of batchToSpace
  102. */
  103. typedef struct tagCcBatchToSpace {
  104. int32_t blockShapeLength;
  105. int32_t blockShape[CC_DIM_MAX];
  106. int32_t crops[2 * CC_DIM_MAX];
  107. } ccBatchToSpace_t;
  108. /**
  109. * @ingroup dnn
  110. * @brief params of spaceToBatch
  111. */
  112. typedef struct tagCcSpaceToBatch {
  113. int32_t blockShapeLength;
  114. int32_t blockShape[CC_DIM_MAX];
  115. int32_t paddings[2 * CC_DIM_MAX];
  116. } ccSpaceToBatch_t;
  117. /**
  118. * @ingroup dnn
  119. * @brief struct define of tensor
  120. */
  121. typedef struct tagCcTensor {
  122. ccTensorFormat_t format;
  123. ccDataType_t dataType;
  124. int32_t dimCnt;
  125. int32_t realDimCnt;
  126. uint32_t dataSize;
  127. int32_t dim[CC_DIM_MAX];
  128. int32_t stride[CC_DIM_MAX];
  129. ccVecQuantizePara_t vecQuantizePara;
  130. } ccTensor_t;
  131. /**
  132. * @ingroup dnn
  133. * @brief struct define of filter tensor
  134. */
  135. typedef struct tagCcFilter {
  136. ccTensorFormat_t format;
  137. ccDataType_t dataType;
  138. int32_t dimCnt;
  139. uint32_t dataSize;
  140. int32_t dim[CC_DIM_MAX];
  141. } ccFilter_t;
  142. /**
  143. * @ingroup dnn
  144. * @brief struct define of convolution operator
  145. */
  146. typedef struct tagCcConvolution {
  147. ccConvolutionMode_t mode;
  148. ccPaddingMode_t padMode;
  149. int32_t dimCnt;
  150. int32_t padding[2 * (CC_DIM_MAX - 2)];
  151. int32_t filterStride[CC_DIM_MAX - 2];
  152. int32_t dilation[CC_DIM_MAX - 2];
  153. int32_t group;
  154. ccQuantizeDescriptor_t quantInfo;
  155. ccConvolutionAipp_t aippInfo;
  156. int32_t adj[CC_DIM_MAX - 2];
  157. int32_t targetShape[CC_DIM_MAX - 2];
  158. int32_t beforePadding[2 * (CC_DIM_MAX - 2)]; // pad before conv
  159. uint32_t reluFlag;
  160. int64_t concatBatchSize;
  161. } ccConvolution_t;
  162. #define ccCorrelation_t ccConvolution_t
  163. typedef struct tagCcFullConnection_t {
  164. ccQuantizeDescriptor_t quantInfo;
  165. uint32_t infoTabSize;
  166. const void *infoTab;
  167. bool reluFlag;
  168. ccFullConnectFwdAlgo_t algo;
  169. } ccFullConnection_t;
  170. typedef struct tagCcConcatFour2Five_t {
  171. uint32_t branchNum; // how many branch for box or class
  172. uint32_t classNum; // box branch's classNum is four, class branch's classNum is class number
  173. } ccConcatFour2Five_t;
  174. typedef struct tagCcTransdata_t {
  175. uint64_t scaleQAddr;
  176. uint8_t scaleQValueMode;
  177. uint64_t offsetQAddr;
  178. uint8_t quantAlgo;
  179. uint8_t quantize8bitFlag;
  180. } ccTransdata_t;
  181. /**
  182. * @ingroup dnn
  183. * @brief struct define of pooling operator
  184. */
  185. typedef struct tagCcPooling {
  186. ccPoolingMode_t mode;
  187. ccPaddingMode_t padMode;
  188. ccNanPropagation_t maxpoolingNanOpt;
  189. int32_t dimCnt;
  190. int32_t windowDim[CC_DIM_MAX - 2];
  191. int32_t padding[CC_DIM_MAX - 2];
  192. int32_t stride[CC_DIM_MAX - 2];
  193. int32_t dataMode;
  194. int32_t ceilMode;
  195. ccQuantizeDescriptor_t quantInfo;
  196. ccPooingFwdAlgo_t algo;
  197. } ccPooling_t;
  198. /**
  199. * @ingroup dnn
  200. * @brief struct define of activation operator
  201. */
  202. typedef struct tagCcActivation {
  203. ccActivationMode_t mode;
  204. ccNanPropagation_t reluNanOpt;
  205. double coef; /* ceiling for clipped RELU, alpha for ELU */
  206. ccActivationPara_u activationPara;
  207. } ccActivation_t;
  208. /**
  209. * @ingroup dnn
  210. * @brief struct define of svdf operator
  211. */
  212. typedef struct tagCcSvdf {
  213. ccTensorFormat_t format;
  214. ccDataType_t dataType;
  215. uint32_t batches;
  216. uint32_t features;
  217. uint32_t rank;
  218. uint32_t inputSize;
  219. uint32_t memorySize;
  220. } ccSvdf_t;
  221. /**
  222. * @ingroup dnn
  223. * @brief struct define of svdf operator
  224. */
  225. typedef struct tagCcHashTableLookup {
  226. ccTensorFormat_t format;
  227. ccDataType_t lookupType;
  228. ccDataType_t keyType;
  229. ccDataType_t valueType;
  230. ccDataType_t outputType;
  231. ccDataType_t hitsType;
  232. uint32_t lookups;
  233. uint32_t keys;
  234. uint32_t rows;
  235. uint32_t features;
  236. uint16_t valueScale;
  237. uint16_t outputScale;
  238. uint16_t valueOffset;
  239. uint16_t outputOffset;
  240. } ccHashTableLookup_t;
  241. /**
  242. * @ingroup dnn
  243. * @brief struct define of prelu operator
  244. */
  245. typedef struct tagCcPRelu {
  246. ccNanPropagation_t reluNanOpt;
  247. int32_t slopeCount;
  248. bool channelShared;
  249. } ccPRelu_t;
  250. /**
  251. * @ingroup dnn
  252. * @brief struct define of crop operator
  253. */
  254. typedef struct tagCcCrop {
  255. int32_t startAxis;
  256. int32_t offset[CC_DIM_MAX];
  257. int32_t offsetCnt;
  258. } ccCrop_t;
  259. /**
  260. * @ingroup dnn
  261. * @brief struct define of SpatialTransformer operator
  262. */
  263. typedef struct tagCcSpatialTransformer {
  264. ccSamplerType_t samplerType;
  265. ccDataType_t dataType;
  266. int32_t dimCnt;
  267. uint64_t dim[CC_DIM_MAX];
  268. uint64_t alignCorner;
  269. } ccSpatialTransformer_t;
  270. /**
  271. * @ingroup dnn
  272. * @brief struct define of ShiftTransformer operator
  273. */
  274. typedef struct tagCcShiftTransformer {
  275. ccSamplerType_t samplerType;
  276. double xPreDefined;
  277. double yPreDefined;
  278. bool xShift;
  279. bool yShift;
  280. int32_t gridH;
  281. int32_t gridW;
  282. } ccShiftTransformer_t;
  283. /**
  284. * @ingroup dnn
  285. * @brief struct define of FasterRcnnProposal operator
  286. */
  287. typedef struct tagCcFasterRcnnProposal {
  288. int32_t preNMStopK;
  289. int32_t postNMStopK;
  290. float nmsTresh;
  291. float minSize;
  292. float featStride;
  293. float baseSize;
  294. int32_t ratioCnt;
  295. int32_t scaleCnt;
  296. float *ratio;
  297. float *scale;
  298. int32_t imgH;
  299. int32_t imgW;
  300. } ccFasterRcnnProposal_t;
  301. /**
  302. * @ingroup dnn
  303. * @brief struct define of LRN operator
  304. */
  305. typedef struct tagCcLRN {
  306. ccLRNMode_t lrnMode;
  307. int32_t lrnN;
  308. double lrnAlpha;
  309. double lrnBeta;
  310. double lrnK;
  311. } ccLRN_t;
  312. /**
  313. * @ingroup dnn
  314. * @brief struct define of instanceNorm
  315. */
  316. typedef struct tagCcInstancenorm {
  317. ccInstanceNormMode_t mode;
  318. double epsilon;
  319. } ccInstancenorm_t;
  320. /**
  321. * @ingroup dnn
  322. * @brief struct define of assignOp operator
  323. */
  324. typedef struct tagCcAssignOp {
  325. ccAssignOpMode_t assignOpMode;
  326. } ccAssignOp_t;
  327. /**
  328. * @ingroup dnn
  329. * @brief struct define of arcSinCos operator
  330. */
  331. typedef struct tagCcArcSinCos {
  332. ccArcSinCosMode_t arcSinCosMode;
  333. } ccArcSinCos_t;
  334. /**
  335. * @ingroup dnn
  336. * @brief struct define of Detectpostprocess operator
  337. */
  338. typedef struct tagCcDetectpostprocess {
  339. int32_t numClasses;
  340. float confThreshold;
  341. float nmsThreshold;
  342. int32_t outTopK;
  343. float bboxRegWeightsDx;
  344. float bboxRegWeightsDy;
  345. float bboxRegWeightsDw;
  346. float bboxRegWeightsDh;
  347. } ccDetectpostprocess_t;
  348. /**
  349. * @ingroup dnn
  350. * @brief struct define of FasterRcnnDetectionOutput operator
  351. */
  352. typedef struct tagCcFasterRcnnDetectionOutput {
  353. int32_t numClasses;
  354. float nmsThreshold;
  355. float postConfThreshold;
  356. int32_t imgH;
  357. int32_t imgW;
  358. int32_t batchSize;
  359. } ccFasterRcnnDetectionOutput_t;
  360. /**
  361. * @ingroup dnn
  362. * @brief struct define of SsdDetectionOutput operator
  363. */
  364. typedef struct tagCcSsdDetectionOutput {
  365. int32_t numClasses;
  366. int32_t backgroundLabelId;
  367. double preConfThreshold;
  368. int32_t preTopK;
  369. double nmsThreshold;
  370. double nmsEta;
  371. ccBoxCodeType_t codeType;
  372. int32_t outTopK;
  373. bool shareLocation;
  374. bool varianceEncodedInTarget;
  375. uint32_t boxTypeNum;
  376. float var[4];
  377. uint32_t variance_num;
  378. } ccSsdDetectionOutput_t;
  379. /**
  380. * @ingroup dnn
  381. * @brief struct define of RefinedetDetectionOutput operator
  382. */
  383. typedef struct tagCcRefinedetDetectionOutput {
  384. int32_t numClasses;
  385. int32_t backgroundLabelId;
  386. double preConfThreshold;
  387. int32_t preTopK;
  388. double nmsThreshold;
  389. double nmsEta;
  390. ccBoxCodeType_t codeType;
  391. int32_t outTopK;
  392. bool shareLocation;
  393. bool varianceEncodedInTarget;
  394. uint32_t boxTypeNum;
  395. float var[4];
  396. uint32_t variance_num;
  397. double objectness_score;
  398. } ccRefinedetDetectionOutput_t;
  399. /**
  400. * @ingroup dnn
  401. * @brief struct define of MsrGenerateRpnProposals operator
  402. */
  403. typedef struct tagCcMsrGenerateRpnProposals {
  404. int32_t preNmsTopK;
  405. int32_t postNmsTopK;
  406. float nmsThreshold;
  407. float rpnMiniSize;
  408. int32_t imgH;
  409. int32_t imgW;
  410. uint32_t boxTypeNum;
  411. float scoreThreshold;
  412. } ccMsrGenerateRpnProposals_t;
  413. /**
  414. * @ingroup dnn
  415. * @brief struct define of RetinaPostprocessor operator
  416. */
  417. typedef struct tagCcRetinaPostprocessor {
  418. int32_t numClasses;
  419. int32_t maxDetections;
  420. float nmsThreshold;
  421. float scoreThreshold;
  422. int32_t imgH;
  423. int32_t imgW;
  424. uint32_t boxTypeNum;
  425. float mean[4];
  426. int32_t meanNum;
  427. float std[4];
  428. int32_t stdNum;
  429. int32_t outputNum;
  430. bool ocrFlag;
  431. } ccRetinaPostprocessor_t;
  432. /**
  433. * @ingroup dnn
  434. * @brief struct define of GenerateSsdAnchors operator
  435. */
  436. typedef struct tagCcGenerateSsdAnchors {
  437. int32_t featureMapShapeList[20];
  438. uint32_t featureMapShapeListSize;
  439. int32_t boxSpecsNum[10];
  440. uint32_t boxSpecsNumSize;
  441. float scales[10];
  442. uint32_t scalesNum;
  443. float aspectRatios[10];
  444. uint32_t aspectRatiosNum;
  445. int32_t baseAnchorSize[2];
  446. uint32_t baseAnchorSizeNum;
  447. int32_t anchorStride[2];
  448. uint32_t anchorStrideNum;
  449. int32_t anchorOffset[2];
  450. uint32_t anchorOffsetNum;
  451. bool reduceBoxesInLowestLayer;
  452. float minScale;
  453. float maxScale;
  454. int32_t imgH;
  455. int32_t imgW;
  456. } ccGenerateSsdAnchors_t;
  457. /**
  458. * @ingroup dnn
  459. * @brief struct define of MscnnBoxOutput operator
  460. */
  461. typedef struct tagCcMscnnBoxOutput {
  462. double fgThreshold;
  463. double nmsThreshold;
  464. ccNmsType_t nmsType;
  465. int32_t fieldH[CC_MAX_INPUT_CNT];
  466. int32_t fieldW[CC_MAX_INPUT_CNT];
  467. int32_t downsampleRate[CC_MAX_INPUT_CNT];
  468. int32_t defaultBoxCnt;
  469. double fieldWhr;
  470. double fieldXyr;
  471. int32_t maxNmsNum;
  472. int32_t maxPostNmsNum;
  473. double minSize;
  474. } ccMscnnBoxOutput_t;
  475. /**
  476. * @ingroup dnn
  477. * @brief struct define of NMS operator
  478. */
  479. typedef struct tagCcNms {
  480. int32_t numClasses;
  481. int32_t backgroundLabelId;
  482. double preConfThreshold;
  483. int32_t preTopK;
  484. double nmsThreshold;
  485. double nmsEta;
  486. int32_t postTopK;
  487. int32_t outTopK;
  488. double postConfThreshold;
  489. bool shareLocation;
  490. } ccNms_t;
  491. /**
  492. * @ingroup dnn
  493. * @brief struct define of NMS/MultiClassNMS operator
  494. */
  495. typedef struct tagCcMultiClassNms {
  496. uint64_t numClasses;
  497. float objThreshold;
  498. float nmsThreshold;
  499. float clsThreshold;
  500. bool normal;
  501. uint64_t coorType;
  502. } ccCcMultiClassNms_t;
  503. /**
  504. * @ingroup dnn
  505. * @brief struct define of YoloDetectionOutput operator
  506. */
  507. typedef struct tagCcYoloDetectionOutput {
  508. ccYoloVersion_t yoloVersion;
  509. uint32_t netH;
  510. uint32_t netW;
  511. uint32_t postTopK;
  512. uint32_t classes;
  513. float nmsThreshold;
  514. float iouThreDecay;
  515. float coorScaleFactor;
  516. bool relative;
  517. float objThreshold;
  518. float clsThreshold;
  519. uint32_t biasNum;
  520. float *bias;
  521. } ccYoloDetectionOutput_t;
  522. /**
  523. * @ingroup dnn
  524. * @brief struct define of GetRegionBox operator
  525. */
  526. #ifndef CC_MAX_YOLO_BIAS_NUM
  527. #define CC_MAX_YOLO_BIAS_NUM (16)
  528. #endif
  529. typedef struct tagCcGetRegionBox {
  530. uint32_t biasNum;
  531. uint32_t H;
  532. uint32_t W;
  533. float bias[CC_MAX_YOLO_BIAS_NUM];
  534. } ccGetRegionBox_t;
  535. /**
  536. * @ingroup dnn
  537. * @brief struct define of CorrectBoxes operator
  538. */
  539. typedef struct tagCorrectBoxes {
  540. uint32_t netW;
  541. uint32_t netH;
  542. bool relative;
  543. } ccCorrectBoxes_t;
  544. /**
  545. * @ingroup dnn
  546. * @brief struct define of ClsProb operator
  547. */
  548. typedef struct tagClsProb {
  549. float objThreshold;
  550. } ccClsProb_t;
  551. /**
  552. * @ingroup dnn
  553. * @brief struct define of SsdPriorBox operator
  554. */
  555. typedef struct tagCcSsdPriorBox {
  556. ccBoxCodeType_t codeType;
  557. double *minSize;
  558. int32_t minSizeNum;
  559. double *maxSize;
  560. int32_t maxSizeNum;
  561. double *aspectRatio;
  562. int32_t aspectRatioNum;
  563. double *variance;
  564. int32_t varianceNum;
  565. int32_t imgH;
  566. int32_t imgW;
  567. double stepH;
  568. double stepW;
  569. double offset;
  570. bool flip;
  571. bool clip;
  572. } ccSsdPriorBox_t;
  573. /**
  574. * @ingroup dnn
  575. * @brief struct define of Yolo2Region operator
  576. */
  577. typedef struct tagCcYolo2Region {
  578. ccSoftmaxTree_t softmaxTree;
  579. bool softmax;
  580. bool background;
  581. bool treeSoftmax;
  582. } ccYolo2Region_t;
  583. /**
  584. * @ingroup dnn
  585. * @brief struct define of YoloRegion operator
  586. */
  587. typedef struct tagCcYoloRegion {
  588. ccSoftmaxTree_t softmaxTree;
  589. bool softmax;
  590. bool background;
  591. bool treeSoftmax;
  592. int32_t classes;
  593. int32_t coords;
  594. int32_t boxes;
  595. ccYoloVersion_t yoloV;
  596. } ccYoloRegion_t;
  597. /**
  598. * @ingroup dnn
  599. * @brief struct define of power operator
  600. */
  601. typedef struct tagCcPower {
  602. float scale;
  603. float shift;
  604. float power;
  605. } ccPower_t;
  606. /**
  607. * @ingroup dnn
  608. * @brief struct define of exp operator
  609. */
  610. typedef struct tagCcExp {
  611. ccDataType_t dataType;
  612. uint32_t paramCnt;
  613. } ccExp_t;
  614. /**
  615. * @ingroup dnn
  616. * @brief struct define of exp operator
  617. */
  618. typedef struct tagCcLog {
  619. ccDataType_t dataType;
  620. uint32_t paramCnt;
  621. } ccLog_t;
  622. /**
  623. * @ingroup dnn
  624. * @brief struct define of pow operator
  625. */
  626. typedef struct tagCcPow {
  627. ccDataType_t dataType;
  628. uint32_t paramCnt;
  629. } ccPow_t;
  630. /**
  631. * @ingroup dnn
  632. * @brief struct define of padv2 operator
  633. */
  634. typedef struct tagCcPadV2 {
  635. ccPadMode_t padMode;
  636. void *padValue;
  637. ccDataType_t padValueType;
  638. int32_t padDimCnt;
  639. int32_t padShapeLow[CC_DIM_MAX];
  640. int32_t padShapeHigh[CC_DIM_MAX];
  641. } ccPadV2_t;
  642. /**
  643. * @ingroup dnn
  644. * @brief struct define of psROIPooling operator
  645. */
  646. typedef struct tagCcPsRoiPooling {
  647. ccPoolingMode_t poolingMode;
  648. int32_t pooledH;
  649. int32_t pooledW;
  650. float spatialScale;
  651. float padRatio;
  652. int32_t groupSize;
  653. int32_t outputDim;
  654. } ccPsRoiPooling_t;
  655. /**
  656. * @ingroup dnn
  657. * @brief struct define of RoIAlign operator
  658. */
  659. typedef struct tagCcRoiAlign {
  660. int32_t pooledH;
  661. int32_t pooledW;
  662. float spatialScale;
  663. int32_t samplingRatio;
  664. } ccRoiAlign_t;
  665. /**
  666. * @ingroup dnn
  667. * @brief struct define of RoiInterpPooling operator
  668. */
  669. typedef struct tagCcRoiInterpPooling {
  670. int32_t pooledH;
  671. int32_t pooledW;
  672. int32_t poolKernelH;
  673. int32_t poolKernelW;
  674. int32_t pooledTailH;
  675. int32_t pooledTailW;
  676. float spatialScaleH;
  677. float spatialScaleW;
  678. } ccRoiInterpPooling_t;
  679. /**
  680. * @ingroup dnn
  681. * @brief struct define of DetectionFull3DOutput operator
  682. */
  683. typedef struct tagCcDetectionFull3DOutput {
  684. int32_t imageWidth;
  685. int32_t imageHeight;
  686. int32_t numAngleBins;
  687. float trcMarginRatioX;
  688. float trcMarginRatioY;
  689. int32_t pitchRangeD;
  690. int32_t pitchPresetD;
  691. float mountHeight;
  692. int32_t visiblenessBins;
  693. float meanVisibleness;
  694. bool discreteVisibleness;
  695. } ccDetectionFull3DOutput_t;
  696. /**
  697. * @ingroup dnn
  698. * @brief struct define of MsrFastRcnnPredictions operator
  699. */
  700. typedef struct tagMsrFastRcnnPredictions {
  701. int32_t numClasses; // num of classes
  702. float scoreThreshold; // the threshold of the score
  703. double nmsThreshold; // the threshold of nms
  704. int32_t postTopK;
  705. int32_t outTopK;
  706. int32_t imgH; // the height of image
  707. int32_t imgW; // the width of image
  708. } ccMsrFastRcnnPredictions_t;
  709. typedef struct tagCcResizeBilinear {
  710. ccResizeOutputDimMode_t resizeOutputDimMode;
  711. bool alignCorners;
  712. int32_t zoom_factor;
  713. int32_t shrink_factor;
  714. int32_t height;
  715. int32_t width;
  716. int32_t pad_begin;
  717. int32_t pad_end;
  718. } ccResizeBilinear_t;
  719. typedef struct tagCcResizeNearestNeighbor {
  720. bool alignCorners;
  721. int32_t height;
  722. int32_t width;
  723. } ccResizeNearestNeighbor_t;
  724. typedef struct tagCcEltwise {
  725. ccQuantize_t *quantInfo;
  726. bool reluFlag;
  727. } ccEltwise_t;
  728. typedef struct tagCcBatchNorm {
  729. bool reluFlag;
  730. } ccBatchNorm_t;
  731. typedef struct tagCcPad {
  732. ccPadMode_t padMode;
  733. float padValue;
  734. int32_t htoppad; // padLow[0]
  735. int32_t hbottompad; // padHigh[0]
  736. int32_t wleftpad; // padLow[1]
  737. int32_t wrightpad; // padHigh[1]
  738. } ccPad_t;
  739. typedef struct tagCcSubCondition {
  740. uint32_t BaseCondValue[4];
  741. ccCMPType_t condType[4];
  742. ccResultType_t resultType;
  743. } ccSubCondition;
  744. typedef struct tagCcShapeClassifyCond {
  745. uint32_t subConditionNum;
  746. ccResultType_t resultType;
  747. uint32_t true_value;
  748. ccSubCondition subCond[2];
  749. } ccShapeClassifyCond;
  750. #ifndef CC_SHAPE_CLASSIFY_CONDITION_NUM
  751. #define CC_SHAPE_CLASSIFY_CONDITION_NUM (8)
  752. #endif
  753. typedef struct tagCcShapeClassify {
  754. uint32_t shapeClassifyConditionNum;
  755. uint32_t defaultValue;
  756. ccShapeClassifyCond shapeClassifyCond[CC_SHAPE_CLASSIFY_CONDITION_NUM];
  757. } ccShapeClassify_t;
  758. /**
  759. * @ingroup dnn
  760. * @bref struct define of square operator
  761. */
  762. typedef struct tagCcSquare {
  763. ccSquareMode_t mode;
  764. } ccSquare_t;
  765. /*
  766. * @ingroup dnn
  767. * @brief operation of segment reduction
  768. */
  769. typedef enum {
  770. CC_SEGMENT_REDUCTION_OP_SUM = 0, /**< sum */
  771. CC_SEGMENT_REDUCTION_OP_INVALID
  772. } ccSegmentReductionOpType_t;
  773. typedef struct tagCcFillParam {
  774. // The filler type.
  775. ccFillOpType_t fillType;
  776. ccDataType_t valueDatatype;
  777. const void *value; // the value in constant fill
  778. const void *min; // the min value in uniform fill
  779. const void *max; // the max value in uniform fill
  780. const void *mean; // the mean value in Gaussian fill
  781. const void *std; // the std value in Gaussian fill
  782. // the seed used to generate data in Gaussian and uniform fill
  783. int64_t seed1;
  784. int64_t seed2;
  785. } ccFillParam_t;
  786. typedef struct tagNonMaxSuppression {
  787. ccDataType_t dataType;
  788. uint32_t paraCount;
  789. } ccNonMaxSuppression_t;
  790. typedef struct tagCcArgmaxmin {
  791. int32_t axisType;
  792. bool outMaxVal;
  793. int64_t topK;
  794. int64_t reduceSize;
  795. int64_t reduceStride;
  796. int64_t axis;
  797. bool keepDims;
  798. } ccArgmaxmin_t;
  799. typedef struct tagUpsamplePara {
  800. int32_t scale;
  801. int32_t scaleHeight;
  802. int32_t scaleWidth;
  803. int32_t upsampleHeight;
  804. int32_t upsampleWidth;
  805. bool padOutHeight;
  806. bool padOutWidth;
  807. } ccUpsamplePara_t;
  808. typedef struct tagCcConcatFive2Four_t {
  809. ccTransForLossMode_t mode;
  810. uint32_t classNum;
  811. } ccConcatFive2Four_t;
  812. }; // namespace cce
  813. #endif // DNN_STRUCT_BASE_HPP__

图引擎模块(GE)是MindSpore的一个子模块,其代码由C++实现,位于前端模块ME和底层硬件之间,起到承接作用。图引擎模块以ME下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示