|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240 |
- // clang-format off
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(AdaptivePooling);
-
- namespace {
- size_t AdaptivePooling_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<AdaptivePooling>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.shape));
- return val;
- }
- bool AdaptivePooling_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<AdaptivePooling>(),
- &&b_ = rhs_.cast_final_safe<AdaptivePooling>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- if (a_.format != b_.format) return false;
- if (a_.shape != b_.shape) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> AdaptivePooling_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<AdaptivePooling>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case AdaptivePooling::Mode::MAX:
- props_.emplace_back("mode", "MAX");
- break;
- case AdaptivePooling::Mode::AVERAGE:
- props_.emplace_back("mode", "AVERAGE");
- break;
- case AdaptivePooling::Mode::AVERAGE_COUNT_EXCLUDE_PADDING:
- props_.emplace_back("mode", "AVERAGE_COUNT_EXCLUDE_PADDING");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- switch (op_.format){
- case AdaptivePooling::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case AdaptivePooling::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case AdaptivePooling::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case AdaptivePooling::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case AdaptivePooling::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case AdaptivePooling::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case AdaptivePooling::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case AdaptivePooling::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case AdaptivePooling::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case AdaptivePooling::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case AdaptivePooling::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case AdaptivePooling::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case AdaptivePooling::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case AdaptivePooling::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case AdaptivePooling::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case AdaptivePooling::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case AdaptivePooling::Format::NCHW64:
- props_.emplace_back("format", "NCHW64");
- break;
- case AdaptivePooling::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- props_.emplace_back("shape", "{std::vector}");
- return props_;
- }
- std::string AdaptivePooling_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<AdaptivePooling>();
- static_cast<void>(op_);
- return "AdaptivePooling";
- }
- } // anonymous namespace
- OP_TRAIT_REG(AdaptivePooling, AdaptivePooling)
- .hash(AdaptivePooling_hash_impl)
- .is_same_st(AdaptivePooling_is_same_st_impl)
- .props(AdaptivePooling_props_impl)
- .make_name(AdaptivePooling_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(AddAxis);
-
- namespace {
- size_t AddAxis_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<AddAxis>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
- return val;
- }
- bool AddAxis_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<AddAxis>(),
- &&b_ = rhs_.cast_final_safe<AddAxis>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.axis != b_.axis) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> AddAxis_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<AddAxis>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("axis", "{std::vector}");
- return props_;
- }
- std::string AddAxis_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<AddAxis>();
- static_cast<void>(op_);
- return "AddAxis";
- }
- } // anonymous namespace
- OP_TRAIT_REG(AddAxis, AddAxis)
- .hash(AddAxis_hash_impl)
- .is_same_st(AddAxis_is_same_st_impl)
- .props(AddAxis_props_impl)
- .make_name(AddAxis_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Argmax);
-
- namespace {
- size_t Argmax_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Argmax>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
- return val;
- }
- bool Argmax_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Argmax>(),
- &&b_ = rhs_.cast_final_safe<Argmax>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.axis != b_.axis) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Argmax_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Argmax>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("axis", std::to_string(op_.axis));
- return props_;
- }
- std::string Argmax_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Argmax>();
- static_cast<void>(op_);
- return "Argmax";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Argmax, Argmax)
- .hash(Argmax_hash_impl)
- .is_same_st(Argmax_is_same_st_impl)
- .props(Argmax_props_impl)
- .make_name(Argmax_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Argmin);
-
- namespace {
- size_t Argmin_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Argmin>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
- return val;
- }
- bool Argmin_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Argmin>(),
- &&b_ = rhs_.cast_final_safe<Argmin>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.axis != b_.axis) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Argmin_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Argmin>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("axis", std::to_string(op_.axis));
- return props_;
- }
- std::string Argmin_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Argmin>();
- static_cast<void>(op_);
- return "Argmin";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Argmin, Argmin)
- .hash(Argmin_hash_impl)
- .is_same_st(Argmin_is_same_st_impl)
- .props(Argmin_props_impl)
- .make_name(Argmin_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Argsort);
-
- namespace {
- size_t Argsort_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Argsort>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.order));
- return val;
- }
- bool Argsort_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Argsort>(),
- &&b_ = rhs_.cast_final_safe<Argsort>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.order != b_.order) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Argsort_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Argsort>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.order){
- case Argsort::Order::ASCENDING:
- props_.emplace_back("order", "ASCENDING");
- break;
- case Argsort::Order::DESCENDING:
- props_.emplace_back("order", "DESCENDING");
- break;
- default:
- props_.emplace_back("order", "INVALID");
- break;
- }
- return props_;
- }
- std::string Argsort_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Argsort>();
- static_cast<void>(op_);
- return "Argsort";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Argsort, Argsort)
- .hash(Argsort_hash_impl)
- .is_same_st(Argsort_is_same_st_impl)
- .props(Argsort_props_impl)
- .make_name(Argsort_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(AssertEqual);
-
- namespace {
- size_t AssertEqual_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<AssertEqual>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.maxerr));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.verbose));
- return val;
- }
- bool AssertEqual_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<AssertEqual>(),
- &&b_ = rhs_.cast_final_safe<AssertEqual>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.maxerr != b_.maxerr) return false;
- if (a_.verbose != b_.verbose) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> AssertEqual_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<AssertEqual>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("maxerr", std::to_string(op_.maxerr));
- props_.emplace_back("verbose", std::to_string(op_.verbose));
- return props_;
- }
- std::string AssertEqual_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<AssertEqual>();
- static_cast<void>(op_);
- return "AssertEqual";
- }
- } // anonymous namespace
- OP_TRAIT_REG(AssertEqual, AssertEqual)
- .hash(AssertEqual_hash_impl)
- .is_same_st(AssertEqual_is_same_st_impl)
- .props(AssertEqual_props_impl)
- .make_name(AssertEqual_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(AtlasRuntime);
-
- namespace {
- size_t AtlasRuntime_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<AtlasRuntime>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.buf));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.buf_size));
- return val;
- }
- bool AtlasRuntime_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<AtlasRuntime>(),
- &&b_ = rhs_.cast_final_safe<AtlasRuntime>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.buf != b_.buf) return false;
- if (a_.buf_size != b_.buf_size) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> AtlasRuntime_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<AtlasRuntime>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("buf", op_.buf);
- props_.emplace_back("buf_size", std::to_string(op_.buf_size));
- return props_;
- }
- std::string AtlasRuntime_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<AtlasRuntime>();
- static_cast<void>(op_);
- return "AtlasRuntime";
- }
- } // anonymous namespace
- OP_TRAIT_REG(AtlasRuntime, AtlasRuntime)
- .hash(AtlasRuntime_hash_impl)
- .is_same_st(AtlasRuntime_is_same_st_impl)
- .props(AtlasRuntime_props_impl)
- .make_name(AtlasRuntime_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Barrier);
-
- namespace {
- size_t Barrier_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Barrier>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.nr_outputs));
- return val;
- }
- bool Barrier_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Barrier>(),
- &&b_ = rhs_.cast_final_safe<Barrier>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.comp_node != b_.comp_node) return false;
- if (a_.nr_outputs != b_.nr_outputs) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Barrier_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Barrier>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("comp_node", op_.comp_node.to_string());
- props_.emplace_back("nr_outputs", std::to_string(op_.nr_outputs));
- return props_;
- }
- std::string Barrier_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Barrier>();
- static_cast<void>(op_);
- return "Barrier";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Barrier, Barrier)
- .hash(Barrier_hash_impl)
- .is_same_st(Barrier_is_same_st_impl)
- .props(Barrier_props_impl)
- .make_name(Barrier_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(BatchConvBias);
-
- namespace {
- size_t BatchConvBias_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchConvBias>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.nonlineMode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
- return val;
- }
- bool BatchConvBias_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<BatchConvBias>(),
- &&b_ = rhs_.cast_final_safe<BatchConvBias>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.nonlineMode != b_.nonlineMode) return false;
- if (a_.mode != b_.mode) return false;
- if (a_.pad_h != b_.pad_h) return false;
- if (a_.pad_w != b_.pad_w) return false;
- if (a_.stride_h != b_.stride_h) return false;
- if (a_.stride_w != b_.stride_w) return false;
- if (a_.dilate_h != b_.dilate_h) return false;
- if (a_.dilate_w != b_.dilate_w) return false;
- if (a_.sparse != b_.sparse) return false;
- if (a_.format != b_.format) return false;
- if (a_.compute_mode != b_.compute_mode) return false;
- if (a_.strategy != b_.strategy) return false;
- if (a_.workspace_limit != b_.workspace_limit) return false;
- if (a_.dtype != b_.dtype) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> BatchConvBias_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchConvBias>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.nonlineMode){
- case BatchConvBias::NonlineMode::IDENTITY:
- props_.emplace_back("nonlineMode", "IDENTITY");
- break;
- case BatchConvBias::NonlineMode::RELU:
- props_.emplace_back("nonlineMode", "RELU");
- break;
- case BatchConvBias::NonlineMode::SIGMOID:
- props_.emplace_back("nonlineMode", "SIGMOID");
- break;
- case BatchConvBias::NonlineMode::H_SWISH:
- props_.emplace_back("nonlineMode", "H_SWISH");
- break;
- default:
- props_.emplace_back("nonlineMode", "INVALID");
- break;
- }
- switch (op_.mode){
- case BatchConvBias::Mode::CROSS_CORRELATION:
- props_.emplace_back("mode", "CROSS_CORRELATION");
- break;
- case BatchConvBias::Mode::CONVOLUTION:
- props_.emplace_back("mode", "CONVOLUTION");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- props_.emplace_back("pad_h", std::to_string(op_.pad_h));
- props_.emplace_back("pad_w", std::to_string(op_.pad_w));
- props_.emplace_back("stride_h", std::to_string(op_.stride_h));
- props_.emplace_back("stride_w", std::to_string(op_.stride_w));
- props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
- props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
- switch (op_.sparse){
- case BatchConvBias::Sparse::DENSE:
- props_.emplace_back("sparse", "DENSE");
- break;
- case BatchConvBias::Sparse::GROUP:
- props_.emplace_back("sparse", "GROUP");
- break;
- default:
- props_.emplace_back("sparse", "INVALID");
- break;
- }
- switch (op_.format){
- case BatchConvBias::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case BatchConvBias::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case BatchConvBias::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case BatchConvBias::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case BatchConvBias::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case BatchConvBias::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case BatchConvBias::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case BatchConvBias::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case BatchConvBias::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case BatchConvBias::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case BatchConvBias::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case BatchConvBias::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case BatchConvBias::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case BatchConvBias::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case BatchConvBias::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case BatchConvBias::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case BatchConvBias::Format::NCHW64:
- props_.emplace_back("format", "NCHW64");
- break;
- case BatchConvBias::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- switch (op_.compute_mode){
- case BatchConvBias::ComputeMode::DEFAULT:
- props_.emplace_back("compute_mode", "DEFAULT");
- break;
- case BatchConvBias::ComputeMode::FLOAT32:
- props_.emplace_back("compute_mode", "FLOAT32");
- break;
- default:
- props_.emplace_back("compute_mode", "INVALID");
- break;
- }
- switch (op_.strategy){
- case BatchConvBias::Strategy::HEURISTIC:
- props_.emplace_back("strategy", "HEURISTIC");
- break;
- case BatchConvBias::Strategy::PROFILE:
- props_.emplace_back("strategy", "PROFILE");
- break;
- case BatchConvBias::Strategy::REPRODUCIBLE:
- props_.emplace_back("strategy", "REPRODUCIBLE");
- break;
- case BatchConvBias::Strategy::OPTIMIZED:
- props_.emplace_back("strategy", "OPTIMIZED");
- break;
- default:
- props_.emplace_back("strategy", "INVALID");
- break;
- }
- props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
- props_.emplace_back("dtype", op_.dtype.name());
- return props_;
- }
- std::string BatchConvBias_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchConvBias>();
- static_cast<void>(op_);
- return "BatchConvBias";
- }
- } // anonymous namespace
- OP_TRAIT_REG(BatchConvBias, BatchConvBias)
- .hash(BatchConvBias_hash_impl)
- .is_same_st(BatchConvBias_is_same_st_impl)
- .props(BatchConvBias_props_impl)
- .make_name(BatchConvBias_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(BatchNorm);
-
- namespace {
- size_t BatchNorm_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchNorm>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.param_dim));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.fwd_mode));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.epsilon));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.avg_factor));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.scale));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.bias));
- return val;
- }
- bool BatchNorm_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<BatchNorm>(),
- &&b_ = rhs_.cast_final_safe<BatchNorm>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.param_dim != b_.param_dim) return false;
- if (a_.fwd_mode != b_.fwd_mode) return false;
- if (a_.epsilon != b_.epsilon) return false;
- if (a_.avg_factor != b_.avg_factor) return false;
- if (a_.scale != b_.scale) return false;
- if (a_.bias != b_.bias) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> BatchNorm_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchNorm>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.param_dim){
- case BatchNorm::ParamDim::DIM_11HW:
- props_.emplace_back("param_dim", "DIM_11HW");
- break;
- case BatchNorm::ParamDim::DIM_1CHW:
- props_.emplace_back("param_dim", "DIM_1CHW");
- break;
- case BatchNorm::ParamDim::DIM_1C11:
- props_.emplace_back("param_dim", "DIM_1C11");
- break;
- case BatchNorm::ParamDim::DIM_111C:
- props_.emplace_back("param_dim", "DIM_111C");
- break;
- default:
- props_.emplace_back("param_dim", "INVALID");
- break;
- }
- switch (op_.fwd_mode){
- case BatchNorm::FwdMode::TRAINING:
- props_.emplace_back("fwd_mode", "TRAINING");
- break;
- case BatchNorm::FwdMode::INFERENCE:
- props_.emplace_back("fwd_mode", "INFERENCE");
- break;
- default:
- props_.emplace_back("fwd_mode", "INVALID");
- break;
- }
- props_.emplace_back("epsilon", std::to_string(op_.epsilon));
- props_.emplace_back("avg_factor", std::to_string(op_.avg_factor));
- props_.emplace_back("scale", std::to_string(op_.scale));
- props_.emplace_back("bias", std::to_string(op_.bias));
- return props_;
- }
- std::string BatchNorm_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchNorm>();
- static_cast<void>(op_);
- return "BatchNorm";
- }
- } // anonymous namespace
- OP_TRAIT_REG(BatchNorm, BatchNorm)
- .hash(BatchNorm_hash_impl)
- .is_same_st(BatchNorm_is_same_st_impl)
- .props(BatchNorm_props_impl)
- .make_name(BatchNorm_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(BatchNormBackward);
-
- namespace {
- size_t BatchNormBackward_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchNormBackward>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.param_dim));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.fwd_mode));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.epsilon));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.avg_factor));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.scale));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.bias));
- return val;
- }
- bool BatchNormBackward_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<BatchNormBackward>(),
- &&b_ = rhs_.cast_final_safe<BatchNormBackward>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.param_dim != b_.param_dim) return false;
- if (a_.fwd_mode != b_.fwd_mode) return false;
- if (a_.epsilon != b_.epsilon) return false;
- if (a_.avg_factor != b_.avg_factor) return false;
- if (a_.scale != b_.scale) return false;
- if (a_.bias != b_.bias) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> BatchNormBackward_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchNormBackward>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.param_dim){
- case BatchNormBackward::ParamDim::DIM_11HW:
- props_.emplace_back("param_dim", "DIM_11HW");
- break;
- case BatchNormBackward::ParamDim::DIM_1CHW:
- props_.emplace_back("param_dim", "DIM_1CHW");
- break;
- case BatchNormBackward::ParamDim::DIM_1C11:
- props_.emplace_back("param_dim", "DIM_1C11");
- break;
- case BatchNormBackward::ParamDim::DIM_111C:
- props_.emplace_back("param_dim", "DIM_111C");
- break;
- default:
- props_.emplace_back("param_dim", "INVALID");
- break;
- }
- switch (op_.fwd_mode){
- case BatchNormBackward::FwdMode::TRAINING:
- props_.emplace_back("fwd_mode", "TRAINING");
- break;
- case BatchNormBackward::FwdMode::INFERENCE:
- props_.emplace_back("fwd_mode", "INFERENCE");
- break;
- default:
- props_.emplace_back("fwd_mode", "INVALID");
- break;
- }
- props_.emplace_back("epsilon", std::to_string(op_.epsilon));
- props_.emplace_back("avg_factor", std::to_string(op_.avg_factor));
- props_.emplace_back("scale", std::to_string(op_.scale));
- props_.emplace_back("bias", std::to_string(op_.bias));
- return props_;
- }
- std::string BatchNormBackward_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchNormBackward>();
- static_cast<void>(op_);
- return "BatchNormBackward";
- }
- } // anonymous namespace
- OP_TRAIT_REG(BatchNormBackward, BatchNormBackward)
- .hash(BatchNormBackward_hash_impl)
- .is_same_st(BatchNormBackward_is_same_st_impl)
- .props(BatchNormBackward_props_impl)
- .make_name(BatchNormBackward_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(BatchedIncrMeshIndexing);
-
- namespace {
- size_t BatchedIncrMeshIndexing_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchedIncrMeshIndexing>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
- return val;
- }
- bool BatchedIncrMeshIndexing_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<BatchedIncrMeshIndexing>(),
- &&b_ = rhs_.cast_final_safe<BatchedIncrMeshIndexing>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.items != b_.items) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> BatchedIncrMeshIndexing_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchedIncrMeshIndexing>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("items", "{std::vector}");
- return props_;
- }
- std::string BatchedIncrMeshIndexing_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchedIncrMeshIndexing>();
- static_cast<void>(op_);
- return "BatchedIncrMeshIndexing";
- }
- } // anonymous namespace
- OP_TRAIT_REG(BatchedIncrMeshIndexing, BatchedIncrMeshIndexing)
- .hash(BatchedIncrMeshIndexing_hash_impl)
- .is_same_st(BatchedIncrMeshIndexing_is_same_st_impl)
- .props(BatchedIncrMeshIndexing_props_impl)
- .make_name(BatchedIncrMeshIndexing_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(BatchedMatrixMul);
-
- namespace {
- size_t BatchedMatrixMul_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchedMatrixMul>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.transposeA));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.transposeB));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dimA));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dimB));
- return val;
- }
- bool BatchedMatrixMul_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<BatchedMatrixMul>(),
- &&b_ = rhs_.cast_final_safe<BatchedMatrixMul>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.transposeA != b_.transposeA) return false;
- if (a_.transposeB != b_.transposeB) return false;
- if (a_.compute_mode != b_.compute_mode) return false;
- if (a_.format != b_.format) return false;
- if (a_.strategy != b_.strategy) return false;
- if (a_.workspace_limit != b_.workspace_limit) return false;
- if (a_.dimA != b_.dimA) return false;
- if (a_.dimB != b_.dimB) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> BatchedMatrixMul_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchedMatrixMul>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("transposeA", std::to_string(op_.transposeA));
- props_.emplace_back("transposeB", std::to_string(op_.transposeB));
- switch (op_.compute_mode){
- case BatchedMatrixMul::ComputeMode::DEFAULT:
- props_.emplace_back("compute_mode", "DEFAULT");
- break;
- case BatchedMatrixMul::ComputeMode::FLOAT32:
- props_.emplace_back("compute_mode", "FLOAT32");
- break;
- default:
- props_.emplace_back("compute_mode", "INVALID");
- break;
- }
- switch (op_.format){
- case BatchedMatrixMul::Format::DEFAULT:
- props_.emplace_back("format", "DEFAULT");
- break;
- case BatchedMatrixMul::Format::MK4:
- props_.emplace_back("format", "MK4");
- break;
- case BatchedMatrixMul::Format::MK8:
- props_.emplace_back("format", "MK8");
- break;
- case BatchedMatrixMul::Format::MK4_DOT:
- props_.emplace_back("format", "MK4_DOT");
- break;
- case BatchedMatrixMul::Format::N32K4_DOT:
- props_.emplace_back("format", "N32K4_DOT");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- switch (op_.strategy){
- case BatchedMatrixMul::Strategy::HEURISTIC:
- props_.emplace_back("strategy", "HEURISTIC");
- break;
- case BatchedMatrixMul::Strategy::PROFILE:
- props_.emplace_back("strategy", "PROFILE");
- break;
- case BatchedMatrixMul::Strategy::REPRODUCIBLE:
- props_.emplace_back("strategy", "REPRODUCIBLE");
- break;
- case BatchedMatrixMul::Strategy::OPTIMIZED:
- props_.emplace_back("strategy", "OPTIMIZED");
- break;
- default:
- props_.emplace_back("strategy", "INVALID");
- break;
- }
- props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
- props_.emplace_back("dimA", std::to_string(op_.dimA));
- props_.emplace_back("dimB", std::to_string(op_.dimB));
- return props_;
- }
- std::string BatchedMatrixMul_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchedMatrixMul>();
- static_cast<void>(op_);
- return "BatchedMatrixMul";
- }
- } // anonymous namespace
- OP_TRAIT_REG(BatchedMatrixMul, BatchedMatrixMul)
- .hash(BatchedMatrixMul_hash_impl)
- .is_same_st(BatchedMatrixMul_is_same_st_impl)
- .props(BatchedMatrixMul_props_impl)
- .make_name(BatchedMatrixMul_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(BatchedMeshIndexing);
-
- namespace {
- size_t BatchedMeshIndexing_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchedMeshIndexing>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
- return val;
- }
- bool BatchedMeshIndexing_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<BatchedMeshIndexing>(),
- &&b_ = rhs_.cast_final_safe<BatchedMeshIndexing>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.items != b_.items) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> BatchedMeshIndexing_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchedMeshIndexing>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("items", "{std::vector}");
- return props_;
- }
- std::string BatchedMeshIndexing_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchedMeshIndexing>();
- static_cast<void>(op_);
- return "BatchedMeshIndexing";
- }
- } // anonymous namespace
- OP_TRAIT_REG(BatchedMeshIndexing, BatchedMeshIndexing)
- .hash(BatchedMeshIndexing_hash_impl)
- .is_same_st(BatchedMeshIndexing_is_same_st_impl)
- .props(BatchedMeshIndexing_props_impl)
- .make_name(BatchedMeshIndexing_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(BatchedSetMeshIndexing);
-
- namespace {
- size_t BatchedSetMeshIndexing_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchedSetMeshIndexing>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
- return val;
- }
- bool BatchedSetMeshIndexing_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<BatchedSetMeshIndexing>(),
- &&b_ = rhs_.cast_final_safe<BatchedSetMeshIndexing>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.items != b_.items) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> BatchedSetMeshIndexing_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchedSetMeshIndexing>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("items", "{std::vector}");
- return props_;
- }
- std::string BatchedSetMeshIndexing_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BatchedSetMeshIndexing>();
- static_cast<void>(op_);
- return "BatchedSetMeshIndexing";
- }
- } // anonymous namespace
- OP_TRAIT_REG(BatchedSetMeshIndexing, BatchedSetMeshIndexing)
- .hash(BatchedSetMeshIndexing_hash_impl)
- .is_same_st(BatchedSetMeshIndexing_is_same_st_impl)
- .props(BatchedSetMeshIndexing_props_impl)
- .make_name(BatchedSetMeshIndexing_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(BetaRNG);
-
- namespace {
- size_t BetaRNG_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BetaRNG>();
- static_cast<void>(op_);
-
- return mgb::hash_pair_combine(
- mgb::hash(op_.dyn_typeinfo()),
- mgb::hash(op_.handle)
- );
- }
- bool BetaRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<BetaRNG>(),
- &&b_ = rhs_.cast_final_safe<BetaRNG>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- return a_.handle == b_.handle;}
- std::vector<std::pair<const char*, std::string>> BetaRNG_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BetaRNG>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("seed", std::to_string(op_.seed));
- props_.emplace_back("handle", std::to_string(op_.handle));
- return props_;
- }
- std::string BetaRNG_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<BetaRNG>();
- static_cast<void>(op_);
- return "BetaRNG";
- }
- } // anonymous namespace
- OP_TRAIT_REG(BetaRNG, BetaRNG)
- .hash(BetaRNG_hash_impl)
- .is_same_st(BetaRNG_is_same_st_impl)
- .props(BetaRNG_props_impl)
- .make_name(BetaRNG_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Borrow);
-
- namespace {
- size_t Borrow_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Borrow>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
- return val;
- }
- bool Borrow_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Borrow>(),
- &&b_ = rhs_.cast_final_safe<Borrow>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.comp_node != b_.comp_node) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Borrow_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Borrow>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("comp_node", op_.comp_node.to_string());
- return props_;
- }
- std::string Borrow_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Borrow>();
- static_cast<void>(op_);
- return "Borrow";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Borrow, Borrow)
- .hash(Borrow_hash_impl)
- .is_same_st(Borrow_is_same_st_impl)
- .props(Borrow_props_impl)
- .make_name(Borrow_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Broadcast);
-
- namespace {
- size_t Broadcast_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Broadcast>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.shape));
- return val;
- }
- bool Broadcast_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Broadcast>(),
- &&b_ = rhs_.cast_final_safe<Broadcast>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.shape != b_.shape) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Broadcast_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Broadcast>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("shape", "{std::vector}");
- return props_;
- }
- std::string Broadcast_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Broadcast>();
- static_cast<void>(op_);
- return "Broadcast";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Broadcast, Broadcast)
- .hash(Broadcast_hash_impl)
- .is_same_st(Broadcast_is_same_st_impl)
- .props(Broadcast_props_impl)
- .make_name(Broadcast_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(CambriconRuntime);
-
- namespace {
- size_t CambriconRuntime_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<CambriconRuntime>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.buf));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.buf_size));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.symbol));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.tensor_dim_mutable));
- return val;
- }
- bool CambriconRuntime_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<CambriconRuntime>(),
- &&b_ = rhs_.cast_final_safe<CambriconRuntime>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.buf != b_.buf) return false;
- if (a_.buf_size != b_.buf_size) return false;
- if (a_.symbol != b_.symbol) return false;
- if (a_.tensor_dim_mutable != b_.tensor_dim_mutable) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> CambriconRuntime_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<CambriconRuntime>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("buf", op_.buf);
- props_.emplace_back("buf_size", std::to_string(op_.buf_size));
- props_.emplace_back("symbol", op_.symbol);
- props_.emplace_back("tensor_dim_mutable", std::to_string(op_.tensor_dim_mutable));
- return props_;
- }
- std::string CambriconRuntime_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<CambriconRuntime>();
- static_cast<void>(op_);
- return "CambriconRuntime";
- }
- } // anonymous namespace
- OP_TRAIT_REG(CambriconRuntime, CambriconRuntime)
- .hash(CambriconRuntime_hash_impl)
- .is_same_st(CambriconRuntime_is_same_st_impl)
- .props(CambriconRuntime_props_impl)
- .make_name(CambriconRuntime_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(CheckNonFinite);
-
- namespace {
- size_t CheckNonFinite_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<CheckNonFinite>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.scale));
- return val;
- }
- bool CheckNonFinite_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<CheckNonFinite>(),
- &&b_ = rhs_.cast_final_safe<CheckNonFinite>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.scale != b_.scale) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> CheckNonFinite_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<CheckNonFinite>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("scale", std::to_string(op_.scale));
- return props_;
- }
- std::string CheckNonFinite_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<CheckNonFinite>();
- static_cast<void>(op_);
- return "CheckNonFinite";
- }
- } // anonymous namespace
- OP_TRAIT_REG(CheckNonFinite, CheckNonFinite)
- .hash(CheckNonFinite_hash_impl)
- .is_same_st(CheckNonFinite_is_same_st_impl)
- .props(CheckNonFinite_props_impl)
- .make_name(CheckNonFinite_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(CollectiveComm);
-
- namespace {
- size_t CollectiveComm_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<CollectiveComm>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.key));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.nr_devices));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.rank));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.is_root));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.local_grad));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.addr));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.port));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.backend));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
- return val;
- }
- bool CollectiveComm_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<CollectiveComm>(),
- &&b_ = rhs_.cast_final_safe<CollectiveComm>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- if (a_.key != b_.key) return false;
- if (a_.nr_devices != b_.nr_devices) return false;
- if (a_.rank != b_.rank) return false;
- if (a_.is_root != b_.is_root) return false;
- if (a_.local_grad != b_.local_grad) return false;
- if (a_.addr != b_.addr) return false;
- if (a_.port != b_.port) return false;
- if (a_.dtype != b_.dtype) return false;
- if (a_.backend != b_.backend) return false;
- if (a_.comp_node != b_.comp_node) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> CollectiveComm_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<CollectiveComm>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case CollectiveComm::Mode::REDUCE_SUM:
- props_.emplace_back("mode", "REDUCE_SUM");
- break;
- case CollectiveComm::Mode::BROADCAST:
- props_.emplace_back("mode", "BROADCAST");
- break;
- case CollectiveComm::Mode::ALL_GATHER:
- props_.emplace_back("mode", "ALL_GATHER");
- break;
- case CollectiveComm::Mode::REDUCE_SCATTER_SUM:
- props_.emplace_back("mode", "REDUCE_SCATTER_SUM");
- break;
- case CollectiveComm::Mode::ALL_REDUCE_SUM:
- props_.emplace_back("mode", "ALL_REDUCE_SUM");
- break;
- case CollectiveComm::Mode::ALL_REDUCE_MAX:
- props_.emplace_back("mode", "ALL_REDUCE_MAX");
- break;
- case CollectiveComm::Mode::ALL_REDUCE_MIN:
- props_.emplace_back("mode", "ALL_REDUCE_MIN");
- break;
- case CollectiveComm::Mode::ALL_REDUCE_PROD:
- props_.emplace_back("mode", "ALL_REDUCE_PROD");
- break;
- case CollectiveComm::Mode::GATHER:
- props_.emplace_back("mode", "GATHER");
- break;
- case CollectiveComm::Mode::SCATTER:
- props_.emplace_back("mode", "SCATTER");
- break;
- case CollectiveComm::Mode::ALL_TO_ALL:
- props_.emplace_back("mode", "ALL_TO_ALL");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- props_.emplace_back("key", op_.key);
- props_.emplace_back("nr_devices", std::to_string(op_.nr_devices));
- props_.emplace_back("rank", std::to_string(op_.rank));
- props_.emplace_back("is_root", std::to_string(op_.is_root));
- props_.emplace_back("local_grad", std::to_string(op_.local_grad));
- props_.emplace_back("addr", op_.addr);
- props_.emplace_back("port", std::to_string(op_.port));
- props_.emplace_back("dtype", op_.dtype.name());
- props_.emplace_back("backend", op_.backend);
- props_.emplace_back("comp_node", op_.comp_node);
- return props_;
- }
- std::string CollectiveComm_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<CollectiveComm>();
- static_cast<void>(op_);
- return "CollectiveComm";
- }
- } // anonymous namespace
- OP_TRAIT_REG(CollectiveComm, CollectiveComm)
- .hash(CollectiveComm_hash_impl)
- .is_same_st(CollectiveComm_is_same_st_impl)
- .props(CollectiveComm_props_impl)
- .make_name(CollectiveComm_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Concat);
-
- namespace {
- size_t Concat_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Concat>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
- return val;
- }
- bool Concat_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Concat>(),
- &&b_ = rhs_.cast_final_safe<Concat>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.axis != b_.axis) return false;
- if (a_.comp_node != b_.comp_node) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Concat_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Concat>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("axis", std::to_string(op_.axis));
- props_.emplace_back("comp_node", op_.comp_node.to_string());
- return props_;
- }
- std::string Concat_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Concat>();
- static_cast<void>(op_);
- return "Concat";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Concat, Concat)
- .hash(Concat_hash_impl)
- .is_same_st(Concat_is_same_st_impl)
- .props(Concat_props_impl)
- .make_name(Concat_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(CondTake);
-
- namespace {
- size_t CondTake_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<CondTake>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- return val;
- }
- bool CondTake_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<CondTake>(),
- &&b_ = rhs_.cast_final_safe<CondTake>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- return true;
- }
- std::vector<std::pair<const char*, std::string>> CondTake_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<CondTake>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- return props_;
- }
- std::string CondTake_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<CondTake>();
- static_cast<void>(op_);
- return "CondTake";
- }
- } // anonymous namespace
- OP_TRAIT_REG(CondTake, CondTake)
- .hash(CondTake_hash_impl)
- .is_same_st(CondTake_is_same_st_impl)
- .props(CondTake_props_impl)
- .make_name(CondTake_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(ConvBias);
-
- namespace {
- size_t ConvBias_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ConvBias>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.nonlineMode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
- return val;
- }
- bool ConvBias_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<ConvBias>(),
- &&b_ = rhs_.cast_final_safe<ConvBias>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.nonlineMode != b_.nonlineMode) return false;
- if (a_.mode != b_.mode) return false;
- if (a_.sparse != b_.sparse) return false;
- if (a_.format != b_.format) return false;
- if (a_.pad_h != b_.pad_h) return false;
- if (a_.pad_w != b_.pad_w) return false;
- if (a_.stride_h != b_.stride_h) return false;
- if (a_.stride_w != b_.stride_w) return false;
- if (a_.dilate_h != b_.dilate_h) return false;
- if (a_.dilate_w != b_.dilate_w) return false;
- if (a_.compute_mode != b_.compute_mode) return false;
- if (a_.strategy != b_.strategy) return false;
- if (a_.workspace_limit != b_.workspace_limit) return false;
- if (a_.dtype != b_.dtype) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> ConvBias_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ConvBias>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.nonlineMode){
- case ConvBias::NonlineMode::IDENTITY:
- props_.emplace_back("nonlineMode", "IDENTITY");
- break;
- case ConvBias::NonlineMode::RELU:
- props_.emplace_back("nonlineMode", "RELU");
- break;
- case ConvBias::NonlineMode::SIGMOID:
- props_.emplace_back("nonlineMode", "SIGMOID");
- break;
- case ConvBias::NonlineMode::H_SWISH:
- props_.emplace_back("nonlineMode", "H_SWISH");
- break;
- default:
- props_.emplace_back("nonlineMode", "INVALID");
- break;
- }
- switch (op_.mode){
- case ConvBias::Mode::CROSS_CORRELATION:
- props_.emplace_back("mode", "CROSS_CORRELATION");
- break;
- case ConvBias::Mode::CONVOLUTION:
- props_.emplace_back("mode", "CONVOLUTION");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- switch (op_.sparse){
- case ConvBias::Sparse::DENSE:
- props_.emplace_back("sparse", "DENSE");
- break;
- case ConvBias::Sparse::GROUP:
- props_.emplace_back("sparse", "GROUP");
- break;
- default:
- props_.emplace_back("sparse", "INVALID");
- break;
- }
- switch (op_.format){
- case ConvBias::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case ConvBias::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case ConvBias::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case ConvBias::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case ConvBias::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case ConvBias::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case ConvBias::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case ConvBias::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case ConvBias::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case ConvBias::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case ConvBias::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case ConvBias::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case ConvBias::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case ConvBias::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case ConvBias::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case ConvBias::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case ConvBias::Format::NCHW64:
- props_.emplace_back("format", "NCHW64");
- break;
- case ConvBias::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- props_.emplace_back("pad_h", std::to_string(op_.pad_h));
- props_.emplace_back("pad_w", std::to_string(op_.pad_w));
- props_.emplace_back("stride_h", std::to_string(op_.stride_h));
- props_.emplace_back("stride_w", std::to_string(op_.stride_w));
- props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
- props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
- switch (op_.compute_mode){
- case ConvBias::ComputeMode::DEFAULT:
- props_.emplace_back("compute_mode", "DEFAULT");
- break;
- case ConvBias::ComputeMode::FLOAT32:
- props_.emplace_back("compute_mode", "FLOAT32");
- break;
- default:
- props_.emplace_back("compute_mode", "INVALID");
- break;
- }
- switch (op_.strategy){
- case ConvBias::Strategy::HEURISTIC:
- props_.emplace_back("strategy", "HEURISTIC");
- break;
- case ConvBias::Strategy::PROFILE:
- props_.emplace_back("strategy", "PROFILE");
- break;
- case ConvBias::Strategy::REPRODUCIBLE:
- props_.emplace_back("strategy", "REPRODUCIBLE");
- break;
- case ConvBias::Strategy::OPTIMIZED:
- props_.emplace_back("strategy", "OPTIMIZED");
- break;
- default:
- props_.emplace_back("strategy", "INVALID");
- break;
- }
- props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
- props_.emplace_back("dtype", op_.dtype.name());
- return props_;
- }
- std::string ConvBias_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ConvBias>();
- static_cast<void>(op_);
- return "ConvBias";
- }
- } // anonymous namespace
- OP_TRAIT_REG(ConvBias, ConvBias)
- .hash(ConvBias_hash_impl)
- .is_same_st(ConvBias_is_same_st_impl)
- .props(ConvBias_props_impl)
- .make_name(ConvBias_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Convolution);
-
- namespace {
- size_t Convolution_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Convolution>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
- return val;
- }
- bool Convolution_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Convolution>(),
- &&b_ = rhs_.cast_final_safe<Convolution>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- if (a_.pad_h != b_.pad_h) return false;
- if (a_.pad_w != b_.pad_w) return false;
- if (a_.stride_h != b_.stride_h) return false;
- if (a_.stride_w != b_.stride_w) return false;
- if (a_.dilate_h != b_.dilate_h) return false;
- if (a_.dilate_w != b_.dilate_w) return false;
- if (a_.sparse != b_.sparse) return false;
- if (a_.format != b_.format) return false;
- if (a_.compute_mode != b_.compute_mode) return false;
- if (a_.strategy != b_.strategy) return false;
- if (a_.workspace_limit != b_.workspace_limit) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Convolution_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Convolution>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case Convolution::Mode::CROSS_CORRELATION:
- props_.emplace_back("mode", "CROSS_CORRELATION");
- break;
- case Convolution::Mode::CONVOLUTION:
- props_.emplace_back("mode", "CONVOLUTION");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- props_.emplace_back("pad_h", std::to_string(op_.pad_h));
- props_.emplace_back("pad_w", std::to_string(op_.pad_w));
- props_.emplace_back("stride_h", std::to_string(op_.stride_h));
- props_.emplace_back("stride_w", std::to_string(op_.stride_w));
- props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
- props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
- switch (op_.sparse){
- case Convolution::Sparse::DENSE:
- props_.emplace_back("sparse", "DENSE");
- break;
- case Convolution::Sparse::GROUP:
- props_.emplace_back("sparse", "GROUP");
- break;
- default:
- props_.emplace_back("sparse", "INVALID");
- break;
- }
- switch (op_.format){
- case Convolution::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case Convolution::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case Convolution::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case Convolution::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case Convolution::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case Convolution::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case Convolution::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case Convolution::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case Convolution::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case Convolution::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case Convolution::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case Convolution::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case Convolution::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case Convolution::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case Convolution::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case Convolution::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case Convolution::Format::NCHW64:
- props_.emplace_back("format", "NCHW64");
- break;
- case Convolution::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- switch (op_.compute_mode){
- case Convolution::ComputeMode::DEFAULT:
- props_.emplace_back("compute_mode", "DEFAULT");
- break;
- case Convolution::ComputeMode::FLOAT32:
- props_.emplace_back("compute_mode", "FLOAT32");
- break;
- default:
- props_.emplace_back("compute_mode", "INVALID");
- break;
- }
- switch (op_.strategy){
- case Convolution::Strategy::HEURISTIC:
- props_.emplace_back("strategy", "HEURISTIC");
- break;
- case Convolution::Strategy::PROFILE:
- props_.emplace_back("strategy", "PROFILE");
- break;
- case Convolution::Strategy::REPRODUCIBLE:
- props_.emplace_back("strategy", "REPRODUCIBLE");
- break;
- case Convolution::Strategy::OPTIMIZED:
- props_.emplace_back("strategy", "OPTIMIZED");
- break;
- default:
- props_.emplace_back("strategy", "INVALID");
- break;
- }
- props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
- return props_;
- }
- std::string Convolution_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Convolution>();
- static_cast<void>(op_);
- return "Convolution";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Convolution, Convolution)
- .hash(Convolution_hash_impl)
- .is_same_st(Convolution_is_same_st_impl)
- .props(Convolution_props_impl)
- .make_name(Convolution_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Convolution3D);
-
- namespace {
- size_t Convolution3D_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Convolution3D>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_d));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_d));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_d));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.data_type));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
- return val;
- }
- bool Convolution3D_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Convolution3D>(),
- &&b_ = rhs_.cast_final_safe<Convolution3D>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- if (a_.pad_d != b_.pad_d) return false;
- if (a_.pad_h != b_.pad_h) return false;
- if (a_.pad_w != b_.pad_w) return false;
- if (a_.stride_d != b_.stride_d) return false;
- if (a_.stride_h != b_.stride_h) return false;
- if (a_.stride_w != b_.stride_w) return false;
- if (a_.dilate_d != b_.dilate_d) return false;
- if (a_.dilate_h != b_.dilate_h) return false;
- if (a_.dilate_w != b_.dilate_w) return false;
- if (a_.sparse != b_.sparse) return false;
- if (a_.data_type != b_.data_type) return false;
- if (a_.format != b_.format) return false;
- if (a_.strategy != b_.strategy) return false;
- if (a_.workspace_limit != b_.workspace_limit) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Convolution3D_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Convolution3D>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case Convolution3D::Mode::CROSS_CORRELATION:
- props_.emplace_back("mode", "CROSS_CORRELATION");
- break;
- case Convolution3D::Mode::CONVOLUTION:
- props_.emplace_back("mode", "CONVOLUTION");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- props_.emplace_back("pad_d", std::to_string(op_.pad_d));
- props_.emplace_back("pad_h", std::to_string(op_.pad_h));
- props_.emplace_back("pad_w", std::to_string(op_.pad_w));
- props_.emplace_back("stride_d", std::to_string(op_.stride_d));
- props_.emplace_back("stride_h", std::to_string(op_.stride_h));
- props_.emplace_back("stride_w", std::to_string(op_.stride_w));
- props_.emplace_back("dilate_d", std::to_string(op_.dilate_d));
- props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
- props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
- switch (op_.sparse){
- case Convolution3D::Sparse::DENSE:
- props_.emplace_back("sparse", "DENSE");
- break;
- case Convolution3D::Sparse::GROUP:
- props_.emplace_back("sparse", "GROUP");
- break;
- default:
- props_.emplace_back("sparse", "INVALID");
- break;
- }
- switch (op_.data_type){
- case Convolution3D::DataType::FLOAT:
- props_.emplace_back("data_type", "FLOAT");
- break;
- case Convolution3D::DataType::FLOAT_IO16xC32:
- props_.emplace_back("data_type", "FLOAT_IO16xC32");
- break;
- default:
- props_.emplace_back("data_type", "INVALID");
- break;
- }
- switch (op_.format){
- case Convolution3D::Format::NCDHW:
- props_.emplace_back("format", "NCDHW");
- break;
- case Convolution3D::Format::NDHWC:
- props_.emplace_back("format", "NDHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- switch (op_.strategy){
- case Convolution3D::Strategy::HEURISTIC:
- props_.emplace_back("strategy", "HEURISTIC");
- break;
- case Convolution3D::Strategy::PROFILE:
- props_.emplace_back("strategy", "PROFILE");
- break;
- case Convolution3D::Strategy::REPRODUCIBLE:
- props_.emplace_back("strategy", "REPRODUCIBLE");
- break;
- case Convolution3D::Strategy::OPTIMIZED:
- props_.emplace_back("strategy", "OPTIMIZED");
- break;
- default:
- props_.emplace_back("strategy", "INVALID");
- break;
- }
- props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
- return props_;
- }
- std::string Convolution3D_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Convolution3D>();
- static_cast<void>(op_);
- return "Convolution3D";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Convolution3D, Convolution3D)
- .hash(Convolution3D_hash_impl)
- .is_same_st(Convolution3D_is_same_st_impl)
- .props(Convolution3D_props_impl)
- .make_name(Convolution3D_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Convolution3DBackwardData);
-
- namespace {
- size_t Convolution3DBackwardData_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Convolution3DBackwardData>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_d));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_d));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_d));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.data_type));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
- return val;
- }
- bool Convolution3DBackwardData_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Convolution3DBackwardData>(),
- &&b_ = rhs_.cast_final_safe<Convolution3DBackwardData>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- if (a_.pad_d != b_.pad_d) return false;
- if (a_.pad_h != b_.pad_h) return false;
- if (a_.pad_w != b_.pad_w) return false;
- if (a_.stride_d != b_.stride_d) return false;
- if (a_.stride_h != b_.stride_h) return false;
- if (a_.stride_w != b_.stride_w) return false;
- if (a_.dilate_d != b_.dilate_d) return false;
- if (a_.dilate_h != b_.dilate_h) return false;
- if (a_.dilate_w != b_.dilate_w) return false;
- if (a_.sparse != b_.sparse) return false;
- if (a_.data_type != b_.data_type) return false;
- if (a_.format != b_.format) return false;
- if (a_.strategy != b_.strategy) return false;
- if (a_.workspace_limit != b_.workspace_limit) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Convolution3DBackwardData_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Convolution3DBackwardData>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case Convolution3DBackwardData::Mode::CROSS_CORRELATION:
- props_.emplace_back("mode", "CROSS_CORRELATION");
- break;
- case Convolution3DBackwardData::Mode::CONVOLUTION:
- props_.emplace_back("mode", "CONVOLUTION");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- props_.emplace_back("pad_d", std::to_string(op_.pad_d));
- props_.emplace_back("pad_h", std::to_string(op_.pad_h));
- props_.emplace_back("pad_w", std::to_string(op_.pad_w));
- props_.emplace_back("stride_d", std::to_string(op_.stride_d));
- props_.emplace_back("stride_h", std::to_string(op_.stride_h));
- props_.emplace_back("stride_w", std::to_string(op_.stride_w));
- props_.emplace_back("dilate_d", std::to_string(op_.dilate_d));
- props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
- props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
- switch (op_.sparse){
- case Convolution3DBackwardData::Sparse::DENSE:
- props_.emplace_back("sparse", "DENSE");
- break;
- case Convolution3DBackwardData::Sparse::GROUP:
- props_.emplace_back("sparse", "GROUP");
- break;
- default:
- props_.emplace_back("sparse", "INVALID");
- break;
- }
- switch (op_.data_type){
- case Convolution3DBackwardData::DataType::FLOAT:
- props_.emplace_back("data_type", "FLOAT");
- break;
- case Convolution3DBackwardData::DataType::FLOAT_IO16xC32:
- props_.emplace_back("data_type", "FLOAT_IO16xC32");
- break;
- default:
- props_.emplace_back("data_type", "INVALID");
- break;
- }
- switch (op_.format){
- case Convolution3DBackwardData::Format::NCDHW:
- props_.emplace_back("format", "NCDHW");
- break;
- case Convolution3DBackwardData::Format::NDHWC:
- props_.emplace_back("format", "NDHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- switch (op_.strategy){
- case Convolution3DBackwardData::Strategy::HEURISTIC:
- props_.emplace_back("strategy", "HEURISTIC");
- break;
- case Convolution3DBackwardData::Strategy::PROFILE:
- props_.emplace_back("strategy", "PROFILE");
- break;
- case Convolution3DBackwardData::Strategy::REPRODUCIBLE:
- props_.emplace_back("strategy", "REPRODUCIBLE");
- break;
- case Convolution3DBackwardData::Strategy::OPTIMIZED:
- props_.emplace_back("strategy", "OPTIMIZED");
- break;
- default:
- props_.emplace_back("strategy", "INVALID");
- break;
- }
- props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
- return props_;
- }
- std::string Convolution3DBackwardData_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Convolution3DBackwardData>();
- static_cast<void>(op_);
- return "Convolution3DBackwardData";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Convolution3DBackwardData, Convolution3DBackwardData)
- .hash(Convolution3DBackwardData_hash_impl)
- .is_same_st(Convolution3DBackwardData_is_same_st_impl)
- .props(Convolution3DBackwardData_props_impl)
- .make_name(Convolution3DBackwardData_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(ConvolutionBackwardData);
-
- namespace {
- size_t ConvolutionBackwardData_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ConvolutionBackwardData>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
- return val;
- }
- bool ConvolutionBackwardData_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<ConvolutionBackwardData>(),
- &&b_ = rhs_.cast_final_safe<ConvolutionBackwardData>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- if (a_.pad_h != b_.pad_h) return false;
- if (a_.pad_w != b_.pad_w) return false;
- if (a_.stride_h != b_.stride_h) return false;
- if (a_.stride_w != b_.stride_w) return false;
- if (a_.dilate_h != b_.dilate_h) return false;
- if (a_.dilate_w != b_.dilate_w) return false;
- if (a_.sparse != b_.sparse) return false;
- if (a_.format != b_.format) return false;
- if (a_.compute_mode != b_.compute_mode) return false;
- if (a_.strategy != b_.strategy) return false;
- if (a_.workspace_limit != b_.workspace_limit) return false;
- if (a_.dtype != b_.dtype) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> ConvolutionBackwardData_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ConvolutionBackwardData>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case ConvolutionBackwardData::Mode::CROSS_CORRELATION:
- props_.emplace_back("mode", "CROSS_CORRELATION");
- break;
- case ConvolutionBackwardData::Mode::CONVOLUTION:
- props_.emplace_back("mode", "CONVOLUTION");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- props_.emplace_back("pad_h", std::to_string(op_.pad_h));
- props_.emplace_back("pad_w", std::to_string(op_.pad_w));
- props_.emplace_back("stride_h", std::to_string(op_.stride_h));
- props_.emplace_back("stride_w", std::to_string(op_.stride_w));
- props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
- props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
- switch (op_.sparse){
- case ConvolutionBackwardData::Sparse::DENSE:
- props_.emplace_back("sparse", "DENSE");
- break;
- case ConvolutionBackwardData::Sparse::GROUP:
- props_.emplace_back("sparse", "GROUP");
- break;
- default:
- props_.emplace_back("sparse", "INVALID");
- break;
- }
- switch (op_.format){
- case ConvolutionBackwardData::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case ConvolutionBackwardData::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case ConvolutionBackwardData::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case ConvolutionBackwardData::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case ConvolutionBackwardData::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case ConvolutionBackwardData::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case ConvolutionBackwardData::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case ConvolutionBackwardData::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case ConvolutionBackwardData::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case ConvolutionBackwardData::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case ConvolutionBackwardData::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case ConvolutionBackwardData::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case ConvolutionBackwardData::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case ConvolutionBackwardData::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case ConvolutionBackwardData::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case ConvolutionBackwardData::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case ConvolutionBackwardData::Format::NCHW64:
- props_.emplace_back("format", "NCHW64");
- break;
- case ConvolutionBackwardData::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- switch (op_.compute_mode){
- case ConvolutionBackwardData::ComputeMode::DEFAULT:
- props_.emplace_back("compute_mode", "DEFAULT");
- break;
- case ConvolutionBackwardData::ComputeMode::FLOAT32:
- props_.emplace_back("compute_mode", "FLOAT32");
- break;
- default:
- props_.emplace_back("compute_mode", "INVALID");
- break;
- }
- switch (op_.strategy){
- case ConvolutionBackwardData::Strategy::HEURISTIC:
- props_.emplace_back("strategy", "HEURISTIC");
- break;
- case ConvolutionBackwardData::Strategy::PROFILE:
- props_.emplace_back("strategy", "PROFILE");
- break;
- case ConvolutionBackwardData::Strategy::REPRODUCIBLE:
- props_.emplace_back("strategy", "REPRODUCIBLE");
- break;
- case ConvolutionBackwardData::Strategy::OPTIMIZED:
- props_.emplace_back("strategy", "OPTIMIZED");
- break;
- default:
- props_.emplace_back("strategy", "INVALID");
- break;
- }
- props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
- props_.emplace_back("dtype", op_.dtype.name());
- return props_;
- }
- std::string ConvolutionBackwardData_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ConvolutionBackwardData>();
- static_cast<void>(op_);
- return "ConvolutionBackwardData";
- }
- } // anonymous namespace
- OP_TRAIT_REG(ConvolutionBackwardData, ConvolutionBackwardData)
- .hash(ConvolutionBackwardData_hash_impl)
- .is_same_st(ConvolutionBackwardData_is_same_st_impl)
- .props(ConvolutionBackwardData_props_impl)
- .make_name(ConvolutionBackwardData_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Copy);
-
- namespace {
- size_t Copy_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Copy>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
- return val;
- }
- bool Copy_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Copy>(),
- &&b_ = rhs_.cast_final_safe<Copy>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.comp_node != b_.comp_node) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Copy_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Copy>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("comp_node", op_.comp_node.to_string());
- return props_;
- }
- std::string Copy_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Copy>();
- static_cast<void>(op_);
- return "Copy";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Copy, Copy)
- .hash(Copy_hash_impl)
- .is_same_st(Copy_is_same_st_impl)
- .props(Copy_props_impl)
- .make_name(Copy_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Correlation);
-
- namespace {
- size_t Correlation_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Correlation>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.kernel_size));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.max_displacement));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride1));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride2));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_size));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.is_multiply));
- return val;
- }
- bool Correlation_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Correlation>(),
- &&b_ = rhs_.cast_final_safe<Correlation>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.format != b_.format) return false;
- if (a_.kernel_size != b_.kernel_size) return false;
- if (a_.max_displacement != b_.max_displacement) return false;
- if (a_.stride1 != b_.stride1) return false;
- if (a_.stride2 != b_.stride2) return false;
- if (a_.pad_size != b_.pad_size) return false;
- if (a_.is_multiply != b_.is_multiply) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Correlation_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Correlation>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.format){
- case Correlation::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case Correlation::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case Correlation::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case Correlation::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case Correlation::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case Correlation::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case Correlation::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case Correlation::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case Correlation::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case Correlation::Format::NCHW_WINOGRAD:
- props_.emplace_back("format", "NCHW_WINOGRAD");
- break;
- case Correlation::Format::NCHW88_WINOGRAD:
- props_.emplace_back("format", "NCHW88_WINOGRAD");
- break;
- case Correlation::Format::NCHW44_WINOGRAD:
- props_.emplace_back("format", "NCHW44_WINOGRAD");
- break;
- case Correlation::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case Correlation::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case Correlation::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case Correlation::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case Correlation::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case Correlation::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case Correlation::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case Correlation::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- props_.emplace_back("kernel_size", std::to_string(op_.kernel_size));
- props_.emplace_back("max_displacement", std::to_string(op_.max_displacement));
- props_.emplace_back("stride1", std::to_string(op_.stride1));
- props_.emplace_back("stride2", std::to_string(op_.stride2));
- props_.emplace_back("pad_size", std::to_string(op_.pad_size));
- props_.emplace_back("is_multiply", std::to_string(op_.is_multiply));
- return props_;
- }
- std::string Correlation_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Correlation>();
- static_cast<void>(op_);
- return "Correlation";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Correlation, Correlation)
- .hash(Correlation_hash_impl)
- .is_same_st(Correlation_is_same_st_impl)
- .props(Correlation_props_impl)
- .make_name(Correlation_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Cumsum);
-
- namespace {
- size_t Cumsum_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Cumsum>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.exclusive));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.reverse));
- return val;
- }
- bool Cumsum_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Cumsum>(),
- &&b_ = rhs_.cast_final_safe<Cumsum>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.axis != b_.axis) return false;
- if (a_.exclusive != b_.exclusive) return false;
- if (a_.reverse != b_.reverse) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Cumsum_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Cumsum>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("axis", std::to_string(op_.axis));
- props_.emplace_back("exclusive", std::to_string(op_.exclusive));
- props_.emplace_back("reverse", std::to_string(op_.reverse));
- return props_;
- }
- std::string Cumsum_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Cumsum>();
- static_cast<void>(op_);
- return "Cumsum";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Cumsum, Cumsum)
- .hash(Cumsum_hash_impl)
- .is_same_st(Cumsum_is_same_st_impl)
- .props(Cumsum_props_impl)
- .make_name(Cumsum_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(CvtColor);
-
- namespace {
- size_t CvtColor_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<CvtColor>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- return val;
- }
- bool CvtColor_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<CvtColor>(),
- &&b_ = rhs_.cast_final_safe<CvtColor>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> CvtColor_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<CvtColor>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case CvtColor::Mode::RGB2GRAY:
- props_.emplace_back("mode", "RGB2GRAY");
- break;
- case CvtColor::Mode::RGB2YUV:
- props_.emplace_back("mode", "RGB2YUV");
- break;
- case CvtColor::Mode::YUV2RGB:
- props_.emplace_back("mode", "YUV2RGB");
- break;
- case CvtColor::Mode::GRAY2RGB:
- props_.emplace_back("mode", "GRAY2RGB");
- break;
- case CvtColor::Mode::RGBA2RGB:
- props_.emplace_back("mode", "RGBA2RGB");
- break;
- case CvtColor::Mode::RGBA2BGR:
- props_.emplace_back("mode", "RGBA2BGR");
- break;
- case CvtColor::Mode::RGBA2GRAY:
- props_.emplace_back("mode", "RGBA2GRAY");
- break;
- case CvtColor::Mode::RGB2BGR:
- props_.emplace_back("mode", "RGB2BGR");
- break;
- case CvtColor::Mode::BGR2GRAY:
- props_.emplace_back("mode", "BGR2GRAY");
- break;
- case CvtColor::Mode::BGR2RGB:
- props_.emplace_back("mode", "BGR2RGB");
- break;
- case CvtColor::Mode::YUV2GRAY_NV21:
- props_.emplace_back("mode", "YUV2GRAY_NV21");
- break;
- case CvtColor::Mode::YUV2RGB_NV21:
- props_.emplace_back("mode", "YUV2RGB_NV21");
- break;
- case CvtColor::Mode::YUV2BGR_NV21:
- props_.emplace_back("mode", "YUV2BGR_NV21");
- break;
- case CvtColor::Mode::YUV2GRAY_NV12:
- props_.emplace_back("mode", "YUV2GRAY_NV12");
- break;
- case CvtColor::Mode::YUV2RGB_NV12:
- props_.emplace_back("mode", "YUV2RGB_NV12");
- break;
- case CvtColor::Mode::YUV2BGR_NV12:
- props_.emplace_back("mode", "YUV2BGR_NV12");
- break;
- case CvtColor::Mode::YUV2GRAY_YV12:
- props_.emplace_back("mode", "YUV2GRAY_YV12");
- break;
- case CvtColor::Mode::YUV2RGB_YV12:
- props_.emplace_back("mode", "YUV2RGB_YV12");
- break;
- case CvtColor::Mode::YUV2BGR_YV12:
- props_.emplace_back("mode", "YUV2BGR_YV12");
- break;
- case CvtColor::Mode::YUV2GRAY_YU12:
- props_.emplace_back("mode", "YUV2GRAY_YU12");
- break;
- case CvtColor::Mode::YUV2RGB_YU12:
- props_.emplace_back("mode", "YUV2RGB_YU12");
- break;
- case CvtColor::Mode::YUV2BGR_YU12:
- props_.emplace_back("mode", "YUV2BGR_YU12");
- break;
- case CvtColor::Mode::YCrCb2RGB:
- props_.emplace_back("mode", "YCrCb2RGB");
- break;
- case CvtColor::Mode::YCrCb2BGR:
- props_.emplace_back("mode", "YCrCb2BGR");
- break;
- case CvtColor::Mode::BT601_YUV2RGB_NV21:
- props_.emplace_back("mode", "BT601_YUV2RGB_NV21");
- break;
- case CvtColor::Mode::BT601_YUV2BGR_NV21:
- props_.emplace_back("mode", "BT601_YUV2BGR_NV21");
- break;
- case CvtColor::Mode::BT601_YUV2RGB_NV12:
- props_.emplace_back("mode", "BT601_YUV2RGB_NV12");
- break;
- case CvtColor::Mode::BT601_YUV2BGR_NV12:
- props_.emplace_back("mode", "BT601_YUV2BGR_NV12");
- break;
- case CvtColor::Mode::BT601_YUV2RGB_YV12:
- props_.emplace_back("mode", "BT601_YUV2RGB_YV12");
- break;
- case CvtColor::Mode::BT601_YUV2BGR_YV12:
- props_.emplace_back("mode", "BT601_YUV2BGR_YV12");
- break;
- case CvtColor::Mode::BT601_YUV2RGB_YU12:
- props_.emplace_back("mode", "BT601_YUV2RGB_YU12");
- break;
- case CvtColor::Mode::BT601_YUV2BGR_YU12:
- props_.emplace_back("mode", "BT601_YUV2BGR_YU12");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- return props_;
- }
- std::string CvtColor_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<CvtColor>();
- static_cast<void>(op_);
- return "CvtColor";
- }
- } // anonymous namespace
- OP_TRAIT_REG(CvtColor, CvtColor)
- .hash(CvtColor_hash_impl)
- .is_same_st(CvtColor_is_same_st_impl)
- .props(CvtColor_props_impl)
- .make_name(CvtColor_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(DeformableConv);
-
- namespace {
- size_t DeformableConv_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<DeformableConv>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
- return val;
- }
- bool DeformableConv_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<DeformableConv>(),
- &&b_ = rhs_.cast_final_safe<DeformableConv>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- if (a_.pad_h != b_.pad_h) return false;
- if (a_.pad_w != b_.pad_w) return false;
- if (a_.stride_h != b_.stride_h) return false;
- if (a_.stride_w != b_.stride_w) return false;
- if (a_.dilate_h != b_.dilate_h) return false;
- if (a_.dilate_w != b_.dilate_w) return false;
- if (a_.sparse != b_.sparse) return false;
- if (a_.format != b_.format) return false;
- if (a_.compute_mode != b_.compute_mode) return false;
- if (a_.strategy != b_.strategy) return false;
- if (a_.workspace_limit != b_.workspace_limit) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> DeformableConv_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<DeformableConv>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case DeformableConv::Mode::CROSS_CORRELATION:
- props_.emplace_back("mode", "CROSS_CORRELATION");
- break;
- case DeformableConv::Mode::CONVOLUTION:
- props_.emplace_back("mode", "CONVOLUTION");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- props_.emplace_back("pad_h", std::to_string(op_.pad_h));
- props_.emplace_back("pad_w", std::to_string(op_.pad_w));
- props_.emplace_back("stride_h", std::to_string(op_.stride_h));
- props_.emplace_back("stride_w", std::to_string(op_.stride_w));
- props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
- props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
- switch (op_.sparse){
- case DeformableConv::Sparse::DENSE:
- props_.emplace_back("sparse", "DENSE");
- break;
- case DeformableConv::Sparse::GROUP:
- props_.emplace_back("sparse", "GROUP");
- break;
- default:
- props_.emplace_back("sparse", "INVALID");
- break;
- }
- switch (op_.format){
- case DeformableConv::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case DeformableConv::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case DeformableConv::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case DeformableConv::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case DeformableConv::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case DeformableConv::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case DeformableConv::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case DeformableConv::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case DeformableConv::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case DeformableConv::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case DeformableConv::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case DeformableConv::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case DeformableConv::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case DeformableConv::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case DeformableConv::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case DeformableConv::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case DeformableConv::Format::NCHW64:
- props_.emplace_back("format", "NCHW64");
- break;
- case DeformableConv::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- switch (op_.compute_mode){
- case DeformableConv::ComputeMode::DEFAULT:
- props_.emplace_back("compute_mode", "DEFAULT");
- break;
- case DeformableConv::ComputeMode::FLOAT32:
- props_.emplace_back("compute_mode", "FLOAT32");
- break;
- default:
- props_.emplace_back("compute_mode", "INVALID");
- break;
- }
- switch (op_.strategy){
- case DeformableConv::Strategy::HEURISTIC:
- props_.emplace_back("strategy", "HEURISTIC");
- break;
- case DeformableConv::Strategy::PROFILE:
- props_.emplace_back("strategy", "PROFILE");
- break;
- case DeformableConv::Strategy::REPRODUCIBLE:
- props_.emplace_back("strategy", "REPRODUCIBLE");
- break;
- case DeformableConv::Strategy::OPTIMIZED:
- props_.emplace_back("strategy", "OPTIMIZED");
- break;
- default:
- props_.emplace_back("strategy", "INVALID");
- break;
- }
- props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
- return props_;
- }
- std::string DeformableConv_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<DeformableConv>();
- static_cast<void>(op_);
- return "DeformableConv";
- }
- } // anonymous namespace
- OP_TRAIT_REG(DeformableConv, DeformableConv)
- .hash(DeformableConv_hash_impl)
- .is_same_st(DeformableConv_is_same_st_impl)
- .props(DeformableConv_props_impl)
- .make_name(DeformableConv_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(DeformablePSROIPooling);
-
- namespace {
- size_t DeformablePSROIPooling_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<DeformablePSROIPooling>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.no_trans));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.spatial_scale));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.trans_std));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pooled_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pooled_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.part_size));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.sample_per_part));
- return val;
- }
- bool DeformablePSROIPooling_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<DeformablePSROIPooling>(),
- &&b_ = rhs_.cast_final_safe<DeformablePSROIPooling>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.no_trans != b_.no_trans) return false;
- if (a_.spatial_scale != b_.spatial_scale) return false;
- if (a_.trans_std != b_.trans_std) return false;
- if (a_.pooled_h != b_.pooled_h) return false;
- if (a_.pooled_w != b_.pooled_w) return false;
- if (a_.part_size != b_.part_size) return false;
- if (a_.sample_per_part != b_.sample_per_part) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> DeformablePSROIPooling_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<DeformablePSROIPooling>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("no_trans", std::to_string(op_.no_trans));
- props_.emplace_back("spatial_scale", std::to_string(op_.spatial_scale));
- props_.emplace_back("trans_std", std::to_string(op_.trans_std));
- props_.emplace_back("pooled_h", std::to_string(op_.pooled_h));
- props_.emplace_back("pooled_w", std::to_string(op_.pooled_w));
- props_.emplace_back("part_size", std::to_string(op_.part_size));
- props_.emplace_back("sample_per_part", std::to_string(op_.sample_per_part));
- return props_;
- }
- std::string DeformablePSROIPooling_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<DeformablePSROIPooling>();
- static_cast<void>(op_);
- return "DeformablePSROIPooling";
- }
- } // anonymous namespace
- OP_TRAIT_REG(DeformablePSROIPooling, DeformablePSROIPooling)
- .hash(DeformablePSROIPooling_hash_impl)
- .is_same_st(DeformablePSROIPooling_is_same_st_impl)
- .props(DeformablePSROIPooling_props_impl)
- .make_name(DeformablePSROIPooling_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Diag);
-
- namespace {
- size_t Diag_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Diag>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.k));
- return val;
- }
- bool Diag_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Diag>(),
- &&b_ = rhs_.cast_final_safe<Diag>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.k != b_.k) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Diag_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Diag>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("k", std::to_string(op_.k));
- return props_;
- }
- std::string Diag_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Diag>();
- static_cast<void>(op_);
- return "Diag";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Diag, Diag)
- .hash(Diag_hash_impl)
- .is_same_st(Diag_is_same_st_impl)
- .props(Diag_props_impl)
- .make_name(Diag_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Dimshuffle);
-
- namespace {
- size_t Dimshuffle_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Dimshuffle>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pattern));
- return val;
- }
- bool Dimshuffle_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Dimshuffle>(),
- &&b_ = rhs_.cast_final_safe<Dimshuffle>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.pattern != b_.pattern) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Dimshuffle_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Dimshuffle>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("pattern", "{std::vector}");
- return props_;
- }
- std::string Dimshuffle_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Dimshuffle>();
- static_cast<void>(op_);
- return "Dimshuffle";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Dimshuffle, Dimshuffle)
- .hash(Dimshuffle_hash_impl)
- .is_same_st(Dimshuffle_is_same_st_impl)
- .props(Dimshuffle_props_impl)
- .make_name(Dimshuffle_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Dot);
-
- namespace {
- size_t Dot_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Dot>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- return val;
- }
- bool Dot_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Dot>(),
- &&b_ = rhs_.cast_final_safe<Dot>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Dot_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Dot>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- return props_;
- }
- std::string Dot_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Dot>();
- static_cast<void>(op_);
- return "Dot";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Dot, Dot)
- .hash(Dot_hash_impl)
- .is_same_st(Dot_is_same_st_impl)
- .props(Dot_props_impl)
- .make_name(Dot_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Dropout);
-
- namespace {
- size_t Dropout_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Dropout>();
- static_cast<void>(op_);
-
- return mgb::hash_pair_combine(
- mgb::hash(op_.dyn_typeinfo()),
- mgb::hash_pair_combine(
- mgb::hash(op_.drop_prob),
- mgb::hash(op_.handle))
- );
- }
- bool Dropout_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Dropout>(),
- &&b_ = rhs_.cast_final_safe<Dropout>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- return a_.handle == b_.handle && a_.drop_prob == b_.drop_prob;}
- std::vector<std::pair<const char*, std::string>> Dropout_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Dropout>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("drop_prob", std::to_string(op_.drop_prob));
- props_.emplace_back("seed", std::to_string(op_.seed));
- props_.emplace_back("handle", std::to_string(op_.handle));
- return props_;
- }
- std::string Dropout_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Dropout>();
- static_cast<void>(op_);
- return "Dropout";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Dropout, Dropout)
- .hash(Dropout_hash_impl)
- .is_same_st(Dropout_is_same_st_impl)
- .props(Dropout_props_impl)
- .make_name(Dropout_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Elemwise);
-
- namespace {
- size_t Elemwise_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Elemwise>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- return val;
- }
- bool Elemwise_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Elemwise>(),
- &&b_ = rhs_.cast_final_safe<Elemwise>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Elemwise_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Elemwise>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case Elemwise::Mode::RELU:
- props_.emplace_back("mode", "RELU");
- break;
- case Elemwise::Mode::ABS:
- props_.emplace_back("mode", "ABS");
- break;
- case Elemwise::Mode::ACOS:
- props_.emplace_back("mode", "ACOS");
- break;
- case Elemwise::Mode::ASIN:
- props_.emplace_back("mode", "ASIN");
- break;
- case Elemwise::Mode::CEIL:
- props_.emplace_back("mode", "CEIL");
- break;
- case Elemwise::Mode::COS:
- props_.emplace_back("mode", "COS");
- break;
- case Elemwise::Mode::EXP:
- props_.emplace_back("mode", "EXP");
- break;
- case Elemwise::Mode::EXPM1:
- props_.emplace_back("mode", "EXPM1");
- break;
- case Elemwise::Mode::FLOOR:
- props_.emplace_back("mode", "FLOOR");
- break;
- case Elemwise::Mode::LOG:
- props_.emplace_back("mode", "LOG");
- break;
- case Elemwise::Mode::LOG1P:
- props_.emplace_back("mode", "LOG1P");
- break;
- case Elemwise::Mode::NEGATE:
- props_.emplace_back("mode", "NEGATE");
- break;
- case Elemwise::Mode::SIGMOID:
- props_.emplace_back("mode", "SIGMOID");
- break;
- case Elemwise::Mode::SIN:
- props_.emplace_back("mode", "SIN");
- break;
- case Elemwise::Mode::TANH:
- props_.emplace_back("mode", "TANH");
- break;
- case Elemwise::Mode::ABS_GRAD:
- props_.emplace_back("mode", "ABS_GRAD");
- break;
- case Elemwise::Mode::ADD:
- props_.emplace_back("mode", "ADD");
- break;
- case Elemwise::Mode::FLOOR_DIV:
- props_.emplace_back("mode", "FLOOR_DIV");
- break;
- case Elemwise::Mode::MAX:
- props_.emplace_back("mode", "MAX");
- break;
- case Elemwise::Mode::MIN:
- props_.emplace_back("mode", "MIN");
- break;
- case Elemwise::Mode::MOD:
- props_.emplace_back("mode", "MOD");
- break;
- case Elemwise::Mode::MUL:
- props_.emplace_back("mode", "MUL");
- break;
- case Elemwise::Mode::POW:
- props_.emplace_back("mode", "POW");
- break;
- case Elemwise::Mode::SIGMOID_GRAD:
- props_.emplace_back("mode", "SIGMOID_GRAD");
- break;
- case Elemwise::Mode::SUB:
- props_.emplace_back("mode", "SUB");
- break;
- case Elemwise::Mode::SWITCH_GT0:
- props_.emplace_back("mode", "SWITCH_GT0");
- break;
- case Elemwise::Mode::TANH_GRAD:
- props_.emplace_back("mode", "TANH_GRAD");
- break;
- case Elemwise::Mode::TRUE_DIV:
- props_.emplace_back("mode", "TRUE_DIV");
- break;
- case Elemwise::Mode::LOG_SUM_EXP:
- props_.emplace_back("mode", "LOG_SUM_EXP");
- break;
- case Elemwise::Mode::LT:
- props_.emplace_back("mode", "LT");
- break;
- case Elemwise::Mode::LEQ:
- props_.emplace_back("mode", "LEQ");
- break;
- case Elemwise::Mode::EQ:
- props_.emplace_back("mode", "EQ");
- break;
- case Elemwise::Mode::SHL:
- props_.emplace_back("mode", "SHL");
- break;
- case Elemwise::Mode::SHR:
- props_.emplace_back("mode", "SHR");
- break;
- case Elemwise::Mode::COND_LEQ_MOV:
- props_.emplace_back("mode", "COND_LEQ_MOV");
- break;
- case Elemwise::Mode::FUSE_MUL_ADD3:
- props_.emplace_back("mode", "FUSE_MUL_ADD3");
- break;
- case Elemwise::Mode::FUSE_MUL_ADD4:
- props_.emplace_back("mode", "FUSE_MUL_ADD4");
- break;
- case Elemwise::Mode::FUSE_ADD_RELU:
- props_.emplace_back("mode", "FUSE_ADD_RELU");
- break;
- case Elemwise::Mode::FUSE_ADD_SIGMOID:
- props_.emplace_back("mode", "FUSE_ADD_SIGMOID");
- break;
- case Elemwise::Mode::FUSE_ADD_TANH:
- props_.emplace_back("mode", "FUSE_ADD_TANH");
- break;
- case Elemwise::Mode::FAST_TANH:
- props_.emplace_back("mode", "FAST_TANH");
- break;
- case Elemwise::Mode::FAST_TANH_GRAD:
- props_.emplace_back("mode", "FAST_TANH_GRAD");
- break;
- case Elemwise::Mode::ROUND:
- props_.emplace_back("mode", "ROUND");
- break;
- case Elemwise::Mode::RMULH:
- props_.emplace_back("mode", "RMULH");
- break;
- case Elemwise::Mode::ATAN2:
- props_.emplace_back("mode", "ATAN2");
- break;
- case Elemwise::Mode::ERF:
- props_.emplace_back("mode", "ERF");
- break;
- case Elemwise::Mode::ERFINV:
- props_.emplace_back("mode", "ERFINV");
- break;
- case Elemwise::Mode::ERFC:
- props_.emplace_back("mode", "ERFC");
- break;
- case Elemwise::Mode::ERFCINV:
- props_.emplace_back("mode", "ERFCINV");
- break;
- case Elemwise::Mode::H_SWISH:
- props_.emplace_back("mode", "H_SWISH");
- break;
- case Elemwise::Mode::H_SWISH_GRAD:
- props_.emplace_back("mode", "H_SWISH_GRAD");
- break;
- case Elemwise::Mode::FUSE_ADD_H_SWISH:
- props_.emplace_back("mode", "FUSE_ADD_H_SWISH");
- break;
- case Elemwise::Mode::NOT:
- props_.emplace_back("mode", "NOT");
- break;
- case Elemwise::Mode::AND:
- props_.emplace_back("mode", "AND");
- break;
- case Elemwise::Mode::OR:
- props_.emplace_back("mode", "OR");
- break;
- case Elemwise::Mode::XOR:
- props_.emplace_back("mode", "XOR");
- break;
- case Elemwise::Mode::SILU:
- props_.emplace_back("mode", "SILU");
- break;
- case Elemwise::Mode::SILU_GRAD:
- props_.emplace_back("mode", "SILU_GRAD");
- break;
- case Elemwise::Mode::GELU:
- props_.emplace_back("mode", "GELU");
- break;
- case Elemwise::Mode::GELU_GRAD:
- props_.emplace_back("mode", "GELU_GRAD");
- break;
- case Elemwise::Mode::COND_LT_MOV:
- props_.emplace_back("mode", "COND_LT_MOV");
- break;
- case Elemwise::Mode::NEQ:
- props_.emplace_back("mode", "NEQ");
- break;
- case Elemwise::Mode::ISNAN:
- props_.emplace_back("mode", "ISNAN");
- break;
- case Elemwise::Mode::ISINF:
- props_.emplace_back("mode", "ISINF");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- return props_;
- }
- std::string Elemwise_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Elemwise>();
- static_cast<void>(op_);
-
- return to_string(op_.mode);
- }
- } // anonymous namespace
- OP_TRAIT_REG(Elemwise, Elemwise)
- .hash(Elemwise_hash_impl)
- .is_same_st(Elemwise_is_same_st_impl)
- .props(Elemwise_props_impl)
- .make_name(Elemwise_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(ElemwiseMultiType);
-
- namespace {
- size_t ElemwiseMultiType_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ElemwiseMultiType>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
- return val;
- }
- bool ElemwiseMultiType_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<ElemwiseMultiType>(),
- &&b_ = rhs_.cast_final_safe<ElemwiseMultiType>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- if (a_.dtype != b_.dtype) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> ElemwiseMultiType_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ElemwiseMultiType>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case ElemwiseMultiType::Mode::FUSE_MUL_ADD3_INT16x32x32x32:
- props_.emplace_back("mode", "FUSE_MUL_ADD3_INT16x32x32x32");
- break;
- case ElemwiseMultiType::Mode::FUSE_MUL_ADD3_IXxF32xF32xI8:
- props_.emplace_back("mode", "FUSE_MUL_ADD3_IXxF32xF32xI8");
- break;
- case ElemwiseMultiType::Mode::ROUND_SHR_SATURATE_IXxI8xI8:
- props_.emplace_back("mode", "ROUND_SHR_SATURATE_IXxI8xI8");
- break;
- case ElemwiseMultiType::Mode::FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT16x16x16x8:
- props_.emplace_back("mode", "FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT16x16x16x8");
- break;
- case ElemwiseMultiType::Mode::FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT32x32x32x8:
- props_.emplace_back("mode", "FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT32x32x32x8");
- break;
- case ElemwiseMultiType::Mode::ROUND_SHR_SATURATE_IXxI8xI16:
- props_.emplace_back("mode", "ROUND_SHR_SATURATE_IXxI8xI16");
- break;
- case ElemwiseMultiType::Mode::QADD:
- props_.emplace_back("mode", "QADD");
- break;
- case ElemwiseMultiType::Mode::QFUSE_ADD_RELU:
- props_.emplace_back("mode", "QFUSE_ADD_RELU");
- break;
- case ElemwiseMultiType::Mode::QMUL:
- props_.emplace_back("mode", "QMUL");
- break;
- case ElemwiseMultiType::Mode::QMIN:
- props_.emplace_back("mode", "QMIN");
- break;
- case ElemwiseMultiType::Mode::QMAX:
- props_.emplace_back("mode", "QMAX");
- break;
- case ElemwiseMultiType::Mode::QSUB:
- props_.emplace_back("mode", "QSUB");
- break;
- case ElemwiseMultiType::Mode::QTRUE_DIV:
- props_.emplace_back("mode", "QTRUE_DIV");
- break;
- case ElemwiseMultiType::Mode::QFUSE_ADD_SIGMOID:
- props_.emplace_back("mode", "QFUSE_ADD_SIGMOID");
- break;
- case ElemwiseMultiType::Mode::QFUSE_ADD_TANH:
- props_.emplace_back("mode", "QFUSE_ADD_TANH");
- break;
- case ElemwiseMultiType::Mode::QRELU:
- props_.emplace_back("mode", "QRELU");
- break;
- case ElemwiseMultiType::Mode::QABS:
- props_.emplace_back("mode", "QABS");
- break;
- case ElemwiseMultiType::Mode::QSIGMOID:
- props_.emplace_back("mode", "QSIGMOID");
- break;
- case ElemwiseMultiType::Mode::QEXP:
- props_.emplace_back("mode", "QEXP");
- break;
- case ElemwiseMultiType::Mode::QTANH:
- props_.emplace_back("mode", "QTANH");
- break;
- case ElemwiseMultiType::Mode::QFUSE_MUL_ADD3:
- props_.emplace_back("mode", "QFUSE_MUL_ADD3");
- break;
- case ElemwiseMultiType::Mode::QFAST_TANH:
- props_.emplace_back("mode", "QFAST_TANH");
- break;
- case ElemwiseMultiType::Mode::QNEGATE:
- props_.emplace_back("mode", "QNEGATE");
- break;
- case ElemwiseMultiType::Mode::QACOS:
- props_.emplace_back("mode", "QACOS");
- break;
- case ElemwiseMultiType::Mode::QASIN:
- props_.emplace_back("mode", "QASIN");
- break;
- case ElemwiseMultiType::Mode::QCEIL:
- props_.emplace_back("mode", "QCEIL");
- break;
- case ElemwiseMultiType::Mode::QCOS:
- props_.emplace_back("mode", "QCOS");
- break;
- case ElemwiseMultiType::Mode::QEXPM1:
- props_.emplace_back("mode", "QEXPM1");
- break;
- case ElemwiseMultiType::Mode::QFLOOR:
- props_.emplace_back("mode", "QFLOOR");
- break;
- case ElemwiseMultiType::Mode::QLOG:
- props_.emplace_back("mode", "QLOG");
- break;
- case ElemwiseMultiType::Mode::QLOG1P:
- props_.emplace_back("mode", "QLOG1P");
- break;
- case ElemwiseMultiType::Mode::QSIN:
- props_.emplace_back("mode", "QSIN");
- break;
- case ElemwiseMultiType::Mode::QROUND:
- props_.emplace_back("mode", "QROUND");
- break;
- case ElemwiseMultiType::Mode::QERF:
- props_.emplace_back("mode", "QERF");
- break;
- case ElemwiseMultiType::Mode::QERFINV:
- props_.emplace_back("mode", "QERFINV");
- break;
- case ElemwiseMultiType::Mode::QERFC:
- props_.emplace_back("mode", "QERFC");
- break;
- case ElemwiseMultiType::Mode::QERFCINV:
- props_.emplace_back("mode", "QERFCINV");
- break;
- case ElemwiseMultiType::Mode::QABS_GRAD:
- props_.emplace_back("mode", "QABS_GRAD");
- break;
- case ElemwiseMultiType::Mode::QFLOOR_DIV:
- props_.emplace_back("mode", "QFLOOR_DIV");
- break;
- case ElemwiseMultiType::Mode::QMOD:
- props_.emplace_back("mode", "QMOD");
- break;
- case ElemwiseMultiType::Mode::QSIGMOID_GRAD:
- props_.emplace_back("mode", "QSIGMOID_GRAD");
- break;
- case ElemwiseMultiType::Mode::QSWITCH_GT0:
- props_.emplace_back("mode", "QSWITCH_GT0");
- break;
- case ElemwiseMultiType::Mode::QTANH_GRAD:
- props_.emplace_back("mode", "QTANH_GRAD");
- break;
- case ElemwiseMultiType::Mode::QLT:
- props_.emplace_back("mode", "QLT");
- break;
- case ElemwiseMultiType::Mode::QLEQ:
- props_.emplace_back("mode", "QLEQ");
- break;
- case ElemwiseMultiType::Mode::QEQ:
- props_.emplace_back("mode", "QEQ");
- break;
- case ElemwiseMultiType::Mode::QPOW:
- props_.emplace_back("mode", "QPOW");
- break;
- case ElemwiseMultiType::Mode::QLOG_SUM_EXP:
- props_.emplace_back("mode", "QLOG_SUM_EXP");
- break;
- case ElemwiseMultiType::Mode::QFAST_TANH_GRAD:
- props_.emplace_back("mode", "QFAST_TANH_GRAD");
- break;
- case ElemwiseMultiType::Mode::QATAN2:
- props_.emplace_back("mode", "QATAN2");
- break;
- case ElemwiseMultiType::Mode::QCOND_LEQ_MOV:
- props_.emplace_back("mode", "QCOND_LEQ_MOV");
- break;
- case ElemwiseMultiType::Mode::QH_SWISH:
- props_.emplace_back("mode", "QH_SWISH");
- break;
- case ElemwiseMultiType::Mode::QFUSE_ADD_H_SWISH:
- props_.emplace_back("mode", "QFUSE_ADD_H_SWISH");
- break;
- case ElemwiseMultiType::Mode::QH_SWISH_GRAD:
- props_.emplace_back("mode", "QH_SWISH_GRAD");
- break;
- case ElemwiseMultiType::Mode::FUSE_MUL_ADD3_INT16xF32xF32xF32:
- props_.emplace_back("mode", "FUSE_MUL_ADD3_INT16xF32xF32xF32");
- break;
- case ElemwiseMultiType::Mode::MUL_INT16xF32xF32:
- props_.emplace_back("mode", "MUL_INT16xF32xF32");
- break;
- case ElemwiseMultiType::Mode::FUSE_MUL_ADD3_UINT8xF32xF32xF32:
- props_.emplace_back("mode", "FUSE_MUL_ADD3_UINT8xF32xF32xF32");
- break;
- case ElemwiseMultiType::Mode::QCOND_LT_MOV:
- props_.emplace_back("mode", "QCOND_LT_MOV");
- break;
- case ElemwiseMultiType::Mode::EQ:
- props_.emplace_back("mode", "EQ");
- break;
- case ElemwiseMultiType::Mode::NEQ:
- props_.emplace_back("mode", "NEQ");
- break;
- case ElemwiseMultiType::Mode::LT:
- props_.emplace_back("mode", "LT");
- break;
- case ElemwiseMultiType::Mode::LEQ:
- props_.emplace_back("mode", "LEQ");
- break;
- case ElemwiseMultiType::Mode::ISNAN:
- props_.emplace_back("mode", "ISNAN");
- break;
- case ElemwiseMultiType::Mode::ISINF:
- props_.emplace_back("mode", "ISINF");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- props_.emplace_back("dtype", op_.dtype.name());
- return props_;
- }
- std::string ElemwiseMultiType_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ElemwiseMultiType>();
- static_cast<void>(op_);
-
- return to_string(op_.mode);
- }
- } // anonymous namespace
- OP_TRAIT_REG(ElemwiseMultiType, ElemwiseMultiType)
- .hash(ElemwiseMultiType_hash_impl)
- .is_same_st(ElemwiseMultiType_is_same_st_impl)
- .props(ElemwiseMultiType_props_impl)
- .make_name(ElemwiseMultiType_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(ExternOpr);
-
- namespace {
- size_t ExternOpr_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ExternOpr>();
- static_cast<void>(op_);
-
- return mgb::hash_pair_combine(
- mgb::hash(op_.dyn_typeinfo()),
- mgb::hash_pair_combine(
- mgb::hash(op_.name),
- mgb::hash(op_.data))
- );
- }
- bool ExternOpr_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<ExternOpr>(),
- &&b_ = rhs_.cast_final_safe<ExternOpr>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.output_shapes != b_.output_shapes) return false;
- if (a_.name != b_.name) return false;
- if (a_.data != b_.data) return false;
- if (a_.data_len != b_.data_len) return false;
- if (a_.output_dtypes != b_.output_dtypes) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> ExternOpr_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ExternOpr>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("output_shapes", "{std::vector}");
- props_.emplace_back("name", op_.name);
- props_.emplace_back("data", op_.data);
- props_.emplace_back("data_len", std::to_string(op_.data_len));
- props_.emplace_back("output_dtypes", "{std::vector}");
- return props_;
- }
- std::string ExternOpr_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ExternOpr>();
- static_cast<void>(op_);
- return "ExternOpr";
- }
- } // anonymous namespace
- OP_TRAIT_REG(ExternOpr, ExternOpr)
- .hash(ExternOpr_hash_impl)
- .is_same_st(ExternOpr_is_same_st_impl)
- .props(ExternOpr_props_impl)
- .make_name(ExternOpr_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Eye);
-
- namespace {
- size_t Eye_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Eye>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.k));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
- return val;
- }
- bool Eye_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Eye>(),
- &&b_ = rhs_.cast_final_safe<Eye>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.k != b_.k) return false;
- if (a_.dtype != b_.dtype) return false;
- if (a_.comp_node != b_.comp_node) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Eye_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Eye>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("k", std::to_string(op_.k));
- props_.emplace_back("dtype", op_.dtype.name());
- props_.emplace_back("comp_node", op_.comp_node.to_string());
- return props_;
- }
- std::string Eye_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Eye>();
- static_cast<void>(op_);
- return "Eye";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Eye, Eye)
- .hash(Eye_hash_impl)
- .is_same_st(Eye_is_same_st_impl)
- .props(Eye_props_impl)
- .make_name(Eye_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(FakeQuant);
-
- namespace {
- size_t FakeQuant_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<FakeQuant>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.qmin));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.qmax));
- return val;
- }
- bool FakeQuant_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<FakeQuant>(),
- &&b_ = rhs_.cast_final_safe<FakeQuant>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.qmin != b_.qmin) return false;
- if (a_.qmax != b_.qmax) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> FakeQuant_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<FakeQuant>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("qmin", std::to_string(op_.qmin));
- props_.emplace_back("qmax", std::to_string(op_.qmax));
- return props_;
- }
- std::string FakeQuant_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<FakeQuant>();
- static_cast<void>(op_);
- return "FakeQuant";
- }
- } // anonymous namespace
- OP_TRAIT_REG(FakeQuant, FakeQuant)
- .hash(FakeQuant_hash_impl)
- .is_same_st(FakeQuant_is_same_st_impl)
- .props(FakeQuant_props_impl)
- .make_name(FakeQuant_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(FastpathCopy);
-
- namespace {
- size_t FastpathCopy_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<FastpathCopy>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- return val;
- }
- bool FastpathCopy_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<FastpathCopy>(),
- &&b_ = rhs_.cast_final_safe<FastpathCopy>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- return true;
- }
- std::vector<std::pair<const char*, std::string>> FastpathCopy_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<FastpathCopy>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- return props_;
- }
- std::string FastpathCopy_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<FastpathCopy>();
- static_cast<void>(op_);
- return "FastpathCopy";
- }
- } // anonymous namespace
- OP_TRAIT_REG(FastpathCopy, FastpathCopy)
- .hash(FastpathCopy_hash_impl)
- .is_same_st(FastpathCopy_is_same_st_impl)
- .props(FastpathCopy_props_impl)
- .make_name(FastpathCopy_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(GammaRNG);
-
- namespace {
- size_t GammaRNG_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<GammaRNG>();
- static_cast<void>(op_);
-
- return mgb::hash_pair_combine(
- mgb::hash(op_.dyn_typeinfo()),
- mgb::hash(op_.handle)
- );
- }
- bool GammaRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<GammaRNG>(),
- &&b_ = rhs_.cast_final_safe<GammaRNG>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- return a_.handle == b_.handle;}
- std::vector<std::pair<const char*, std::string>> GammaRNG_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<GammaRNG>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("seed", std::to_string(op_.seed));
- props_.emplace_back("handle", std::to_string(op_.handle));
- return props_;
- }
- std::string GammaRNG_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<GammaRNG>();
- static_cast<void>(op_);
- return "GammaRNG";
- }
- } // anonymous namespace
- OP_TRAIT_REG(GammaRNG, GammaRNG)
- .hash(GammaRNG_hash_impl)
- .is_same_st(GammaRNG_is_same_st_impl)
- .props(GammaRNG_props_impl)
- .make_name(GammaRNG_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(GaussianRNG);
-
- namespace {
- size_t GaussianRNG_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<GaussianRNG>();
- static_cast<void>(op_);
-
- return mgb::hash_pair_combine(
- mgb::hash(op_.dyn_typeinfo()),
- mgb::hash_pair_combine(
- mgb::hash(op_.handle),
- mgb::hash_pair_combine(
- mgb::hash(op_.mean),
- mgb::hash_pair_combine(
- mgb::hash(op_.std),
- mgb::hash(op_.dtype.enumv())
- )
- )
- )
- );
- }
- bool GaussianRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<GaussianRNG>(),
- &&b_ = rhs_.cast_final_safe<GaussianRNG>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- return a_.handle == b_.handle && a_.mean == b_.mean && a_.std == b_.std && a_.dtype == b_.dtype;}
- std::vector<std::pair<const char*, std::string>> GaussianRNG_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<GaussianRNG>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("seed", std::to_string(op_.seed));
- props_.emplace_back("mean", std::to_string(op_.mean));
- props_.emplace_back("std", std::to_string(op_.std));
- props_.emplace_back("dtype", op_.dtype.name());
- props_.emplace_back("handle", std::to_string(op_.handle));
- return props_;
- }
- std::string GaussianRNG_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<GaussianRNG>();
- static_cast<void>(op_);
- return "GaussianRNG";
- }
- } // anonymous namespace
- OP_TRAIT_REG(GaussianRNG, GaussianRNG)
- .hash(GaussianRNG_hash_impl)
- .is_same_st(GaussianRNG_is_same_st_impl)
- .props(GaussianRNG_props_impl)
- .make_name(GaussianRNG_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(GetVarShape);
-
- namespace {
- size_t GetVarShape_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<GetVarShape>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
- return val;
- }
- bool GetVarShape_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<GetVarShape>(),
- &&b_ = rhs_.cast_final_safe<GetVarShape>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.axis != b_.axis) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> GetVarShape_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<GetVarShape>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("axis", std::to_string(op_.axis));
- return props_;
- }
- std::string GetVarShape_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<GetVarShape>();
- static_cast<void>(op_);
- return "GetVarShape";
- }
- } // anonymous namespace
- OP_TRAIT_REG(GetVarShape, GetVarShape)
- .hash(GetVarShape_hash_impl)
- .is_same_st(GetVarShape_is_same_st_impl)
- .props(GetVarShape_props_impl)
- .make_name(GetVarShape_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(GroupLocal);
-
- namespace {
- size_t GroupLocal_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<GroupLocal>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
- return val;
- }
- bool GroupLocal_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<GroupLocal>(),
- &&b_ = rhs_.cast_final_safe<GroupLocal>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- if (a_.pad_h != b_.pad_h) return false;
- if (a_.pad_w != b_.pad_w) return false;
- if (a_.stride_h != b_.stride_h) return false;
- if (a_.stride_w != b_.stride_w) return false;
- if (a_.dilate_h != b_.dilate_h) return false;
- if (a_.dilate_w != b_.dilate_w) return false;
- if (a_.sparse != b_.sparse) return false;
- if (a_.format != b_.format) return false;
- if (a_.compute_mode != b_.compute_mode) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> GroupLocal_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<GroupLocal>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case GroupLocal::Mode::CROSS_CORRELATION:
- props_.emplace_back("mode", "CROSS_CORRELATION");
- break;
- case GroupLocal::Mode::CONVOLUTION:
- props_.emplace_back("mode", "CONVOLUTION");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- props_.emplace_back("pad_h", std::to_string(op_.pad_h));
- props_.emplace_back("pad_w", std::to_string(op_.pad_w));
- props_.emplace_back("stride_h", std::to_string(op_.stride_h));
- props_.emplace_back("stride_w", std::to_string(op_.stride_w));
- props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
- props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
- switch (op_.sparse){
- case GroupLocal::Sparse::DENSE:
- props_.emplace_back("sparse", "DENSE");
- break;
- case GroupLocal::Sparse::GROUP:
- props_.emplace_back("sparse", "GROUP");
- break;
- default:
- props_.emplace_back("sparse", "INVALID");
- break;
- }
- switch (op_.format){
- case GroupLocal::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case GroupLocal::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case GroupLocal::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case GroupLocal::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case GroupLocal::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case GroupLocal::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case GroupLocal::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case GroupLocal::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case GroupLocal::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case GroupLocal::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case GroupLocal::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case GroupLocal::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case GroupLocal::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case GroupLocal::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case GroupLocal::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case GroupLocal::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case GroupLocal::Format::NCHW64:
- props_.emplace_back("format", "NCHW64");
- break;
- case GroupLocal::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- switch (op_.compute_mode){
- case GroupLocal::ComputeMode::DEFAULT:
- props_.emplace_back("compute_mode", "DEFAULT");
- break;
- case GroupLocal::ComputeMode::FLOAT32:
- props_.emplace_back("compute_mode", "FLOAT32");
- break;
- default:
- props_.emplace_back("compute_mode", "INVALID");
- break;
- }
- return props_;
- }
- std::string GroupLocal_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<GroupLocal>();
- static_cast<void>(op_);
- return "GroupLocal";
- }
- } // anonymous namespace
- OP_TRAIT_REG(GroupLocal, GroupLocal)
- .hash(GroupLocal_hash_impl)
- .is_same_st(GroupLocal_is_same_st_impl)
- .props(GroupLocal_props_impl)
- .make_name(GroupLocal_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Identity);
-
- namespace {
- size_t Identity_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Identity>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- return val;
- }
- bool Identity_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Identity>(),
- &&b_ = rhs_.cast_final_safe<Identity>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Identity_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Identity>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- return props_;
- }
- std::string Identity_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Identity>();
- static_cast<void>(op_);
- return "Identity";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Identity, Identity)
- .hash(Identity_hash_impl)
- .is_same_st(Identity_is_same_st_impl)
- .props(Identity_props_impl)
- .make_name(Identity_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Images2Neibs);
-
- namespace {
- size_t Images2Neibs_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Images2Neibs>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.window_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.window_w));
- return val;
- }
- bool Images2Neibs_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Images2Neibs>(),
- &&b_ = rhs_.cast_final_safe<Images2Neibs>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.pad_h != b_.pad_h) return false;
- if (a_.pad_w != b_.pad_w) return false;
- if (a_.stride_h != b_.stride_h) return false;
- if (a_.stride_w != b_.stride_w) return false;
- if (a_.dilate_h != b_.dilate_h) return false;
- if (a_.dilate_w != b_.dilate_w) return false;
- if (a_.window_h != b_.window_h) return false;
- if (a_.window_w != b_.window_w) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Images2Neibs_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Images2Neibs>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("pad_h", std::to_string(op_.pad_h));
- props_.emplace_back("pad_w", std::to_string(op_.pad_w));
- props_.emplace_back("stride_h", std::to_string(op_.stride_h));
- props_.emplace_back("stride_w", std::to_string(op_.stride_w));
- props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
- props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
- props_.emplace_back("window_h", std::to_string(op_.window_h));
- props_.emplace_back("window_w", std::to_string(op_.window_w));
- return props_;
- }
- std::string Images2Neibs_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Images2Neibs>();
- static_cast<void>(op_);
- return "Images2Neibs";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Images2Neibs, Images2Neibs)
- .hash(Images2Neibs_hash_impl)
- .is_same_st(Images2Neibs_is_same_st_impl)
- .props(Images2Neibs_props_impl)
- .make_name(Images2Neibs_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(IncrMeshIndexing);
-
- namespace {
- size_t IncrMeshIndexing_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IncrMeshIndexing>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
- return val;
- }
- bool IncrMeshIndexing_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<IncrMeshIndexing>(),
- &&b_ = rhs_.cast_final_safe<IncrMeshIndexing>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.items != b_.items) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> IncrMeshIndexing_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IncrMeshIndexing>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("items", "{std::vector}");
- return props_;
- }
- std::string IncrMeshIndexing_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IncrMeshIndexing>();
- static_cast<void>(op_);
- return "IncrMeshIndexing";
- }
- } // anonymous namespace
- OP_TRAIT_REG(IncrMeshIndexing, IncrMeshIndexing)
- .hash(IncrMeshIndexing_hash_impl)
- .is_same_st(IncrMeshIndexing_is_same_st_impl)
- .props(IncrMeshIndexing_props_impl)
- .make_name(IncrMeshIndexing_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(IncrSubtensor);
-
- namespace {
- size_t IncrSubtensor_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IncrSubtensor>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
- return val;
- }
- bool IncrSubtensor_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<IncrSubtensor>(),
- &&b_ = rhs_.cast_final_safe<IncrSubtensor>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.items != b_.items) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> IncrSubtensor_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IncrSubtensor>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("items", "{std::vector}");
- return props_;
- }
- std::string IncrSubtensor_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IncrSubtensor>();
- static_cast<void>(op_);
- return "IncrSubtensor";
- }
- } // anonymous namespace
- OP_TRAIT_REG(IncrSubtensor, IncrSubtensor)
- .hash(IncrSubtensor_hash_impl)
- .is_same_st(IncrSubtensor_is_same_st_impl)
- .props(IncrSubtensor_props_impl)
- .make_name(IncrSubtensor_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(IndexingIncrMultiAxisVec);
-
- namespace {
- size_t IndexingIncrMultiAxisVec_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IndexingIncrMultiAxisVec>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
- return val;
- }
- bool IndexingIncrMultiAxisVec_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<IndexingIncrMultiAxisVec>(),
- &&b_ = rhs_.cast_final_safe<IndexingIncrMultiAxisVec>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.items != b_.items) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> IndexingIncrMultiAxisVec_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IndexingIncrMultiAxisVec>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("items", "{std::vector}");
- return props_;
- }
- std::string IndexingIncrMultiAxisVec_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IndexingIncrMultiAxisVec>();
- static_cast<void>(op_);
- return "IndexingIncrMultiAxisVec";
- }
- } // anonymous namespace
- OP_TRAIT_REG(IndexingIncrMultiAxisVec, IndexingIncrMultiAxisVec)
- .hash(IndexingIncrMultiAxisVec_hash_impl)
- .is_same_st(IndexingIncrMultiAxisVec_is_same_st_impl)
- .props(IndexingIncrMultiAxisVec_props_impl)
- .make_name(IndexingIncrMultiAxisVec_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(IndexingMultiAxisVec);
-
- namespace {
- size_t IndexingMultiAxisVec_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IndexingMultiAxisVec>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
- return val;
- }
- bool IndexingMultiAxisVec_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<IndexingMultiAxisVec>(),
- &&b_ = rhs_.cast_final_safe<IndexingMultiAxisVec>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.items != b_.items) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> IndexingMultiAxisVec_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IndexingMultiAxisVec>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("items", "{std::vector}");
- return props_;
- }
- std::string IndexingMultiAxisVec_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IndexingMultiAxisVec>();
- static_cast<void>(op_);
- return "IndexingMultiAxisVec";
- }
- } // anonymous namespace
- OP_TRAIT_REG(IndexingMultiAxisVec, IndexingMultiAxisVec)
- .hash(IndexingMultiAxisVec_hash_impl)
- .is_same_st(IndexingMultiAxisVec_is_same_st_impl)
- .props(IndexingMultiAxisVec_props_impl)
- .make_name(IndexingMultiAxisVec_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(IndexingOneHot);
-
- namespace {
- size_t IndexingOneHot_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IndexingOneHot>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.ndim));
- return val;
- }
- bool IndexingOneHot_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<IndexingOneHot>(),
- &&b_ = rhs_.cast_final_safe<IndexingOneHot>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.axis != b_.axis) return false;
- if (a_.ndim != b_.ndim) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> IndexingOneHot_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IndexingOneHot>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("axis", std::to_string(op_.axis));
- props_.emplace_back("ndim", std::to_string(op_.ndim));
- return props_;
- }
- std::string IndexingOneHot_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IndexingOneHot>();
- static_cast<void>(op_);
- return "IndexingOneHot";
- }
- } // anonymous namespace
- OP_TRAIT_REG(IndexingOneHot, IndexingOneHot)
- .hash(IndexingOneHot_hash_impl)
- .is_same_st(IndexingOneHot_is_same_st_impl)
- .props(IndexingOneHot_props_impl)
- .make_name(IndexingOneHot_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(IndexingSetMultiAxisVec);
-
- namespace {
- size_t IndexingSetMultiAxisVec_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IndexingSetMultiAxisVec>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
- return val;
- }
- bool IndexingSetMultiAxisVec_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<IndexingSetMultiAxisVec>(),
- &&b_ = rhs_.cast_final_safe<IndexingSetMultiAxisVec>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.items != b_.items) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> IndexingSetMultiAxisVec_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IndexingSetMultiAxisVec>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("items", "{std::vector}");
- return props_;
- }
- std::string IndexingSetMultiAxisVec_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IndexingSetMultiAxisVec>();
- static_cast<void>(op_);
- return "IndexingSetMultiAxisVec";
- }
- } // anonymous namespace
- OP_TRAIT_REG(IndexingSetMultiAxisVec, IndexingSetMultiAxisVec)
- .hash(IndexingSetMultiAxisVec_hash_impl)
- .is_same_st(IndexingSetMultiAxisVec_is_same_st_impl)
- .props(IndexingSetMultiAxisVec_props_impl)
- .make_name(IndexingSetMultiAxisVec_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(IndexingSetOneHot);
-
- namespace {
- size_t IndexingSetOneHot_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IndexingSetOneHot>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.ndim));
- return val;
- }
- bool IndexingSetOneHot_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<IndexingSetOneHot>(),
- &&b_ = rhs_.cast_final_safe<IndexingSetOneHot>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.axis != b_.axis) return false;
- if (a_.ndim != b_.ndim) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> IndexingSetOneHot_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IndexingSetOneHot>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("axis", std::to_string(op_.axis));
- props_.emplace_back("ndim", std::to_string(op_.ndim));
- return props_;
- }
- std::string IndexingSetOneHot_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<IndexingSetOneHot>();
- static_cast<void>(op_);
- return "IndexingSetOneHot";
- }
- } // anonymous namespace
- OP_TRAIT_REG(IndexingSetOneHot, IndexingSetOneHot)
- .hash(IndexingSetOneHot_hash_impl)
- .is_same_st(IndexingSetOneHot_is_same_st_impl)
- .props(IndexingSetOneHot_props_impl)
- .make_name(IndexingSetOneHot_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(InplaceAdd);
-
- namespace {
- size_t InplaceAdd_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<InplaceAdd>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- return val;
- }
- bool InplaceAdd_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<InplaceAdd>(),
- &&b_ = rhs_.cast_final_safe<InplaceAdd>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- return true;
- }
- std::vector<std::pair<const char*, std::string>> InplaceAdd_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<InplaceAdd>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- return props_;
- }
- std::string InplaceAdd_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<InplaceAdd>();
- static_cast<void>(op_);
- return "InplaceAdd";
- }
- } // anonymous namespace
- OP_TRAIT_REG(InplaceAdd, InplaceAdd)
- .hash(InplaceAdd_hash_impl)
- .is_same_st(InplaceAdd_is_same_st_impl)
- .props(InplaceAdd_props_impl)
- .make_name(InplaceAdd_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(LAMBUpdate);
-
- namespace {
- size_t LAMBUpdate_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LAMBUpdate>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.beta_1));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.beta_2));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.step));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.lr));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.weight_decay));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.eps));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.bias_correction));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.always_adapt));
- return val;
- }
- bool LAMBUpdate_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<LAMBUpdate>(),
- &&b_ = rhs_.cast_final_safe<LAMBUpdate>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.beta_1 != b_.beta_1) return false;
- if (a_.beta_2 != b_.beta_2) return false;
- if (a_.step != b_.step) return false;
- if (a_.lr != b_.lr) return false;
- if (a_.weight_decay != b_.weight_decay) return false;
- if (a_.eps != b_.eps) return false;
- if (a_.bias_correction != b_.bias_correction) return false;
- if (a_.always_adapt != b_.always_adapt) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> LAMBUpdate_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LAMBUpdate>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("beta_1", std::to_string(op_.beta_1));
- props_.emplace_back("beta_2", std::to_string(op_.beta_2));
- props_.emplace_back("step", std::to_string(op_.step));
- props_.emplace_back("lr", std::to_string(op_.lr));
- props_.emplace_back("weight_decay", std::to_string(op_.weight_decay));
- props_.emplace_back("eps", std::to_string(op_.eps));
- props_.emplace_back("bias_correction", std::to_string(op_.bias_correction));
- props_.emplace_back("always_adapt", std::to_string(op_.always_adapt));
- return props_;
- }
- std::string LAMBUpdate_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LAMBUpdate>();
- static_cast<void>(op_);
- return "LAMBUpdate";
- }
- } // anonymous namespace
- OP_TRAIT_REG(LAMBUpdate, LAMBUpdate)
- .hash(LAMBUpdate_hash_impl)
- .is_same_st(LAMBUpdate_is_same_st_impl)
- .props(LAMBUpdate_props_impl)
- .make_name(LAMBUpdate_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(LRN);
-
- namespace {
- size_t LRN_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LRN>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.n));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.k));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.alpha));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.beta));
- return val;
- }
- bool LRN_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<LRN>(),
- &&b_ = rhs_.cast_final_safe<LRN>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.n != b_.n) return false;
- if (a_.k != b_.k) return false;
- if (a_.alpha != b_.alpha) return false;
- if (a_.beta != b_.beta) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> LRN_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LRN>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("n", std::to_string(op_.n));
- props_.emplace_back("k", std::to_string(op_.k));
- props_.emplace_back("alpha", std::to_string(op_.alpha));
- props_.emplace_back("beta", std::to_string(op_.beta));
- return props_;
- }
- std::string LRN_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LRN>();
- static_cast<void>(op_);
- return "LRN";
- }
- } // anonymous namespace
- OP_TRAIT_REG(LRN, LRN)
- .hash(LRN_hash_impl)
- .is_same_st(LRN_is_same_st_impl)
- .props(LRN_props_impl)
- .make_name(LRN_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(LSQ);
-
- namespace {
- size_t LSQ_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LSQ>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.qmin));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.qmax));
- return val;
- }
- bool LSQ_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<LSQ>(),
- &&b_ = rhs_.cast_final_safe<LSQ>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.qmin != b_.qmin) return false;
- if (a_.qmax != b_.qmax) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> LSQ_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LSQ>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("qmin", std::to_string(op_.qmin));
- props_.emplace_back("qmax", std::to_string(op_.qmax));
- return props_;
- }
- std::string LSQ_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LSQ>();
- static_cast<void>(op_);
- return "LSQ";
- }
- } // anonymous namespace
- OP_TRAIT_REG(LSQ, LSQ)
- .hash(LSQ_hash_impl)
- .is_same_st(LSQ_is_same_st_impl)
- .props(LSQ_props_impl)
- .make_name(LSQ_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(LSTM);
-
- namespace {
- size_t LSTM_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LSTM>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.num_layers));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.bidirectional));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.bias));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.hidden_size));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.proj_size));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dropout));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.fwd_mode));
- return val;
- }
- bool LSTM_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<LSTM>(),
- &&b_ = rhs_.cast_final_safe<LSTM>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.num_layers != b_.num_layers) return false;
- if (a_.bidirectional != b_.bidirectional) return false;
- if (a_.bias != b_.bias) return false;
- if (a_.hidden_size != b_.hidden_size) return false;
- if (a_.proj_size != b_.proj_size) return false;
- if (a_.dropout != b_.dropout) return false;
- if (a_.fwd_mode != b_.fwd_mode) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> LSTM_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LSTM>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("num_layers", std::to_string(op_.num_layers));
- props_.emplace_back("bidirectional", std::to_string(op_.bidirectional));
- props_.emplace_back("bias", std::to_string(op_.bias));
- props_.emplace_back("hidden_size", std::to_string(op_.hidden_size));
- props_.emplace_back("proj_size", std::to_string(op_.proj_size));
- props_.emplace_back("dropout", std::to_string(op_.dropout));
- switch (op_.fwd_mode){
- case LSTM::FwdMode::TRAINING:
- props_.emplace_back("fwd_mode", "TRAINING");
- break;
- case LSTM::FwdMode::INFERENCE:
- props_.emplace_back("fwd_mode", "INFERENCE");
- break;
- default:
- props_.emplace_back("fwd_mode", "INVALID");
- break;
- }
- return props_;
- }
- std::string LSTM_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LSTM>();
- static_cast<void>(op_);
- return "LSTM";
- }
- } // anonymous namespace
- OP_TRAIT_REG(LSTM, LSTM)
- .hash(LSTM_hash_impl)
- .is_same_st(LSTM_is_same_st_impl)
- .props(LSTM_props_impl)
- .make_name(LSTM_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(LSTMCell);
-
- namespace {
- size_t LSTMCell_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LSTMCell>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- return val;
- }
- bool LSTMCell_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<LSTMCell>(),
- &&b_ = rhs_.cast_final_safe<LSTMCell>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- return true;
- }
- std::vector<std::pair<const char*, std::string>> LSTMCell_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LSTMCell>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- return props_;
- }
- std::string LSTMCell_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LSTMCell>();
- static_cast<void>(op_);
- return "LSTMCell";
- }
- } // anonymous namespace
- OP_TRAIT_REG(LSTMCell, LSTMCell)
- .hash(LSTMCell_hash_impl)
- .is_same_st(LSTMCell_is_same_st_impl)
- .props(LSTMCell_props_impl)
- .make_name(LSTMCell_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(LayerNorm);
-
- namespace {
- size_t LayerNorm_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LayerNorm>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.affine));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.eps));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.normalized_dim));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.normalized_size));
- return val;
- }
- bool LayerNorm_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<LayerNorm>(),
- &&b_ = rhs_.cast_final_safe<LayerNorm>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.affine != b_.affine) return false;
- if (a_.eps != b_.eps) return false;
- if (a_.normalized_dim != b_.normalized_dim) return false;
- if (a_.normalized_size != b_.normalized_size) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> LayerNorm_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LayerNorm>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("affine", std::to_string(op_.affine));
- props_.emplace_back("eps", std::to_string(op_.eps));
- props_.emplace_back("normalized_dim", std::to_string(op_.normalized_dim));
- props_.emplace_back("normalized_size", std::to_string(op_.normalized_size));
- return props_;
- }
- std::string LayerNorm_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<LayerNorm>();
- static_cast<void>(op_);
- return "LayerNorm";
- }
- } // anonymous namespace
- OP_TRAIT_REG(LayerNorm, LayerNorm)
- .hash(LayerNorm_hash_impl)
- .is_same_st(LayerNorm_is_same_st_impl)
- .props(LayerNorm_props_impl)
- .make_name(LayerNorm_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Linspace);
-
- namespace {
- size_t Linspace_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Linspace>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.endpoint));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
- return val;
- }
- bool Linspace_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Linspace>(),
- &&b_ = rhs_.cast_final_safe<Linspace>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.endpoint != b_.endpoint) return false;
- if (a_.comp_node != b_.comp_node) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Linspace_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Linspace>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("endpoint", std::to_string(op_.endpoint));
- props_.emplace_back("comp_node", op_.comp_node.to_string());
- return props_;
- }
- std::string Linspace_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Linspace>();
- static_cast<void>(op_);
- return "Linspace";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Linspace, Linspace)
- .hash(Linspace_hash_impl)
- .is_same_st(Linspace_is_same_st_impl)
- .props(Linspace_props_impl)
- .make_name(Linspace_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(MagicMindRuntime);
-
- namespace {
- size_t MagicMindRuntime_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<MagicMindRuntime>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.buf));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.buf_size));
- return val;
- }
- bool MagicMindRuntime_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<MagicMindRuntime>(),
- &&b_ = rhs_.cast_final_safe<MagicMindRuntime>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.buf != b_.buf) return false;
- if (a_.buf_size != b_.buf_size) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> MagicMindRuntime_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<MagicMindRuntime>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("buf", op_.buf);
- props_.emplace_back("buf_size", std::to_string(op_.buf_size));
- return props_;
- }
- std::string MagicMindRuntime_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<MagicMindRuntime>();
- static_cast<void>(op_);
- return "MagicMindRuntime";
- }
- } // anonymous namespace
- OP_TRAIT_REG(MagicMindRuntime, MagicMindRuntime)
- .hash(MagicMindRuntime_hash_impl)
- .is_same_st(MagicMindRuntime_is_same_st_impl)
- .props(MagicMindRuntime_props_impl)
- .make_name(MagicMindRuntime_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(MatrixInverse);
-
- namespace {
- size_t MatrixInverse_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<MatrixInverse>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- return val;
- }
- bool MatrixInverse_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<MatrixInverse>(),
- &&b_ = rhs_.cast_final_safe<MatrixInverse>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- return true;
- }
- std::vector<std::pair<const char*, std::string>> MatrixInverse_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<MatrixInverse>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- return props_;
- }
- std::string MatrixInverse_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<MatrixInverse>();
- static_cast<void>(op_);
- return "MatrixInverse";
- }
- } // anonymous namespace
- OP_TRAIT_REG(MatrixInverse, MatrixInverse)
- .hash(MatrixInverse_hash_impl)
- .is_same_st(MatrixInverse_is_same_st_impl)
- .props(MatrixInverse_props_impl)
- .make_name(MatrixInverse_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(MatrixMul);
-
- namespace {
- size_t MatrixMul_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<MatrixMul>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.transposeA));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.transposeB));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dimA));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dimB));
- return val;
- }
- bool MatrixMul_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<MatrixMul>(),
- &&b_ = rhs_.cast_final_safe<MatrixMul>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.transposeA != b_.transposeA) return false;
- if (a_.transposeB != b_.transposeB) return false;
- if (a_.compute_mode != b_.compute_mode) return false;
- if (a_.format != b_.format) return false;
- if (a_.strategy != b_.strategy) return false;
- if (a_.workspace_limit != b_.workspace_limit) return false;
- if (a_.dimA != b_.dimA) return false;
- if (a_.dimB != b_.dimB) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> MatrixMul_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<MatrixMul>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("transposeA", std::to_string(op_.transposeA));
- props_.emplace_back("transposeB", std::to_string(op_.transposeB));
- switch (op_.compute_mode){
- case MatrixMul::ComputeMode::DEFAULT:
- props_.emplace_back("compute_mode", "DEFAULT");
- break;
- case MatrixMul::ComputeMode::FLOAT32:
- props_.emplace_back("compute_mode", "FLOAT32");
- break;
- default:
- props_.emplace_back("compute_mode", "INVALID");
- break;
- }
- switch (op_.format){
- case MatrixMul::Format::DEFAULT:
- props_.emplace_back("format", "DEFAULT");
- break;
- case MatrixMul::Format::MK4:
- props_.emplace_back("format", "MK4");
- break;
- case MatrixMul::Format::MK8:
- props_.emplace_back("format", "MK8");
- break;
- case MatrixMul::Format::MK4_DOT:
- props_.emplace_back("format", "MK4_DOT");
- break;
- case MatrixMul::Format::N32K4_DOT:
- props_.emplace_back("format", "N32K4_DOT");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- switch (op_.strategy){
- case MatrixMul::Strategy::HEURISTIC:
- props_.emplace_back("strategy", "HEURISTIC");
- break;
- case MatrixMul::Strategy::PROFILE:
- props_.emplace_back("strategy", "PROFILE");
- break;
- case MatrixMul::Strategy::REPRODUCIBLE:
- props_.emplace_back("strategy", "REPRODUCIBLE");
- break;
- case MatrixMul::Strategy::OPTIMIZED:
- props_.emplace_back("strategy", "OPTIMIZED");
- break;
- default:
- props_.emplace_back("strategy", "INVALID");
- break;
- }
- props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
- props_.emplace_back("dimA", std::to_string(op_.dimA));
- props_.emplace_back("dimB", std::to_string(op_.dimB));
- return props_;
- }
- std::string MatrixMul_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<MatrixMul>();
- static_cast<void>(op_);
- return "MatrixMul";
- }
- } // anonymous namespace
- OP_TRAIT_REG(MatrixMul, MatrixMul)
- .hash(MatrixMul_hash_impl)
- .is_same_st(MatrixMul_is_same_st_impl)
- .props(MatrixMul_props_impl)
- .make_name(MatrixMul_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(MeshIndexing);
-
- namespace {
- size_t MeshIndexing_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<MeshIndexing>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
- return val;
- }
- bool MeshIndexing_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<MeshIndexing>(),
- &&b_ = rhs_.cast_final_safe<MeshIndexing>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.items != b_.items) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> MeshIndexing_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<MeshIndexing>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("items", "{std::vector}");
- return props_;
- }
- std::string MeshIndexing_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<MeshIndexing>();
- static_cast<void>(op_);
- return "MeshIndexing";
- }
- } // anonymous namespace
- OP_TRAIT_REG(MeshIndexing, MeshIndexing)
- .hash(MeshIndexing_hash_impl)
- .is_same_st(MeshIndexing_is_same_st_impl)
- .props(MeshIndexing_props_impl)
- .make_name(MeshIndexing_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(NMSKeep);
-
- namespace {
- size_t NMSKeep_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<NMSKeep>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.iou_thresh));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.max_output));
- return val;
- }
- bool NMSKeep_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<NMSKeep>(),
- &&b_ = rhs_.cast_final_safe<NMSKeep>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.iou_thresh != b_.iou_thresh) return false;
- if (a_.max_output != b_.max_output) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> NMSKeep_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<NMSKeep>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("iou_thresh", std::to_string(op_.iou_thresh));
- props_.emplace_back("max_output", std::to_string(op_.max_output));
- return props_;
- }
- std::string NMSKeep_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<NMSKeep>();
- static_cast<void>(op_);
- return "NMSKeep";
- }
- } // anonymous namespace
- OP_TRAIT_REG(NMSKeep, NMSKeep)
- .hash(NMSKeep_hash_impl)
- .is_same_st(NMSKeep_is_same_st_impl)
- .props(NMSKeep_props_impl)
- .make_name(NMSKeep_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(NvOf);
-
- namespace {
- size_t NvOf_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<NvOf>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.precision));
- return val;
- }
- bool NvOf_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<NvOf>(),
- &&b_ = rhs_.cast_final_safe<NvOf>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.precision != b_.precision) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> NvOf_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<NvOf>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("precision", std::to_string(op_.precision));
- return props_;
- }
- std::string NvOf_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<NvOf>();
- static_cast<void>(op_);
- return "NvOf";
- }
- } // anonymous namespace
- OP_TRAIT_REG(NvOf, NvOf)
- .hash(NvOf_hash_impl)
- .is_same_st(NvOf_is_same_st_impl)
- .props(NvOf_props_impl)
- .make_name(NvOf_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Padding);
-
- namespace {
- size_t Padding_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Padding>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim0));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim1));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim2));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim3));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim4));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim5));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim6));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim0));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim1));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim2));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim3));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim4));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim5));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim6));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.padding_val));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.padding_mode));
- return val;
- }
- bool Padding_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Padding>(),
- &&b_ = rhs_.cast_final_safe<Padding>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.front_offset_dim0 != b_.front_offset_dim0) return false;
- if (a_.front_offset_dim1 != b_.front_offset_dim1) return false;
- if (a_.front_offset_dim2 != b_.front_offset_dim2) return false;
- if (a_.front_offset_dim3 != b_.front_offset_dim3) return false;
- if (a_.front_offset_dim4 != b_.front_offset_dim4) return false;
- if (a_.front_offset_dim5 != b_.front_offset_dim5) return false;
- if (a_.front_offset_dim6 != b_.front_offset_dim6) return false;
- if (a_.back_offset_dim0 != b_.back_offset_dim0) return false;
- if (a_.back_offset_dim1 != b_.back_offset_dim1) return false;
- if (a_.back_offset_dim2 != b_.back_offset_dim2) return false;
- if (a_.back_offset_dim3 != b_.back_offset_dim3) return false;
- if (a_.back_offset_dim4 != b_.back_offset_dim4) return false;
- if (a_.back_offset_dim5 != b_.back_offset_dim5) return false;
- if (a_.back_offset_dim6 != b_.back_offset_dim6) return false;
- if (a_.padding_val != b_.padding_val) return false;
- if (a_.padding_mode != b_.padding_mode) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Padding_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Padding>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("front_offset_dim0", std::to_string(op_.front_offset_dim0));
- props_.emplace_back("front_offset_dim1", std::to_string(op_.front_offset_dim1));
- props_.emplace_back("front_offset_dim2", std::to_string(op_.front_offset_dim2));
- props_.emplace_back("front_offset_dim3", std::to_string(op_.front_offset_dim3));
- props_.emplace_back("front_offset_dim4", std::to_string(op_.front_offset_dim4));
- props_.emplace_back("front_offset_dim5", std::to_string(op_.front_offset_dim5));
- props_.emplace_back("front_offset_dim6", std::to_string(op_.front_offset_dim6));
- props_.emplace_back("back_offset_dim0", std::to_string(op_.back_offset_dim0));
- props_.emplace_back("back_offset_dim1", std::to_string(op_.back_offset_dim1));
- props_.emplace_back("back_offset_dim2", std::to_string(op_.back_offset_dim2));
- props_.emplace_back("back_offset_dim3", std::to_string(op_.back_offset_dim3));
- props_.emplace_back("back_offset_dim4", std::to_string(op_.back_offset_dim4));
- props_.emplace_back("back_offset_dim5", std::to_string(op_.back_offset_dim5));
- props_.emplace_back("back_offset_dim6", std::to_string(op_.back_offset_dim6));
- props_.emplace_back("padding_val", std::to_string(op_.padding_val));
- switch (op_.padding_mode){
- case Padding::PaddingMode::REPLICATE:
- props_.emplace_back("padding_mode", "REPLICATE");
- break;
- case Padding::PaddingMode::REFLECT:
- props_.emplace_back("padding_mode", "REFLECT");
- break;
- case Padding::PaddingMode::CONSTANT:
- props_.emplace_back("padding_mode", "CONSTANT");
- break;
- default:
- props_.emplace_back("padding_mode", "INVALID");
- break;
- }
- return props_;
- }
- std::string Padding_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Padding>();
- static_cast<void>(op_);
- return "Padding";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Padding, Padding)
- .hash(Padding_hash_impl)
- .is_same_st(Padding_is_same_st_impl)
- .props(Padding_props_impl)
- .make_name(Padding_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(ParamPackConcat);
-
- namespace {
- size_t ParamPackConcat_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ParamPackConcat>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.offsets));
- return val;
- }
- bool ParamPackConcat_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<ParamPackConcat>(),
- &&b_ = rhs_.cast_final_safe<ParamPackConcat>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.offsets != b_.offsets) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> ParamPackConcat_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ParamPackConcat>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("offsets", "{std::vector}");
- return props_;
- }
- std::string ParamPackConcat_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ParamPackConcat>();
- static_cast<void>(op_);
- return "ParamPackConcat";
- }
- } // anonymous namespace
- OP_TRAIT_REG(ParamPackConcat, ParamPackConcat)
- .hash(ParamPackConcat_hash_impl)
- .is_same_st(ParamPackConcat_is_same_st_impl)
- .props(ParamPackConcat_props_impl)
- .make_name(ParamPackConcat_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(ParamPackSplit);
-
- namespace {
- size_t ParamPackSplit_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ParamPackSplit>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.offsets));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.shapes));
- return val;
- }
- bool ParamPackSplit_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<ParamPackSplit>(),
- &&b_ = rhs_.cast_final_safe<ParamPackSplit>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.offsets != b_.offsets) return false;
- if (a_.shapes != b_.shapes) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> ParamPackSplit_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ParamPackSplit>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("offsets", "{std::vector}");
- props_.emplace_back("shapes", "{std::vector}");
- return props_;
- }
- std::string ParamPackSplit_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ParamPackSplit>();
- static_cast<void>(op_);
- return "ParamPackSplit";
- }
- } // anonymous namespace
- OP_TRAIT_REG(ParamPackSplit, ParamPackSplit)
- .hash(ParamPackSplit_hash_impl)
- .is_same_st(ParamPackSplit_is_same_st_impl)
- .props(ParamPackSplit_props_impl)
- .make_name(ParamPackSplit_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(PermutationRNG);
-
- namespace {
- size_t PermutationRNG_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<PermutationRNG>();
- static_cast<void>(op_);
-
- return mgb::hash_pair_combine(
- mgb::hash(op_.dyn_typeinfo()),
- mgb::hash_pair_combine(
- mgb::hash(op_.handle),
- mgb::hash(op_.dtype.enumv())
- )
- );
- }
- bool PermutationRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<PermutationRNG>(),
- &&b_ = rhs_.cast_final_safe<PermutationRNG>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- return a_.handle == b_.handle && a_.dtype == b_.dtype;}
- std::vector<std::pair<const char*, std::string>> PermutationRNG_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<PermutationRNG>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("seed", std::to_string(op_.seed));
- props_.emplace_back("dtype", op_.dtype.name());
- props_.emplace_back("handle", std::to_string(op_.handle));
- return props_;
- }
- std::string PermutationRNG_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<PermutationRNG>();
- static_cast<void>(op_);
- return "PermutationRNG";
- }
- } // anonymous namespace
- OP_TRAIT_REG(PermutationRNG, PermutationRNG)
- .hash(PermutationRNG_hash_impl)
- .is_same_st(PermutationRNG_is_same_st_impl)
- .props(PermutationRNG_props_impl)
- .make_name(PermutationRNG_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(PixelShuffle);
-
- namespace {
- size_t PixelShuffle_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<PixelShuffle>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.factor));
- return val;
- }
- bool PixelShuffle_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<PixelShuffle>(),
- &&b_ = rhs_.cast_final_safe<PixelShuffle>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.factor != b_.factor) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> PixelShuffle_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<PixelShuffle>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("factor", std::to_string(op_.factor));
- return props_;
- }
- std::string PixelShuffle_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<PixelShuffle>();
- static_cast<void>(op_);
- return "PixelShuffle";
- }
- } // anonymous namespace
- OP_TRAIT_REG(PixelShuffle, PixelShuffle)
- .hash(PixelShuffle_hash_impl)
- .is_same_st(PixelShuffle_is_same_st_impl)
- .props(PixelShuffle_props_impl)
- .make_name(PixelShuffle_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(PixelShuffleBackward);
-
- namespace {
- size_t PixelShuffleBackward_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<PixelShuffleBackward>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.factor));
- return val;
- }
- bool PixelShuffleBackward_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<PixelShuffleBackward>(),
- &&b_ = rhs_.cast_final_safe<PixelShuffleBackward>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.factor != b_.factor) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> PixelShuffleBackward_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<PixelShuffleBackward>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("factor", std::to_string(op_.factor));
- return props_;
- }
- std::string PixelShuffleBackward_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<PixelShuffleBackward>();
- static_cast<void>(op_);
- return "PixelShuffleBackward";
- }
- } // anonymous namespace
- OP_TRAIT_REG(PixelShuffleBackward, PixelShuffleBackward)
- .hash(PixelShuffleBackward_hash_impl)
- .is_same_st(PixelShuffleBackward_is_same_st_impl)
- .props(PixelShuffleBackward_props_impl)
- .make_name(PixelShuffleBackward_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(PoissonRNG);
-
- namespace {
- size_t PoissonRNG_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<PoissonRNG>();
- static_cast<void>(op_);
-
- return mgb::hash_pair_combine(
- mgb::hash(op_.dyn_typeinfo()),
- mgb::hash(op_.handle)
- );
- }
- bool PoissonRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<PoissonRNG>(),
- &&b_ = rhs_.cast_final_safe<PoissonRNG>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- return a_.handle == b_.handle;}
- std::vector<std::pair<const char*, std::string>> PoissonRNG_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<PoissonRNG>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("seed", std::to_string(op_.seed));
- props_.emplace_back("handle", std::to_string(op_.handle));
- return props_;
- }
- std::string PoissonRNG_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<PoissonRNG>();
- static_cast<void>(op_);
- return "PoissonRNG";
- }
- } // anonymous namespace
- OP_TRAIT_REG(PoissonRNG, PoissonRNG)
- .hash(PoissonRNG_hash_impl)
- .is_same_st(PoissonRNG_is_same_st_impl)
- .props(PoissonRNG_props_impl)
- .make_name(PoissonRNG_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Pooling);
-
- namespace {
- size_t Pooling_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Pooling>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.window_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.window_w));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
- return val;
- }
- bool Pooling_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Pooling>(),
- &&b_ = rhs_.cast_final_safe<Pooling>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- if (a_.pad_h != b_.pad_h) return false;
- if (a_.pad_w != b_.pad_w) return false;
- if (a_.stride_h != b_.stride_h) return false;
- if (a_.stride_w != b_.stride_w) return false;
- if (a_.window_h != b_.window_h) return false;
- if (a_.window_w != b_.window_w) return false;
- if (a_.format != b_.format) return false;
- if (a_.strategy != b_.strategy) return false;
- if (a_.workspace_limit != b_.workspace_limit) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Pooling_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Pooling>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case Pooling::Mode::MAX:
- props_.emplace_back("mode", "MAX");
- break;
- case Pooling::Mode::AVERAGE:
- props_.emplace_back("mode", "AVERAGE");
- break;
- case Pooling::Mode::AVERAGE_COUNT_EXCLUDE_PADDING:
- props_.emplace_back("mode", "AVERAGE_COUNT_EXCLUDE_PADDING");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- props_.emplace_back("pad_h", std::to_string(op_.pad_h));
- props_.emplace_back("pad_w", std::to_string(op_.pad_w));
- props_.emplace_back("stride_h", std::to_string(op_.stride_h));
- props_.emplace_back("stride_w", std::to_string(op_.stride_w));
- props_.emplace_back("window_h", std::to_string(op_.window_h));
- props_.emplace_back("window_w", std::to_string(op_.window_w));
- switch (op_.format){
- case Pooling::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case Pooling::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case Pooling::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case Pooling::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case Pooling::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case Pooling::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case Pooling::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case Pooling::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case Pooling::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case Pooling::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case Pooling::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case Pooling::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case Pooling::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case Pooling::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case Pooling::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case Pooling::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case Pooling::Format::NCHW64:
- props_.emplace_back("format", "NCHW64");
- break;
- case Pooling::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- switch (op_.strategy){
- case Pooling::Strategy::HEURISTIC:
- props_.emplace_back("strategy", "HEURISTIC");
- break;
- case Pooling::Strategy::PROFILE:
- props_.emplace_back("strategy", "PROFILE");
- break;
- case Pooling::Strategy::REPRODUCIBLE:
- props_.emplace_back("strategy", "REPRODUCIBLE");
- break;
- case Pooling::Strategy::OPTIMIZED:
- props_.emplace_back("strategy", "OPTIMIZED");
- break;
- default:
- props_.emplace_back("strategy", "INVALID");
- break;
- }
- props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
- return props_;
- }
- std::string Pooling_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Pooling>();
- static_cast<void>(op_);
- return "Pooling";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Pooling, Pooling)
- .hash(Pooling_hash_impl)
- .is_same_st(Pooling_is_same_st_impl)
- .props(Pooling_props_impl)
- .make_name(Pooling_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(RNN);
-
- namespace {
- size_t RNN_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<RNN>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.num_layers));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.bidirectional));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.bias));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.hidden_size));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dropout));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.nonlineMode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.fwd_mode));
- return val;
- }
- bool RNN_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<RNN>(),
- &&b_ = rhs_.cast_final_safe<RNN>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.num_layers != b_.num_layers) return false;
- if (a_.bidirectional != b_.bidirectional) return false;
- if (a_.bias != b_.bias) return false;
- if (a_.hidden_size != b_.hidden_size) return false;
- if (a_.dropout != b_.dropout) return false;
- if (a_.nonlineMode != b_.nonlineMode) return false;
- if (a_.fwd_mode != b_.fwd_mode) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> RNN_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<RNN>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("num_layers", std::to_string(op_.num_layers));
- props_.emplace_back("bidirectional", std::to_string(op_.bidirectional));
- props_.emplace_back("bias", std::to_string(op_.bias));
- props_.emplace_back("hidden_size", std::to_string(op_.hidden_size));
- props_.emplace_back("dropout", std::to_string(op_.dropout));
- switch (op_.nonlineMode){
- case RNN::NonlineMode::IDENTITY:
- props_.emplace_back("nonlineMode", "IDENTITY");
- break;
- case RNN::NonlineMode::RELU:
- props_.emplace_back("nonlineMode", "RELU");
- break;
- case RNN::NonlineMode::TANH:
- props_.emplace_back("nonlineMode", "TANH");
- break;
- default:
- props_.emplace_back("nonlineMode", "INVALID");
- break;
- }
- switch (op_.fwd_mode){
- case RNN::FwdMode::TRAINING:
- props_.emplace_back("fwd_mode", "TRAINING");
- break;
- case RNN::FwdMode::INFERENCE:
- props_.emplace_back("fwd_mode", "INFERENCE");
- break;
- default:
- props_.emplace_back("fwd_mode", "INVALID");
- break;
- }
- return props_;
- }
- std::string RNN_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<RNN>();
- static_cast<void>(op_);
- return "RNN";
- }
- } // anonymous namespace
- OP_TRAIT_REG(RNN, RNN)
- .hash(RNN_hash_impl)
- .is_same_st(RNN_is_same_st_impl)
- .props(RNN_props_impl)
- .make_name(RNN_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(RNNCell);
-
- namespace {
- size_t RNNCell_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<RNNCell>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.nonlineMode));
- return val;
- }
- bool RNNCell_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<RNNCell>(),
- &&b_ = rhs_.cast_final_safe<RNNCell>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.nonlineMode != b_.nonlineMode) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> RNNCell_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<RNNCell>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.nonlineMode){
- case RNNCell::NonlineMode::IDENTITY:
- props_.emplace_back("nonlineMode", "IDENTITY");
- break;
- case RNNCell::NonlineMode::RELU:
- props_.emplace_back("nonlineMode", "RELU");
- break;
- case RNNCell::NonlineMode::TANH:
- props_.emplace_back("nonlineMode", "TANH");
- break;
- default:
- props_.emplace_back("nonlineMode", "INVALID");
- break;
- }
- return props_;
- }
- std::string RNNCell_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<RNNCell>();
- static_cast<void>(op_);
- return "RNNCell";
- }
- } // anonymous namespace
- OP_TRAIT_REG(RNNCell, RNNCell)
- .hash(RNNCell_hash_impl)
- .is_same_st(RNNCell_is_same_st_impl)
- .props(RNNCell_props_impl)
- .make_name(RNNCell_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(ROIAlign);
-
- namespace {
- size_t ROIAlign_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ROIAlign>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.spatial_scale));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.offset));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pooled_height));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pooled_width));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.sample_height));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.sample_width));
- return val;
- }
- bool ROIAlign_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<ROIAlign>(),
- &&b_ = rhs_.cast_final_safe<ROIAlign>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- if (a_.format != b_.format) return false;
- if (a_.spatial_scale != b_.spatial_scale) return false;
- if (a_.offset != b_.offset) return false;
- if (a_.pooled_height != b_.pooled_height) return false;
- if (a_.pooled_width != b_.pooled_width) return false;
- if (a_.sample_height != b_.sample_height) return false;
- if (a_.sample_width != b_.sample_width) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> ROIAlign_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ROIAlign>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case ROIAlign::Mode::MAX:
- props_.emplace_back("mode", "MAX");
- break;
- case ROIAlign::Mode::AVERAGE:
- props_.emplace_back("mode", "AVERAGE");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- switch (op_.format){
- case ROIAlign::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case ROIAlign::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case ROIAlign::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case ROIAlign::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case ROIAlign::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case ROIAlign::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case ROIAlign::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case ROIAlign::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case ROIAlign::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case ROIAlign::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case ROIAlign::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case ROIAlign::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case ROIAlign::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case ROIAlign::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case ROIAlign::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case ROIAlign::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case ROIAlign::Format::NCHW64:
- props_.emplace_back("format", "NCHW64");
- break;
- case ROIAlign::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- props_.emplace_back("spatial_scale", std::to_string(op_.spatial_scale));
- props_.emplace_back("offset", std::to_string(op_.offset));
- props_.emplace_back("pooled_height", std::to_string(op_.pooled_height));
- props_.emplace_back("pooled_width", std::to_string(op_.pooled_width));
- props_.emplace_back("sample_height", std::to_string(op_.sample_height));
- props_.emplace_back("sample_width", std::to_string(op_.sample_width));
- return props_;
- }
- std::string ROIAlign_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ROIAlign>();
- static_cast<void>(op_);
- return "ROIAlign";
- }
- } // anonymous namespace
- OP_TRAIT_REG(ROIAlign, ROIAlign)
- .hash(ROIAlign_hash_impl)
- .is_same_st(ROIAlign_is_same_st_impl)
- .props(ROIAlign_props_impl)
- .make_name(ROIAlign_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(ROIPooling);
-
- namespace {
- size_t ROIPooling_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ROIPooling>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.scale));
- return val;
- }
- bool ROIPooling_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<ROIPooling>(),
- &&b_ = rhs_.cast_final_safe<ROIPooling>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- if (a_.scale != b_.scale) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> ROIPooling_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ROIPooling>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case ROIPooling::Mode::MAX:
- props_.emplace_back("mode", "MAX");
- break;
- case ROIPooling::Mode::AVERAGE:
- props_.emplace_back("mode", "AVERAGE");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- props_.emplace_back("scale", std::to_string(op_.scale));
- return props_;
- }
- std::string ROIPooling_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ROIPooling>();
- static_cast<void>(op_);
- return "ROIPooling";
- }
- } // anonymous namespace
- OP_TRAIT_REG(ROIPooling, ROIPooling)
- .hash(ROIPooling_hash_impl)
- .is_same_st(ROIPooling_is_same_st_impl)
- .props(ROIPooling_props_impl)
- .make_name(ROIPooling_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Reduce);
-
- namespace {
- size_t Reduce_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Reduce>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.data_type));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.keepdim));
- return val;
- }
- bool Reduce_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Reduce>(),
- &&b_ = rhs_.cast_final_safe<Reduce>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- if (a_.axis != b_.axis) return false;
- if (a_.data_type != b_.data_type) return false;
- if (a_.keepdim != b_.keepdim) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Reduce_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Reduce>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case Reduce::Mode::SUM:
- props_.emplace_back("mode", "SUM");
- break;
- case Reduce::Mode::SUM_SQR:
- props_.emplace_back("mode", "SUM_SQR");
- break;
- case Reduce::Mode::PRODUCT:
- props_.emplace_back("mode", "PRODUCT");
- break;
- case Reduce::Mode::MIN:
- props_.emplace_back("mode", "MIN");
- break;
- case Reduce::Mode::MAX:
- props_.emplace_back("mode", "MAX");
- break;
- case Reduce::Mode::MEAN:
- props_.emplace_back("mode", "MEAN");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- props_.emplace_back("axis", std::to_string(op_.axis));
- switch (op_.data_type){
- case Reduce::DataType::DEFAULT:
- props_.emplace_back("data_type", "DEFAULT");
- break;
- case Reduce::DataType::FLOAT_IO16xC32:
- props_.emplace_back("data_type", "FLOAT_IO16xC32");
- break;
- case Reduce::DataType::FLOAT_O32xC32:
- props_.emplace_back("data_type", "FLOAT_O32xC32");
- break;
- case Reduce::DataType::FLOAT_O16xC32:
- props_.emplace_back("data_type", "FLOAT_O16xC32");
- break;
- case Reduce::DataType::QUINT_I8xO32:
- props_.emplace_back("data_type", "QUINT_I8xO32");
- break;
- case Reduce::DataType::QINT_I8xO32:
- props_.emplace_back("data_type", "QINT_I8xO32");
- break;
- default:
- props_.emplace_back("data_type", "INVALID");
- break;
- }
- props_.emplace_back("keepdim", std::to_string(op_.keepdim));
- return props_;
- }
- std::string Reduce_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Reduce>();
- static_cast<void>(op_);
- return "Reduce";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Reduce, Reduce)
- .hash(Reduce_hash_impl)
- .is_same_st(Reduce_is_same_st_impl)
- .props(Reduce_props_impl)
- .make_name(Reduce_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Remap);
-
- namespace {
- size_t Remap_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Remap>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.border_type));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.scalar));
- return val;
- }
- bool Remap_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Remap>(),
- &&b_ = rhs_.cast_final_safe<Remap>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.imode != b_.imode) return false;
- if (a_.border_type != b_.border_type) return false;
- if (a_.format != b_.format) return false;
- if (a_.scalar != b_.scalar) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Remap_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Remap>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.imode){
- case Remap::InterpolationMode::NEAREST:
- props_.emplace_back("imode", "NEAREST");
- break;
- case Remap::InterpolationMode::LINEAR:
- props_.emplace_back("imode", "LINEAR");
- break;
- case Remap::InterpolationMode::AREA:
- props_.emplace_back("imode", "AREA");
- break;
- case Remap::InterpolationMode::CUBIC:
- props_.emplace_back("imode", "CUBIC");
- break;
- case Remap::InterpolationMode::LANCZOS4:
- props_.emplace_back("imode", "LANCZOS4");
- break;
- default:
- props_.emplace_back("imode", "INVALID");
- break;
- }
- switch (op_.border_type){
- case Remap::BorderMode::REPLICATE:
- props_.emplace_back("border_type", "REPLICATE");
- break;
- case Remap::BorderMode::REFLECT:
- props_.emplace_back("border_type", "REFLECT");
- break;
- case Remap::BorderMode::REFLECT_101:
- props_.emplace_back("border_type", "REFLECT_101");
- break;
- case Remap::BorderMode::WRAP:
- props_.emplace_back("border_type", "WRAP");
- break;
- case Remap::BorderMode::CONSTANT:
- props_.emplace_back("border_type", "CONSTANT");
- break;
- case Remap::BorderMode::TRANSPARENT:
- props_.emplace_back("border_type", "TRANSPARENT");
- break;
- case Remap::BorderMode::ISOLATED:
- props_.emplace_back("border_type", "ISOLATED");
- break;
- default:
- props_.emplace_back("border_type", "INVALID");
- break;
- }
- switch (op_.format){
- case Remap::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case Remap::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case Remap::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case Remap::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case Remap::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case Remap::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case Remap::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case Remap::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case Remap::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case Remap::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case Remap::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case Remap::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case Remap::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case Remap::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case Remap::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case Remap::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case Remap::Format::NCHW64:
- props_.emplace_back("format", "NCHW64");
- break;
- case Remap::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- props_.emplace_back("scalar", std::to_string(op_.scalar));
- return props_;
- }
- std::string Remap_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Remap>();
- static_cast<void>(op_);
- return "Remap";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Remap, Remap)
- .hash(Remap_hash_impl)
- .is_same_st(Remap_is_same_st_impl)
- .props(Remap_props_impl)
- .make_name(Remap_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(RemoteRecv);
-
- namespace {
- size_t RemoteRecv_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<RemoteRecv>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.key));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.addr));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.port));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.rank_from));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.cn));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.shape));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.backend));
- return val;
- }
- bool RemoteRecv_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<RemoteRecv>(),
- &&b_ = rhs_.cast_final_safe<RemoteRecv>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.key != b_.key) return false;
- if (a_.addr != b_.addr) return false;
- if (a_.port != b_.port) return false;
- if (a_.rank_from != b_.rank_from) return false;
- if (a_.cn != b_.cn) return false;
- if (a_.shape != b_.shape) return false;
- if (a_.dtype != b_.dtype) return false;
- if (a_.backend != b_.backend) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> RemoteRecv_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<RemoteRecv>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("key", op_.key);
- props_.emplace_back("addr", op_.addr);
- props_.emplace_back("port", std::to_string(op_.port));
- props_.emplace_back("rank_from", std::to_string(op_.rank_from));
- props_.emplace_back("cn", op_.cn.to_string());
- props_.emplace_back("shape", "{std::vector}");
- props_.emplace_back("dtype", op_.dtype.name());
- props_.emplace_back("backend", op_.backend);
- return props_;
- }
- std::string RemoteRecv_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<RemoteRecv>();
- static_cast<void>(op_);
- return "RemoteRecv";
- }
- } // anonymous namespace
- OP_TRAIT_REG(RemoteRecv, RemoteRecv)
- .hash(RemoteRecv_hash_impl)
- .is_same_st(RemoteRecv_is_same_st_impl)
- .props(RemoteRecv_props_impl)
- .make_name(RemoteRecv_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(RemoteSend);
-
- namespace {
- size_t RemoteSend_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<RemoteSend>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.key));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.addr));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.port));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.rank_to));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.backend));
- return val;
- }
- bool RemoteSend_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<RemoteSend>(),
- &&b_ = rhs_.cast_final_safe<RemoteSend>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.key != b_.key) return false;
- if (a_.addr != b_.addr) return false;
- if (a_.port != b_.port) return false;
- if (a_.rank_to != b_.rank_to) return false;
- if (a_.backend != b_.backend) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> RemoteSend_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<RemoteSend>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("key", op_.key);
- props_.emplace_back("addr", op_.addr);
- props_.emplace_back("port", std::to_string(op_.port));
- props_.emplace_back("rank_to", std::to_string(op_.rank_to));
- props_.emplace_back("backend", op_.backend);
- return props_;
- }
- std::string RemoteSend_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<RemoteSend>();
- static_cast<void>(op_);
- return "RemoteSend";
- }
- } // anonymous namespace
- OP_TRAIT_REG(RemoteSend, RemoteSend)
- .hash(RemoteSend_hash_impl)
- .is_same_st(RemoteSend_is_same_st_impl)
- .props(RemoteSend_props_impl)
- .make_name(RemoteSend_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(RemoveAxis);
-
- namespace {
- size_t RemoveAxis_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<RemoveAxis>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
- return val;
- }
- bool RemoveAxis_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<RemoveAxis>(),
- &&b_ = rhs_.cast_final_safe<RemoveAxis>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.axis != b_.axis) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> RemoveAxis_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<RemoveAxis>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("axis", "{std::vector}");
- return props_;
- }
- std::string RemoveAxis_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<RemoveAxis>();
- static_cast<void>(op_);
- return "RemoveAxis";
- }
- } // anonymous namespace
- OP_TRAIT_REG(RemoveAxis, RemoveAxis)
- .hash(RemoveAxis_hash_impl)
- .is_same_st(RemoveAxis_is_same_st_impl)
- .props(RemoveAxis_props_impl)
- .make_name(RemoveAxis_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Reshape);
-
- namespace {
- size_t Reshape_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Reshape>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.shape));
- return val;
- }
- bool Reshape_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Reshape>(),
- &&b_ = rhs_.cast_final_safe<Reshape>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.axis != b_.axis) return false;
- if (a_.shape != b_.shape) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Reshape_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Reshape>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("axis", std::to_string(op_.axis));
- props_.emplace_back("shape", "{std::vector}");
- return props_;
- }
- std::string Reshape_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Reshape>();
- static_cast<void>(op_);
- return "Reshape";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Reshape, Reshape)
- .hash(Reshape_hash_impl)
- .is_same_st(Reshape_is_same_st_impl)
- .props(Reshape_props_impl)
- .make_name(Reshape_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Resize);
-
- namespace {
- size_t Resize_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Resize>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- return val;
- }
- bool Resize_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Resize>(),
- &&b_ = rhs_.cast_final_safe<Resize>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.imode != b_.imode) return false;
- if (a_.format != b_.format) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Resize_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Resize>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.imode){
- case Resize::InterpolationMode::NEAREST:
- props_.emplace_back("imode", "NEAREST");
- break;
- case Resize::InterpolationMode::LINEAR:
- props_.emplace_back("imode", "LINEAR");
- break;
- case Resize::InterpolationMode::AREA:
- props_.emplace_back("imode", "AREA");
- break;
- case Resize::InterpolationMode::CUBIC:
- props_.emplace_back("imode", "CUBIC");
- break;
- case Resize::InterpolationMode::LANCZOS4:
- props_.emplace_back("imode", "LANCZOS4");
- break;
- default:
- props_.emplace_back("imode", "INVALID");
- break;
- }
- switch (op_.format){
- case Resize::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case Resize::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case Resize::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case Resize::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case Resize::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case Resize::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case Resize::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case Resize::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case Resize::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case Resize::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case Resize::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case Resize::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case Resize::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case Resize::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case Resize::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case Resize::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case Resize::Format::NCHW64:
- props_.emplace_back("format", "NCHW64");
- break;
- case Resize::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- return props_;
- }
- std::string Resize_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Resize>();
- static_cast<void>(op_);
- return "Resize";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Resize, Resize)
- .hash(Resize_hash_impl)
- .is_same_st(Resize_is_same_st_impl)
- .props(Resize_props_impl)
- .make_name(Resize_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(SVD);
-
- namespace {
- size_t SVD_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<SVD>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.full_matrices));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.compute_uv));
- return val;
- }
- bool SVD_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<SVD>(),
- &&b_ = rhs_.cast_final_safe<SVD>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.full_matrices != b_.full_matrices) return false;
- if (a_.compute_uv != b_.compute_uv) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> SVD_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<SVD>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("full_matrices", std::to_string(op_.full_matrices));
- props_.emplace_back("compute_uv", std::to_string(op_.compute_uv));
- return props_;
- }
- std::string SVD_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<SVD>();
- static_cast<void>(op_);
- return "SVD";
- }
- } // anonymous namespace
- OP_TRAIT_REG(SVD, SVD)
- .hash(SVD_hash_impl)
- .is_same_st(SVD_is_same_st_impl)
- .props(SVD_props_impl)
- .make_name(SVD_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(SetMeshIndexing);
-
- namespace {
- size_t SetMeshIndexing_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<SetMeshIndexing>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
- return val;
- }
- bool SetMeshIndexing_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<SetMeshIndexing>(),
- &&b_ = rhs_.cast_final_safe<SetMeshIndexing>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.items != b_.items) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> SetMeshIndexing_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<SetMeshIndexing>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("items", "{std::vector}");
- return props_;
- }
- std::string SetMeshIndexing_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<SetMeshIndexing>();
- static_cast<void>(op_);
- return "SetMeshIndexing";
- }
- } // anonymous namespace
- OP_TRAIT_REG(SetMeshIndexing, SetMeshIndexing)
- .hash(SetMeshIndexing_hash_impl)
- .is_same_st(SetMeshIndexing_is_same_st_impl)
- .props(SetMeshIndexing_props_impl)
- .make_name(SetMeshIndexing_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(SetSubtensor);
-
- namespace {
- size_t SetSubtensor_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<SetSubtensor>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
- return val;
- }
- bool SetSubtensor_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<SetSubtensor>(),
- &&b_ = rhs_.cast_final_safe<SetSubtensor>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.items != b_.items) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> SetSubtensor_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<SetSubtensor>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("items", "{std::vector}");
- return props_;
- }
- std::string SetSubtensor_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<SetSubtensor>();
- static_cast<void>(op_);
- return "SetSubtensor";
- }
- } // anonymous namespace
- OP_TRAIT_REG(SetSubtensor, SetSubtensor)
- .hash(SetSubtensor_hash_impl)
- .is_same_st(SetSubtensor_is_same_st_impl)
- .props(SetSubtensor_props_impl)
- .make_name(SetSubtensor_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(ShuffleRNG);
-
- namespace {
- size_t ShuffleRNG_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ShuffleRNG>();
- static_cast<void>(op_);
-
- return mgb::hash_pair_combine(
- mgb::hash(op_.dyn_typeinfo()),
- mgb::hash(op_.handle)
- );
- }
- bool ShuffleRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<ShuffleRNG>(),
- &&b_ = rhs_.cast_final_safe<ShuffleRNG>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- return a_.handle == b_.handle;}
- std::vector<std::pair<const char*, std::string>> ShuffleRNG_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ShuffleRNG>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("seed", std::to_string(op_.seed));
- props_.emplace_back("handle", std::to_string(op_.handle));
- return props_;
- }
- std::string ShuffleRNG_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<ShuffleRNG>();
- static_cast<void>(op_);
- return "ShuffleRNG";
- }
- } // anonymous namespace
- OP_TRAIT_REG(ShuffleRNG, ShuffleRNG)
- .hash(ShuffleRNG_hash_impl)
- .is_same_st(ShuffleRNG_is_same_st_impl)
- .props(ShuffleRNG_props_impl)
- .make_name(ShuffleRNG_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(SlidingWindowTranspose);
-
- namespace {
- size_t SlidingWindowTranspose_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<SlidingWindowTranspose>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.out_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.out_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.window_h));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.window_w));
- return val;
- }
- bool SlidingWindowTranspose_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<SlidingWindowTranspose>(),
- &&b_ = rhs_.cast_final_safe<SlidingWindowTranspose>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.out_h != b_.out_h) return false;
- if (a_.out_w != b_.out_w) return false;
- if (a_.pad_h != b_.pad_h) return false;
- if (a_.pad_w != b_.pad_w) return false;
- if (a_.stride_h != b_.stride_h) return false;
- if (a_.stride_w != b_.stride_w) return false;
- if (a_.dilate_h != b_.dilate_h) return false;
- if (a_.dilate_w != b_.dilate_w) return false;
- if (a_.window_h != b_.window_h) return false;
- if (a_.window_w != b_.window_w) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> SlidingWindowTranspose_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<SlidingWindowTranspose>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("out_h", std::to_string(op_.out_h));
- props_.emplace_back("out_w", std::to_string(op_.out_w));
- props_.emplace_back("pad_h", std::to_string(op_.pad_h));
- props_.emplace_back("pad_w", std::to_string(op_.pad_w));
- props_.emplace_back("stride_h", std::to_string(op_.stride_h));
- props_.emplace_back("stride_w", std::to_string(op_.stride_w));
- props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
- props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
- props_.emplace_back("window_h", std::to_string(op_.window_h));
- props_.emplace_back("window_w", std::to_string(op_.window_w));
- return props_;
- }
- std::string SlidingWindowTranspose_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<SlidingWindowTranspose>();
- static_cast<void>(op_);
- return "SlidingWindowTranspose";
- }
- } // anonymous namespace
- OP_TRAIT_REG(SlidingWindowTranspose, SlidingWindowTranspose)
- .hash(SlidingWindowTranspose_hash_impl)
- .is_same_st(SlidingWindowTranspose_is_same_st_impl)
- .props(SlidingWindowTranspose_props_impl)
- .make_name(SlidingWindowTranspose_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Softmax);
-
- namespace {
- size_t Softmax_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Softmax>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
- return val;
- }
- bool Softmax_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Softmax>(),
- &&b_ = rhs_.cast_final_safe<Softmax>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.axis != b_.axis) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Softmax_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Softmax>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("axis", std::to_string(op_.axis));
- return props_;
- }
- std::string Softmax_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Softmax>();
- static_cast<void>(op_);
- return "Softmax";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Softmax, Softmax)
- .hash(Softmax_hash_impl)
- .is_same_st(Softmax_is_same_st_impl)
- .props(Softmax_props_impl)
- .make_name(Softmax_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Split);
-
- namespace {
- size_t Split_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Split>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.nsections));
- return val;
- }
- bool Split_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Split>(),
- &&b_ = rhs_.cast_final_safe<Split>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.axis != b_.axis) return false;
- if (a_.nsections != b_.nsections) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Split_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Split>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("axis", std::to_string(op_.axis));
- props_.emplace_back("nsections", std::to_string(op_.nsections));
- return props_;
- }
- std::string Split_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Split>();
- static_cast<void>(op_);
- return "Split";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Split, Split)
- .hash(Split_hash_impl)
- .is_same_st(Split_is_same_st_impl)
- .props(Split_props_impl)
- .make_name(Split_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(Subtensor);
-
- namespace {
- size_t Subtensor_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Subtensor>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
- return val;
- }
- bool Subtensor_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<Subtensor>(),
- &&b_ = rhs_.cast_final_safe<Subtensor>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.items != b_.items) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> Subtensor_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Subtensor>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("items", "{std::vector}");
- return props_;
- }
- std::string Subtensor_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<Subtensor>();
- static_cast<void>(op_);
- return "Subtensor";
- }
- } // anonymous namespace
- OP_TRAIT_REG(Subtensor, Subtensor)
- .hash(Subtensor_hash_impl)
- .is_same_st(Subtensor_is_same_st_impl)
- .props(Subtensor_props_impl)
- .make_name(Subtensor_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(TQT);
-
- namespace {
- size_t TQT_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<TQT>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.qmin));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.qmax));
- return val;
- }
- bool TQT_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<TQT>(),
- &&b_ = rhs_.cast_final_safe<TQT>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.qmin != b_.qmin) return false;
- if (a_.qmax != b_.qmax) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> TQT_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<TQT>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("qmin", std::to_string(op_.qmin));
- props_.emplace_back("qmax", std::to_string(op_.qmax));
- return props_;
- }
- std::string TQT_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<TQT>();
- static_cast<void>(op_);
- return "TQT";
- }
- } // anonymous namespace
- OP_TRAIT_REG(TQT, TQT)
- .hash(TQT_hash_impl)
- .is_same_st(TQT_is_same_st_impl)
- .props(TQT_props_impl)
- .make_name(TQT_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(TensorRTRuntime);
-
- namespace {
- size_t TensorRTRuntime_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<TensorRTRuntime>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.buf));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.buf_size));
- return val;
- }
- bool TensorRTRuntime_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<TensorRTRuntime>(),
- &&b_ = rhs_.cast_final_safe<TensorRTRuntime>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.buf != b_.buf) return false;
- if (a_.buf_size != b_.buf_size) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> TensorRTRuntime_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<TensorRTRuntime>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("buf", op_.buf);
- props_.emplace_back("buf_size", std::to_string(op_.buf_size));
- return props_;
- }
- std::string TensorRTRuntime_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<TensorRTRuntime>();
- static_cast<void>(op_);
- return "TensorRTRuntime";
- }
- } // anonymous namespace
- OP_TRAIT_REG(TensorRTRuntime, TensorRTRuntime)
- .hash(TensorRTRuntime_hash_impl)
- .is_same_st(TensorRTRuntime_is_same_st_impl)
- .props(TensorRTRuntime_props_impl)
- .make_name(TensorRTRuntime_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(TopK);
-
- namespace {
- size_t TopK_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<TopK>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
- return val;
- }
- bool TopK_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<TopK>(),
- &&b_ = rhs_.cast_final_safe<TopK>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.mode != b_.mode) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> TopK_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<TopK>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.mode){
- case TopK::Mode::KTH_ONLY:
- props_.emplace_back("mode", "KTH_ONLY");
- break;
- case TopK::Mode::VALUE_IDX_NOSORT:
- props_.emplace_back("mode", "VALUE_IDX_NOSORT");
- break;
- case TopK::Mode::VALUE_IDX_SORTED:
- props_.emplace_back("mode", "VALUE_IDX_SORTED");
- break;
- default:
- props_.emplace_back("mode", "INVALID");
- break;
- }
- return props_;
- }
- std::string TopK_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<TopK>();
- static_cast<void>(op_);
- return "TopK";
- }
- } // anonymous namespace
- OP_TRAIT_REG(TopK, TopK)
- .hash(TopK_hash_impl)
- .is_same_st(TopK_is_same_st_impl)
- .props(TopK_props_impl)
- .make_name(TopK_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(TypeCvt);
-
- namespace {
- size_t TypeCvt_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<TypeCvt>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
- return val;
- }
- bool TypeCvt_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<TypeCvt>(),
- &&b_ = rhs_.cast_final_safe<TypeCvt>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.dtype != b_.dtype) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> TypeCvt_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<TypeCvt>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("dtype", op_.dtype.name());
- return props_;
- }
- std::string TypeCvt_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<TypeCvt>();
- static_cast<void>(op_);
- return "TypeCvt";
- }
- } // anonymous namespace
- OP_TRAIT_REG(TypeCvt, TypeCvt)
- .hash(TypeCvt_hash_impl)
- .is_same_st(TypeCvt_is_same_st_impl)
- .props(TypeCvt_props_impl)
- .make_name(TypeCvt_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(UniformRNG);
-
- namespace {
- size_t UniformRNG_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<UniformRNG>();
- static_cast<void>(op_);
-
- return mgb::hash_pair_combine(
- mgb::hash(op_.dyn_typeinfo()),
- mgb::hash_pair_combine(
- mgb::hash(op_.handle),
- mgb::hash(op_.dtype.enumv())
- )
- );
- }
- bool UniformRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<UniformRNG>(),
- &&b_ = rhs_.cast_final_safe<UniformRNG>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- return a_.handle == b_.handle && a_.dtype == b_.dtype;}
- std::vector<std::pair<const char*, std::string>> UniformRNG_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<UniformRNG>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- props_.emplace_back("seed", std::to_string(op_.seed));
- props_.emplace_back("dtype", op_.dtype.name());
- props_.emplace_back("handle", std::to_string(op_.handle));
- return props_;
- }
- std::string UniformRNG_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<UniformRNG>();
- static_cast<void>(op_);
- return "UniformRNG";
- }
- } // anonymous namespace
- OP_TRAIT_REG(UniformRNG, UniformRNG)
- .hash(UniformRNG_hash_impl)
- .is_same_st(UniformRNG_is_same_st_impl)
- .props(UniformRNG_props_impl)
- .make_name(UniformRNG_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(WarpAffine);
-
- namespace {
- size_t WarpAffine_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<WarpAffine>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.border_mode));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.border_val));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- return val;
- }
- bool WarpAffine_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<WarpAffine>(),
- &&b_ = rhs_.cast_final_safe<WarpAffine>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.imode != b_.imode) return false;
- if (a_.border_mode != b_.border_mode) return false;
- if (a_.border_val != b_.border_val) return false;
- if (a_.format != b_.format) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> WarpAffine_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<WarpAffine>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.imode){
- case WarpAffine::InterpolationMode::NEAREST:
- props_.emplace_back("imode", "NEAREST");
- break;
- case WarpAffine::InterpolationMode::LINEAR:
- props_.emplace_back("imode", "LINEAR");
- break;
- case WarpAffine::InterpolationMode::AREA:
- props_.emplace_back("imode", "AREA");
- break;
- case WarpAffine::InterpolationMode::CUBIC:
- props_.emplace_back("imode", "CUBIC");
- break;
- case WarpAffine::InterpolationMode::LANCZOS4:
- props_.emplace_back("imode", "LANCZOS4");
- break;
- default:
- props_.emplace_back("imode", "INVALID");
- break;
- }
- switch (op_.border_mode){
- case WarpAffine::BorderMode::REPLICATE:
- props_.emplace_back("border_mode", "REPLICATE");
- break;
- case WarpAffine::BorderMode::REFLECT:
- props_.emplace_back("border_mode", "REFLECT");
- break;
- case WarpAffine::BorderMode::REFLECT_101:
- props_.emplace_back("border_mode", "REFLECT_101");
- break;
- case WarpAffine::BorderMode::WRAP:
- props_.emplace_back("border_mode", "WRAP");
- break;
- case WarpAffine::BorderMode::CONSTANT:
- props_.emplace_back("border_mode", "CONSTANT");
- break;
- case WarpAffine::BorderMode::TRANSPARENT:
- props_.emplace_back("border_mode", "TRANSPARENT");
- break;
- case WarpAffine::BorderMode::ISOLATED:
- props_.emplace_back("border_mode", "ISOLATED");
- break;
- default:
- props_.emplace_back("border_mode", "INVALID");
- break;
- }
- props_.emplace_back("border_val", std::to_string(op_.border_val));
- switch (op_.format){
- case WarpAffine::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case WarpAffine::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case WarpAffine::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case WarpAffine::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case WarpAffine::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case WarpAffine::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case WarpAffine::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case WarpAffine::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case WarpAffine::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case WarpAffine::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case WarpAffine::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case WarpAffine::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case WarpAffine::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case WarpAffine::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case WarpAffine::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case WarpAffine::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case WarpAffine::Format::NCHW64:
- props_.emplace_back("format", "NCHW64");
- break;
- case WarpAffine::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- return props_;
- }
- std::string WarpAffine_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<WarpAffine>();
- static_cast<void>(op_);
- return "WarpAffine";
- }
- } // anonymous namespace
- OP_TRAIT_REG(WarpAffine, WarpAffine)
- .hash(WarpAffine_hash_impl)
- .is_same_st(WarpAffine_is_same_st_impl)
- .props(WarpAffine_props_impl)
- .make_name(WarpAffine_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(WarpPerspective);
-
- namespace {
- size_t WarpPerspective_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<WarpPerspective>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.bmode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.border_val));
- return val;
- }
- bool WarpPerspective_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<WarpPerspective>(),
- &&b_ = rhs_.cast_final_safe<WarpPerspective>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.imode != b_.imode) return false;
- if (a_.bmode != b_.bmode) return false;
- if (a_.format != b_.format) return false;
- if (a_.border_val != b_.border_val) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> WarpPerspective_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<WarpPerspective>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.imode){
- case WarpPerspective::InterpolationMode::NEAREST:
- props_.emplace_back("imode", "NEAREST");
- break;
- case WarpPerspective::InterpolationMode::LINEAR:
- props_.emplace_back("imode", "LINEAR");
- break;
- case WarpPerspective::InterpolationMode::AREA:
- props_.emplace_back("imode", "AREA");
- break;
- case WarpPerspective::InterpolationMode::CUBIC:
- props_.emplace_back("imode", "CUBIC");
- break;
- case WarpPerspective::InterpolationMode::LANCZOS4:
- props_.emplace_back("imode", "LANCZOS4");
- break;
- default:
- props_.emplace_back("imode", "INVALID");
- break;
- }
- switch (op_.bmode){
- case WarpPerspective::BorderMode::REPLICATE:
- props_.emplace_back("bmode", "REPLICATE");
- break;
- case WarpPerspective::BorderMode::REFLECT:
- props_.emplace_back("bmode", "REFLECT");
- break;
- case WarpPerspective::BorderMode::REFLECT_101:
- props_.emplace_back("bmode", "REFLECT_101");
- break;
- case WarpPerspective::BorderMode::WRAP:
- props_.emplace_back("bmode", "WRAP");
- break;
- case WarpPerspective::BorderMode::CONSTANT:
- props_.emplace_back("bmode", "CONSTANT");
- break;
- case WarpPerspective::BorderMode::TRANSPARENT:
- props_.emplace_back("bmode", "TRANSPARENT");
- break;
- case WarpPerspective::BorderMode::ISOLATED:
- props_.emplace_back("bmode", "ISOLATED");
- break;
- default:
- props_.emplace_back("bmode", "INVALID");
- break;
- }
- switch (op_.format){
- case WarpPerspective::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case WarpPerspective::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case WarpPerspective::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case WarpPerspective::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case WarpPerspective::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case WarpPerspective::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case WarpPerspective::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case WarpPerspective::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case WarpPerspective::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case WarpPerspective::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case WarpPerspective::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case WarpPerspective::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case WarpPerspective::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case WarpPerspective::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case WarpPerspective::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case WarpPerspective::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case WarpPerspective::Format::NCHW64:
- props_.emplace_back("format", "NCHW64");
- break;
- case WarpPerspective::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- props_.emplace_back("border_val", std::to_string(op_.border_val));
- return props_;
- }
- std::string WarpPerspective_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<WarpPerspective>();
- static_cast<void>(op_);
- return "WarpPerspective";
- }
- } // anonymous namespace
- OP_TRAIT_REG(WarpPerspective, WarpPerspective)
- .hash(WarpPerspective_hash_impl)
- .is_same_st(WarpPerspective_is_same_st_impl)
- .props(WarpPerspective_props_impl)
- .make_name(WarpPerspective_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(WarpPerspectiveBackwardData);
-
- namespace {
- size_t WarpPerspectiveBackwardData_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardData>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.bmode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.border_val));
- return val;
- }
- bool WarpPerspectiveBackwardData_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<WarpPerspectiveBackwardData>(),
- &&b_ = rhs_.cast_final_safe<WarpPerspectiveBackwardData>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.imode != b_.imode) return false;
- if (a_.bmode != b_.bmode) return false;
- if (a_.format != b_.format) return false;
- if (a_.border_val != b_.border_val) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> WarpPerspectiveBackwardData_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardData>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.imode){
- case WarpPerspectiveBackwardData::InterpolationMode::NEAREST:
- props_.emplace_back("imode", "NEAREST");
- break;
- case WarpPerspectiveBackwardData::InterpolationMode::LINEAR:
- props_.emplace_back("imode", "LINEAR");
- break;
- case WarpPerspectiveBackwardData::InterpolationMode::AREA:
- props_.emplace_back("imode", "AREA");
- break;
- case WarpPerspectiveBackwardData::InterpolationMode::CUBIC:
- props_.emplace_back("imode", "CUBIC");
- break;
- case WarpPerspectiveBackwardData::InterpolationMode::LANCZOS4:
- props_.emplace_back("imode", "LANCZOS4");
- break;
- default:
- props_.emplace_back("imode", "INVALID");
- break;
- }
- switch (op_.bmode){
- case WarpPerspectiveBackwardData::BorderMode::REPLICATE:
- props_.emplace_back("bmode", "REPLICATE");
- break;
- case WarpPerspectiveBackwardData::BorderMode::REFLECT:
- props_.emplace_back("bmode", "REFLECT");
- break;
- case WarpPerspectiveBackwardData::BorderMode::REFLECT_101:
- props_.emplace_back("bmode", "REFLECT_101");
- break;
- case WarpPerspectiveBackwardData::BorderMode::WRAP:
- props_.emplace_back("bmode", "WRAP");
- break;
- case WarpPerspectiveBackwardData::BorderMode::CONSTANT:
- props_.emplace_back("bmode", "CONSTANT");
- break;
- case WarpPerspectiveBackwardData::BorderMode::TRANSPARENT:
- props_.emplace_back("bmode", "TRANSPARENT");
- break;
- case WarpPerspectiveBackwardData::BorderMode::ISOLATED:
- props_.emplace_back("bmode", "ISOLATED");
- break;
- default:
- props_.emplace_back("bmode", "INVALID");
- break;
- }
- switch (op_.format){
- case WarpPerspectiveBackwardData::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case WarpPerspectiveBackwardData::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case WarpPerspectiveBackwardData::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case WarpPerspectiveBackwardData::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case WarpPerspectiveBackwardData::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case WarpPerspectiveBackwardData::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case WarpPerspectiveBackwardData::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case WarpPerspectiveBackwardData::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case WarpPerspectiveBackwardData::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case WarpPerspectiveBackwardData::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case WarpPerspectiveBackwardData::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case WarpPerspectiveBackwardData::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case WarpPerspectiveBackwardData::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case WarpPerspectiveBackwardData::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case WarpPerspectiveBackwardData::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case WarpPerspectiveBackwardData::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case WarpPerspectiveBackwardData::Format::NCHW64:
- props_.emplace_back("format", "NCHW64");
- break;
- case WarpPerspectiveBackwardData::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- props_.emplace_back("border_val", std::to_string(op_.border_val));
- return props_;
- }
- std::string WarpPerspectiveBackwardData_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardData>();
- static_cast<void>(op_);
- return "WarpPerspectiveBackwardData";
- }
- } // anonymous namespace
- OP_TRAIT_REG(WarpPerspectiveBackwardData, WarpPerspectiveBackwardData)
- .hash(WarpPerspectiveBackwardData_hash_impl)
- .is_same_st(WarpPerspectiveBackwardData_is_same_st_impl)
- .props(WarpPerspectiveBackwardData_props_impl)
- .make_name(WarpPerspectiveBackwardData_make_name_impl);
-
- MGB_DYN_TYPE_OBJ_FINAL_IMPL(WarpPerspectiveBackwardMat);
-
- namespace {
- size_t WarpPerspectiveBackwardMat_hash_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardMat>();
- static_cast<void>(op_);
- size_t val = mgb::hash(op_.dyn_typeinfo());
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.bmode));
- val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
- val = mgb::hash_pair_combine(val, mgb::hash(op_.border_val));
- return val;
- }
- bool WarpPerspectiveBackwardMat_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
- auto &&a_ = lhs_.cast_final_safe<WarpPerspectiveBackwardMat>(),
- &&b_ = rhs_.cast_final_safe<WarpPerspectiveBackwardMat>();
- static_cast<void>(a_);
- static_cast<void>(b_);
- if (a_.imode != b_.imode) return false;
- if (a_.bmode != b_.bmode) return false;
- if (a_.format != b_.format) return false;
- if (a_.border_val != b_.border_val) return false;
- return true;
- }
- std::vector<std::pair<const char*, std::string>> WarpPerspectiveBackwardMat_props_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardMat>();
- static_cast<void>(op_);
- std::vector<std::pair<const char*, std::string>> props_;
- switch (op_.imode){
- case WarpPerspectiveBackwardMat::InterpolationMode::NEAREST:
- props_.emplace_back("imode", "NEAREST");
- break;
- case WarpPerspectiveBackwardMat::InterpolationMode::LINEAR:
- props_.emplace_back("imode", "LINEAR");
- break;
- case WarpPerspectiveBackwardMat::InterpolationMode::AREA:
- props_.emplace_back("imode", "AREA");
- break;
- case WarpPerspectiveBackwardMat::InterpolationMode::CUBIC:
- props_.emplace_back("imode", "CUBIC");
- break;
- case WarpPerspectiveBackwardMat::InterpolationMode::LANCZOS4:
- props_.emplace_back("imode", "LANCZOS4");
- break;
- default:
- props_.emplace_back("imode", "INVALID");
- break;
- }
- switch (op_.bmode){
- case WarpPerspectiveBackwardMat::BorderMode::REPLICATE:
- props_.emplace_back("bmode", "REPLICATE");
- break;
- case WarpPerspectiveBackwardMat::BorderMode::REFLECT:
- props_.emplace_back("bmode", "REFLECT");
- break;
- case WarpPerspectiveBackwardMat::BorderMode::REFLECT_101:
- props_.emplace_back("bmode", "REFLECT_101");
- break;
- case WarpPerspectiveBackwardMat::BorderMode::WRAP:
- props_.emplace_back("bmode", "WRAP");
- break;
- case WarpPerspectiveBackwardMat::BorderMode::CONSTANT:
- props_.emplace_back("bmode", "CONSTANT");
- break;
- case WarpPerspectiveBackwardMat::BorderMode::TRANSPARENT:
- props_.emplace_back("bmode", "TRANSPARENT");
- break;
- case WarpPerspectiveBackwardMat::BorderMode::ISOLATED:
- props_.emplace_back("bmode", "ISOLATED");
- break;
- default:
- props_.emplace_back("bmode", "INVALID");
- break;
- }
- switch (op_.format){
- case WarpPerspectiveBackwardMat::Format::NCHW:
- props_.emplace_back("format", "NCHW");
- break;
- case WarpPerspectiveBackwardMat::Format::NHWC:
- props_.emplace_back("format", "NHWC");
- break;
- case WarpPerspectiveBackwardMat::Format::NHWCD4:
- props_.emplace_back("format", "NHWCD4");
- break;
- case WarpPerspectiveBackwardMat::Format::NCHW4:
- props_.emplace_back("format", "NCHW4");
- break;
- case WarpPerspectiveBackwardMat::Format::NCHW8:
- props_.emplace_back("format", "NCHW8");
- break;
- case WarpPerspectiveBackwardMat::Format::NCHW32:
- props_.emplace_back("format", "NCHW32");
- break;
- case WarpPerspectiveBackwardMat::Format::NCHW88:
- props_.emplace_back("format", "NCHW88");
- break;
- case WarpPerspectiveBackwardMat::Format::NCHW44:
- props_.emplace_back("format", "NCHW44");
- break;
- case WarpPerspectiveBackwardMat::Format::NCHW44_DOT:
- props_.emplace_back("format", "NCHW44_DOT");
- break;
- case WarpPerspectiveBackwardMat::Format::NCHW4_NCHW32:
- props_.emplace_back("format", "NCHW4_NCHW32");
- break;
- case WarpPerspectiveBackwardMat::Format::NCHW32_NCHW4:
- props_.emplace_back("format", "NCHW32_NCHW4");
- break;
- case WarpPerspectiveBackwardMat::Format::NCHW4_NCHW:
- props_.emplace_back("format", "NCHW4_NCHW");
- break;
- case WarpPerspectiveBackwardMat::Format::NHWC_NCHW:
- props_.emplace_back("format", "NHWC_NCHW");
- break;
- case WarpPerspectiveBackwardMat::Format::NHWC_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
- break;
- case WarpPerspectiveBackwardMat::Format::NCHW_NCHW4_IC_SMALL:
- props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
- break;
- case WarpPerspectiveBackwardMat::Format::CHWN4:
- props_.emplace_back("format", "CHWN4");
- break;
- case WarpPerspectiveBackwardMat::Format::NCHW64:
- props_.emplace_back("format", "NCHW64");
- break;
- case WarpPerspectiveBackwardMat::Format::NCHW4_NHWC:
- props_.emplace_back("format", "NCHW4_NHWC");
- break;
- default:
- props_.emplace_back("format", "INVALID");
- break;
- }
- props_.emplace_back("border_val", std::to_string(op_.border_val));
- return props_;
- }
- std::string WarpPerspectiveBackwardMat_make_name_impl(const OpDef& def_) {
- auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardMat>();
- static_cast<void>(op_);
- return "WarpPerspectiveBackwardMat";
- }
- } // anonymous namespace
- OP_TRAIT_REG(WarpPerspectiveBackwardMat, WarpPerspectiveBackwardMat)
- .hash(WarpPerspectiveBackwardMat_hash_impl)
- .is_same_st(WarpPerspectiveBackwardMat_is_same_st_impl)
- .props(WarpPerspectiveBackwardMat_props_impl)
- .make_name(WarpPerspectiveBackwardMat_make_name_impl);
-
- // clang-format on
|