mnn-schema.js 110 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292
  1. export const MNN = {};
  2. MNN.NetSource = {
  3. CAFFE: 0,
  4. TENSORFLOW: 1,
  5. TFLITE: 2,
  6. ONNX: 3,
  7. TORCH: 4
  8. };
  9. MNN.DataType = {
  10. DT_INVALID: 0,
  11. DT_FLOAT: 1,
  12. DT_DOUBLE: 2,
  13. DT_INT32: 3,
  14. DT_UINT8: 4,
  15. DT_INT16: 5,
  16. DT_INT8: 6,
  17. DT_STRING: 7,
  18. DT_COMPLEX64: 8,
  19. DT_INT64: 9,
  20. DT_BOOL: 10,
  21. DT_QINT8: 11,
  22. DT_QUINT8: 12,
  23. DT_QINT32: 13,
  24. DT_BFLOAT16: 14,
  25. DT_QINT16: 15,
  26. DT_QUINT16: 16,
  27. DT_UINT16: 17,
  28. DT_COMPLEX128: 18,
  29. DT_HALF: 19,
  30. DT_RESOURCE: 20,
  31. DT_VARIANT: 21
  32. };
  33. MNN.MNN_DATA_FORMAT = {
  34. NCHW: 0,
  35. NHWC: 1,
  36. NC4HW4: 2,
  37. NHWC4: 3,
  38. UNKNOWN: 4
  39. };
  40. MNN.Blob = class Blob {
  41. static decode(reader, position) {
  42. const $ = new MNN.Blob();
  43. $.dims = reader.array(position, 4, Int32Array);
  44. $.dataFormat = reader.int8_(position, 6, 0);
  45. $.dataType = reader.int32_(position, 8, 1);
  46. $.uint8s = reader.array(position, 10, Uint8Array);
  47. $.int8s = reader.array(position, 12, Int8Array);
  48. $.int32s = reader.array(position, 14, Int32Array);
  49. $.int64s = reader.int64s_(position, 16);
  50. $.float32s = reader.array(position, 18, Float32Array);
  51. $.strings = reader.strings_(position, 20);
  52. $.external = reader.int64s_(position, 22);
  53. return $;
  54. }
  55. static decodeText(reader, json) {
  56. const $ = new MNN.Blob();
  57. $.dims = reader.array(json.dims, Int32Array);
  58. $.dataFormat = MNN.MNN_DATA_FORMAT[json.dataFormat];
  59. $.dataType = MNN.DataType[json.dataType];
  60. $.uint8s = reader.array(json.uint8s, Uint8Array);
  61. $.int8s = reader.array(json.int8s, Int8Array);
  62. $.int32s = reader.array(json.int32s, Int32Array);
  63. $.int64s = reader.array(json.int64s);
  64. $.float32s = reader.array(json.float32s, Float32Array);
  65. $.strings = reader.array(json.strings);
  66. $.external = reader.array(json.external);
  67. return $;
  68. }
  69. };
  70. MNN.ListValue = class ListValue {
  71. static decode(reader, position) {
  72. const $ = new MNN.ListValue();
  73. $.s = reader.strings_(position, 4);
  74. $.i = reader.array(position, 6, Int32Array);
  75. $.f = reader.array(position, 8, Float32Array);
  76. $.b = reader.bools_(position, 10);
  77. $.type = reader.array(position, 12, Int32Array);
  78. return $;
  79. }
  80. static decodeText(reader, json) {
  81. const $ = new MNN.ListValue();
  82. $.s = reader.array(json.s);
  83. $.i = reader.array(json.i, Int32Array);
  84. $.f = reader.array(json.f, Float32Array);
  85. $.b = reader.array(json.b);
  86. $.type = reader.objects(json.type, MNN.DataType);
  87. return $;
  88. }
  89. };
  90. MNN.Attribute = class Attribute {
  91. static decode(reader, position) {
  92. const $ = new MNN.Attribute();
  93. $.s = reader.string_(position, 4, null);
  94. $.i = reader.int32_(position, 6, 0);
  95. $.b = reader.bool_(position, 8, false);
  96. $.key = reader.string_(position, 10, null);
  97. $.type = reader.int32_(position, 12, 0);
  98. $.f = reader.float32_(position, 14, 0);
  99. $.tensor = reader.table(position, 16, MNN.Blob);
  100. $.list = reader.table(position, 18, MNN.ListValue);
  101. $.func = reader.table(position, 20, MNN.NamedAttrList);
  102. return $;
  103. }
  104. static decodeText(reader, json) {
  105. const $ = new MNN.Attribute();
  106. $.s = reader.value(json.s, null);
  107. $.i = reader.value(json.i, 0);
  108. $.b = reader.value(json.b, false);
  109. $.key = reader.value(json.key, null);
  110. $.type = MNN.DataType[json.type];
  111. $.f = reader.value(json.f, 0);
  112. $.tensor = reader.object(json.tensor, MNN.Blob);
  113. $.list = reader.object(json.list, MNN.ListValue);
  114. $.func = reader.object(json.func, MNN.NamedAttrList);
  115. return $;
  116. }
  117. };
  118. MNN.NamedAttrList = class NamedAttrList {
  119. static decode(reader, position) {
  120. const $ = new MNN.NamedAttrList();
  121. $.name = reader.string_(position, 4, null);
  122. $.attr = reader.tables(position, 6, MNN.Attribute);
  123. return $;
  124. }
  125. static decodeText(reader, json) {
  126. const $ = new MNN.NamedAttrList();
  127. $.name = reader.value(json.name, null);
  128. $.attr = reader.objects(json.attr, MNN.Attribute);
  129. return $;
  130. }
  131. };
  132. MNN.PadMode = {
  133. CAFFE: 0,
  134. VALID: 1,
  135. SAME: 2
  136. };
  137. MNN.Convolution2DCommon = class Convolution2DCommon {
  138. static decode(reader, position) {
  139. const $ = new MNN.Convolution2DCommon();
  140. $.padX = reader.int32_(position, 4, 0);
  141. $.padY = reader.int32_(position, 6, 0);
  142. $.kernelX = reader.int32_(position, 8, 1);
  143. $.kernelY = reader.int32_(position, 10, 1);
  144. $.strideX = reader.int32_(position, 12, 1);
  145. $.strideY = reader.int32_(position, 14, 1);
  146. $.dilateX = reader.int32_(position, 16, 1);
  147. $.dilateY = reader.int32_(position, 18, 1);
  148. $.padMode = reader.int8_(position, 20, 0);
  149. $.group = reader.int32_(position, 22, 1);
  150. $.outputCount = reader.int32_(position, 24, 0);
  151. $.inputCount = reader.int32_(position, 26, 0);
  152. $.relu = reader.bool_(position, 28, false);
  153. $.relu6 = reader.bool_(position, 30, false);
  154. $.pads = reader.array(position, 32, Int32Array);
  155. $.outPads = reader.array(position, 34, Int32Array);
  156. $.hasOutputShape = reader.bool_(position, 36, false);
  157. return $;
  158. }
  159. static decodeText(reader, json) {
  160. const $ = new MNN.Convolution2DCommon();
  161. $.padX = reader.value(json.padX, 0);
  162. $.padY = reader.value(json.padY, 0);
  163. $.kernelX = reader.value(json.kernelX, 1);
  164. $.kernelY = reader.value(json.kernelY, 1);
  165. $.strideX = reader.value(json.strideX, 1);
  166. $.strideY = reader.value(json.strideY, 1);
  167. $.dilateX = reader.value(json.dilateX, 1);
  168. $.dilateY = reader.value(json.dilateY, 1);
  169. $.padMode = MNN.PadMode[json.padMode];
  170. $.group = reader.value(json.group, 1);
  171. $.outputCount = reader.value(json.outputCount, 0);
  172. $.inputCount = reader.value(json.inputCount, 0);
  173. $.relu = reader.value(json.relu, false);
  174. $.relu6 = reader.value(json.relu6, false);
  175. $.pads = reader.array(json.pads, Int32Array);
  176. $.outPads = reader.array(json.outPads, Int32Array);
  177. $.hasOutputShape = reader.value(json.hasOutputShape, false);
  178. return $;
  179. }
  180. };
  181. MNN.Convolution3DCommon = class Convolution3DCommon {
  182. static decode(reader, position) {
  183. const $ = new MNN.Convolution3DCommon();
  184. $.dilates = reader.array(position, 4, Int32Array);
  185. $.strides = reader.array(position, 6, Int32Array);
  186. $.kernels = reader.array(position, 8, Int32Array);
  187. $.pads = reader.array(position, 10, Int32Array);
  188. $.padMode = reader.int8_(position, 12, 0);
  189. $.inputCount = reader.int32_(position, 14, 0);
  190. $.outputCount = reader.int32_(position, 16, 0);
  191. $.relu = reader.bool_(position, 18, false);
  192. $.relu6 = reader.bool_(position, 20, false);
  193. $.group = reader.int32_(position, 22, 1);
  194. $.outPads = reader.array(position, 24, Int32Array);
  195. $.hasOutputShape = reader.bool_(position, 26, false);
  196. return $;
  197. }
  198. static decodeText(reader, json) {
  199. const $ = new MNN.Convolution3DCommon();
  200. $.dilates = reader.array(json.dilates, Int32Array);
  201. $.strides = reader.array(json.strides, Int32Array);
  202. $.kernels = reader.array(json.kernels, Int32Array);
  203. $.pads = reader.array(json.pads, Int32Array);
  204. $.padMode = MNN.PadMode[json.padMode];
  205. $.inputCount = reader.value(json.inputCount, 0);
  206. $.outputCount = reader.value(json.outputCount, 0);
  207. $.relu = reader.value(json.relu, false);
  208. $.relu6 = reader.value(json.relu6, false);
  209. $.group = reader.value(json.group, 1);
  210. $.outPads = reader.array(json.outPads, Int32Array);
  211. $.hasOutputShape = reader.value(json.hasOutputShape, false);
  212. return $;
  213. }
  214. };
  215. MNN.SparseAlgo = {
  216. RANDOM: 0,
  217. SIMD_OC: 1
  218. };
  219. MNN.SparseCommon = class SparseCommon {
  220. static decode(reader, position) {
  221. const $ = new MNN.SparseCommon();
  222. $.method = reader.int8_(position, 4, 0);
  223. $.args = reader.tables(position, 6, MNN.Attribute);
  224. return $;
  225. }
  226. static decodeText(reader, json) {
  227. const $ = new MNN.SparseCommon();
  228. $.method = MNN.SparseAlgo[json.method];
  229. $.args = reader.objects(json.args, MNN.Attribute);
  230. return $;
  231. }
  232. };
  233. MNN.IDSTQuan = class IDSTQuan {
  234. static decode(reader, position) {
  235. const $ = new MNN.IDSTQuan();
  236. $.buffer = reader.array(position, 4, Int8Array);
  237. $.alpha = reader.array(position, 6, Float32Array);
  238. $.type = reader.int32_(position, 8, 0);
  239. $.useInt32 = reader.bool_(position, 10, false);
  240. $.quantScale = reader.float32_(position, 12, 0);
  241. $.scaleIn = reader.float32_(position, 14, 0);
  242. $.scaleOut = reader.float32_(position, 16, 0);
  243. $.aMaxOrBits = reader.int32_(position, 18, 0);
  244. $.aMin = reader.int32_(position, 20, 0);
  245. $.readType = reader.int32_(position, 22, 0);
  246. $.has_scaleInt = reader.bool_(position, 24, false);
  247. $.shapeInt32 = reader.bool_(position, 26, false);
  248. $.weightSize = reader.uint32_(position, 28, 0);
  249. $.index = reader.array(position, 30, Uint32Array);
  250. return $;
  251. }
  252. static decodeText(reader, json) {
  253. const $ = new MNN.IDSTQuan();
  254. $.buffer = reader.array(json.buffer, Int8Array);
  255. $.alpha = reader.array(json.alpha, Float32Array);
  256. $.type = reader.value(json.type, 0);
  257. $.useInt32 = reader.value(json.useInt32, false);
  258. $.quantScale = reader.value(json.quantScale, 0);
  259. $.scaleIn = reader.value(json.scaleIn, 0);
  260. $.scaleOut = reader.value(json.scaleOut, 0);
  261. $.aMaxOrBits = reader.value(json.aMaxOrBits, 0);
  262. $.aMin = reader.value(json.aMin, 0);
  263. $.readType = reader.value(json.readType, 0);
  264. $.has_scaleInt = reader.value(json.has_scaleInt, false);
  265. $.shapeInt32 = reader.value(json.shapeInt32, false);
  266. $.weightSize = reader.value(json.weightSize, 0);
  267. $.index = reader.array(json.index, Uint32Array);
  268. return $;
  269. }
  270. };
  271. MNN.QuantizeAlgo = {
  272. DEFAULT: 0,
  273. OVERFLOW_AWARE: 1,
  274. WINOGRAD_AWARE: 2
  275. };
  276. MNN.QuantizedFloatParam = class QuantizedFloatParam {
  277. static decode(reader, position) {
  278. const $ = new MNN.QuantizedFloatParam();
  279. $.weight = reader.array(position, 4, Int8Array);
  280. $.bias = reader.array(position, 6, Int32Array);
  281. $.scale = reader.array(position, 8, Float32Array);
  282. $.tensorScale = reader.array(position, 10, Float32Array);
  283. $.method = reader.int8_(position, 12, 0);
  284. $.nbits = reader.int32_(position, 14, 8);
  285. $.zeroPoint = reader.int8_(position, 16, 0);
  286. $.outputZeroPoint = reader.int8_(position, 18, 0);
  287. $.clampMin = reader.int8_(position, 20, -128);
  288. $.clampMax = reader.int8_(position, 22, 127);
  289. $.winogradAttr = reader.array(position, 24, Int32Array);
  290. $.outputDataType = reader.int32_(position, 26, 6);
  291. $.floatzeros = reader.array(position, 28, Float32Array);
  292. return $;
  293. }
  294. static decodeText(reader, json) {
  295. const $ = new MNN.QuantizedFloatParam();
  296. $.weight = reader.array(json.weight, Int8Array);
  297. $.bias = reader.array(json.bias, Int32Array);
  298. $.scale = reader.array(json.scale, Float32Array);
  299. $.tensorScale = reader.array(json.tensorScale, Float32Array);
  300. $.method = MNN.QuantizeAlgo[json.method];
  301. $.nbits = reader.value(json.nbits, 8);
  302. $.zeroPoint = reader.value(json.zeroPoint, 0);
  303. $.outputZeroPoint = reader.value(json.outputZeroPoint, 0);
  304. $.clampMin = reader.value(json.clampMin, -128);
  305. $.clampMax = reader.value(json.clampMax, 127);
  306. $.winogradAttr = reader.array(json.winogradAttr, Int32Array);
  307. $.outputDataType = MNN.DataType[json.outputDataType];
  308. $.floatzeros = reader.array(json.floatzeros, Float32Array);
  309. return $;
  310. }
  311. };
  312. MNN.Convolution2D = class Convolution2D {
  313. static decode(reader, position) {
  314. const $ = new MNN.Convolution2D();
  315. $.common = reader.table(position, 4, MNN.Convolution2DCommon);
  316. $.weight = reader.array(position, 6, Float32Array);
  317. $.bias = reader.array(position, 8, Float32Array);
  318. $.quanParameter = reader.table(position, 10, MNN.IDSTQuan);
  319. $.symmetricQuan = reader.table(position, 12, MNN.QuantizedFloatParam);
  320. $.sparseParameter = reader.table(position, 14, MNN.SparseCommon);
  321. $.external = reader.int64s_(position, 16);
  322. return $;
  323. }
  324. static decodeText(reader, json) {
  325. const $ = new MNN.Convolution2D();
  326. $.common = reader.object(json.common, MNN.Convolution2DCommon);
  327. $.weight = reader.array(json.weight, Float32Array);
  328. $.bias = reader.array(json.bias, Float32Array);
  329. $.quanParameter = reader.object(json.quanParameter, MNN.IDSTQuan);
  330. $.symmetricQuan = reader.object(json.symmetricQuan, MNN.QuantizedFloatParam);
  331. $.sparseParameter = reader.object(json.sparseParameter, MNN.SparseCommon);
  332. $.external = reader.array(json.external);
  333. return $;
  334. }
  335. };
  336. MNN.Convolution3D = class Convolution3D {
  337. static decode(reader, position) {
  338. const $ = new MNN.Convolution3D();
  339. $.common = reader.table(position, 4, MNN.Convolution3DCommon);
  340. $.weight = reader.array(position, 6, Float32Array);
  341. $.bias = reader.array(position, 8, Float32Array);
  342. $.external = reader.int64s_(position, 10);
  343. return $;
  344. }
  345. static decodeText(reader, json) {
  346. const $ = new MNN.Convolution3D();
  347. $.common = reader.object(json.common, MNN.Convolution3DCommon);
  348. $.weight = reader.array(json.weight, Float32Array);
  349. $.bias = reader.array(json.bias, Float32Array);
  350. $.external = reader.array(json.external);
  351. return $;
  352. }
  353. };
  354. MNN.InnerProduct = class InnerProduct {
  355. static decode(reader, position) {
  356. const $ = new MNN.InnerProduct();
  357. $.outputCount = reader.int32_(position, 4, 0);
  358. $.biasTerm = reader.int32_(position, 6, 0);
  359. $.weightSize = reader.int32_(position, 8, 0);
  360. $.weight = reader.array(position, 10, Float32Array);
  361. $.bias = reader.array(position, 12, Float32Array);
  362. $.axis = reader.int32_(position, 14, 0);
  363. $.transpose = reader.bool_(position, 16, false);
  364. $.quanParameter = reader.table(position, 18, MNN.IDSTQuan);
  365. return $;
  366. }
  367. static decodeText(reader, json) {
  368. const $ = new MNN.InnerProduct();
  369. $.outputCount = reader.value(json.outputCount, 0);
  370. $.biasTerm = reader.value(json.biasTerm, 0);
  371. $.weightSize = reader.value(json.weightSize, 0);
  372. $.weight = reader.array(json.weight, Float32Array);
  373. $.bias = reader.array(json.bias, Float32Array);
  374. $.axis = reader.value(json.axis, 0);
  375. $.transpose = reader.value(json.transpose, false);
  376. $.quanParameter = reader.object(json.quanParameter, MNN.IDSTQuan);
  377. return $;
  378. }
  379. };
  380. MNN.PoolType = {
  381. MAXPOOL: 0,
  382. AVEPOOL: 1
  383. };
  384. MNN.PoolPadType = {
  385. CAFFE: 0,
  386. VALID: 1,
  387. SAME: 2
  388. };
  389. MNN.AvgPoolCountType = {
  390. DEFAULT: 0,
  391. INCLUDE_PADDING: 1,
  392. EXCLUDE_PADDING: 2
  393. };
  394. MNN.Pool = class Pool {
  395. static decode(reader, position) {
  396. const $ = new MNN.Pool();
  397. $.padX = reader.int32_(position, 4, 0);
  398. $.padY = reader.int32_(position, 6, 0);
  399. $.isGlobal = reader.bool_(position, 8, false);
  400. $.kernelX = reader.int32_(position, 10, 0);
  401. $.kernelY = reader.int32_(position, 12, 0);
  402. $.strideX = reader.int32_(position, 14, 0);
  403. $.strideY = reader.int32_(position, 16, 0);
  404. $.type = reader.int8_(position, 18, 0);
  405. $.padType = reader.int8_(position, 20, 0);
  406. $.dataType = reader.int32_(position, 22, 1);
  407. $.ceilModel = reader.bool_(position, 24, true);
  408. $.pads = reader.array(position, 26, Int32Array);
  409. $.countType = reader.int8_(position, 28, 0);
  410. return $;
  411. }
  412. static decodeText(reader, json) {
  413. const $ = new MNN.Pool();
  414. $.padX = reader.value(json.padX, 0);
  415. $.padY = reader.value(json.padY, 0);
  416. $.isGlobal = reader.value(json.isGlobal, false);
  417. $.kernelX = reader.value(json.kernelX, 0);
  418. $.kernelY = reader.value(json.kernelY, 0);
  419. $.strideX = reader.value(json.strideX, 0);
  420. $.strideY = reader.value(json.strideY, 0);
  421. $.type = MNN.PoolType[json.type];
  422. $.padType = MNN.PoolPadType[json.padType];
  423. $.dataType = MNN.DataType[json.dataType];
  424. $.ceilModel = reader.value(json.ceilModel, true);
  425. $.pads = reader.array(json.pads, Int32Array);
  426. $.countType = MNN.AvgPoolCountType[json.countType];
  427. return $;
  428. }
  429. };
  430. MNN.Pool3D = class Pool3D {
  431. static decode(reader, position) {
  432. const $ = new MNN.Pool3D();
  433. $.strides = reader.array(position, 4, Int32Array);
  434. $.kernels = reader.array(position, 6, Int32Array);
  435. $.pads = reader.array(position, 8, Int32Array);
  436. $.type = reader.int8_(position, 10, 0);
  437. $.padType = reader.int8_(position, 12, 0);
  438. $.isGlobal = reader.bool_(position, 14, false);
  439. return $;
  440. }
  441. static decodeText(reader, json) {
  442. const $ = new MNN.Pool3D();
  443. $.strides = reader.array(json.strides, Int32Array);
  444. $.kernels = reader.array(json.kernels, Int32Array);
  445. $.pads = reader.array(json.pads, Int32Array);
  446. $.type = MNN.PoolType[json.type];
  447. $.padType = MNN.PoolPadType[json.padType];
  448. $.isGlobal = reader.value(json.isGlobal, false);
  449. return $;
  450. }
  451. };
  452. MNN.Relu = class Relu {
  453. static decode(reader, position) {
  454. const $ = new MNN.Relu();
  455. $.slope = reader.float32_(position, 4, 0);
  456. return $;
  457. }
  458. static decodeText(reader, json) {
  459. const $ = new MNN.Relu();
  460. $.slope = reader.value(json.slope, 0);
  461. return $;
  462. }
  463. };
  464. MNN.Relu6 = class Relu6 {
  465. static decode(reader, position) {
  466. const $ = new MNN.Relu6();
  467. $.minValue = reader.float32_(position, 4, 0);
  468. $.maxValue = reader.float32_(position, 6, 6);
  469. return $;
  470. }
  471. static decodeText(reader, json) {
  472. const $ = new MNN.Relu6();
  473. $.minValue = reader.value(json.minValue, 0);
  474. $.maxValue = reader.value(json.maxValue, 6);
  475. return $;
  476. }
  477. };
  478. MNN.PRelu = class PRelu {
  479. static decode(reader, position) {
  480. const $ = new MNN.PRelu();
  481. $.slopeCount = reader.int32_(position, 4, 0);
  482. $.slope = reader.array(position, 6, Float32Array);
  483. return $;
  484. }
  485. static decodeText(reader, json) {
  486. const $ = new MNN.PRelu();
  487. $.slopeCount = reader.value(json.slopeCount, 0);
  488. $.slope = reader.array(json.slope, Float32Array);
  489. return $;
  490. }
  491. };
  492. MNN.ELU = class ELU {
  493. static decode(reader, position) {
  494. const $ = new MNN.ELU();
  495. $.alpha = reader.float32_(position, 4, 0);
  496. return $;
  497. }
  498. static decodeText(reader, json) {
  499. const $ = new MNN.ELU();
  500. $.alpha = reader.value(json.alpha, 0);
  501. return $;
  502. }
  503. };
  504. MNN.LRN = class LRN {
  505. static decode(reader, position) {
  506. const $ = new MNN.LRN();
  507. $.regionType = reader.int32_(position, 4, 0);
  508. $.localSize = reader.int32_(position, 6, 0);
  509. $.alpha = reader.float32_(position, 8, 0);
  510. $.beta = reader.float32_(position, 10, 0);
  511. $.bias = reader.float32_(position, 12, 1);
  512. return $;
  513. }
  514. static decodeText(reader, json) {
  515. const $ = new MNN.LRN();
  516. $.regionType = reader.value(json.regionType, 0);
  517. $.localSize = reader.value(json.localSize, 0);
  518. $.alpha = reader.value(json.alpha, 0);
  519. $.beta = reader.value(json.beta, 0);
  520. $.bias = reader.value(json.bias, 1);
  521. return $;
  522. }
  523. };
  524. MNN.ArgMax = class ArgMax {
  525. static decode(reader, position) {
  526. const $ = new MNN.ArgMax();
  527. $.outMaxVal = reader.int32_(position, 4, 0);
  528. $.topK = reader.int32_(position, 6, 0);
  529. $.axis = reader.int32_(position, 8, 0);
  530. $.softmaxThreshold = reader.int32_(position, 10, 0);
  531. return $;
  532. }
  533. static decodeText(reader, json) {
  534. const $ = new MNN.ArgMax();
  535. $.outMaxVal = reader.value(json.outMaxVal, 0);
  536. $.topK = reader.value(json.topK, 0);
  537. $.axis = reader.value(json.axis, 0);
  538. $.softmaxThreshold = reader.value(json.softmaxThreshold, 0);
  539. return $;
  540. }
  541. };
  542. MNN.Axis = class Axis {
  543. static decode(reader, position) {
  544. const $ = new MNN.Axis();
  545. $.axis = reader.int32_(position, 4, 0);
  546. return $;
  547. }
  548. static decodeText(reader, json) {
  549. const $ = new MNN.Axis();
  550. $.axis = reader.value(json.axis, 0);
  551. return $;
  552. }
  553. };
  554. MNN.Input = class Input {
  555. static decode(reader, position) {
  556. const $ = new MNN.Input();
  557. $.dims = reader.array(position, 4, Int32Array);
  558. $.dtype = reader.int32_(position, 6, 1);
  559. $.dformat = reader.int8_(position, 8, 2);
  560. return $;
  561. }
  562. static decodeText(reader, json) {
  563. const $ = new MNN.Input();
  564. $.dims = reader.array(json.dims, Int32Array);
  565. $.dtype = MNN.DataType[json.dtype];
  566. $.dformat = MNN.MNN_DATA_FORMAT[json.dformat];
  567. return $;
  568. }
  569. };
  570. MNN.LSTM = class LSTM {
  571. static decode(reader, position) {
  572. const $ = new MNN.LSTM();
  573. $.outputCount = reader.int32_(position, 4, 0);
  574. $.weightSize = reader.int32_(position, 6, 0);
  575. $.clippingThreshold = reader.float32_(position, 8, 0);
  576. $.weightI = reader.table(position, 10, MNN.Blob);
  577. $.weightH = reader.table(position, 12, MNN.Blob);
  578. $.bias = reader.table(position, 14, MNN.Blob);
  579. $.weightIQ = reader.table(position, 16, MNN.Blob);
  580. $.weightIA = reader.table(position, 18, MNN.Blob);
  581. $.quantScale = reader.float32_(position, 20, 0);
  582. return $;
  583. }
  584. static decodeText(reader, json) {
  585. const $ = new MNN.LSTM();
  586. $.outputCount = reader.value(json.outputCount, 0);
  587. $.weightSize = reader.value(json.weightSize, 0);
  588. $.clippingThreshold = reader.value(json.clippingThreshold, 0);
  589. $.weightI = reader.object(json.weightI, MNN.Blob);
  590. $.weightH = reader.object(json.weightH, MNN.Blob);
  591. $.bias = reader.object(json.bias, MNN.Blob);
  592. $.weightIQ = reader.object(json.weightIQ, MNN.Blob);
  593. $.weightIA = reader.object(json.weightIA, MNN.Blob);
  594. $.quantScale = reader.value(json.quantScale, 0);
  595. return $;
  596. }
  597. };
  598. MNN.Slice = class Slice {
  599. static decode(reader, position) {
  600. const $ = new MNN.Slice();
  601. $.axis = reader.int32_(position, 4, 0);
  602. $.slicePoints = reader.array(position, 6, Int32Array);
  603. $.sourceType = reader.int8_(position, 8, 0);
  604. return $;
  605. }
  606. static decodeText(reader, json) {
  607. const $ = new MNN.Slice();
  608. $.axis = reader.value(json.axis, 0);
  609. $.slicePoints = reader.array(json.slicePoints, Int32Array);
  610. $.sourceType = MNN.NetSource[json.sourceType];
  611. return $;
  612. }
  613. };
  614. MNN.BatchNorm = class BatchNorm {
  615. static decode(reader, position) {
  616. const $ = new MNN.BatchNorm();
  617. $.channels = reader.int32_(position, 4, 0);
  618. $.slopeData = reader.array(position, 6, Float32Array);
  619. $.meanData = reader.array(position, 8, Float32Array);
  620. $.varData = reader.array(position, 10, Float32Array);
  621. $.biasData = reader.array(position, 12, Float32Array);
  622. $.Adata = reader.array(position, 14, Float32Array);
  623. $.Bdata = reader.array(position, 16, Float32Array);
  624. $.epsilon = reader.float32_(position, 18, 0.001);
  625. return $;
  626. }
  627. static decodeText(reader, json) {
  628. const $ = new MNN.BatchNorm();
  629. $.channels = reader.value(json.channels, 0);
  630. $.slopeData = reader.array(json.slopeData, Float32Array);
  631. $.meanData = reader.array(json.meanData, Float32Array);
  632. $.varData = reader.array(json.varData, Float32Array);
  633. $.biasData = reader.array(json.biasData, Float32Array);
  634. $.Adata = reader.array(json.Adata, Float32Array);
  635. $.Bdata = reader.array(json.Bdata, Float32Array);
  636. $.epsilon = reader.value(json.epsilon, 0.001);
  637. return $;
  638. }
  639. };
  640. MNN.Scale = class Scale {
  641. static decode(reader, position) {
  642. const $ = new MNN.Scale();
  643. $.channels = reader.int32_(position, 4, 0);
  644. $.scaleData = reader.array(position, 6, Float32Array);
  645. $.biasData = reader.array(position, 8, Float32Array);
  646. $.external = reader.int64s_(position, 10);
  647. return $;
  648. }
  649. static decodeText(reader, json) {
  650. const $ = new MNN.Scale();
  651. $.channels = reader.value(json.channels, 0);
  652. $.scaleData = reader.array(json.scaleData, Float32Array);
  653. $.biasData = reader.array(json.biasData, Float32Array);
  654. $.external = reader.array(json.external);
  655. return $;
  656. }
  657. };
  658. MNN.EltwiseType = {
  659. PROD: 0,
  660. SUM: 1,
  661. MAXIMUM: 2,
  662. SUB: 3
  663. };
  664. MNN.Eltwise = class Eltwise {
  665. static decode(reader, position) {
  666. const $ = new MNN.Eltwise();
  667. $.type = reader.int8_(position, 4, 0);
  668. $.coeff = reader.array(position, 6, Float32Array);
  669. return $;
  670. }
  671. static decodeText(reader, json) {
  672. const $ = new MNN.Eltwise();
  673. $.type = MNN.EltwiseType[json.type];
  674. $.coeff = reader.array(json.coeff, Float32Array);
  675. return $;
  676. }
  677. };
  678. MNN.Flatten = class Flatten {
  679. static decode(reader, position) {
  680. const $ = new MNN.Flatten();
  681. $.axis = reader.int32_(position, 4, 0);
  682. $.endAxis = reader.int32_(position, 6, 0);
  683. return $;
  684. }
  685. static decodeText(reader, json) {
  686. const $ = new MNN.Flatten();
  687. $.axis = reader.value(json.axis, 0);
  688. $.endAxis = reader.value(json.endAxis, 0);
  689. return $;
  690. }
  691. };
  692. MNN.Permute = class Permute {
  693. static decode(reader, position) {
  694. const $ = new MNN.Permute();
  695. $.dims = reader.array(position, 4, Int32Array);
  696. return $;
  697. }
  698. static decodeText(reader, json) {
  699. const $ = new MNN.Permute();
  700. $.dims = reader.array(json.dims, Int32Array);
  701. return $;
  702. }
  703. };
  704. MNN.Reshape = class Reshape {
  705. static decode(reader, position) {
  706. const $ = new MNN.Reshape();
  707. $.dims = reader.array(position, 4, Int32Array);
  708. $.dimType = reader.int8_(position, 6, 0);
  709. return $;
  710. }
  711. static decodeText(reader, json) {
  712. const $ = new MNN.Reshape();
  713. $.dims = reader.array(json.dims, Int32Array);
  714. $.dimType = MNN.MNN_DATA_FORMAT[json.dimType];
  715. return $;
  716. }
  717. };
  718. MNN.DetectionOutput = class DetectionOutput {
  719. static decode(reader, position) {
  720. const $ = new MNN.DetectionOutput();
  721. $.classCount = reader.int32_(position, 4, 0);
  722. $.nmsThresholdold = reader.float32_(position, 6, 0);
  723. $.nmsTopK = reader.int32_(position, 8, 0);
  724. $.keepTopK = reader.int32_(position, 10, 0);
  725. $.confidenceThreshold = reader.float32_(position, 12, 0);
  726. $.shareLocation = reader.int32_(position, 14, 0);
  727. $.backgroundLable = reader.int32_(position, 16, 0);
  728. $.varianceEncodedTarget = reader.int32_(position, 18, 0);
  729. $.codeType = reader.int32_(position, 20, 0);
  730. $.objectnessScore = reader.float32_(position, 22, 0.01);
  731. return $;
  732. }
  733. static decodeText(reader, json) {
  734. const $ = new MNN.DetectionOutput();
  735. $.classCount = reader.value(json.classCount, 0);
  736. $.nmsThresholdold = reader.value(json.nmsThresholdold, 0);
  737. $.nmsTopK = reader.value(json.nmsTopK, 0);
  738. $.keepTopK = reader.value(json.keepTopK, 0);
  739. $.confidenceThreshold = reader.value(json.confidenceThreshold, 0);
  740. $.shareLocation = reader.value(json.shareLocation, 0);
  741. $.backgroundLable = reader.value(json.backgroundLable, 0);
  742. $.varianceEncodedTarget = reader.value(json.varianceEncodedTarget, 0);
  743. $.codeType = reader.value(json.codeType, 0);
  744. $.objectnessScore = reader.value(json.objectnessScore, 0.01);
  745. return $;
  746. }
  747. };
  748. MNN.RoiParameters = class RoiParameters {
  749. static decode(reader, position) {
  750. const $ = new MNN.RoiParameters();
  751. $.pooledWidth = reader.int32_(position, 4, 0);
  752. $.pooledHeight = reader.int32_(position, 6, 0);
  753. $.spatialScale = reader.float32_(position, 8, 0);
  754. $.samplingRatio = reader.int32_(position, 10, -1);
  755. $.aligned = reader.bool_(position, 12, false);
  756. $.poolType = reader.int8_(position, 14, 1);
  757. $.outputGrad = reader.bool_(position, 16, false);
  758. return $;
  759. }
  760. static decodeText(reader, json) {
  761. const $ = new MNN.RoiParameters();
  762. $.pooledWidth = reader.value(json.pooledWidth, 0);
  763. $.pooledHeight = reader.value(json.pooledHeight, 0);
  764. $.spatialScale = reader.value(json.spatialScale, 0);
  765. $.samplingRatio = reader.value(json.samplingRatio, -1);
  766. $.aligned = reader.value(json.aligned, false);
  767. $.poolType = MNN.PoolType[json.poolType];
  768. $.outputGrad = reader.value(json.outputGrad, false);
  769. return $;
  770. }
  771. };
  772. MNN.Proposal = class Proposal {
  773. static decode(reader, position) {
  774. const $ = new MNN.Proposal();
  775. $.featStride = reader.int32_(position, 4, 0);
  776. $.baseSize = reader.int32_(position, 6, 0);
  777. $.preNmsTopN = reader.int32_(position, 8, 0);
  778. $.afterNmsTopN = reader.int32_(position, 10, 0);
  779. $.nmsThreshold = reader.float32_(position, 12, 0);
  780. $.minSize = reader.int32_(position, 14, 0);
  781. $.ratios = reader.table(position, 16, MNN.Blob);
  782. $.scales = reader.table(position, 18, MNN.Blob);
  783. $.anchors = reader.table(position, 20, MNN.Blob);
  784. return $;
  785. }
  786. static decodeText(reader, json) {
  787. const $ = new MNN.Proposal();
  788. $.featStride = reader.value(json.featStride, 0);
  789. $.baseSize = reader.value(json.baseSize, 0);
  790. $.preNmsTopN = reader.value(json.preNmsTopN, 0);
  791. $.afterNmsTopN = reader.value(json.afterNmsTopN, 0);
  792. $.nmsThreshold = reader.value(json.nmsThreshold, 0);
  793. $.minSize = reader.value(json.minSize, 0);
  794. $.ratios = reader.object(json.ratios, MNN.Blob);
  795. $.scales = reader.object(json.scales, MNN.Blob);
  796. $.anchors = reader.object(json.anchors, MNN.Blob);
  797. return $;
  798. }
  799. };
  800. MNN.CoordinateTransformationMode = {
  801. NotSet: 0,
  802. AlignCorners: 1,
  803. HalfPixels: 2,
  804. PytorchHalfPixels: 3,
  805. Asymmetric: 4,
  806. TensorflowHalfPixels: 5,
  807. TensorflowCropAndResize: 6
  808. };
  809. MNN.Interp = class Interp {
  810. static decode(reader, position) {
  811. const $ = new MNN.Interp();
  812. $.widthScale = reader.float32_(position, 4, 0);
  813. $.heightScale = reader.float32_(position, 6, 0);
  814. $.outputWidth = reader.int32_(position, 8, 0);
  815. $.outputHeight = reader.int32_(position, 10, 0);
  816. $.resizeType = reader.int32_(position, 12, 0);
  817. $.alignCorners = reader.bool_(position, 14, false);
  818. $.halfPixelCenters = reader.bool_(position, 16, false);
  819. $.widthOffset = reader.float32_(position, 18, 0);
  820. $.heightOffset = reader.float32_(position, 20, 0);
  821. $.cubicCoeffA = reader.float32_(position, 22, -0.75);
  822. $.ctm = reader.int8_(position, 24, 0);
  823. $.depthScale = reader.float32_(position, 26, 0);
  824. $.outputDepth = reader.int32_(position, 28, 0);
  825. $.depthOffset = reader.float32_(position, 30, 0);
  826. return $;
  827. }
  828. static decodeText(reader, json) {
  829. const $ = new MNN.Interp();
  830. $.widthScale = reader.value(json.widthScale, 0);
  831. $.heightScale = reader.value(json.heightScale, 0);
  832. $.outputWidth = reader.value(json.outputWidth, 0);
  833. $.outputHeight = reader.value(json.outputHeight, 0);
  834. $.resizeType = reader.value(json.resizeType, 0);
  835. $.alignCorners = reader.value(json.alignCorners, false);
  836. $.halfPixelCenters = reader.value(json.halfPixelCenters, false);
  837. $.widthOffset = reader.value(json.widthOffset, 0);
  838. $.heightOffset = reader.value(json.heightOffset, 0);
  839. $.cubicCoeffA = reader.value(json.cubicCoeffA, -0.75);
  840. $.ctm = MNN.CoordinateTransformationMode[json.ctm];
  841. $.depthScale = reader.value(json.depthScale, 0);
  842. $.outputDepth = reader.value(json.outputDepth, 0);
  843. $.depthOffset = reader.value(json.depthOffset, 0);
  844. return $;
  845. }
  846. };
  847. MNN.Resize = class Resize {
  848. static decode(reader, position) {
  849. const $ = new MNN.Resize();
  850. $.xScale = reader.float32_(position, 4, 0);
  851. $.yScale = reader.float32_(position, 6, 0);
  852. return $;
  853. }
  854. static decodeText(reader, json) {
  855. const $ = new MNN.Resize();
  856. $.xScale = reader.value(json.xScale, 0);
  857. $.yScale = reader.value(json.yScale, 0);
  858. return $;
  859. }
  860. };
  861. MNN.PriorBox = class PriorBox {
  862. static decode(reader, position) {
  863. const $ = new MNN.PriorBox();
  864. $.minSizes = reader.array(position, 4, Float32Array);
  865. $.maxSizes = reader.array(position, 6, Float32Array);
  866. $.aspectRatios = reader.array(position, 8, Float32Array);
  867. $.variances = reader.array(position, 10, Float32Array);
  868. $.flip = reader.bool_(position, 12, false);
  869. $.clip = reader.bool_(position, 14, false);
  870. $.imageWidth = reader.int32_(position, 16, 0);
  871. $.imageHeight = reader.int32_(position, 18, 0);
  872. $.stepWidth = reader.int32_(position, 20, 0);
  873. $.stepHeight = reader.int32_(position, 22, 0);
  874. $.offset = reader.float32_(position, 24, 0);
  875. return $;
  876. }
  877. static decodeText(reader, json) {
  878. const $ = new MNN.PriorBox();
  879. $.minSizes = reader.array(json.minSizes, Float32Array);
  880. $.maxSizes = reader.array(json.maxSizes, Float32Array);
  881. $.aspectRatios = reader.array(json.aspectRatios, Float32Array);
  882. $.variances = reader.array(json.variances, Float32Array);
  883. $.flip = reader.value(json.flip, false);
  884. $.clip = reader.value(json.clip, false);
  885. $.imageWidth = reader.value(json.imageWidth, 0);
  886. $.imageHeight = reader.value(json.imageHeight, 0);
  887. $.stepWidth = reader.value(json.stepWidth, 0);
  888. $.stepHeight = reader.value(json.stepHeight, 0);
  889. $.offset = reader.value(json.offset, 0);
  890. return $;
  891. }
  892. };
  893. MNN.Normalize = class Normalize {
  894. static decode(reader, position) {
  895. const $ = new MNN.Normalize();
  896. $.acrossSpatial = reader.int32_(position, 4, 0);
  897. $.channelShared = reader.int32_(position, 6, 0);
  898. $.eps = reader.float32_(position, 8, 0);
  899. $.scale = reader.array(position, 10, Float32Array);
  900. return $;
  901. }
  902. static decodeText(reader, json) {
  903. const $ = new MNN.Normalize();
  904. $.acrossSpatial = reader.value(json.acrossSpatial, 0);
  905. $.channelShared = reader.value(json.channelShared, 0);
  906. $.eps = reader.value(json.eps, 0);
  907. $.scale = reader.array(json.scale, Float32Array);
  908. return $;
  909. }
  910. };
  911. MNN.EltwiseInt8 = class EltwiseInt8 {
  912. static decode(reader, position) {
  913. const $ = new MNN.EltwiseInt8();
  914. $.type = reader.int8_(position, 4, 0);
  915. $.inputQuan0 = reader.table(position, 6, MNN.QuantizedFloatParam);
  916. $.inputQuan1 = reader.table(position, 8, MNN.QuantizedFloatParam);
  917. $.outputQuan = reader.table(position, 10, MNN.QuantizedFloatParam);
  918. return $;
  919. }
  920. static decodeText(reader, json) {
  921. const $ = new MNN.EltwiseInt8();
  922. $.type = MNN.EltwiseType[json.type];
  923. $.inputQuan0 = reader.object(json.inputQuan0, MNN.QuantizedFloatParam);
  924. $.inputQuan1 = reader.object(json.inputQuan1, MNN.QuantizedFloatParam);
  925. $.outputQuan = reader.object(json.outputQuan, MNN.QuantizedFloatParam);
  926. return $;
  927. }
  928. };
  929. MNN.CumSum = class CumSum {
  930. static decode(reader, position) {
  931. const $ = new MNN.CumSum();
  932. $.exclusive = reader.bool_(position, 4, false);
  933. $.reverse = reader.bool_(position, 6, false);
  934. return $;
  935. }
  936. static decodeText(reader, json) {
  937. const $ = new MNN.CumSum();
  938. $.exclusive = reader.value(json.exclusive, false);
  939. $.reverse = reader.value(json.reverse, false);
  940. return $;
  941. }
  942. };
  943. MNN.BinaryOpOperation = {
  944. ADD: 0,
  945. SUB: 1,
  946. MUL: 2,
  947. DIV: 3,
  948. MAX_TEMP: 4,
  949. MIN_TEMP: 5,
  950. POW: 6,
  951. REALDIV: 7,
  952. MINIMUM: 8,
  953. MAXIMUM: 9,
  954. GREATER: 10,
  955. GREATER_EQUAL: 11,
  956. LESS: 12,
  957. FLOORDIV: 13,
  958. SquaredDifference: 14,
  959. EQUAL: 15,
  960. LESS_EQUAL: 16,
  961. FLOORMOD: 17,
  962. MOD: 19,
  963. ATAN2: 20,
  964. LOGICALOR: 21,
  965. NOTEQUAL: 22,
  966. BITWISE_AND: 23,
  967. BITWISE_OR: 24,
  968. BITWISE_XOR: 25,
  969. LOGICALXOR: 26,
  970. LEFTSHIFT: 27,
  971. RIGHTSHIFT: 28
  972. };
  973. MNN.BinaryOp = class BinaryOp {
  974. static decode(reader, position) {
  975. const $ = new MNN.BinaryOp();
  976. $.opType = reader.int32_(position, 4, 0);
  977. $.T = reader.int32_(position, 6, 1);
  978. $.activationType = reader.int32_(position, 8, 0);
  979. return $;
  980. }
  981. static decodeText(reader, json) {
  982. const $ = new MNN.BinaryOp();
  983. $.opType = MNN.BinaryOpOperation[json.opType];
  984. $.T = MNN.DataType[json.T];
  985. $.activationType = reader.value(json.activationType, 0);
  986. return $;
  987. }
  988. };
  989. MNN.PackParam = class PackParam {
  990. static decode(reader, position) {
  991. const $ = new MNN.PackParam();
  992. $.dataType = reader.int32_(position, 4, 0);
  993. $.axis = reader.int32_(position, 6, 0);
  994. return $;
  995. }
  996. static decodeText(reader, json) {
  997. const $ = new MNN.PackParam();
  998. $.dataType = MNN.DataType[json.dataType];
  999. $.axis = reader.value(json.axis, 0);
  1000. return $;
  1001. }
  1002. };
  1003. MNN.StridedSliceParam = class StridedSliceParam {
  1004. static decode(reader, position) {
  1005. const $ = new MNN.StridedSliceParam();
  1006. $.Index = reader.int32_(position, 4, 0);
  1007. $.T = reader.int32_(position, 6, 0);
  1008. $.beginMask = reader.int32_(position, 8, 0);
  1009. $.endMask = reader.int32_(position, 10, 0);
  1010. $.ellipsisMask = reader.int32_(position, 12, 0);
  1011. $.newAxisMask = reader.int32_(position, 14, 0);
  1012. $.shrinkAxisMask = reader.int32_(position, 16, 0);
  1013. $.fromType = reader.int32_(position, 18, 0);
  1014. return $;
  1015. }
  1016. static decodeText(reader, json) {
  1017. const $ = new MNN.StridedSliceParam();
  1018. $.Index = MNN.DataType[json.Index];
  1019. $.T = MNN.DataType[json.T];
  1020. $.beginMask = reader.value(json.beginMask, 0);
  1021. $.endMask = reader.value(json.endMask, 0);
  1022. $.ellipsisMask = reader.value(json.ellipsisMask, 0);
  1023. $.newAxisMask = reader.value(json.newAxisMask, 0);
  1024. $.shrinkAxisMask = reader.value(json.shrinkAxisMask, 0);
  1025. $.fromType = reader.value(json.fromType, 0);
  1026. return $;
  1027. }
  1028. };
  1029. MNN.SqueezeParam = class SqueezeParam {
  1030. static decode(reader, position) {
  1031. const $ = new MNN.SqueezeParam();
  1032. $.squeezeDims = reader.array(position, 4, Int32Array);
  1033. return $;
  1034. }
  1035. static decodeText(reader, json) {
  1036. const $ = new MNN.SqueezeParam();
  1037. $.squeezeDims = reader.array(json.squeezeDims, Int32Array);
  1038. return $;
  1039. }
  1040. };
  1041. MNN.CastParam = class CastParam {
  1042. static decode(reader, position) {
  1043. const $ = new MNN.CastParam();
  1044. $.srcT = reader.int32_(position, 4, 0);
  1045. $.dstT = reader.int32_(position, 6, 0);
  1046. return $;
  1047. }
  1048. static decodeText(reader, json) {
  1049. const $ = new MNN.CastParam();
  1050. $.srcT = MNN.DataType[json.srcT];
  1051. $.dstT = MNN.DataType[json.dstT];
  1052. return $;
  1053. }
  1054. };
  1055. MNN.ReductionType = {
  1056. SUM: 0,
  1057. ASUM: 1,
  1058. SUMSQ: 2,
  1059. MEAN: 3,
  1060. MAXIMUM: 4,
  1061. MINIMUM: 5,
  1062. PROD: 6,
  1063. ANY: 7,
  1064. ALL: 8
  1065. };
  1066. MNN.ReductionParam = class ReductionParam {
  1067. static decode(reader, position) {
  1068. const $ = new MNN.ReductionParam();
  1069. $.operation = reader.int8_(position, 4, 0);
  1070. $.dim = reader.array(position, 6, Int32Array);
  1071. $.coeff = reader.float32_(position, 8, 0);
  1072. $.keepDims = reader.bool_(position, 10, false);
  1073. $.dType = reader.int32_(position, 12, 1);
  1074. return $;
  1075. }
  1076. static decodeText(reader, json) {
  1077. const $ = new MNN.ReductionParam();
  1078. $.operation = MNN.ReductionType[json.operation];
  1079. $.dim = reader.array(json.dim, Int32Array);
  1080. $.coeff = reader.value(json.coeff, 0);
  1081. $.keepDims = reader.value(json.keepDims, false);
  1082. $.dType = MNN.DataType[json.dType];
  1083. return $;
  1084. }
  1085. };
  1086. MNN.Gather = class Gather {
  1087. static decode(reader, position) {
  1088. const $ = new MNN.Gather();
  1089. $.Tindices = reader.int32_(position, 4, 0);
  1090. $.Tparams = reader.int32_(position, 6, 0);
  1091. $.validateIndices = reader.bool_(position, 8, false);
  1092. $.axis = reader.int32_(position, 10, 0);
  1093. return $;
  1094. }
  1095. static decodeText(reader, json) {
  1096. const $ = new MNN.Gather();
  1097. $.Tindices = MNN.DataType[json.Tindices];
  1098. $.Tparams = MNN.DataType[json.Tparams];
  1099. $.validateIndices = reader.value(json.validateIndices, false);
  1100. $.axis = reader.value(json.axis, 0);
  1101. return $;
  1102. }
  1103. };
  1104. MNN.ExpandDims = class ExpandDims {
  1105. static decode(reader, position) {
  1106. const $ = new MNN.ExpandDims();
  1107. $.T = reader.int32_(position, 4, 0);
  1108. $.Tdim = reader.int32_(position, 6, 0);
  1109. $.axis = reader.int32_(position, 8, 0);
  1110. return $;
  1111. }
  1112. static decodeText(reader, json) {
  1113. const $ = new MNN.ExpandDims();
  1114. $.T = MNN.DataType[json.T];
  1115. $.Tdim = MNN.DataType[json.Tdim];
  1116. $.axis = reader.value(json.axis, 0);
  1117. return $;
  1118. }
  1119. };
  1120. MNN.Selu = class Selu {
  1121. static decode(reader, position) {
  1122. const $ = new MNN.Selu();
  1123. $.scale = reader.float32_(position, 4, 0);
  1124. $.alpha = reader.float32_(position, 6, 0);
  1125. return $;
  1126. }
  1127. static decodeText(reader, json) {
  1128. const $ = new MNN.Selu();
  1129. $.scale = reader.value(json.scale, 0);
  1130. $.alpha = reader.value(json.alpha, 0);
  1131. return $;
  1132. }
  1133. };
  1134. MNN.AsString = class AsString {
  1135. static decode(reader, position) {
  1136. const $ = new MNN.AsString();
  1137. $.T = reader.int32_(position, 4, 0);
  1138. $.precision = reader.int32_(position, 6, 0);
  1139. $.scientific = reader.bool_(position, 8, false);
  1140. $.shortest = reader.bool_(position, 10, false);
  1141. $.width = reader.int32_(position, 12, 0);
  1142. $.fillString = reader.string_(position, 14, null);
  1143. return $;
  1144. }
  1145. static decodeText(reader, json) {
  1146. const $ = new MNN.AsString();
  1147. $.T = MNN.DataType[json.T];
  1148. $.precision = reader.value(json.precision, 0);
  1149. $.scientific = reader.value(json.scientific, false);
  1150. $.shortest = reader.value(json.shortest, false);
  1151. $.width = reader.value(json.width, 0);
  1152. $.fillString = reader.value(json.fillString, null);
  1153. return $;
  1154. }
  1155. };
  1156. MNN.ReduceJoin = class ReduceJoin {
  1157. static decode(reader, position) {
  1158. const $ = new MNN.ReduceJoin();
  1159. $.keepDims = reader.bool_(position, 4, false);
  1160. $.separator = reader.string_(position, 6, null);
  1161. return $;
  1162. }
  1163. static decodeText(reader, json) {
  1164. const $ = new MNN.ReduceJoin();
  1165. $.keepDims = reader.value(json.keepDims, false);
  1166. $.separator = reader.value(json.separator, null);
  1167. return $;
  1168. }
  1169. };
  1170. MNN.UnaryOpOperation = {
  1171. ABS: 0,
  1172. NEG: 1,
  1173. FLOOR: 2,
  1174. CEIL: 3,
  1175. SQUARE: 4,
  1176. SQRT: 5,
  1177. RSQRT: 6,
  1178. EXP: 7,
  1179. LOG: 8,
  1180. SIN: 9,
  1181. COS: 10,
  1182. TAN: 11,
  1183. ASIN: 12,
  1184. ACOS: 13,
  1185. ATAN: 14,
  1186. RECIPROCAL: 15,
  1187. LOG1P: 16,
  1188. BNLL: 17,
  1189. ACOSH: 18,
  1190. SINH: 19,
  1191. ASINH: 20,
  1192. ATANH: 21,
  1193. SIGN: 22,
  1194. ROUND: 23,
  1195. COSH: 24,
  1196. ERF: 25,
  1197. ERFC: 26,
  1198. ERFINV: 27,
  1199. EXPM1: 28,
  1200. SIGMOID: 29,
  1201. TANH: 30,
  1202. HARDSWISH: 31,
  1203. GELU: 32,
  1204. GELU_STANDARD: 33,
  1205. SILU: 34
  1206. };
  1207. MNN.UnaryOp = class UnaryOp {
  1208. static decode(reader, position) {
  1209. const $ = new MNN.UnaryOp();
  1210. $.opType = reader.int32_(position, 4, 0);
  1211. $.T = reader.int32_(position, 6, 0);
  1212. $.tableInt8 = reader.array(position, 8, Int8Array);
  1213. return $;
  1214. }
  1215. static decodeText(reader, json) {
  1216. const $ = new MNN.UnaryOp();
  1217. $.opType = MNN.UnaryOpOperation[json.opType];
  1218. $.T = MNN.DataType[json.T];
  1219. $.tableInt8 = reader.array(json.tableInt8, Int8Array);
  1220. return $;
  1221. }
  1222. };
  1223. MNN.TopKV2 = class TopKV2 {
  1224. static decode(reader, position) {
  1225. const $ = new MNN.TopKV2();
  1226. $.T = reader.int32_(position, 4, 1);
  1227. $.sorted = reader.bool_(position, 6, false);
  1228. $.largest = reader.bool_(position, 8, true);
  1229. return $;
  1230. }
  1231. static decodeText(reader, json) {
  1232. const $ = new MNN.TopKV2();
  1233. $.T = MNN.DataType[json.T];
  1234. $.sorted = reader.value(json.sorted, false);
  1235. $.largest = reader.value(json.largest, true);
  1236. return $;
  1237. }
  1238. };
  1239. MNN.CropAndResizeMethod = {
  1240. BILINEAR: 0,
  1241. NEAREST: 1
  1242. };
  1243. MNN.CropAndResize = class CropAndResize {
  1244. static decode(reader, position) {
  1245. const $ = new MNN.CropAndResize();
  1246. $.extrapolationValue = reader.float32_(position, 4, 0);
  1247. $.method = reader.int8_(position, 6, 0);
  1248. return $;
  1249. }
  1250. static decodeText(reader, json) {
  1251. const $ = new MNN.CropAndResize();
  1252. $.extrapolationValue = reader.value(json.extrapolationValue, 0);
  1253. $.method = MNN.CropAndResizeMethod[json.method];
  1254. return $;
  1255. }
  1256. };
  1257. MNN.Fill = class Fill {
  1258. static decode(/* reader, position */) {
  1259. const $ = new MNN.Fill();
  1260. return $;
  1261. }
  1262. static decodeText(/* reader, json */) {
  1263. const $ = new MNN.Fill();
  1264. return $;
  1265. }
  1266. };
  1267. MNN.GatherV2 = class GatherV2 {
  1268. static decode(reader, position) {
  1269. const $ = new MNN.GatherV2();
  1270. $.Taxis = reader.int32_(position, 4, 0);
  1271. $.Tindices = reader.int32_(position, 6, 0);
  1272. $.Tparams = reader.int32_(position, 8, 0);
  1273. return $;
  1274. }
  1275. static decodeText(reader, json) {
  1276. const $ = new MNN.GatherV2();
  1277. $.Taxis = MNN.DataType[json.Taxis];
  1278. $.Tindices = MNN.DataType[json.Tindices];
  1279. $.Tparams = MNN.DataType[json.Tparams];
  1280. return $;
  1281. }
  1282. };
  1283. MNN.NonMaxSuppressionV2 = class NonMaxSuppressionV2 {
  1284. static decode(/* reader, position */) {
  1285. const $ = new MNN.NonMaxSuppressionV2();
  1286. return $;
  1287. }
  1288. static decodeText(/* reader, json */) {
  1289. const $ = new MNN.NonMaxSuppressionV2();
  1290. return $;
  1291. }
  1292. };
  1293. MNN.Range = class Range {
  1294. static decode(reader, position) {
  1295. const $ = new MNN.Range();
  1296. $.Tidx = reader.int32_(position, 4, 0);
  1297. return $;
  1298. }
  1299. static decodeText(reader, json) {
  1300. const $ = new MNN.Range();
  1301. $.Tidx = MNN.DataType[json.Tidx];
  1302. return $;
  1303. }
  1304. };
  1305. MNN.Rank = class Rank {
  1306. static decode(/* reader, position */) {
  1307. const $ = new MNN.Rank();
  1308. return $;
  1309. }
  1310. static decodeText(/* reader, json */) {
  1311. const $ = new MNN.Rank();
  1312. return $;
  1313. }
  1314. };
  1315. MNN.Size = class Size {
  1316. static decode(reader, position) {
  1317. const $ = new MNN.Size();
  1318. $.outputDataType = reader.int32_(position, 4, 0);
  1319. return $;
  1320. }
  1321. static decodeText(reader, json) {
  1322. const $ = new MNN.Size();
  1323. $.outputDataType = MNN.DataType[json.outputDataType];
  1324. return $;
  1325. }
  1326. };
  1327. MNN.Transpose = class Transpose {
  1328. static decode(reader, position) {
  1329. const $ = new MNN.Transpose();
  1330. $.Tperm = reader.int32_(position, 4, 0);
  1331. return $;
  1332. }
  1333. static decodeText(reader, json) {
  1334. const $ = new MNN.Transpose();
  1335. $.Tperm = MNN.DataType[json.Tperm];
  1336. return $;
  1337. }
  1338. };
  1339. MNN.SliceTf = class SliceTf {
  1340. static decode(reader, position) {
  1341. const $ = new MNN.SliceTf();
  1342. $.T = reader.int32_(position, 4, 0);
  1343. return $;
  1344. }
  1345. static decodeText(reader, json) {
  1346. const $ = new MNN.SliceTf();
  1347. $.T = MNN.DataType[json.T];
  1348. return $;
  1349. }
  1350. };
  1351. MNN.QuantizeMaxMin = class QuantizeMaxMin {
  1352. static decode(reader, position) {
  1353. const $ = new MNN.QuantizeMaxMin();
  1354. $.T = reader.int32_(position, 4, 0);
  1355. return $;
  1356. }
  1357. static decodeText(reader, json) {
  1358. const $ = new MNN.QuantizeMaxMin();
  1359. $.T = MNN.DataType[json.T];
  1360. return $;
  1361. }
  1362. };
  1363. MNN.Crop = class Crop {
  1364. static decode(reader, position) {
  1365. const $ = new MNN.Crop();
  1366. $.axis = reader.int32_(position, 4, 2);
  1367. $.offset = reader.array(position, 6, Int32Array);
  1368. return $;
  1369. }
  1370. static decodeText(reader, json) {
  1371. const $ = new MNN.Crop();
  1372. $.axis = reader.value(json.axis, 2);
  1373. $.offset = reader.array(json.offset, Int32Array);
  1374. return $;
  1375. }
  1376. };
  1377. MNN.SpaceBatch = class SpaceBatch {
  1378. static decode(reader, position) {
  1379. const $ = new MNN.SpaceBatch();
  1380. $.blockShape = reader.table(position, 4, MNN.Blob);
  1381. $.padding = reader.table(position, 6, MNN.Blob);
  1382. return $;
  1383. }
  1384. static decodeText(reader, json) {
  1385. const $ = new MNN.SpaceBatch();
  1386. $.blockShape = reader.object(json.blockShape, MNN.Blob);
  1387. $.padding = reader.object(json.padding, MNN.Blob);
  1388. return $;
  1389. }
  1390. };
  1391. MNN.MatMul = class MatMul {
  1392. static decode(reader, position) {
  1393. const $ = new MNN.MatMul();
  1394. $.T = reader.int32_(position, 4, 0);
  1395. $.transposeA = reader.bool_(position, 6, false);
  1396. $.transposeB = reader.bool_(position, 8, false);
  1397. $.weight = reader.array(position, 10, Float32Array);
  1398. $.bias = reader.array(position, 12, Float32Array);
  1399. return $;
  1400. }
  1401. static decodeText(reader, json) {
  1402. const $ = new MNN.MatMul();
  1403. $.T = MNN.DataType[json.T];
  1404. $.transposeA = reader.value(json.transposeA, false);
  1405. $.transposeB = reader.value(json.transposeB, false);
  1406. $.weight = reader.array(json.weight, Float32Array);
  1407. $.bias = reader.array(json.bias, Float32Array);
  1408. return $;
  1409. }
  1410. };
  1411. MNN.MomentsParam = class MomentsParam {
  1412. static decode(reader, position) {
  1413. const $ = new MNN.MomentsParam();
  1414. $.dim = reader.array(position, 4, Int32Array);
  1415. $.keepDims = reader.bool_(position, 6, true);
  1416. $.dType = reader.int32_(position, 8, 1);
  1417. return $;
  1418. }
  1419. static decodeText(reader, json) {
  1420. const $ = new MNN.MomentsParam();
  1421. $.dim = reader.array(json.dim, Int32Array);
  1422. $.keepDims = reader.value(json.keepDims, true);
  1423. $.dType = MNN.DataType[json.dType];
  1424. return $;
  1425. }
  1426. };
  1427. MNN.RNNParam = class RNNParam {
  1428. static decode(reader, position) {
  1429. const $ = new MNN.RNNParam();
  1430. $.numUnits = reader.int32_(position, 4, 0);
  1431. $.isBidirectionalRNN = reader.bool_(position, 6, false);
  1432. $.linearBeforeReset = reader.bool_(position, 8, false);
  1433. $.keepAllOutputs = reader.bool_(position, 10, false);
  1434. $.fwGateWeight = reader.table(position, 12, MNN.Blob);
  1435. $.fwGateBias = reader.table(position, 14, MNN.Blob);
  1436. $.fwCandidateWeight = reader.table(position, 16, MNN.Blob);
  1437. $.fwCandidateBias = reader.table(position, 18, MNN.Blob);
  1438. $.fwRecurrentBias = reader.table(position, 20, MNN.Blob);
  1439. $.bwGateWeight = reader.table(position, 22, MNN.Blob);
  1440. $.bwGateBias = reader.table(position, 24, MNN.Blob);
  1441. $.bwCandidateWeight = reader.table(position, 26, MNN.Blob);
  1442. $.bwCandidateBias = reader.table(position, 28, MNN.Blob);
  1443. $.bwRecurrentBias = reader.table(position, 30, MNN.Blob);
  1444. return $;
  1445. }
  1446. static decodeText(reader, json) {
  1447. const $ = new MNN.RNNParam();
  1448. $.numUnits = reader.value(json.numUnits, 0);
  1449. $.isBidirectionalRNN = reader.value(json.isBidirectionalRNN, false);
  1450. $.linearBeforeReset = reader.value(json.linearBeforeReset, false);
  1451. $.keepAllOutputs = reader.value(json.keepAllOutputs, false);
  1452. $.fwGateWeight = reader.object(json.fwGateWeight, MNN.Blob);
  1453. $.fwGateBias = reader.object(json.fwGateBias, MNN.Blob);
  1454. $.fwCandidateWeight = reader.object(json.fwCandidateWeight, MNN.Blob);
  1455. $.fwCandidateBias = reader.object(json.fwCandidateBias, MNN.Blob);
  1456. $.fwRecurrentBias = reader.object(json.fwRecurrentBias, MNN.Blob);
  1457. $.bwGateWeight = reader.object(json.bwGateWeight, MNN.Blob);
  1458. $.bwGateBias = reader.object(json.bwGateBias, MNN.Blob);
  1459. $.bwCandidateWeight = reader.object(json.bwCandidateWeight, MNN.Blob);
  1460. $.bwCandidateBias = reader.object(json.bwCandidateBias, MNN.Blob);
  1461. $.bwRecurrentBias = reader.object(json.bwRecurrentBias, MNN.Blob);
  1462. return $;
  1463. }
  1464. };
  1465. MNN.BatchMatMulParam = class BatchMatMulParam {
  1466. static decode(reader, position) {
  1467. const $ = new MNN.BatchMatMulParam();
  1468. $.adjX = reader.bool_(position, 4, false);
  1469. $.adjY = reader.bool_(position, 6, false);
  1470. return $;
  1471. }
  1472. static decodeText(reader, json) {
  1473. const $ = new MNN.BatchMatMulParam();
  1474. $.adjX = reader.value(json.adjX, false);
  1475. $.adjY = reader.value(json.adjY, false);
  1476. return $;
  1477. }
  1478. };
  1479. MNN.DepthToSpaceMode = {
  1480. DCR: 0,
  1481. CRD: 1
  1482. };
  1483. MNN.DepthSpaceParam = class DepthSpaceParam {
  1484. static decode(reader, position) {
  1485. const $ = new MNN.DepthSpaceParam();
  1486. $.blockSize = reader.int32_(position, 4, 0);
  1487. $.mode = reader.int8_(position, 6, 0);
  1488. return $;
  1489. }
  1490. static decodeText(reader, json) {
  1491. const $ = new MNN.DepthSpaceParam();
  1492. $.blockSize = reader.value(json.blockSize, 0);
  1493. $.mode = MNN.DepthToSpaceMode[json.mode];
  1494. return $;
  1495. }
  1496. };
  1497. MNN.ReverseSequenceParam = class ReverseSequenceParam {
  1498. static decode(reader, position) {
  1499. const $ = new MNN.ReverseSequenceParam();
  1500. $.batchDim = reader.int32_(position, 4, 0);
  1501. $.seqDim = reader.int32_(position, 6, 0);
  1502. return $;
  1503. }
  1504. static decodeText(reader, json) {
  1505. const $ = new MNN.ReverseSequenceParam();
  1506. $.batchDim = reader.value(json.batchDim, 0);
  1507. $.seqDim = reader.value(json.seqDim, 0);
  1508. return $;
  1509. }
  1510. };
  1511. MNN.DetectionPostProcessParam = class DetectionPostProcessParam {
  1512. static decode(reader, position) {
  1513. const $ = new MNN.DetectionPostProcessParam();
  1514. $.maxDetections = reader.int32_(position, 4, 0);
  1515. $.maxClassesPerDetection = reader.int32_(position, 6, 0);
  1516. $.detectionsPerClass = reader.int32_(position, 8, 0);
  1517. $.nmsScoreThreshold = reader.float32_(position, 10, 0);
  1518. $.iouThreshold = reader.float32_(position, 12, 0);
  1519. $.numClasses = reader.int32_(position, 14, 0);
  1520. $.useRegularNMS = reader.bool_(position, 16, false);
  1521. $.centerSizeEncoding = reader.array(position, 18, Float32Array);
  1522. return $;
  1523. }
  1524. static decodeText(reader, json) {
  1525. const $ = new MNN.DetectionPostProcessParam();
  1526. $.maxDetections = reader.value(json.maxDetections, 0);
  1527. $.maxClassesPerDetection = reader.value(json.maxClassesPerDetection, 0);
  1528. $.detectionsPerClass = reader.value(json.detectionsPerClass, 0);
  1529. $.nmsScoreThreshold = reader.value(json.nmsScoreThreshold, 0);
  1530. $.iouThreshold = reader.value(json.iouThreshold, 0);
  1531. $.numClasses = reader.value(json.numClasses, 0);
  1532. $.useRegularNMS = reader.value(json.useRegularNMS, false);
  1533. $.centerSizeEncoding = reader.array(json.centerSizeEncoding, Float32Array);
  1534. return $;
  1535. }
  1536. };
  1537. MNN.OneHotParam = class OneHotParam {
  1538. static decode(reader, position) {
  1539. const $ = new MNN.OneHotParam();
  1540. $.dType = reader.int32_(position, 4, 1);
  1541. $.axis = reader.int32_(position, 6, -1);
  1542. return $;
  1543. }
  1544. static decodeText(reader, json) {
  1545. const $ = new MNN.OneHotParam();
  1546. $.dType = MNN.DataType[json.dType];
  1547. $.axis = reader.value(json.axis, -1);
  1548. return $;
  1549. }
  1550. };
  1551. MNN.PadValueMode = {
  1552. CONSTANT: 0,
  1553. REFLECT: 1,
  1554. SYMMETRIC: 2,
  1555. EDGE: 3
  1556. };
  1557. MNN.PadParam = class PadParam {
  1558. static decode(reader, position) {
  1559. const $ = new MNN.PadParam();
  1560. $.mode = reader.int8_(position, 4, 0);
  1561. return $;
  1562. }
  1563. static decodeText(reader, json) {
  1564. const $ = new MNN.PadParam();
  1565. $.mode = MNN.PadValueMode[json.mode];
  1566. return $;
  1567. }
  1568. };
  1569. MNN.LayerNorm = class LayerNorm {
  1570. static decode(reader, position) {
  1571. const $ = new MNN.LayerNorm();
  1572. $.axis = reader.array(position, 4, Int32Array);
  1573. $.epsilon = reader.float32_(position, 6, 0);
  1574. $.gamma = reader.array(position, 8, Float32Array);
  1575. $.beta = reader.array(position, 10, Float32Array);
  1576. $.group = reader.int32_(position, 12, 1);
  1577. $.external = reader.int64s_(position, 14);
  1578. $.useRMSNorm = reader.bool_(position, 16, false);
  1579. return $;
  1580. }
  1581. static decodeText(reader, json) {
  1582. const $ = new MNN.LayerNorm();
  1583. $.axis = reader.array(json.axis, Int32Array);
  1584. $.epsilon = reader.value(json.epsilon, 0);
  1585. $.gamma = reader.array(json.gamma, Float32Array);
  1586. $.beta = reader.array(json.beta, Float32Array);
  1587. $.group = reader.value(json.group, 1);
  1588. $.external = reader.array(json.external);
  1589. $.useRMSNorm = reader.value(json.useRMSNorm, false);
  1590. return $;
  1591. }
  1592. };
  1593. MNN.GroupNorm = class GroupNorm {
  1594. static decode(reader, position) {
  1595. const $ = new MNN.GroupNorm();
  1596. $.axis = reader.int32_(position, 4, 0);
  1597. $.epsilon = reader.float32_(position, 6, 0);
  1598. $.gamma = reader.array(position, 8, Float32Array);
  1599. $.beta = reader.array(position, 10, Float32Array);
  1600. $.group = reader.int32_(position, 12, 1);
  1601. $.bSwish = reader.int32_(position, 14, 0);
  1602. $.external = reader.int64s_(position, 16);
  1603. return $;
  1604. }
  1605. static decodeText(reader, json) {
  1606. const $ = new MNN.GroupNorm();
  1607. $.axis = reader.value(json.axis, 0);
  1608. $.epsilon = reader.value(json.epsilon, 0);
  1609. $.gamma = reader.array(json.gamma, Float32Array);
  1610. $.beta = reader.array(json.beta, Float32Array);
  1611. $.group = reader.value(json.group, 1);
  1612. $.bSwish = reader.value(json.bSwish, 0);
  1613. $.external = reader.array(json.external);
  1614. return $;
  1615. }
  1616. };
  1617. MNN.RandomUniform = class RandomUniform {
  1618. static decode(reader, position) {
  1619. const $ = new MNN.RandomUniform();
  1620. $.seed = reader.int32_(position, 4, 0);
  1621. $.seed2 = reader.int32_(position, 6, 0);
  1622. $.type = reader.int32_(position, 8, 1);
  1623. $.low = reader.float32_(position, 10, 0);
  1624. $.high = reader.float32_(position, 12, 1);
  1625. return $;
  1626. }
  1627. static decodeText(reader, json) {
  1628. const $ = new MNN.RandomUniform();
  1629. $.seed = reader.value(json.seed, 0);
  1630. $.seed2 = reader.value(json.seed2, 0);
  1631. $.type = MNN.DataType[json.type];
  1632. $.low = reader.value(json.low, 0);
  1633. $.high = reader.value(json.high, 1);
  1634. return $;
  1635. }
  1636. };
  1637. MNN.TensorArray = class TensorArray {
  1638. static decode(reader, position) {
  1639. const $ = new MNN.TensorArray();
  1640. $.dynamic_size = reader.bool_(position, 4, false);
  1641. $.identical_element_shapes = reader.bool_(position, 6, false);
  1642. $.element_shape = reader.array(position, 8, Int32Array);
  1643. $.T = reader.int32_(position, 10, 1);
  1644. $.axis = reader.int32_(position, 12, 0);
  1645. $.keepdims = reader.bool_(position, 14, true);
  1646. $.new_axis = reader.bool_(position, 16, false);
  1647. return $;
  1648. }
  1649. static decodeText(reader, json) {
  1650. const $ = new MNN.TensorArray();
  1651. $.dynamic_size = reader.value(json.dynamic_size, false);
  1652. $.identical_element_shapes = reader.value(json.identical_element_shapes, false);
  1653. $.element_shape = reader.array(json.element_shape, Int32Array);
  1654. $.T = MNN.DataType[json.T];
  1655. $.axis = reader.value(json.axis, 0);
  1656. $.keepdims = reader.value(json.keepdims, true);
  1657. $.new_axis = reader.value(json.new_axis, false);
  1658. return $;
  1659. }
  1660. };
  1661. MNN.LSTMBlockCell = class LSTMBlockCell {
  1662. static decode(reader, position) {
  1663. const $ = new MNN.LSTMBlockCell();
  1664. $.cell_clip = reader.float32_(position, 4, 3);
  1665. $.forget_bias = reader.float32_(position, 6, 1);
  1666. $.use_peephole = reader.bool_(position, 8, false);
  1667. return $;
  1668. }
  1669. static decodeText(reader, json) {
  1670. const $ = new MNN.LSTMBlockCell();
  1671. $.cell_clip = reader.value(json.cell_clip, 3);
  1672. $.forget_bias = reader.value(json.forget_bias, 1);
  1673. $.use_peephole = reader.value(json.use_peephole, false);
  1674. return $;
  1675. }
  1676. };
  1677. MNN.FusedActivation = {
  1678. kTfLiteActNone: 0,
  1679. kTfLiteActRelu: 1,
  1680. kTfLiteActRelu1: 2,
  1681. kTfLiteActRelu6: 3,
  1682. kTfLiteActTanh: 4,
  1683. kTfLiteActSignBit: 5,
  1684. kTfLiteActSigmoid: 6
  1685. };
  1686. MNN.QuantizedParam = class QuantizedParam {
  1687. static decode(reader, position) {
  1688. const $ = new MNN.QuantizedParam();
  1689. $.zeroPoint = reader.int32_(position, 4, 0);
  1690. $.scale = reader.float32_(position, 6, 0);
  1691. return $;
  1692. }
  1693. static decodeText(reader, json) {
  1694. const $ = new MNN.QuantizedParam();
  1695. $.zeroPoint = reader.value(json.zeroPoint, 0);
  1696. $.scale = reader.value(json.scale, 0);
  1697. return $;
  1698. }
  1699. };
  1700. MNN.QuantizedAdd = class QuantizedAdd {
  1701. static decode(reader, position) {
  1702. const $ = new MNN.QuantizedAdd();
  1703. $.activationType = reader.int8_(position, 4, 0);
  1704. $.input1QuantizedParam = reader.table(position, 6, MNN.QuantizedParam);
  1705. $.input2QuantizedParam = reader.table(position, 8, MNN.QuantizedParam);
  1706. $.outputQuantizedParam = reader.table(position, 10, MNN.QuantizedParam);
  1707. return $;
  1708. }
  1709. static decodeText(reader, json) {
  1710. const $ = new MNN.QuantizedAdd();
  1711. $.activationType = MNN.FusedActivation[json.activationType];
  1712. $.input1QuantizedParam = reader.object(json.input1QuantizedParam, MNN.QuantizedParam);
  1713. $.input2QuantizedParam = reader.object(json.input2QuantizedParam, MNN.QuantizedParam);
  1714. $.outputQuantizedParam = reader.object(json.outputQuantizedParam, MNN.QuantizedParam);
  1715. return $;
  1716. }
  1717. };
  1718. MNN.ModeFormat = {
  1719. TENSORFLOW: 0,
  1720. TFLITE: 1
  1721. };
  1722. MNN.QuantizeMode = {
  1723. MIN_COMBINED: 0,
  1724. MIN_FIRST: 1,
  1725. SCALED: 2
  1726. };
  1727. MNN.Dequantize = class Dequantize {
  1728. static decode(reader, position) {
  1729. const $ = new MNN.Dequantize();
  1730. $.inputQuantizedParam = reader.table(position, 4, MNN.QuantizedParam);
  1731. $.mode = reader.int8_(position, 6, 0);
  1732. $.modelFormat = reader.int8_(position, 8, 0);
  1733. $.type = reader.int32_(position, 10, 0);
  1734. return $;
  1735. }
  1736. static decodeText(reader, json) {
  1737. const $ = new MNN.Dequantize();
  1738. $.inputQuantizedParam = reader.object(json.inputQuantizedParam, MNN.QuantizedParam);
  1739. $.mode = MNN.QuantizeMode[json.mode];
  1740. $.modelFormat = MNN.ModeFormat[json.modelFormat];
  1741. $.type = MNN.DataType[json.type];
  1742. return $;
  1743. }
  1744. };
  1745. MNN.QuantizedAvgPool = class QuantizedAvgPool {
  1746. static decode(reader, position) {
  1747. const $ = new MNN.QuantizedAvgPool();
  1748. $.kernelX = reader.int32_(position, 4, 0);
  1749. $.kernelY = reader.int32_(position, 6, 0);
  1750. $.modelFormat = reader.int8_(position, 8, 0);
  1751. $.outputActivationMax = reader.int32_(position, 10, 0);
  1752. $.outputActivationMin = reader.int32_(position, 12, 0);
  1753. $.padType = reader.int8_(position, 14, 0);
  1754. $.padX = reader.int32_(position, 16, 0);
  1755. $.padY = reader.int32_(position, 18, 0);
  1756. $.strideX = reader.int32_(position, 20, 0);
  1757. $.strideY = reader.int32_(position, 22, 0);
  1758. $.type = reader.int32_(position, 24, 0);
  1759. return $;
  1760. }
  1761. static decodeText(reader, json) {
  1762. const $ = new MNN.QuantizedAvgPool();
  1763. $.kernelX = reader.value(json.kernelX, 0);
  1764. $.kernelY = reader.value(json.kernelY, 0);
  1765. $.modelFormat = MNN.ModeFormat[json.modelFormat];
  1766. $.outputActivationMax = reader.value(json.outputActivationMax, 0);
  1767. $.outputActivationMin = reader.value(json.outputActivationMin, 0);
  1768. $.padType = MNN.PoolPadType[json.padType];
  1769. $.padX = reader.value(json.padX, 0);
  1770. $.padY = reader.value(json.padY, 0);
  1771. $.strideX = reader.value(json.strideX, 0);
  1772. $.strideY = reader.value(json.strideY, 0);
  1773. $.type = MNN.DataType[json.type];
  1774. return $;
  1775. }
  1776. };
  1777. MNN.QuantizedBiasAdd = class QuantizedBiasAdd {
  1778. static decode(reader, position) {
  1779. const $ = new MNN.QuantizedBiasAdd();
  1780. $.bias = reader.array(position, 4, Int32Array);
  1781. $.inputType = reader.int32_(position, 6, 0);
  1782. $.max = reader.int32_(position, 8, 0);
  1783. $.min = reader.int32_(position, 10, 0);
  1784. $.outputType = reader.int32_(position, 12, 0);
  1785. return $;
  1786. }
  1787. static decodeText(reader, json) {
  1788. const $ = new MNN.QuantizedBiasAdd();
  1789. $.bias = reader.array(json.bias, Int32Array);
  1790. $.inputType = MNN.DataType[json.inputType];
  1791. $.max = reader.value(json.max, 0);
  1792. $.min = reader.value(json.min, 0);
  1793. $.outputType = MNN.DataType[json.outputType];
  1794. return $;
  1795. }
  1796. };
  1797. MNN.QuantizedConcat = class QuantizedConcat {
  1798. static decode(reader, position) {
  1799. const $ = new MNN.QuantizedConcat();
  1800. $.activationType = reader.int8_(position, 4, 0);
  1801. $.axis = reader.int32_(position, 6, 0);
  1802. $.inputScale = reader.array(position, 8, Float32Array);
  1803. $.inputZeroPoint = reader.array(position, 10, Int32Array);
  1804. $.outputQuantizedParam = reader.table(position, 12, MNN.QuantizedParam);
  1805. return $;
  1806. }
  1807. static decodeText(reader, json) {
  1808. const $ = new MNN.QuantizedConcat();
  1809. $.activationType = MNN.FusedActivation[json.activationType];
  1810. $.axis = reader.value(json.axis, 0);
  1811. $.inputScale = reader.array(json.inputScale, Float32Array);
  1812. $.inputZeroPoint = reader.array(json.inputZeroPoint, Int32Array);
  1813. $.outputQuantizedParam = reader.object(json.outputQuantizedParam, MNN.QuantizedParam);
  1814. return $;
  1815. }
  1816. };
  1817. MNN.QuantizedLogistic = class QuantizedLogistic {
  1818. static decode(reader, position) {
  1819. const $ = new MNN.QuantizedLogistic();
  1820. $.inputQuantizedParam = reader.table(position, 4, MNN.QuantizedParam);
  1821. $.outputQuantizedParam = reader.table(position, 6, MNN.QuantizedParam);
  1822. return $;
  1823. }
  1824. static decodeText(reader, json) {
  1825. const $ = new MNN.QuantizedLogistic();
  1826. $.inputQuantizedParam = reader.object(json.inputQuantizedParam, MNN.QuantizedParam);
  1827. $.outputQuantizedParam = reader.object(json.outputQuantizedParam, MNN.QuantizedParam);
  1828. return $;
  1829. }
  1830. };
  1831. MNN.QuantizedMatMul = class QuantizedMatMul {
  1832. static decode(reader, position) {
  1833. const $ = new MNN.QuantizedMatMul();
  1834. $.transposeA = reader.bool_(position, 4, false);
  1835. $.transposeB = reader.bool_(position, 6, false);
  1836. return $;
  1837. }
  1838. static decodeText(reader, json) {
  1839. const $ = new MNN.QuantizedMatMul();
  1840. $.transposeA = reader.value(json.transposeA, false);
  1841. $.transposeB = reader.value(json.transposeB, false);
  1842. return $;
  1843. }
  1844. };
  1845. MNN.QuantizedMaxPool = class QuantizedMaxPool {
  1846. static decode(reader, position) {
  1847. const $ = new MNN.QuantizedMaxPool();
  1848. $.kernelX = reader.int32_(position, 4, 0);
  1849. $.kernelY = reader.int32_(position, 6, 0);
  1850. $.modelFormat = reader.int8_(position, 8, 0);
  1851. $.outputActivationMax = reader.int32_(position, 10, 0);
  1852. $.outputActivationMin = reader.int32_(position, 12, 0);
  1853. $.padType = reader.int8_(position, 14, 0);
  1854. $.padX = reader.int32_(position, 16, 0);
  1855. $.padY = reader.int32_(position, 18, 0);
  1856. $.strideX = reader.int32_(position, 20, 0);
  1857. $.strideY = reader.int32_(position, 22, 0);
  1858. $.type = reader.int32_(position, 24, 0);
  1859. return $;
  1860. }
  1861. static decodeText(reader, json) {
  1862. const $ = new MNN.QuantizedMaxPool();
  1863. $.kernelX = reader.value(json.kernelX, 0);
  1864. $.kernelY = reader.value(json.kernelY, 0);
  1865. $.modelFormat = MNN.ModeFormat[json.modelFormat];
  1866. $.outputActivationMax = reader.value(json.outputActivationMax, 0);
  1867. $.outputActivationMin = reader.value(json.outputActivationMin, 0);
  1868. $.padType = MNN.PoolPadType[json.padType];
  1869. $.padX = reader.value(json.padX, 0);
  1870. $.padY = reader.value(json.padY, 0);
  1871. $.strideX = reader.value(json.strideX, 0);
  1872. $.strideY = reader.value(json.strideY, 0);
  1873. $.type = MNN.DataType[json.type];
  1874. return $;
  1875. }
  1876. };
  1877. MNN.QuantizedRelu = class QuantizedRelu {
  1878. static decode(reader, position) {
  1879. const $ = new MNN.QuantizedRelu();
  1880. $.type = reader.int32_(position, 4, 0);
  1881. return $;
  1882. }
  1883. static decodeText(reader, json) {
  1884. const $ = new MNN.QuantizedRelu();
  1885. $.type = MNN.DataType[json.type];
  1886. return $;
  1887. }
  1888. };
  1889. MNN.QuantizedRelu6 = class QuantizedRelu6 {
  1890. static decode(reader, position) {
  1891. const $ = new MNN.QuantizedRelu6();
  1892. $.type = reader.int32_(position, 4, 0);
  1893. return $;
  1894. }
  1895. static decodeText(reader, json) {
  1896. const $ = new MNN.QuantizedRelu6();
  1897. $.type = MNN.DataType[json.type];
  1898. return $;
  1899. }
  1900. };
  1901. MNN.QuantizedReshape = class QuantizedReshape {
  1902. static decode(reader, position) {
  1903. const $ = new MNN.QuantizedReshape();
  1904. $.dims = reader.array(position, 4, Int32Array);
  1905. $.modelFormat = reader.int8_(position, 6, 0);
  1906. return $;
  1907. }
  1908. static decodeText(reader, json) {
  1909. const $ = new MNN.QuantizedReshape();
  1910. $.dims = reader.array(json.dims, Int32Array);
  1911. $.modelFormat = MNN.ModeFormat[json.modelFormat];
  1912. return $;
  1913. }
  1914. };
  1915. MNN.QuantizedSoftmax = class QuantizedSoftmax {
  1916. static decode(reader, position) {
  1917. const $ = new MNN.QuantizedSoftmax();
  1918. $.beta = reader.float32_(position, 4, 0);
  1919. $.inputScale = reader.float32_(position, 6, 0);
  1920. return $;
  1921. }
  1922. static decodeText(reader, json) {
  1923. const $ = new MNN.QuantizedSoftmax();
  1924. $.beta = reader.value(json.beta, 0);
  1925. $.inputScale = reader.value(json.inputScale, 0);
  1926. return $;
  1927. }
  1928. };
  1929. MNN.QuantizeRoundMode = {
  1930. HALF_AWAY_FROM_ZERO: 0,
  1931. HALF_TO_EVEN: 1
  1932. };
  1933. MNN.QuantizeV2 = class QuantizeV2 {
  1934. static decode(reader, position) {
  1935. const $ = new MNN.QuantizeV2();
  1936. $.type = reader.int32_(position, 4, 0);
  1937. $.mode = reader.int8_(position, 6, 0);
  1938. $.roundMode = reader.int8_(position, 8, 0);
  1939. return $;
  1940. }
  1941. static decodeText(reader, json) {
  1942. const $ = new MNN.QuantizeV2();
  1943. $.type = MNN.DataType[json.type];
  1944. $.mode = MNN.QuantizeMode[json.mode];
  1945. $.roundMode = MNN.QuantizeRoundMode[json.roundMode];
  1946. return $;
  1947. }
  1948. };
  1949. MNN.RequantizationRange = class RequantizationRange {
  1950. static decode(/* reader, position */) {
  1951. const $ = new MNN.RequantizationRange();
  1952. return $;
  1953. }
  1954. static decodeText(/* reader, json */) {
  1955. const $ = new MNN.RequantizationRange();
  1956. return $;
  1957. }
  1958. };
  1959. MNN.Requantize = class Requantize {
  1960. static decode(/* reader, position */) {
  1961. const $ = new MNN.Requantize();
  1962. return $;
  1963. }
  1964. static decodeText(/* reader, json */) {
  1965. const $ = new MNN.Requantize();
  1966. return $;
  1967. }
  1968. };
  1969. MNN.TfQuantizedConv2D = class TfQuantizedConv2D {
  1970. static decode(reader, position) {
  1971. const $ = new MNN.TfQuantizedConv2D();
  1972. $.bias = reader.array(position, 4, Int32Array);
  1973. $.biasflag = reader.bool_(position, 6, false);
  1974. $.common = reader.table(position, 8, MNN.Convolution2DCommon);
  1975. $.weight = reader.array(position, 10, Uint8Array);
  1976. $.activationType = reader.int8_(position, 12, 0);
  1977. $.multiplier = reader.int32_(position, 14, 0);
  1978. $.outMax = reader.int32_(position, 16, 0);
  1979. $.outMin = reader.int32_(position, 18, 0);
  1980. $.shift = reader.int32_(position, 20, 0);
  1981. $.biasQuantizedParam = reader.table(position, 22, MNN.QuantizedParam);
  1982. $.depthMultiplier = reader.int32_(position, 24, 0);
  1983. $.filterQuantizedParam = reader.table(position, 26, MNN.QuantizedParam);
  1984. $.inputQuantizedParam = reader.table(position, 28, MNN.QuantizedParam);
  1985. $.modelFormat = reader.int8_(position, 30, 0);
  1986. $.outputQuantizedParam = reader.table(position, 32, MNN.QuantizedParam);
  1987. return $;
  1988. }
  1989. static decodeText(reader, json) {
  1990. const $ = new MNN.TfQuantizedConv2D();
  1991. $.bias = reader.array(json.bias, Int32Array);
  1992. $.biasflag = reader.value(json.biasflag, false);
  1993. $.common = reader.object(json.common, MNN.Convolution2DCommon);
  1994. $.weight = reader.array(json.weight, Uint8Array);
  1995. $.activationType = MNN.FusedActivation[json.activationType];
  1996. $.multiplier = reader.value(json.multiplier, 0);
  1997. $.outMax = reader.value(json.outMax, 0);
  1998. $.outMin = reader.value(json.outMin, 0);
  1999. $.shift = reader.value(json.shift, 0);
  2000. $.biasQuantizedParam = reader.object(json.biasQuantizedParam, MNN.QuantizedParam);
  2001. $.depthMultiplier = reader.value(json.depthMultiplier, 0);
  2002. $.filterQuantizedParam = reader.object(json.filterQuantizedParam, MNN.QuantizedParam);
  2003. $.inputQuantizedParam = reader.object(json.inputQuantizedParam, MNN.QuantizedParam);
  2004. $.modelFormat = MNN.ModeFormat[json.modelFormat];
  2005. $.outputQuantizedParam = reader.object(json.outputQuantizedParam, MNN.QuantizedParam);
  2006. return $;
  2007. }
  2008. };
  2009. MNN.ExtraInfo = class ExtraInfo {
  2010. static decode(reader, position) {
  2011. const $ = new MNN.ExtraInfo();
  2012. $.buffer = reader.array(position, 4, Int8Array);
  2013. $.name = reader.string_(position, 6, null);
  2014. $.version = reader.string_(position, 8, null);
  2015. return $;
  2016. }
  2017. static decodeText(reader, json) {
  2018. const $ = new MNN.ExtraInfo();
  2019. $.buffer = reader.array(json.buffer, Int8Array);
  2020. $.name = reader.value(json.name, null);
  2021. $.version = reader.value(json.version, null);
  2022. return $;
  2023. }
  2024. };
  2025. MNN.TensorConvertInfo = class TensorConvertInfo {
  2026. static decode(reader, position) {
  2027. const $ = new MNN.TensorConvertInfo();
  2028. $.source = reader.int8_(position, 4, 0);
  2029. $.dest = reader.int8_(position, 6, 0);
  2030. return $;
  2031. }
  2032. static decodeText(reader, json) {
  2033. const $ = new MNN.TensorConvertInfo();
  2034. $.source = MNN.MNN_DATA_FORMAT[json.source];
  2035. $.dest = MNN.MNN_DATA_FORMAT[json.dest];
  2036. return $;
  2037. }
  2038. };
  2039. MNN.SampleMode = {
  2040. BILINEAR: 0,
  2041. NEAREST: 1
  2042. };
  2043. MNN.BorderMode = {
  2044. ZEROS: 0,
  2045. CLAMP: 1,
  2046. REFLECTION: 2,
  2047. CUBE: 3
  2048. };
  2049. MNN.GridSample = class GridSample {
  2050. static decode(reader, position) {
  2051. const $ = new MNN.GridSample();
  2052. $.mode = reader.int8_(position, 4, 0);
  2053. $.paddingMode = reader.int8_(position, 6, 0);
  2054. $.alignCorners = reader.bool_(position, 8, false);
  2055. $.backward = reader.bool_(position, 10, false);
  2056. return $;
  2057. }
  2058. static decodeText(reader, json) {
  2059. const $ = new MNN.GridSample();
  2060. $.mode = MNN.SampleMode[json.mode];
  2061. $.paddingMode = MNN.BorderMode[json.paddingMode];
  2062. $.alignCorners = reader.value(json.alignCorners, false);
  2063. $.backward = reader.value(json.backward, false);
  2064. return $;
  2065. }
  2066. };
  2067. MNN.ImageFormatType = {
  2068. RGBA: 0,
  2069. RGB: 1,
  2070. BGR: 2,
  2071. GRAY: 3,
  2072. BGRA: 4,
  2073. YCrCb: 5,
  2074. YUV: 6,
  2075. HSV: 7,
  2076. XYZ: 8,
  2077. BGR555: 9,
  2078. BGR565: 10,
  2079. YUV_NV21: 11,
  2080. YUV_NV12: 12,
  2081. YUV_I420: 13,
  2082. HSV_FULL: 14
  2083. };
  2084. MNN.FilterType = {
  2085. NEAREST: 0,
  2086. BILINEAR: 1,
  2087. BICUBIC: 2
  2088. };
  2089. MNN.WrapType = {
  2090. CLAMP_TO_EDGE: 0,
  2091. ZERO: 1,
  2092. REPEAT: 2
  2093. };
  2094. MNN.ImageProcessParam = class ImageProcessParam {
  2095. static decode(reader, position) {
  2096. const $ = new MNN.ImageProcessParam();
  2097. $.filterType = reader.int8_(position, 4, 0);
  2098. $.sourceFormat = reader.int32_(position, 6, 0);
  2099. $.destFormat = reader.int32_(position, 8, 0);
  2100. $.wrap = reader.int8_(position, 10, 0);
  2101. $.mean = reader.array(position, 12, Float32Array);
  2102. $.normal = reader.array(position, 14, Float32Array);
  2103. $.transform = reader.array(position, 16, Float32Array);
  2104. $.paddingValue = reader.int8_(position, 18, 0);
  2105. $.shape = reader.array(position, 20, Int32Array);
  2106. $.outputType = reader.int32_(position, 22, 0);
  2107. $.draw = reader.bool_(position, 24, false);
  2108. return $;
  2109. }
  2110. static decodeText(reader, json) {
  2111. const $ = new MNN.ImageProcessParam();
  2112. $.filterType = MNN.FilterType[json.filterType];
  2113. $.sourceFormat = MNN.ImageFormatType[json.sourceFormat];
  2114. $.destFormat = MNN.ImageFormatType[json.destFormat];
  2115. $.wrap = MNN.WrapType[json.wrap];
  2116. $.mean = reader.array(json.mean, Float32Array);
  2117. $.normal = reader.array(json.normal, Float32Array);
  2118. $.transform = reader.array(json.transform, Float32Array);
  2119. $.paddingValue = reader.value(json.paddingValue, 0);
  2120. $.shape = reader.array(json.shape, Int32Array);
  2121. $.outputType = MNN.DataType[json.outputType];
  2122. $.draw = reader.value(json.draw, false);
  2123. return $;
  2124. }
  2125. };
  2126. MNN.OpType = {
  2127. AbsVal: 0,
  2128. QuantizedAdd: 1,
  2129. ArgMax: 2,
  2130. AsString: 3,
  2131. InstanceNorm: 4,
  2132. BatchToSpaceND: 5,
  2133. Copy: 6,
  2134. BinaryOp: 7,
  2135. Bnll: 8,
  2136. Cast: 9,
  2137. Concat: 10,
  2138. Const: 11,
  2139. Convolution: 12,
  2140. ConvolutionDepthwise: 13,
  2141. Crop: 14,
  2142. CropAndResize: 15,
  2143. ImageProcess: 16,
  2144. Deconvolution: 17,
  2145. DeconvolutionDepthwise: 18,
  2146. Dequantize: 19,
  2147. DetectionOutput: 20,
  2148. Dropout: 21,
  2149. Eltwise: 22,
  2150. ELU: 23,
  2151. Unique: 24,
  2152. Exp: 25,
  2153. ExpandDims: 26,
  2154. Fill: 27,
  2155. Flatten: 28,
  2156. Im2Col: 29,
  2157. Gather: 30,
  2158. GatherV2: 31,
  2159. Im2Seq: 32,
  2160. InnerProduct: 33,
  2161. Input: 34,
  2162. Interp: 35,
  2163. Log: 36,
  2164. LRN: 37,
  2165. LSTM: 38,
  2166. MatMul: 39,
  2167. MoE: 40,
  2168. NonMaxSuppression: 41,
  2169. NonMaxSuppressionV2: 42,
  2170. Normalize: 43,
  2171. Pack: 44,
  2172. Padding: 45,
  2173. Permute: 46,
  2174. Pooling: 47,
  2175. Power: 48,
  2176. PReLU: 49,
  2177. PriorBox: 50,
  2178. Proposal: 51,
  2179. QuantizedAvgPool: 52,
  2180. QuantizedBiasAdd: 53,
  2181. QuantizedConcat: 54,
  2182. QuantizedDepthwiseConv2D: 55,
  2183. QuantizedLogistic: 56,
  2184. RasterAndInterpolate: 57,
  2185. QuantizedMaxPool: 58,
  2186. Texture: 59,
  2187. RasterDiff: 60,
  2188. QuantizedReshape: 61,
  2189. QuantizedSoftmax: 62,
  2190. QuantizeMaxMin: 63,
  2191. QuantizeV2: 64,
  2192. Range: 65,
  2193. Rank: 66,
  2194. ReduceJoin: 67,
  2195. Reduction: 68,
  2196. ReLU: 69,
  2197. ReLU6: 70,
  2198. RequantizationRange: 71,
  2199. Requantize: 72,
  2200. Reshape: 73,
  2201. Resize: 74,
  2202. RNN: 75,
  2203. ROIPooling: 76,
  2204. Scale: 77,
  2205. Selu: 78,
  2206. Seq2Out: 79,
  2207. Shape: 80,
  2208. Sigmoid: 81,
  2209. Size: 82,
  2210. Slice: 83,
  2211. SliceTf: 84,
  2212. Softmax: 85,
  2213. SpaceToBatchND: 86,
  2214. SpatialProduct: 87,
  2215. Col2Im: 88,
  2216. Segment: 89,
  2217. Squeeze: 90,
  2218. StridedSlice: 91,
  2219. CastLike: 92,
  2220. StringSplit: 93,
  2221. StringToNumber: 94,
  2222. TanH: 95,
  2223. TfQuantizedConv2D: 96,
  2224. Threshold: 97,
  2225. Tile: 98,
  2226. TopKV2: 99,
  2227. Transpose: 100,
  2228. UnaryOp: 101,
  2229. Unpack: 102,
  2230. Where: 103,
  2231. Moments: 104,
  2232. RNNSequenceGRU: 105,
  2233. BatchMatMul: 106,
  2234. Unsqueeze: 107,
  2235. CosineSimilarity: 108,
  2236. DepthToSpace: 109,
  2237. SpaceToDepth: 110,
  2238. ReverseSequence: 111,
  2239. Pooling3D: 112,
  2240. Convolution3D: 113,
  2241. MatrixBandPart: 114,
  2242. GatherND: 115,
  2243. DetectionPostProcess: 116,
  2244. UnravelIndex: 117,
  2245. ScatterNd: 118,
  2246. OneHot: 119,
  2247. BroadcastTo: 120,
  2248. Dilation2D: 121,
  2249. Interp3D: 122,
  2250. Raster: 128,
  2251. ConvertTensor: 129,
  2252. ArgMin: 130,
  2253. LinSpace: 131,
  2254. RandomUniform: 132,
  2255. TensorArray: 133,
  2256. TensorArraySize: 134,
  2257. TensorArrayRead: 135,
  2258. TensorArrayWrite: 136,
  2259. TensorArrayGather: 137,
  2260. TensorArrayScatter: 138,
  2261. TensorArraySplit: 139,
  2262. TensorArrayConcat: 140,
  2263. LSTMBlockCell: 141,
  2264. Reverse: 142,
  2265. ROIAlign: 143,
  2266. RandomNormal: 144,
  2267. TensorArrayInsert: 145,
  2268. TensorArrayErase: 146,
  2269. EyeLike: 147,
  2270. CumSum: 148,
  2271. Det: 149,
  2272. CumProd: 150,
  2273. ScatterElements: 151,
  2274. GatherElements: 152,
  2275. Svd: 153,
  2276. Histogram: 154,
  2277. DynamicQuant: 155,
  2278. Stft: 156,
  2279. Plugin: 256,
  2280. Select: 257,
  2281. ZerosLike: 258,
  2282. Broastcast: 259,
  2283. SetDiff1D: 260,
  2284. ReluGrad: 261,
  2285. Identity: 262,
  2286. PoolGrad: 263,
  2287. SoftmaxGrad: 264,
  2288. Conv2DBackPropFilter: 265,
  2289. TrainableParam: 266,
  2290. BatchNorm: 267,
  2291. ConvTranspose3D: 268,
  2292. ZeroGrad: 269,
  2293. Attention: 299,
  2294. FmhaV2: 300,
  2295. Fmhca: 301,
  2296. SeqLen2Spatial: 302,
  2297. SplitGeLU: 303,
  2298. GroupNorm: 304,
  2299. LinearAttention: 305,
  2300. Extra: 512,
  2301. ConvInt8: 513,
  2302. Int8ToFloat: 514,
  2303. DepthwiseConvInt8: 515,
  2304. FloatToInt8: 517,
  2305. EltwiseInt8: 518,
  2306. While: 600,
  2307. If: 601,
  2308. LayerNorm: 603,
  2309. GridSample: 604
  2310. };
  2311. MNN.Plugin = class Plugin {
  2312. static decode(reader, position) {
  2313. const $ = new MNN.Plugin();
  2314. $.type = reader.string_(position, 4, null);
  2315. $.attr = reader.tables(position, 6, MNN.Attribute);
  2316. return $;
  2317. }
  2318. static decodeText(reader, json) {
  2319. const $ = new MNN.Plugin();
  2320. $.type = reader.value(json.type, null);
  2321. $.attr = reader.objects(json.attr, MNN.Attribute);
  2322. return $;
  2323. }
  2324. };
  2325. MNN.Extra = class Extra {
  2326. static decode(reader, position) {
  2327. const $ = new MNN.Extra();
  2328. $.type = reader.string_(position, 4, null);
  2329. $.engine = reader.string_(position, 6, null);
  2330. $.info = reader.array(position, 8, Int8Array);
  2331. $.attr = reader.tables(position, 10, MNN.Attribute);
  2332. $.vector = reader.bool_(position, 12, false);
  2333. return $;
  2334. }
  2335. static decodeText(reader, json) {
  2336. const $ = new MNN.Extra();
  2337. $.type = reader.value(json.type, null);
  2338. $.engine = reader.value(json.engine, null);
  2339. $.info = reader.array(json.info, Int8Array);
  2340. $.attr = reader.objects(json.attr, MNN.Attribute);
  2341. $.vector = reader.value(json.vector, false);
  2342. return $;
  2343. }
  2344. };
  2345. MNN.StringVec = class StringVec {
  2346. static decode(reader, position) {
  2347. const $ = new MNN.StringVec();
  2348. $.data = reader.strings_(position, 4);
  2349. return $;
  2350. }
  2351. static decodeText(reader, json) {
  2352. const $ = new MNN.StringVec();
  2353. $.data = reader.array(json.data);
  2354. return $;
  2355. }
  2356. };
  2357. MNN.AttentionParam = class AttentionParam {
  2358. static decode(reader, position) {
  2359. const $ = new MNN.AttentionParam();
  2360. $.kv_cache = reader.bool_(position, 4, true);
  2361. return $;
  2362. }
  2363. static decodeText(reader, json) {
  2364. const $ = new MNN.AttentionParam();
  2365. $.kv_cache = reader.value(json.kv_cache, true);
  2366. return $;
  2367. }
  2368. };
  2369. MNN.LinearAttentionParam = class LinearAttentionParam {
  2370. static decode(reader, position) {
  2371. const $ = new MNN.LinearAttentionParam();
  2372. $.attn_type = reader.string_(position, 4, null);
  2373. $.num_k_heads = reader.int32_(position, 6, 0);
  2374. $.num_v_heads = reader.int32_(position, 8, 0);
  2375. $.head_k_dim = reader.int32_(position, 10, 0);
  2376. $.head_v_dim = reader.int32_(position, 12, 0);
  2377. $.use_qk_l2norm = reader.bool_(position, 14, false);
  2378. return $;
  2379. }
  2380. static decodeText(reader, json) {
  2381. const $ = new MNN.LinearAttentionParam();
  2382. $.attn_type = reader.value(json.attn_type, null);
  2383. $.num_k_heads = reader.value(json.num_k_heads, 0);
  2384. $.num_v_heads = reader.value(json.num_v_heads, 0);
  2385. $.head_k_dim = reader.value(json.head_k_dim, 0);
  2386. $.head_v_dim = reader.value(json.head_v_dim, 0);
  2387. $.use_qk_l2norm = reader.value(json.use_qk_l2norm, false);
  2388. return $;
  2389. }
  2390. };
  2391. MNN.FmhaV2Param = class FmhaV2Param {
  2392. static decode(reader, position) {
  2393. const $ = new MNN.FmhaV2Param();
  2394. $.heads = reader.int32_(position, 4, 0);
  2395. return $;
  2396. }
  2397. static decodeText(reader, json) {
  2398. const $ = new MNN.FmhaV2Param();
  2399. $.heads = reader.value(json.heads, 0);
  2400. return $;
  2401. }
  2402. };
  2403. MNN.FmhcaParam = class FmhcaParam {
  2404. static decode(reader, position) {
  2405. const $ = new MNN.FmhcaParam();
  2406. $.heads = reader.int32_(position, 4, 0);
  2407. return $;
  2408. }
  2409. static decodeText(reader, json) {
  2410. const $ = new MNN.FmhcaParam();
  2411. $.heads = reader.value(json.heads, 0);
  2412. return $;
  2413. }
  2414. };
  2415. MNN.StftParam = class StftParam {
  2416. static decode(reader, position) {
  2417. const $ = new MNN.StftParam();
  2418. $.n_fft = reader.int32_(position, 4, 0);
  2419. $.hop_length = reader.int32_(position, 6, 0);
  2420. $.abs = reader.bool_(position, 8, true);
  2421. return $;
  2422. }
  2423. static decodeText(reader, json) {
  2424. const $ = new MNN.StftParam();
  2425. $.n_fft = reader.value(json.n_fft, 0);
  2426. $.hop_length = reader.value(json.hop_length, 0);
  2427. $.abs = reader.value(json.abs, true);
  2428. return $;
  2429. }
  2430. };
  2431. MNN.WhileParam = class WhileParam {
  2432. static decode(reader, position) {
  2433. const $ = new MNN.WhileParam();
  2434. $.cond_graph = reader.string_(position, 4, null);
  2435. $.body_graph = reader.string_(position, 6, null);
  2436. $.aliases_inputs = reader.tables(position, 8, MNN.StringVec);
  2437. $.aliases_outputs = reader.strings_(position, 10);
  2438. $.aliases_updates = reader.tables(position, 12, MNN.StringVec);
  2439. return $;
  2440. }
  2441. static decodeText(reader, json) {
  2442. const $ = new MNN.WhileParam();
  2443. $.cond_graph = reader.value(json.cond_graph, null);
  2444. $.body_graph = reader.value(json.body_graph, null);
  2445. $.aliases_inputs = reader.objects(json.aliases_inputs, MNN.StringVec);
  2446. $.aliases_outputs = reader.array(json.aliases_outputs);
  2447. $.aliases_updates = reader.objects(json.aliases_updates, MNN.StringVec);
  2448. return $;
  2449. }
  2450. };
  2451. MNN.IfParam = class IfParam {
  2452. static decode(reader, position) {
  2453. const $ = new MNN.IfParam();
  2454. $.then_graph = reader.string_(position, 4, null);
  2455. $.else_graph = reader.string_(position, 6, null);
  2456. $.aliases_inputs = reader.tables(position, 8, MNN.StringVec);
  2457. $.aliases_outputs = reader.tables(position, 10, MNN.StringVec);
  2458. return $;
  2459. }
  2460. static decodeText(reader, json) {
  2461. const $ = new MNN.IfParam();
  2462. $.then_graph = reader.value(json.then_graph, null);
  2463. $.else_graph = reader.value(json.else_graph, null);
  2464. $.aliases_inputs = reader.objects(json.aliases_inputs, MNN.StringVec);
  2465. $.aliases_outputs = reader.objects(json.aliases_outputs, MNN.StringVec);
  2466. return $;
  2467. }
  2468. };
  2469. MNN.RegionCommand = class RegionCommand {
  2470. static decode(reader, position) {
  2471. const $ = new MNN.RegionCommand();
  2472. $.op = reader.table(position, 4, MNN.Op);
  2473. $.steps = reader.array(position, 6, Int32Array);
  2474. $.size = reader.array(position, 8, Int32Array);
  2475. $.indexes = reader.array(position, 10, Int32Array);
  2476. $.view = reader.tables(position, 12, MNN.View);
  2477. $.fuse = reader.int32_(position, 14, -1);
  2478. $.iterIndexes = reader.array(position, 16, Int32Array);
  2479. return $;
  2480. }
  2481. static decodeText(reader, json) {
  2482. const $ = new MNN.RegionCommand();
  2483. $.op = reader.object(json.op, MNN.Op);
  2484. $.steps = reader.array(json.steps, Int32Array);
  2485. $.size = reader.array(json.size, Int32Array);
  2486. $.indexes = reader.array(json.indexes, Int32Array);
  2487. $.view = reader.objects(json.view, MNN.View);
  2488. $.fuse = reader.value(json.fuse, -1);
  2489. $.iterIndexes = reader.array(json.iterIndexes, Int32Array);
  2490. return $;
  2491. }
  2492. };
  2493. MNN.LoopParam = class LoopParam {
  2494. static decode(reader, position) {
  2495. const $ = new MNN.LoopParam();
  2496. $.tensorNumber = reader.int32_(position, 4, 0);
  2497. $.outputIndexes = reader.array(position, 6, Int32Array);
  2498. $.inputIndexes = reader.array(position, 8, Int32Array);
  2499. $.extraTensorInfos = reader.tables(position, 10, MNN.TensorDescribe);
  2500. $.parallel = reader.bool_(position, 12, true);
  2501. $.loopNumber = reader.int32_(position, 14, 0);
  2502. $.commands = reader.tables(position, 16, MNN.RegionCommand);
  2503. $.initCommand = reader.tables(position, 18, MNN.RegionCommand);
  2504. return $;
  2505. }
  2506. static decodeText(reader, json) {
  2507. const $ = new MNN.LoopParam();
  2508. $.tensorNumber = reader.value(json.tensorNumber, 0);
  2509. $.outputIndexes = reader.array(json.outputIndexes, Int32Array);
  2510. $.inputIndexes = reader.array(json.inputIndexes, Int32Array);
  2511. $.extraTensorInfos = reader.objects(json.extraTensorInfos, MNN.TensorDescribe);
  2512. $.parallel = reader.value(json.parallel, true);
  2513. $.loopNumber = reader.value(json.loopNumber, 0);
  2514. $.commands = reader.objects(json.commands, MNN.RegionCommand);
  2515. $.initCommand = reader.objects(json.initCommand, MNN.RegionCommand);
  2516. return $;
  2517. }
  2518. };
  2519. MNN.OpParameter = class {
  2520. static decode(reader, position, type) {
  2521. switch (type) {
  2522. case 1: return MNN.QuantizedAdd.decode(reader, position);
  2523. case 2: return MNN.ArgMax.decode(reader, position);
  2524. case 3: return MNN.AsString.decode(reader, position);
  2525. case 4: return MNN.Axis.decode(reader, position);
  2526. case 5: return MNN.BatchNorm.decode(reader, position);
  2527. case 6: return MNN.BinaryOp.decode(reader, position);
  2528. case 7: return MNN.Blob.decode(reader, position);
  2529. case 8: return MNN.CastParam.decode(reader, position);
  2530. case 9: return MNN.Convolution2D.decode(reader, position);
  2531. case 10: return MNN.Crop.decode(reader, position);
  2532. case 11: return MNN.CropAndResize.decode(reader, position);
  2533. case 12: return MNN.Dequantize.decode(reader, position);
  2534. case 13: return MNN.DetectionOutput.decode(reader, position);
  2535. case 14: return MNN.Eltwise.decode(reader, position);
  2536. case 15: return MNN.ExpandDims.decode(reader, position);
  2537. case 16: return MNN.Fill.decode(reader, position);
  2538. case 17: return MNN.Flatten.decode(reader, position);
  2539. case 18: return MNN.Gather.decode(reader, position);
  2540. case 19: return MNN.GatherV2.decode(reader, position);
  2541. case 20: return MNN.InnerProduct.decode(reader, position);
  2542. case 21: return MNN.Input.decode(reader, position);
  2543. case 22: return MNN.Interp.decode(reader, position);
  2544. case 23: return MNN.LRN.decode(reader, position);
  2545. case 24: return MNN.LSTM.decode(reader, position);
  2546. case 25: return MNN.MatMul.decode(reader, position);
  2547. case 26: return MNN.NonMaxSuppressionV2.decode(reader, position);
  2548. case 27: return MNN.Normalize.decode(reader, position);
  2549. case 28: return MNN.PackParam.decode(reader, position);
  2550. case 29: return MNN.Permute.decode(reader, position);
  2551. case 30: return MNN.Plugin.decode(reader, position);
  2552. case 31: return MNN.Pool.decode(reader, position);
  2553. case 32: return MNN.PRelu.decode(reader, position);
  2554. case 33: return MNN.PriorBox.decode(reader, position);
  2555. case 34: return MNN.Proposal.decode(reader, position);
  2556. case 35: return MNN.QuantizedAvgPool.decode(reader, position);
  2557. case 36: return MNN.QuantizedBiasAdd.decode(reader, position);
  2558. case 37: return MNN.QuantizedConcat.decode(reader, position);
  2559. case 38: return MNN.QuantizedLogistic.decode(reader, position);
  2560. case 39: return MNN.QuantizedMatMul.decode(reader, position);
  2561. case 40: return MNN.QuantizedMaxPool.decode(reader, position);
  2562. case 41: return MNN.QuantizedRelu.decode(reader, position);
  2563. case 42: return MNN.QuantizedRelu6.decode(reader, position);
  2564. case 43: return MNN.QuantizedReshape.decode(reader, position);
  2565. case 44: return MNN.QuantizedSoftmax.decode(reader, position);
  2566. case 45: return MNN.QuantizeMaxMin.decode(reader, position);
  2567. case 46: return MNN.QuantizeV2.decode(reader, position);
  2568. case 47: return MNN.Range.decode(reader, position);
  2569. case 48: return MNN.Rank.decode(reader, position);
  2570. case 49: return MNN.ReduceJoin.decode(reader, position);
  2571. case 50: return MNN.ReductionParam.decode(reader, position);
  2572. case 51: return MNN.Relu.decode(reader, position);
  2573. case 52: return MNN.Relu6.decode(reader, position);
  2574. case 53: return MNN.RequantizationRange.decode(reader, position);
  2575. case 54: return MNN.Requantize.decode(reader, position);
  2576. case 55: return MNN.Reshape.decode(reader, position);
  2577. case 56: return MNN.Resize.decode(reader, position);
  2578. case 57: return MNN.RoiParameters.decode(reader, position);
  2579. case 58: return MNN.Scale.decode(reader, position);
  2580. case 59: return MNN.Selu.decode(reader, position);
  2581. case 60: return MNN.Size.decode(reader, position);
  2582. case 61: return MNN.Slice.decode(reader, position);
  2583. case 62: return MNN.SliceTf.decode(reader, position);
  2584. case 63: return MNN.SpaceBatch.decode(reader, position);
  2585. case 64: return MNN.SqueezeParam.decode(reader, position);
  2586. case 65: return MNN.StridedSliceParam.decode(reader, position);
  2587. case 66: return MNN.TensorConvertInfo.decode(reader, position);
  2588. case 67: return MNN.TfQuantizedConv2D.decode(reader, position);
  2589. case 68: return MNN.TopKV2.decode(reader, position);
  2590. case 69: return MNN.Transpose.decode(reader, position);
  2591. case 70: return MNN.UnaryOp.decode(reader, position);
  2592. case 71: return MNN.MomentsParam.decode(reader, position);
  2593. case 72: return MNN.RNNParam.decode(reader, position);
  2594. case 73: return MNN.BatchMatMulParam.decode(reader, position);
  2595. case 74: return MNN.QuantizedFloatParam.decode(reader, position);
  2596. case 75: return MNN.DepthSpaceParam.decode(reader, position);
  2597. case 76: return MNN.EltwiseInt8.decode(reader, position);
  2598. case 77: return MNN.ReverseSequenceParam.decode(reader, position);
  2599. case 78: return MNN.Extra.decode(reader, position);
  2600. case 79: return MNN.Pool3D.decode(reader, position);
  2601. case 80: return MNN.Convolution3D.decode(reader, position);
  2602. case 81: return MNN.ELU.decode(reader, position);
  2603. case 82: return MNN.DetectionPostProcessParam.decode(reader, position);
  2604. case 83: return MNN.OneHotParam.decode(reader, position);
  2605. case 84: return MNN.PadParam.decode(reader, position);
  2606. case 85: return MNN.WhileParam.decode(reader, position);
  2607. case 86: return MNN.IfParam.decode(reader, position);
  2608. case 87: return MNN.RandomUniform.decode(reader, position);
  2609. case 88: return MNN.LayerNorm.decode(reader, position);
  2610. case 89: return MNN.TensorArray.decode(reader, position);
  2611. case 90: return MNN.LSTMBlockCell.decode(reader, position);
  2612. case 91: return MNN.GridSample.decode(reader, position);
  2613. case 92: return MNN.LoopParam.decode(reader, position);
  2614. case 93: return MNN.ImageProcessParam.decode(reader, position);
  2615. case 94: return MNN.CumSum.decode(reader, position);
  2616. case 95: return MNN.GroupNorm.decode(reader, position);
  2617. case 96: return MNN.FmhaV2Param.decode(reader, position);
  2618. case 97: return MNN.FmhcaParam.decode(reader, position);
  2619. case 98: return MNN.AttentionParam.decode(reader, position);
  2620. case 99: return MNN.StftParam.decode(reader, position);
  2621. case 100: return MNN.LinearAttentionParam.decode(reader, position);
  2622. default: return undefined;
  2623. }
  2624. }
  2625. static decodeText(reader, json, type) {
  2626. switch (type) {
  2627. case 'QuantizedAdd': return MNN.QuantizedAdd.decodeText(reader, json);
  2628. case 'ArgMax': return MNN.ArgMax.decodeText(reader, json);
  2629. case 'AsString': return MNN.AsString.decodeText(reader, json);
  2630. case 'Axis': return MNN.Axis.decodeText(reader, json);
  2631. case 'BatchNorm': return MNN.BatchNorm.decodeText(reader, json);
  2632. case 'BinaryOp': return MNN.BinaryOp.decodeText(reader, json);
  2633. case 'Blob': return MNN.Blob.decodeText(reader, json);
  2634. case 'CastParam': return MNN.CastParam.decodeText(reader, json);
  2635. case 'Convolution2D': return MNN.Convolution2D.decodeText(reader, json);
  2636. case 'Crop': return MNN.Crop.decodeText(reader, json);
  2637. case 'CropAndResize': return MNN.CropAndResize.decodeText(reader, json);
  2638. case 'Dequantize': return MNN.Dequantize.decodeText(reader, json);
  2639. case 'DetectionOutput': return MNN.DetectionOutput.decodeText(reader, json);
  2640. case 'Eltwise': return MNN.Eltwise.decodeText(reader, json);
  2641. case 'ExpandDims': return MNN.ExpandDims.decodeText(reader, json);
  2642. case 'Fill': return MNN.Fill.decodeText(reader, json);
  2643. case 'Flatten': return MNN.Flatten.decodeText(reader, json);
  2644. case 'Gather': return MNN.Gather.decodeText(reader, json);
  2645. case 'GatherV2': return MNN.GatherV2.decodeText(reader, json);
  2646. case 'InnerProduct': return MNN.InnerProduct.decodeText(reader, json);
  2647. case 'Input': return MNN.Input.decodeText(reader, json);
  2648. case 'Interp': return MNN.Interp.decodeText(reader, json);
  2649. case 'LRN': return MNN.LRN.decodeText(reader, json);
  2650. case 'LSTM': return MNN.LSTM.decodeText(reader, json);
  2651. case 'MatMul': return MNN.MatMul.decodeText(reader, json);
  2652. case 'NonMaxSuppressionV2': return MNN.NonMaxSuppressionV2.decodeText(reader, json);
  2653. case 'Normalize': return MNN.Normalize.decodeText(reader, json);
  2654. case 'PackParam': return MNN.PackParam.decodeText(reader, json);
  2655. case 'Permute': return MNN.Permute.decodeText(reader, json);
  2656. case 'Plugin': return MNN.Plugin.decodeText(reader, json);
  2657. case 'Pool': return MNN.Pool.decodeText(reader, json);
  2658. case 'PRelu': return MNN.PRelu.decodeText(reader, json);
  2659. case 'PriorBox': return MNN.PriorBox.decodeText(reader, json);
  2660. case 'Proposal': return MNN.Proposal.decodeText(reader, json);
  2661. case 'QuantizedAvgPool': return MNN.QuantizedAvgPool.decodeText(reader, json);
  2662. case 'QuantizedBiasAdd': return MNN.QuantizedBiasAdd.decodeText(reader, json);
  2663. case 'QuantizedConcat': return MNN.QuantizedConcat.decodeText(reader, json);
  2664. case 'QuantizedLogistic': return MNN.QuantizedLogistic.decodeText(reader, json);
  2665. case 'QuantizedMatMul': return MNN.QuantizedMatMul.decodeText(reader, json);
  2666. case 'QuantizedMaxPool': return MNN.QuantizedMaxPool.decodeText(reader, json);
  2667. case 'QuantizedRelu': return MNN.QuantizedRelu.decodeText(reader, json);
  2668. case 'QuantizedRelu6': return MNN.QuantizedRelu6.decodeText(reader, json);
  2669. case 'QuantizedReshape': return MNN.QuantizedReshape.decodeText(reader, json);
  2670. case 'QuantizedSoftmax': return MNN.QuantizedSoftmax.decodeText(reader, json);
  2671. case 'QuantizeMaxMin': return MNN.QuantizeMaxMin.decodeText(reader, json);
  2672. case 'QuantizeV2': return MNN.QuantizeV2.decodeText(reader, json);
  2673. case 'Range': return MNN.Range.decodeText(reader, json);
  2674. case 'Rank': return MNN.Rank.decodeText(reader, json);
  2675. case 'ReduceJoin': return MNN.ReduceJoin.decodeText(reader, json);
  2676. case 'ReductionParam': return MNN.ReductionParam.decodeText(reader, json);
  2677. case 'Relu': return MNN.Relu.decodeText(reader, json);
  2678. case 'Relu6': return MNN.Relu6.decodeText(reader, json);
  2679. case 'RequantizationRange': return MNN.RequantizationRange.decodeText(reader, json);
  2680. case 'Requantize': return MNN.Requantize.decodeText(reader, json);
  2681. case 'Reshape': return MNN.Reshape.decodeText(reader, json);
  2682. case 'Resize': return MNN.Resize.decodeText(reader, json);
  2683. case 'RoiParameters': return MNN.RoiParameters.decodeText(reader, json);
  2684. case 'Scale': return MNN.Scale.decodeText(reader, json);
  2685. case 'Selu': return MNN.Selu.decodeText(reader, json);
  2686. case 'Size': return MNN.Size.decodeText(reader, json);
  2687. case 'Slice': return MNN.Slice.decodeText(reader, json);
  2688. case 'SliceTf': return MNN.SliceTf.decodeText(reader, json);
  2689. case 'SpaceBatch': return MNN.SpaceBatch.decodeText(reader, json);
  2690. case 'SqueezeParam': return MNN.SqueezeParam.decodeText(reader, json);
  2691. case 'StridedSliceParam': return MNN.StridedSliceParam.decodeText(reader, json);
  2692. case 'TensorConvertInfo': return MNN.TensorConvertInfo.decodeText(reader, json);
  2693. case 'TfQuantizedConv2D': return MNN.TfQuantizedConv2D.decodeText(reader, json);
  2694. case 'TopKV2': return MNN.TopKV2.decodeText(reader, json);
  2695. case 'Transpose': return MNN.Transpose.decodeText(reader, json);
  2696. case 'UnaryOp': return MNN.UnaryOp.decodeText(reader, json);
  2697. case 'MomentsParam': return MNN.MomentsParam.decodeText(reader, json);
  2698. case 'RNNParam': return MNN.RNNParam.decodeText(reader, json);
  2699. case 'BatchMatMulParam': return MNN.BatchMatMulParam.decodeText(reader, json);
  2700. case 'QuantizedFloatParam': return MNN.QuantizedFloatParam.decodeText(reader, json);
  2701. case 'DepthSpaceParam': return MNN.DepthSpaceParam.decodeText(reader, json);
  2702. case 'EltwiseInt8': return MNN.EltwiseInt8.decodeText(reader, json);
  2703. case 'ReverseSequenceParam': return MNN.ReverseSequenceParam.decodeText(reader, json);
  2704. case 'Extra': return MNN.Extra.decodeText(reader, json);
  2705. case 'Pool3D': return MNN.Pool3D.decodeText(reader, json);
  2706. case 'Convolution3D': return MNN.Convolution3D.decodeText(reader, json);
  2707. case 'ELU': return MNN.ELU.decodeText(reader, json);
  2708. case 'DetectionPostProcessParam': return MNN.DetectionPostProcessParam.decodeText(reader, json);
  2709. case 'OneHotParam': return MNN.OneHotParam.decodeText(reader, json);
  2710. case 'PadParam': return MNN.PadParam.decodeText(reader, json);
  2711. case 'WhileParam': return MNN.WhileParam.decodeText(reader, json);
  2712. case 'IfParam': return MNN.IfParam.decodeText(reader, json);
  2713. case 'RandomUniform': return MNN.RandomUniform.decodeText(reader, json);
  2714. case 'LayerNorm': return MNN.LayerNorm.decodeText(reader, json);
  2715. case 'TensorArray': return MNN.TensorArray.decodeText(reader, json);
  2716. case 'LSTMBlockCell': return MNN.LSTMBlockCell.decodeText(reader, json);
  2717. case 'GridSample': return MNN.GridSample.decodeText(reader, json);
  2718. case 'LoopParam': return MNN.LoopParam.decodeText(reader, json);
  2719. case 'ImageProcessParam': return MNN.ImageProcessParam.decodeText(reader, json);
  2720. case 'CumSum': return MNN.CumSum.decodeText(reader, json);
  2721. case 'GroupNorm': return MNN.GroupNorm.decodeText(reader, json);
  2722. case 'FmhaV2Param': return MNN.FmhaV2Param.decodeText(reader, json);
  2723. case 'FmhcaParam': return MNN.FmhcaParam.decodeText(reader, json);
  2724. case 'AttentionParam': return MNN.AttentionParam.decodeText(reader, json);
  2725. case 'StftParam': return MNN.StftParam.decodeText(reader, json);
  2726. case 'LinearAttentionParam': return MNN.LinearAttentionParam.decodeText(reader, json);
  2727. default: return undefined;
  2728. }
  2729. }
  2730. };
  2731. MNN.Op = class Op {
  2732. static decode(reader, position) {
  2733. const $ = new MNN.Op();
  2734. $.inputIndexes = reader.array(position, 4, Int32Array);
  2735. $.main = reader.union(position, 6, MNN.OpParameter);
  2736. $.name = reader.string_(position, 10, null);
  2737. $.outputIndexes = reader.array(position, 12, Int32Array);
  2738. $.type = reader.int32_(position, 14, 0);
  2739. $.defaultDimentionFormat = reader.int8_(position, 16, 1);
  2740. $.externalPath = reader.string_(position, 18, null);
  2741. return $;
  2742. }
  2743. static decodeText(reader, json) {
  2744. const $ = new MNN.Op();
  2745. $.inputIndexes = reader.array(json.inputIndexes, Int32Array);
  2746. $.main = MNN.OpParameter.decodeText(reader, json.main, json.main_type);
  2747. $.name = reader.value(json.name, null);
  2748. $.outputIndexes = reader.array(json.outputIndexes, Int32Array);
  2749. $.type = MNN.OpType[json.type];
  2750. $.defaultDimentionFormat = MNN.MNN_DATA_FORMAT[json.defaultDimentionFormat];
  2751. $.externalPath = reader.value(json.externalPath, null);
  2752. return $;
  2753. }
  2754. };
  2755. MNN.View = class View {
  2756. static decode(reader, position) {
  2757. const $ = new MNN.View();
  2758. $.offset = reader.int32_(position, 4, 0);
  2759. $.stride = reader.array(position, 6, Int32Array);
  2760. return $;
  2761. }
  2762. static decodeText(reader, json) {
  2763. const $ = new MNN.View();
  2764. $.offset = reader.value(json.offset, 0);
  2765. $.stride = reader.array(json.stride, Int32Array);
  2766. return $;
  2767. }
  2768. };
  2769. MNN.Region = class Region {
  2770. static decode(reader, position) {
  2771. const $ = new MNN.Region();
  2772. $.src = reader.table(position, 4, MNN.View);
  2773. $.dst = reader.table(position, 6, MNN.View);
  2774. $.size = reader.array(position, 8, Int32Array);
  2775. $.origin = reader.int32_(position, 10, 0);
  2776. return $;
  2777. }
  2778. static decodeText(reader, json) {
  2779. const $ = new MNN.Region();
  2780. $.src = reader.object(json.src, MNN.View);
  2781. $.dst = reader.object(json.dst, MNN.View);
  2782. $.size = reader.array(json.size, Int32Array);
  2783. $.origin = reader.value(json.origin, 0);
  2784. return $;
  2785. }
  2786. };
  2787. MNN.TensorDescribe = class TensorDescribe {
  2788. static decode(reader, position) {
  2789. const $ = new MNN.TensorDescribe();
  2790. $.blob = reader.table(position, 4, MNN.Blob);
  2791. $.index = reader.int32_(position, 6, 0);
  2792. $.name = reader.string_(position, 8, null);
  2793. $.regions = reader.tables(position, 10, MNN.Region);
  2794. $.quantInfo = reader.table(position, 12, MNN.TensorQuantInfo);
  2795. return $;
  2796. }
  2797. static decodeText(reader, json) {
  2798. const $ = new MNN.TensorDescribe();
  2799. $.blob = reader.object(json.blob, MNN.Blob);
  2800. $.index = reader.value(json.index, 0);
  2801. $.name = reader.value(json.name, null);
  2802. $.regions = reader.objects(json.regions, MNN.Region);
  2803. $.quantInfo = reader.object(json.quantInfo, MNN.TensorQuantInfo);
  2804. return $;
  2805. }
  2806. };
  2807. MNN.ForwardType = {
  2808. CPU: 0,
  2809. METAL: 1,
  2810. CUDA: 2,
  2811. OPENCL: 3,
  2812. AUTO: 4,
  2813. NNAPI: 5,
  2814. OPENGLES: 6,
  2815. VULKAN: 7
  2816. };
  2817. MNN.Usage = {
  2818. INFERENCE: 0,
  2819. TRAIN: 1,
  2820. INFERENCE_STATIC: 2
  2821. };
  2822. MNN.SubGraphProto = class SubGraphProto {
  2823. static decode(reader, position) {
  2824. const $ = new MNN.SubGraphProto();
  2825. $.name = reader.string_(position, 4, null);
  2826. $.inputs = reader.array(position, 6, Int32Array);
  2827. $.outputs = reader.array(position, 8, Int32Array);
  2828. $.tensors = reader.strings_(position, 10);
  2829. $.nodes = reader.tables(position, 12, MNN.Op);
  2830. $.extraTensorDescribe = reader.tables(position, 14, MNN.TensorDescribe);
  2831. return $;
  2832. }
  2833. static decodeText(reader, json) {
  2834. const $ = new MNN.SubGraphProto();
  2835. $.name = reader.value(json.name, null);
  2836. $.inputs = reader.array(json.inputs, Int32Array);
  2837. $.outputs = reader.array(json.outputs, Int32Array);
  2838. $.tensors = reader.array(json.tensors);
  2839. $.nodes = reader.objects(json.nodes, MNN.Op);
  2840. $.extraTensorDescribe = reader.objects(json.extraTensorDescribe, MNN.TensorDescribe);
  2841. return $;
  2842. }
  2843. };
  2844. MNN.TensorQuantInfo = class TensorQuantInfo {
  2845. static decode(reader, position) {
  2846. const $ = new MNN.TensorQuantInfo();
  2847. $.scale = reader.float32_(position, 4, 0);
  2848. $.zero = reader.float32_(position, 6, 0);
  2849. $.min = reader.float32_(position, 8, -128);
  2850. $.max = reader.float32_(position, 10, 127);
  2851. $.type = reader.int32_(position, 12, 0);
  2852. return $;
  2853. }
  2854. static decodeText(reader, json) {
  2855. const $ = new MNN.TensorQuantInfo();
  2856. $.scale = reader.value(json.scale, 0);
  2857. $.zero = reader.value(json.zero, 0);
  2858. $.min = reader.value(json.min, -128);
  2859. $.max = reader.value(json.max, 127);
  2860. $.type = MNN.DataType[json.type];
  2861. return $;
  2862. }
  2863. };
  2864. MNN.Net = class Net {
  2865. static create(reader) {
  2866. return MNN.Net.decode(reader, reader.root);
  2867. }
  2868. static createText(reader) {
  2869. return MNN.Net.decodeText(reader, reader.root);
  2870. }
  2871. static decode(reader, position) {
  2872. const $ = new MNN.Net();
  2873. $.bizCode = reader.string_(position, 4, null);
  2874. $.extraTensorDescribe = reader.tables(position, 6, MNN.TensorDescribe);
  2875. $.extraInfo = reader.table(position, 8, MNN.ExtraInfo);
  2876. $.oplists = reader.tables(position, 10, MNN.Op);
  2877. $.outputName = reader.strings_(position, 12);
  2878. $.preferForwardType = reader.int8_(position, 14, 0);
  2879. $.sourceType = reader.int8_(position, 16, 0);
  2880. $.tensorName = reader.strings_(position, 18);
  2881. $.tensorNumber = reader.int32_(position, 20, 0);
  2882. $.usage = reader.int8_(position, 22, 0);
  2883. $.subgraphs = reader.tables(position, 24, MNN.SubGraphProto);
  2884. $.mnn_uuid = reader.string_(position, 26, null);
  2885. return $;
  2886. }
  2887. static decodeText(reader, json) {
  2888. const $ = new MNN.Net();
  2889. $.bizCode = reader.value(json.bizCode, null);
  2890. $.extraTensorDescribe = reader.objects(json.extraTensorDescribe, MNN.TensorDescribe);
  2891. $.extraInfo = reader.object(json.extraInfo, MNN.ExtraInfo);
  2892. $.oplists = reader.objects(json.oplists, MNN.Op);
  2893. $.outputName = reader.array(json.outputName);
  2894. $.preferForwardType = MNN.ForwardType[json.preferForwardType];
  2895. $.sourceType = MNN.NetSource[json.sourceType];
  2896. $.tensorName = reader.array(json.tensorName);
  2897. $.tensorNumber = reader.value(json.tensorNumber, 0);
  2898. $.usage = MNN.Usage[json.usage];
  2899. $.subgraphs = reader.objects(json.subgraphs, MNN.SubGraphProto);
  2900. $.mnn_uuid = reader.value(json.mnn_uuid, null);
  2901. return $;
  2902. }
  2903. };