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

opdef.cpp.inl 272 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240
  1. // clang-format off
  2. MGB_DYN_TYPE_OBJ_FINAL_IMPL(AdaptivePooling);
  3. namespace {
  4. size_t AdaptivePooling_hash_impl(const OpDef& def_) {
  5. auto&& op_ = def_.cast_final_safe<AdaptivePooling>();
  6. static_cast<void>(op_);
  7. size_t val = mgb::hash(op_.dyn_typeinfo());
  8. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  9. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  10. val = mgb::hash_pair_combine(val, mgb::hash(op_.shape));
  11. return val;
  12. }
  13. bool AdaptivePooling_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  14. auto &&a_ = lhs_.cast_final_safe<AdaptivePooling>(),
  15. &&b_ = rhs_.cast_final_safe<AdaptivePooling>();
  16. static_cast<void>(a_);
  17. static_cast<void>(b_);
  18. if (a_.mode != b_.mode) return false;
  19. if (a_.format != b_.format) return false;
  20. if (a_.shape != b_.shape) return false;
  21. return true;
  22. }
  23. std::vector<std::pair<const char*, std::string>> AdaptivePooling_props_impl(const OpDef& def_) {
  24. auto&& op_ = def_.cast_final_safe<AdaptivePooling>();
  25. static_cast<void>(op_);
  26. std::vector<std::pair<const char*, std::string>> props_;
  27. switch (op_.mode){
  28. case AdaptivePooling::Mode::MAX:
  29. props_.emplace_back("mode", "MAX");
  30. break;
  31. case AdaptivePooling::Mode::AVERAGE:
  32. props_.emplace_back("mode", "AVERAGE");
  33. break;
  34. case AdaptivePooling::Mode::AVERAGE_COUNT_EXCLUDE_PADDING:
  35. props_.emplace_back("mode", "AVERAGE_COUNT_EXCLUDE_PADDING");
  36. break;
  37. default:
  38. props_.emplace_back("mode", "INVALID");
  39. break;
  40. }
  41. switch (op_.format){
  42. case AdaptivePooling::Format::NCHW:
  43. props_.emplace_back("format", "NCHW");
  44. break;
  45. case AdaptivePooling::Format::NHWC:
  46. props_.emplace_back("format", "NHWC");
  47. break;
  48. case AdaptivePooling::Format::NHWCD4:
  49. props_.emplace_back("format", "NHWCD4");
  50. break;
  51. case AdaptivePooling::Format::NCHW4:
  52. props_.emplace_back("format", "NCHW4");
  53. break;
  54. case AdaptivePooling::Format::NCHW8:
  55. props_.emplace_back("format", "NCHW8");
  56. break;
  57. case AdaptivePooling::Format::NCHW32:
  58. props_.emplace_back("format", "NCHW32");
  59. break;
  60. case AdaptivePooling::Format::NCHW88:
  61. props_.emplace_back("format", "NCHW88");
  62. break;
  63. case AdaptivePooling::Format::NCHW44:
  64. props_.emplace_back("format", "NCHW44");
  65. break;
  66. case AdaptivePooling::Format::NCHW44_DOT:
  67. props_.emplace_back("format", "NCHW44_DOT");
  68. break;
  69. case AdaptivePooling::Format::NCHW4_NCHW32:
  70. props_.emplace_back("format", "NCHW4_NCHW32");
  71. break;
  72. case AdaptivePooling::Format::NCHW32_NCHW4:
  73. props_.emplace_back("format", "NCHW32_NCHW4");
  74. break;
  75. case AdaptivePooling::Format::NCHW4_NCHW:
  76. props_.emplace_back("format", "NCHW4_NCHW");
  77. break;
  78. case AdaptivePooling::Format::NHWC_NCHW:
  79. props_.emplace_back("format", "NHWC_NCHW");
  80. break;
  81. case AdaptivePooling::Format::NHWC_NCHW4_IC_SMALL:
  82. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  83. break;
  84. case AdaptivePooling::Format::NCHW_NCHW4_IC_SMALL:
  85. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  86. break;
  87. case AdaptivePooling::Format::CHWN4:
  88. props_.emplace_back("format", "CHWN4");
  89. break;
  90. case AdaptivePooling::Format::NCHW64:
  91. props_.emplace_back("format", "NCHW64");
  92. break;
  93. case AdaptivePooling::Format::NCHW4_NHWC:
  94. props_.emplace_back("format", "NCHW4_NHWC");
  95. break;
  96. default:
  97. props_.emplace_back("format", "INVALID");
  98. break;
  99. }
  100. props_.emplace_back("shape", "{std::vector}");
  101. return props_;
  102. }
  103. std::string AdaptivePooling_make_name_impl(const OpDef& def_) {
  104. auto&& op_ = def_.cast_final_safe<AdaptivePooling>();
  105. static_cast<void>(op_);
  106. return "AdaptivePooling";
  107. }
  108. } // anonymous namespace
  109. OP_TRAIT_REG(AdaptivePooling, AdaptivePooling)
  110. .hash(AdaptivePooling_hash_impl)
  111. .is_same_st(AdaptivePooling_is_same_st_impl)
  112. .props(AdaptivePooling_props_impl)
  113. .make_name(AdaptivePooling_make_name_impl);
  114. MGB_DYN_TYPE_OBJ_FINAL_IMPL(AddAxis);
  115. namespace {
  116. size_t AddAxis_hash_impl(const OpDef& def_) {
  117. auto&& op_ = def_.cast_final_safe<AddAxis>();
  118. static_cast<void>(op_);
  119. size_t val = mgb::hash(op_.dyn_typeinfo());
  120. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  121. return val;
  122. }
  123. bool AddAxis_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  124. auto &&a_ = lhs_.cast_final_safe<AddAxis>(),
  125. &&b_ = rhs_.cast_final_safe<AddAxis>();
  126. static_cast<void>(a_);
  127. static_cast<void>(b_);
  128. if (a_.axis != b_.axis) return false;
  129. return true;
  130. }
  131. std::vector<std::pair<const char*, std::string>> AddAxis_props_impl(const OpDef& def_) {
  132. auto&& op_ = def_.cast_final_safe<AddAxis>();
  133. static_cast<void>(op_);
  134. std::vector<std::pair<const char*, std::string>> props_;
  135. props_.emplace_back("axis", "{std::vector}");
  136. return props_;
  137. }
  138. std::string AddAxis_make_name_impl(const OpDef& def_) {
  139. auto&& op_ = def_.cast_final_safe<AddAxis>();
  140. static_cast<void>(op_);
  141. return "AddAxis";
  142. }
  143. } // anonymous namespace
  144. OP_TRAIT_REG(AddAxis, AddAxis)
  145. .hash(AddAxis_hash_impl)
  146. .is_same_st(AddAxis_is_same_st_impl)
  147. .props(AddAxis_props_impl)
  148. .make_name(AddAxis_make_name_impl);
  149. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Argmax);
  150. namespace {
  151. size_t Argmax_hash_impl(const OpDef& def_) {
  152. auto&& op_ = def_.cast_final_safe<Argmax>();
  153. static_cast<void>(op_);
  154. size_t val = mgb::hash(op_.dyn_typeinfo());
  155. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  156. return val;
  157. }
  158. bool Argmax_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  159. auto &&a_ = lhs_.cast_final_safe<Argmax>(),
  160. &&b_ = rhs_.cast_final_safe<Argmax>();
  161. static_cast<void>(a_);
  162. static_cast<void>(b_);
  163. if (a_.axis != b_.axis) return false;
  164. return true;
  165. }
  166. std::vector<std::pair<const char*, std::string>> Argmax_props_impl(const OpDef& def_) {
  167. auto&& op_ = def_.cast_final_safe<Argmax>();
  168. static_cast<void>(op_);
  169. std::vector<std::pair<const char*, std::string>> props_;
  170. props_.emplace_back("axis", std::to_string(op_.axis));
  171. return props_;
  172. }
  173. std::string Argmax_make_name_impl(const OpDef& def_) {
  174. auto&& op_ = def_.cast_final_safe<Argmax>();
  175. static_cast<void>(op_);
  176. return "Argmax";
  177. }
  178. } // anonymous namespace
  179. OP_TRAIT_REG(Argmax, Argmax)
  180. .hash(Argmax_hash_impl)
  181. .is_same_st(Argmax_is_same_st_impl)
  182. .props(Argmax_props_impl)
  183. .make_name(Argmax_make_name_impl);
  184. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Argmin);
  185. namespace {
  186. size_t Argmin_hash_impl(const OpDef& def_) {
  187. auto&& op_ = def_.cast_final_safe<Argmin>();
  188. static_cast<void>(op_);
  189. size_t val = mgb::hash(op_.dyn_typeinfo());
  190. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  191. return val;
  192. }
  193. bool Argmin_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  194. auto &&a_ = lhs_.cast_final_safe<Argmin>(),
  195. &&b_ = rhs_.cast_final_safe<Argmin>();
  196. static_cast<void>(a_);
  197. static_cast<void>(b_);
  198. if (a_.axis != b_.axis) return false;
  199. return true;
  200. }
  201. std::vector<std::pair<const char*, std::string>> Argmin_props_impl(const OpDef& def_) {
  202. auto&& op_ = def_.cast_final_safe<Argmin>();
  203. static_cast<void>(op_);
  204. std::vector<std::pair<const char*, std::string>> props_;
  205. props_.emplace_back("axis", std::to_string(op_.axis));
  206. return props_;
  207. }
  208. std::string Argmin_make_name_impl(const OpDef& def_) {
  209. auto&& op_ = def_.cast_final_safe<Argmin>();
  210. static_cast<void>(op_);
  211. return "Argmin";
  212. }
  213. } // anonymous namespace
  214. OP_TRAIT_REG(Argmin, Argmin)
  215. .hash(Argmin_hash_impl)
  216. .is_same_st(Argmin_is_same_st_impl)
  217. .props(Argmin_props_impl)
  218. .make_name(Argmin_make_name_impl);
  219. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Argsort);
  220. namespace {
  221. size_t Argsort_hash_impl(const OpDef& def_) {
  222. auto&& op_ = def_.cast_final_safe<Argsort>();
  223. static_cast<void>(op_);
  224. size_t val = mgb::hash(op_.dyn_typeinfo());
  225. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.order));
  226. return val;
  227. }
  228. bool Argsort_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  229. auto &&a_ = lhs_.cast_final_safe<Argsort>(),
  230. &&b_ = rhs_.cast_final_safe<Argsort>();
  231. static_cast<void>(a_);
  232. static_cast<void>(b_);
  233. if (a_.order != b_.order) return false;
  234. return true;
  235. }
  236. std::vector<std::pair<const char*, std::string>> Argsort_props_impl(const OpDef& def_) {
  237. auto&& op_ = def_.cast_final_safe<Argsort>();
  238. static_cast<void>(op_);
  239. std::vector<std::pair<const char*, std::string>> props_;
  240. switch (op_.order){
  241. case Argsort::Order::ASCENDING:
  242. props_.emplace_back("order", "ASCENDING");
  243. break;
  244. case Argsort::Order::DESCENDING:
  245. props_.emplace_back("order", "DESCENDING");
  246. break;
  247. default:
  248. props_.emplace_back("order", "INVALID");
  249. break;
  250. }
  251. return props_;
  252. }
  253. std::string Argsort_make_name_impl(const OpDef& def_) {
  254. auto&& op_ = def_.cast_final_safe<Argsort>();
  255. static_cast<void>(op_);
  256. return "Argsort";
  257. }
  258. } // anonymous namespace
  259. OP_TRAIT_REG(Argsort, Argsort)
  260. .hash(Argsort_hash_impl)
  261. .is_same_st(Argsort_is_same_st_impl)
  262. .props(Argsort_props_impl)
  263. .make_name(Argsort_make_name_impl);
  264. MGB_DYN_TYPE_OBJ_FINAL_IMPL(AssertEqual);
  265. namespace {
  266. size_t AssertEqual_hash_impl(const OpDef& def_) {
  267. auto&& op_ = def_.cast_final_safe<AssertEqual>();
  268. static_cast<void>(op_);
  269. size_t val = mgb::hash(op_.dyn_typeinfo());
  270. val = mgb::hash_pair_combine(val, mgb::hash(op_.maxerr));
  271. val = mgb::hash_pair_combine(val, mgb::hash(op_.verbose));
  272. return val;
  273. }
  274. bool AssertEqual_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  275. auto &&a_ = lhs_.cast_final_safe<AssertEqual>(),
  276. &&b_ = rhs_.cast_final_safe<AssertEqual>();
  277. static_cast<void>(a_);
  278. static_cast<void>(b_);
  279. if (a_.maxerr != b_.maxerr) return false;
  280. if (a_.verbose != b_.verbose) return false;
  281. return true;
  282. }
  283. std::vector<std::pair<const char*, std::string>> AssertEqual_props_impl(const OpDef& def_) {
  284. auto&& op_ = def_.cast_final_safe<AssertEqual>();
  285. static_cast<void>(op_);
  286. std::vector<std::pair<const char*, std::string>> props_;
  287. props_.emplace_back("maxerr", std::to_string(op_.maxerr));
  288. props_.emplace_back("verbose", std::to_string(op_.verbose));
  289. return props_;
  290. }
  291. std::string AssertEqual_make_name_impl(const OpDef& def_) {
  292. auto&& op_ = def_.cast_final_safe<AssertEqual>();
  293. static_cast<void>(op_);
  294. return "AssertEqual";
  295. }
  296. } // anonymous namespace
  297. OP_TRAIT_REG(AssertEqual, AssertEqual)
  298. .hash(AssertEqual_hash_impl)
  299. .is_same_st(AssertEqual_is_same_st_impl)
  300. .props(AssertEqual_props_impl)
  301. .make_name(AssertEqual_make_name_impl);
  302. MGB_DYN_TYPE_OBJ_FINAL_IMPL(AtlasRuntime);
  303. namespace {
  304. size_t AtlasRuntime_hash_impl(const OpDef& def_) {
  305. auto&& op_ = def_.cast_final_safe<AtlasRuntime>();
  306. static_cast<void>(op_);
  307. size_t val = mgb::hash(op_.dyn_typeinfo());
  308. val = mgb::hash_pair_combine(val, mgb::hash(op_.buf));
  309. val = mgb::hash_pair_combine(val, mgb::hash(op_.buf_size));
  310. return val;
  311. }
  312. bool AtlasRuntime_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  313. auto &&a_ = lhs_.cast_final_safe<AtlasRuntime>(),
  314. &&b_ = rhs_.cast_final_safe<AtlasRuntime>();
  315. static_cast<void>(a_);
  316. static_cast<void>(b_);
  317. if (a_.buf != b_.buf) return false;
  318. if (a_.buf_size != b_.buf_size) return false;
  319. return true;
  320. }
  321. std::vector<std::pair<const char*, std::string>> AtlasRuntime_props_impl(const OpDef& def_) {
  322. auto&& op_ = def_.cast_final_safe<AtlasRuntime>();
  323. static_cast<void>(op_);
  324. std::vector<std::pair<const char*, std::string>> props_;
  325. props_.emplace_back("buf", op_.buf);
  326. props_.emplace_back("buf_size", std::to_string(op_.buf_size));
  327. return props_;
  328. }
  329. std::string AtlasRuntime_make_name_impl(const OpDef& def_) {
  330. auto&& op_ = def_.cast_final_safe<AtlasRuntime>();
  331. static_cast<void>(op_);
  332. return "AtlasRuntime";
  333. }
  334. } // anonymous namespace
  335. OP_TRAIT_REG(AtlasRuntime, AtlasRuntime)
  336. .hash(AtlasRuntime_hash_impl)
  337. .is_same_st(AtlasRuntime_is_same_st_impl)
  338. .props(AtlasRuntime_props_impl)
  339. .make_name(AtlasRuntime_make_name_impl);
  340. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Barrier);
  341. namespace {
  342. size_t Barrier_hash_impl(const OpDef& def_) {
  343. auto&& op_ = def_.cast_final_safe<Barrier>();
  344. static_cast<void>(op_);
  345. size_t val = mgb::hash(op_.dyn_typeinfo());
  346. val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
  347. val = mgb::hash_pair_combine(val, mgb::hash(op_.nr_outputs));
  348. return val;
  349. }
  350. bool Barrier_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  351. auto &&a_ = lhs_.cast_final_safe<Barrier>(),
  352. &&b_ = rhs_.cast_final_safe<Barrier>();
  353. static_cast<void>(a_);
  354. static_cast<void>(b_);
  355. if (a_.comp_node != b_.comp_node) return false;
  356. if (a_.nr_outputs != b_.nr_outputs) return false;
  357. return true;
  358. }
  359. std::vector<std::pair<const char*, std::string>> Barrier_props_impl(const OpDef& def_) {
  360. auto&& op_ = def_.cast_final_safe<Barrier>();
  361. static_cast<void>(op_);
  362. std::vector<std::pair<const char*, std::string>> props_;
  363. props_.emplace_back("comp_node", op_.comp_node.to_string());
  364. props_.emplace_back("nr_outputs", std::to_string(op_.nr_outputs));
  365. return props_;
  366. }
  367. std::string Barrier_make_name_impl(const OpDef& def_) {
  368. auto&& op_ = def_.cast_final_safe<Barrier>();
  369. static_cast<void>(op_);
  370. return "Barrier";
  371. }
  372. } // anonymous namespace
  373. OP_TRAIT_REG(Barrier, Barrier)
  374. .hash(Barrier_hash_impl)
  375. .is_same_st(Barrier_is_same_st_impl)
  376. .props(Barrier_props_impl)
  377. .make_name(Barrier_make_name_impl);
  378. MGB_DYN_TYPE_OBJ_FINAL_IMPL(BatchConvBias);
  379. namespace {
  380. size_t BatchConvBias_hash_impl(const OpDef& def_) {
  381. auto&& op_ = def_.cast_final_safe<BatchConvBias>();
  382. static_cast<void>(op_);
  383. size_t val = mgb::hash(op_.dyn_typeinfo());
  384. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.nonlineMode));
  385. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  386. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  387. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  388. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  389. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  390. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
  391. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
  392. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
  393. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  394. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
  395. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
  396. val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
  397. val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
  398. return val;
  399. }
  400. bool BatchConvBias_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  401. auto &&a_ = lhs_.cast_final_safe<BatchConvBias>(),
  402. &&b_ = rhs_.cast_final_safe<BatchConvBias>();
  403. static_cast<void>(a_);
  404. static_cast<void>(b_);
  405. if (a_.nonlineMode != b_.nonlineMode) return false;
  406. if (a_.mode != b_.mode) return false;
  407. if (a_.pad_h != b_.pad_h) return false;
  408. if (a_.pad_w != b_.pad_w) return false;
  409. if (a_.stride_h != b_.stride_h) return false;
  410. if (a_.stride_w != b_.stride_w) return false;
  411. if (a_.dilate_h != b_.dilate_h) return false;
  412. if (a_.dilate_w != b_.dilate_w) return false;
  413. if (a_.sparse != b_.sparse) return false;
  414. if (a_.format != b_.format) return false;
  415. if (a_.compute_mode != b_.compute_mode) return false;
  416. if (a_.strategy != b_.strategy) return false;
  417. if (a_.workspace_limit != b_.workspace_limit) return false;
  418. if (a_.dtype != b_.dtype) return false;
  419. return true;
  420. }
  421. std::vector<std::pair<const char*, std::string>> BatchConvBias_props_impl(const OpDef& def_) {
  422. auto&& op_ = def_.cast_final_safe<BatchConvBias>();
  423. static_cast<void>(op_);
  424. std::vector<std::pair<const char*, std::string>> props_;
  425. switch (op_.nonlineMode){
  426. case BatchConvBias::NonlineMode::IDENTITY:
  427. props_.emplace_back("nonlineMode", "IDENTITY");
  428. break;
  429. case BatchConvBias::NonlineMode::RELU:
  430. props_.emplace_back("nonlineMode", "RELU");
  431. break;
  432. case BatchConvBias::NonlineMode::SIGMOID:
  433. props_.emplace_back("nonlineMode", "SIGMOID");
  434. break;
  435. case BatchConvBias::NonlineMode::H_SWISH:
  436. props_.emplace_back("nonlineMode", "H_SWISH");
  437. break;
  438. default:
  439. props_.emplace_back("nonlineMode", "INVALID");
  440. break;
  441. }
  442. switch (op_.mode){
  443. case BatchConvBias::Mode::CROSS_CORRELATION:
  444. props_.emplace_back("mode", "CROSS_CORRELATION");
  445. break;
  446. case BatchConvBias::Mode::CONVOLUTION:
  447. props_.emplace_back("mode", "CONVOLUTION");
  448. break;
  449. default:
  450. props_.emplace_back("mode", "INVALID");
  451. break;
  452. }
  453. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  454. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  455. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  456. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  457. props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
  458. props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
  459. switch (op_.sparse){
  460. case BatchConvBias::Sparse::DENSE:
  461. props_.emplace_back("sparse", "DENSE");
  462. break;
  463. case BatchConvBias::Sparse::GROUP:
  464. props_.emplace_back("sparse", "GROUP");
  465. break;
  466. default:
  467. props_.emplace_back("sparse", "INVALID");
  468. break;
  469. }
  470. switch (op_.format){
  471. case BatchConvBias::Format::NCHW:
  472. props_.emplace_back("format", "NCHW");
  473. break;
  474. case BatchConvBias::Format::NHWC:
  475. props_.emplace_back("format", "NHWC");
  476. break;
  477. case BatchConvBias::Format::NHWCD4:
  478. props_.emplace_back("format", "NHWCD4");
  479. break;
  480. case BatchConvBias::Format::NCHW4:
  481. props_.emplace_back("format", "NCHW4");
  482. break;
  483. case BatchConvBias::Format::NCHW8:
  484. props_.emplace_back("format", "NCHW8");
  485. break;
  486. case BatchConvBias::Format::NCHW32:
  487. props_.emplace_back("format", "NCHW32");
  488. break;
  489. case BatchConvBias::Format::NCHW88:
  490. props_.emplace_back("format", "NCHW88");
  491. break;
  492. case BatchConvBias::Format::NCHW44:
  493. props_.emplace_back("format", "NCHW44");
  494. break;
  495. case BatchConvBias::Format::NCHW44_DOT:
  496. props_.emplace_back("format", "NCHW44_DOT");
  497. break;
  498. case BatchConvBias::Format::NCHW4_NCHW32:
  499. props_.emplace_back("format", "NCHW4_NCHW32");
  500. break;
  501. case BatchConvBias::Format::NCHW32_NCHW4:
  502. props_.emplace_back("format", "NCHW32_NCHW4");
  503. break;
  504. case BatchConvBias::Format::NCHW4_NCHW:
  505. props_.emplace_back("format", "NCHW4_NCHW");
  506. break;
  507. case BatchConvBias::Format::NHWC_NCHW:
  508. props_.emplace_back("format", "NHWC_NCHW");
  509. break;
  510. case BatchConvBias::Format::NHWC_NCHW4_IC_SMALL:
  511. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  512. break;
  513. case BatchConvBias::Format::NCHW_NCHW4_IC_SMALL:
  514. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  515. break;
  516. case BatchConvBias::Format::CHWN4:
  517. props_.emplace_back("format", "CHWN4");
  518. break;
  519. case BatchConvBias::Format::NCHW64:
  520. props_.emplace_back("format", "NCHW64");
  521. break;
  522. case BatchConvBias::Format::NCHW4_NHWC:
  523. props_.emplace_back("format", "NCHW4_NHWC");
  524. break;
  525. default:
  526. props_.emplace_back("format", "INVALID");
  527. break;
  528. }
  529. switch (op_.compute_mode){
  530. case BatchConvBias::ComputeMode::DEFAULT:
  531. props_.emplace_back("compute_mode", "DEFAULT");
  532. break;
  533. case BatchConvBias::ComputeMode::FLOAT32:
  534. props_.emplace_back("compute_mode", "FLOAT32");
  535. break;
  536. default:
  537. props_.emplace_back("compute_mode", "INVALID");
  538. break;
  539. }
  540. switch (op_.strategy){
  541. case BatchConvBias::Strategy::HEURISTIC:
  542. props_.emplace_back("strategy", "HEURISTIC");
  543. break;
  544. case BatchConvBias::Strategy::PROFILE:
  545. props_.emplace_back("strategy", "PROFILE");
  546. break;
  547. case BatchConvBias::Strategy::REPRODUCIBLE:
  548. props_.emplace_back("strategy", "REPRODUCIBLE");
  549. break;
  550. case BatchConvBias::Strategy::OPTIMIZED:
  551. props_.emplace_back("strategy", "OPTIMIZED");
  552. break;
  553. default:
  554. props_.emplace_back("strategy", "INVALID");
  555. break;
  556. }
  557. props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
  558. props_.emplace_back("dtype", op_.dtype.name());
  559. return props_;
  560. }
  561. std::string BatchConvBias_make_name_impl(const OpDef& def_) {
  562. auto&& op_ = def_.cast_final_safe<BatchConvBias>();
  563. static_cast<void>(op_);
  564. return "BatchConvBias";
  565. }
  566. } // anonymous namespace
  567. OP_TRAIT_REG(BatchConvBias, BatchConvBias)
  568. .hash(BatchConvBias_hash_impl)
  569. .is_same_st(BatchConvBias_is_same_st_impl)
  570. .props(BatchConvBias_props_impl)
  571. .make_name(BatchConvBias_make_name_impl);
  572. MGB_DYN_TYPE_OBJ_FINAL_IMPL(BatchNorm);
  573. namespace {
  574. size_t BatchNorm_hash_impl(const OpDef& def_) {
  575. auto&& op_ = def_.cast_final_safe<BatchNorm>();
  576. static_cast<void>(op_);
  577. size_t val = mgb::hash(op_.dyn_typeinfo());
  578. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.param_dim));
  579. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.fwd_mode));
  580. val = mgb::hash_pair_combine(val, mgb::hash(op_.epsilon));
  581. val = mgb::hash_pair_combine(val, mgb::hash(op_.avg_factor));
  582. val = mgb::hash_pair_combine(val, mgb::hash(op_.scale));
  583. val = mgb::hash_pair_combine(val, mgb::hash(op_.bias));
  584. return val;
  585. }
  586. bool BatchNorm_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  587. auto &&a_ = lhs_.cast_final_safe<BatchNorm>(),
  588. &&b_ = rhs_.cast_final_safe<BatchNorm>();
  589. static_cast<void>(a_);
  590. static_cast<void>(b_);
  591. if (a_.param_dim != b_.param_dim) return false;
  592. if (a_.fwd_mode != b_.fwd_mode) return false;
  593. if (a_.epsilon != b_.epsilon) return false;
  594. if (a_.avg_factor != b_.avg_factor) return false;
  595. if (a_.scale != b_.scale) return false;
  596. if (a_.bias != b_.bias) return false;
  597. return true;
  598. }
  599. std::vector<std::pair<const char*, std::string>> BatchNorm_props_impl(const OpDef& def_) {
  600. auto&& op_ = def_.cast_final_safe<BatchNorm>();
  601. static_cast<void>(op_);
  602. std::vector<std::pair<const char*, std::string>> props_;
  603. switch (op_.param_dim){
  604. case BatchNorm::ParamDim::DIM_11HW:
  605. props_.emplace_back("param_dim", "DIM_11HW");
  606. break;
  607. case BatchNorm::ParamDim::DIM_1CHW:
  608. props_.emplace_back("param_dim", "DIM_1CHW");
  609. break;
  610. case BatchNorm::ParamDim::DIM_1C11:
  611. props_.emplace_back("param_dim", "DIM_1C11");
  612. break;
  613. case BatchNorm::ParamDim::DIM_111C:
  614. props_.emplace_back("param_dim", "DIM_111C");
  615. break;
  616. default:
  617. props_.emplace_back("param_dim", "INVALID");
  618. break;
  619. }
  620. switch (op_.fwd_mode){
  621. case BatchNorm::FwdMode::TRAINING:
  622. props_.emplace_back("fwd_mode", "TRAINING");
  623. break;
  624. case BatchNorm::FwdMode::INFERENCE:
  625. props_.emplace_back("fwd_mode", "INFERENCE");
  626. break;
  627. default:
  628. props_.emplace_back("fwd_mode", "INVALID");
  629. break;
  630. }
  631. props_.emplace_back("epsilon", std::to_string(op_.epsilon));
  632. props_.emplace_back("avg_factor", std::to_string(op_.avg_factor));
  633. props_.emplace_back("scale", std::to_string(op_.scale));
  634. props_.emplace_back("bias", std::to_string(op_.bias));
  635. return props_;
  636. }
  637. std::string BatchNorm_make_name_impl(const OpDef& def_) {
  638. auto&& op_ = def_.cast_final_safe<BatchNorm>();
  639. static_cast<void>(op_);
  640. return "BatchNorm";
  641. }
  642. } // anonymous namespace
  643. OP_TRAIT_REG(BatchNorm, BatchNorm)
  644. .hash(BatchNorm_hash_impl)
  645. .is_same_st(BatchNorm_is_same_st_impl)
  646. .props(BatchNorm_props_impl)
  647. .make_name(BatchNorm_make_name_impl);
  648. MGB_DYN_TYPE_OBJ_FINAL_IMPL(BatchNormBackward);
  649. namespace {
  650. size_t BatchNormBackward_hash_impl(const OpDef& def_) {
  651. auto&& op_ = def_.cast_final_safe<BatchNormBackward>();
  652. static_cast<void>(op_);
  653. size_t val = mgb::hash(op_.dyn_typeinfo());
  654. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.param_dim));
  655. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.fwd_mode));
  656. val = mgb::hash_pair_combine(val, mgb::hash(op_.epsilon));
  657. val = mgb::hash_pair_combine(val, mgb::hash(op_.avg_factor));
  658. val = mgb::hash_pair_combine(val, mgb::hash(op_.scale));
  659. val = mgb::hash_pair_combine(val, mgb::hash(op_.bias));
  660. return val;
  661. }
  662. bool BatchNormBackward_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  663. auto &&a_ = lhs_.cast_final_safe<BatchNormBackward>(),
  664. &&b_ = rhs_.cast_final_safe<BatchNormBackward>();
  665. static_cast<void>(a_);
  666. static_cast<void>(b_);
  667. if (a_.param_dim != b_.param_dim) return false;
  668. if (a_.fwd_mode != b_.fwd_mode) return false;
  669. if (a_.epsilon != b_.epsilon) return false;
  670. if (a_.avg_factor != b_.avg_factor) return false;
  671. if (a_.scale != b_.scale) return false;
  672. if (a_.bias != b_.bias) return false;
  673. return true;
  674. }
  675. std::vector<std::pair<const char*, std::string>> BatchNormBackward_props_impl(const OpDef& def_) {
  676. auto&& op_ = def_.cast_final_safe<BatchNormBackward>();
  677. static_cast<void>(op_);
  678. std::vector<std::pair<const char*, std::string>> props_;
  679. switch (op_.param_dim){
  680. case BatchNormBackward::ParamDim::DIM_11HW:
  681. props_.emplace_back("param_dim", "DIM_11HW");
  682. break;
  683. case BatchNormBackward::ParamDim::DIM_1CHW:
  684. props_.emplace_back("param_dim", "DIM_1CHW");
  685. break;
  686. case BatchNormBackward::ParamDim::DIM_1C11:
  687. props_.emplace_back("param_dim", "DIM_1C11");
  688. break;
  689. case BatchNormBackward::ParamDim::DIM_111C:
  690. props_.emplace_back("param_dim", "DIM_111C");
  691. break;
  692. default:
  693. props_.emplace_back("param_dim", "INVALID");
  694. break;
  695. }
  696. switch (op_.fwd_mode){
  697. case BatchNormBackward::FwdMode::TRAINING:
  698. props_.emplace_back("fwd_mode", "TRAINING");
  699. break;
  700. case BatchNormBackward::FwdMode::INFERENCE:
  701. props_.emplace_back("fwd_mode", "INFERENCE");
  702. break;
  703. default:
  704. props_.emplace_back("fwd_mode", "INVALID");
  705. break;
  706. }
  707. props_.emplace_back("epsilon", std::to_string(op_.epsilon));
  708. props_.emplace_back("avg_factor", std::to_string(op_.avg_factor));
  709. props_.emplace_back("scale", std::to_string(op_.scale));
  710. props_.emplace_back("bias", std::to_string(op_.bias));
  711. return props_;
  712. }
  713. std::string BatchNormBackward_make_name_impl(const OpDef& def_) {
  714. auto&& op_ = def_.cast_final_safe<BatchNormBackward>();
  715. static_cast<void>(op_);
  716. return "BatchNormBackward";
  717. }
  718. } // anonymous namespace
  719. OP_TRAIT_REG(BatchNormBackward, BatchNormBackward)
  720. .hash(BatchNormBackward_hash_impl)
  721. .is_same_st(BatchNormBackward_is_same_st_impl)
  722. .props(BatchNormBackward_props_impl)
  723. .make_name(BatchNormBackward_make_name_impl);
  724. MGB_DYN_TYPE_OBJ_FINAL_IMPL(BatchedIncrMeshIndexing);
  725. namespace {
  726. size_t BatchedIncrMeshIndexing_hash_impl(const OpDef& def_) {
  727. auto&& op_ = def_.cast_final_safe<BatchedIncrMeshIndexing>();
  728. static_cast<void>(op_);
  729. size_t val = mgb::hash(op_.dyn_typeinfo());
  730. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  731. return val;
  732. }
  733. bool BatchedIncrMeshIndexing_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  734. auto &&a_ = lhs_.cast_final_safe<BatchedIncrMeshIndexing>(),
  735. &&b_ = rhs_.cast_final_safe<BatchedIncrMeshIndexing>();
  736. static_cast<void>(a_);
  737. static_cast<void>(b_);
  738. if (a_.items != b_.items) return false;
  739. return true;
  740. }
  741. std::vector<std::pair<const char*, std::string>> BatchedIncrMeshIndexing_props_impl(const OpDef& def_) {
  742. auto&& op_ = def_.cast_final_safe<BatchedIncrMeshIndexing>();
  743. static_cast<void>(op_);
  744. std::vector<std::pair<const char*, std::string>> props_;
  745. props_.emplace_back("items", "{std::vector}");
  746. return props_;
  747. }
  748. std::string BatchedIncrMeshIndexing_make_name_impl(const OpDef& def_) {
  749. auto&& op_ = def_.cast_final_safe<BatchedIncrMeshIndexing>();
  750. static_cast<void>(op_);
  751. return "BatchedIncrMeshIndexing";
  752. }
  753. } // anonymous namespace
  754. OP_TRAIT_REG(BatchedIncrMeshIndexing, BatchedIncrMeshIndexing)
  755. .hash(BatchedIncrMeshIndexing_hash_impl)
  756. .is_same_st(BatchedIncrMeshIndexing_is_same_st_impl)
  757. .props(BatchedIncrMeshIndexing_props_impl)
  758. .make_name(BatchedIncrMeshIndexing_make_name_impl);
  759. MGB_DYN_TYPE_OBJ_FINAL_IMPL(BatchedMatrixMul);
  760. namespace {
  761. size_t BatchedMatrixMul_hash_impl(const OpDef& def_) {
  762. auto&& op_ = def_.cast_final_safe<BatchedMatrixMul>();
  763. static_cast<void>(op_);
  764. size_t val = mgb::hash(op_.dyn_typeinfo());
  765. val = mgb::hash_pair_combine(val, mgb::hash(op_.transposeA));
  766. val = mgb::hash_pair_combine(val, mgb::hash(op_.transposeB));
  767. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
  768. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  769. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
  770. val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
  771. val = mgb::hash_pair_combine(val, mgb::hash(op_.dimA));
  772. val = mgb::hash_pair_combine(val, mgb::hash(op_.dimB));
  773. return val;
  774. }
  775. bool BatchedMatrixMul_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  776. auto &&a_ = lhs_.cast_final_safe<BatchedMatrixMul>(),
  777. &&b_ = rhs_.cast_final_safe<BatchedMatrixMul>();
  778. static_cast<void>(a_);
  779. static_cast<void>(b_);
  780. if (a_.transposeA != b_.transposeA) return false;
  781. if (a_.transposeB != b_.transposeB) return false;
  782. if (a_.compute_mode != b_.compute_mode) return false;
  783. if (a_.format != b_.format) return false;
  784. if (a_.strategy != b_.strategy) return false;
  785. if (a_.workspace_limit != b_.workspace_limit) return false;
  786. if (a_.dimA != b_.dimA) return false;
  787. if (a_.dimB != b_.dimB) return false;
  788. return true;
  789. }
  790. std::vector<std::pair<const char*, std::string>> BatchedMatrixMul_props_impl(const OpDef& def_) {
  791. auto&& op_ = def_.cast_final_safe<BatchedMatrixMul>();
  792. static_cast<void>(op_);
  793. std::vector<std::pair<const char*, std::string>> props_;
  794. props_.emplace_back("transposeA", std::to_string(op_.transposeA));
  795. props_.emplace_back("transposeB", std::to_string(op_.transposeB));
  796. switch (op_.compute_mode){
  797. case BatchedMatrixMul::ComputeMode::DEFAULT:
  798. props_.emplace_back("compute_mode", "DEFAULT");
  799. break;
  800. case BatchedMatrixMul::ComputeMode::FLOAT32:
  801. props_.emplace_back("compute_mode", "FLOAT32");
  802. break;
  803. default:
  804. props_.emplace_back("compute_mode", "INVALID");
  805. break;
  806. }
  807. switch (op_.format){
  808. case BatchedMatrixMul::Format::DEFAULT:
  809. props_.emplace_back("format", "DEFAULT");
  810. break;
  811. case BatchedMatrixMul::Format::MK4:
  812. props_.emplace_back("format", "MK4");
  813. break;
  814. case BatchedMatrixMul::Format::MK8:
  815. props_.emplace_back("format", "MK8");
  816. break;
  817. case BatchedMatrixMul::Format::MK4_DOT:
  818. props_.emplace_back("format", "MK4_DOT");
  819. break;
  820. case BatchedMatrixMul::Format::N32K4_DOT:
  821. props_.emplace_back("format", "N32K4_DOT");
  822. break;
  823. default:
  824. props_.emplace_back("format", "INVALID");
  825. break;
  826. }
  827. switch (op_.strategy){
  828. case BatchedMatrixMul::Strategy::HEURISTIC:
  829. props_.emplace_back("strategy", "HEURISTIC");
  830. break;
  831. case BatchedMatrixMul::Strategy::PROFILE:
  832. props_.emplace_back("strategy", "PROFILE");
  833. break;
  834. case BatchedMatrixMul::Strategy::REPRODUCIBLE:
  835. props_.emplace_back("strategy", "REPRODUCIBLE");
  836. break;
  837. case BatchedMatrixMul::Strategy::OPTIMIZED:
  838. props_.emplace_back("strategy", "OPTIMIZED");
  839. break;
  840. default:
  841. props_.emplace_back("strategy", "INVALID");
  842. break;
  843. }
  844. props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
  845. props_.emplace_back("dimA", std::to_string(op_.dimA));
  846. props_.emplace_back("dimB", std::to_string(op_.dimB));
  847. return props_;
  848. }
  849. std::string BatchedMatrixMul_make_name_impl(const OpDef& def_) {
  850. auto&& op_ = def_.cast_final_safe<BatchedMatrixMul>();
  851. static_cast<void>(op_);
  852. return "BatchedMatrixMul";
  853. }
  854. } // anonymous namespace
  855. OP_TRAIT_REG(BatchedMatrixMul, BatchedMatrixMul)
  856. .hash(BatchedMatrixMul_hash_impl)
  857. .is_same_st(BatchedMatrixMul_is_same_st_impl)
  858. .props(BatchedMatrixMul_props_impl)
  859. .make_name(BatchedMatrixMul_make_name_impl);
  860. MGB_DYN_TYPE_OBJ_FINAL_IMPL(BatchedMeshIndexing);
  861. namespace {
  862. size_t BatchedMeshIndexing_hash_impl(const OpDef& def_) {
  863. auto&& op_ = def_.cast_final_safe<BatchedMeshIndexing>();
  864. static_cast<void>(op_);
  865. size_t val = mgb::hash(op_.dyn_typeinfo());
  866. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  867. return val;
  868. }
  869. bool BatchedMeshIndexing_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  870. auto &&a_ = lhs_.cast_final_safe<BatchedMeshIndexing>(),
  871. &&b_ = rhs_.cast_final_safe<BatchedMeshIndexing>();
  872. static_cast<void>(a_);
  873. static_cast<void>(b_);
  874. if (a_.items != b_.items) return false;
  875. return true;
  876. }
  877. std::vector<std::pair<const char*, std::string>> BatchedMeshIndexing_props_impl(const OpDef& def_) {
  878. auto&& op_ = def_.cast_final_safe<BatchedMeshIndexing>();
  879. static_cast<void>(op_);
  880. std::vector<std::pair<const char*, std::string>> props_;
  881. props_.emplace_back("items", "{std::vector}");
  882. return props_;
  883. }
  884. std::string BatchedMeshIndexing_make_name_impl(const OpDef& def_) {
  885. auto&& op_ = def_.cast_final_safe<BatchedMeshIndexing>();
  886. static_cast<void>(op_);
  887. return "BatchedMeshIndexing";
  888. }
  889. } // anonymous namespace
  890. OP_TRAIT_REG(BatchedMeshIndexing, BatchedMeshIndexing)
  891. .hash(BatchedMeshIndexing_hash_impl)
  892. .is_same_st(BatchedMeshIndexing_is_same_st_impl)
  893. .props(BatchedMeshIndexing_props_impl)
  894. .make_name(BatchedMeshIndexing_make_name_impl);
  895. MGB_DYN_TYPE_OBJ_FINAL_IMPL(BatchedSetMeshIndexing);
  896. namespace {
  897. size_t BatchedSetMeshIndexing_hash_impl(const OpDef& def_) {
  898. auto&& op_ = def_.cast_final_safe<BatchedSetMeshIndexing>();
  899. static_cast<void>(op_);
  900. size_t val = mgb::hash(op_.dyn_typeinfo());
  901. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  902. return val;
  903. }
  904. bool BatchedSetMeshIndexing_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  905. auto &&a_ = lhs_.cast_final_safe<BatchedSetMeshIndexing>(),
  906. &&b_ = rhs_.cast_final_safe<BatchedSetMeshIndexing>();
  907. static_cast<void>(a_);
  908. static_cast<void>(b_);
  909. if (a_.items != b_.items) return false;
  910. return true;
  911. }
  912. std::vector<std::pair<const char*, std::string>> BatchedSetMeshIndexing_props_impl(const OpDef& def_) {
  913. auto&& op_ = def_.cast_final_safe<BatchedSetMeshIndexing>();
  914. static_cast<void>(op_);
  915. std::vector<std::pair<const char*, std::string>> props_;
  916. props_.emplace_back("items", "{std::vector}");
  917. return props_;
  918. }
  919. std::string BatchedSetMeshIndexing_make_name_impl(const OpDef& def_) {
  920. auto&& op_ = def_.cast_final_safe<BatchedSetMeshIndexing>();
  921. static_cast<void>(op_);
  922. return "BatchedSetMeshIndexing";
  923. }
  924. } // anonymous namespace
  925. OP_TRAIT_REG(BatchedSetMeshIndexing, BatchedSetMeshIndexing)
  926. .hash(BatchedSetMeshIndexing_hash_impl)
  927. .is_same_st(BatchedSetMeshIndexing_is_same_st_impl)
  928. .props(BatchedSetMeshIndexing_props_impl)
  929. .make_name(BatchedSetMeshIndexing_make_name_impl);
  930. MGB_DYN_TYPE_OBJ_FINAL_IMPL(BetaRNG);
  931. namespace {
  932. size_t BetaRNG_hash_impl(const OpDef& def_) {
  933. auto&& op_ = def_.cast_final_safe<BetaRNG>();
  934. static_cast<void>(op_);
  935. return mgb::hash_pair_combine(
  936. mgb::hash(op_.dyn_typeinfo()),
  937. mgb::hash(op_.handle)
  938. );
  939. }
  940. bool BetaRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  941. auto &&a_ = lhs_.cast_final_safe<BetaRNG>(),
  942. &&b_ = rhs_.cast_final_safe<BetaRNG>();
  943. static_cast<void>(a_);
  944. static_cast<void>(b_);
  945. return a_.handle == b_.handle;}
  946. std::vector<std::pair<const char*, std::string>> BetaRNG_props_impl(const OpDef& def_) {
  947. auto&& op_ = def_.cast_final_safe<BetaRNG>();
  948. static_cast<void>(op_);
  949. std::vector<std::pair<const char*, std::string>> props_;
  950. props_.emplace_back("seed", std::to_string(op_.seed));
  951. props_.emplace_back("handle", std::to_string(op_.handle));
  952. return props_;
  953. }
  954. std::string BetaRNG_make_name_impl(const OpDef& def_) {
  955. auto&& op_ = def_.cast_final_safe<BetaRNG>();
  956. static_cast<void>(op_);
  957. return "BetaRNG";
  958. }
  959. } // anonymous namespace
  960. OP_TRAIT_REG(BetaRNG, BetaRNG)
  961. .hash(BetaRNG_hash_impl)
  962. .is_same_st(BetaRNG_is_same_st_impl)
  963. .props(BetaRNG_props_impl)
  964. .make_name(BetaRNG_make_name_impl);
  965. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Borrow);
  966. namespace {
  967. size_t Borrow_hash_impl(const OpDef& def_) {
  968. auto&& op_ = def_.cast_final_safe<Borrow>();
  969. static_cast<void>(op_);
  970. size_t val = mgb::hash(op_.dyn_typeinfo());
  971. val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
  972. return val;
  973. }
  974. bool Borrow_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  975. auto &&a_ = lhs_.cast_final_safe<Borrow>(),
  976. &&b_ = rhs_.cast_final_safe<Borrow>();
  977. static_cast<void>(a_);
  978. static_cast<void>(b_);
  979. if (a_.comp_node != b_.comp_node) return false;
  980. return true;
  981. }
  982. std::vector<std::pair<const char*, std::string>> Borrow_props_impl(const OpDef& def_) {
  983. auto&& op_ = def_.cast_final_safe<Borrow>();
  984. static_cast<void>(op_);
  985. std::vector<std::pair<const char*, std::string>> props_;
  986. props_.emplace_back("comp_node", op_.comp_node.to_string());
  987. return props_;
  988. }
  989. std::string Borrow_make_name_impl(const OpDef& def_) {
  990. auto&& op_ = def_.cast_final_safe<Borrow>();
  991. static_cast<void>(op_);
  992. return "Borrow";
  993. }
  994. } // anonymous namespace
  995. OP_TRAIT_REG(Borrow, Borrow)
  996. .hash(Borrow_hash_impl)
  997. .is_same_st(Borrow_is_same_st_impl)
  998. .props(Borrow_props_impl)
  999. .make_name(Borrow_make_name_impl);
  1000. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Broadcast);
  1001. namespace {
  1002. size_t Broadcast_hash_impl(const OpDef& def_) {
  1003. auto&& op_ = def_.cast_final_safe<Broadcast>();
  1004. static_cast<void>(op_);
  1005. size_t val = mgb::hash(op_.dyn_typeinfo());
  1006. val = mgb::hash_pair_combine(val, mgb::hash(op_.shape));
  1007. return val;
  1008. }
  1009. bool Broadcast_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  1010. auto &&a_ = lhs_.cast_final_safe<Broadcast>(),
  1011. &&b_ = rhs_.cast_final_safe<Broadcast>();
  1012. static_cast<void>(a_);
  1013. static_cast<void>(b_);
  1014. if (a_.shape != b_.shape) return false;
  1015. return true;
  1016. }
  1017. std::vector<std::pair<const char*, std::string>> Broadcast_props_impl(const OpDef& def_) {
  1018. auto&& op_ = def_.cast_final_safe<Broadcast>();
  1019. static_cast<void>(op_);
  1020. std::vector<std::pair<const char*, std::string>> props_;
  1021. props_.emplace_back("shape", "{std::vector}");
  1022. return props_;
  1023. }
  1024. std::string Broadcast_make_name_impl(const OpDef& def_) {
  1025. auto&& op_ = def_.cast_final_safe<Broadcast>();
  1026. static_cast<void>(op_);
  1027. return "Broadcast";
  1028. }
  1029. } // anonymous namespace
  1030. OP_TRAIT_REG(Broadcast, Broadcast)
  1031. .hash(Broadcast_hash_impl)
  1032. .is_same_st(Broadcast_is_same_st_impl)
  1033. .props(Broadcast_props_impl)
  1034. .make_name(Broadcast_make_name_impl);
  1035. MGB_DYN_TYPE_OBJ_FINAL_IMPL(CambriconRuntime);
  1036. namespace {
  1037. size_t CambriconRuntime_hash_impl(const OpDef& def_) {
  1038. auto&& op_ = def_.cast_final_safe<CambriconRuntime>();
  1039. static_cast<void>(op_);
  1040. size_t val = mgb::hash(op_.dyn_typeinfo());
  1041. val = mgb::hash_pair_combine(val, mgb::hash(op_.buf));
  1042. val = mgb::hash_pair_combine(val, mgb::hash(op_.buf_size));
  1043. val = mgb::hash_pair_combine(val, mgb::hash(op_.symbol));
  1044. val = mgb::hash_pair_combine(val, mgb::hash(op_.tensor_dim_mutable));
  1045. return val;
  1046. }
  1047. bool CambriconRuntime_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  1048. auto &&a_ = lhs_.cast_final_safe<CambriconRuntime>(),
  1049. &&b_ = rhs_.cast_final_safe<CambriconRuntime>();
  1050. static_cast<void>(a_);
  1051. static_cast<void>(b_);
  1052. if (a_.buf != b_.buf) return false;
  1053. if (a_.buf_size != b_.buf_size) return false;
  1054. if (a_.symbol != b_.symbol) return false;
  1055. if (a_.tensor_dim_mutable != b_.tensor_dim_mutable) return false;
  1056. return true;
  1057. }
  1058. std::vector<std::pair<const char*, std::string>> CambriconRuntime_props_impl(const OpDef& def_) {
  1059. auto&& op_ = def_.cast_final_safe<CambriconRuntime>();
  1060. static_cast<void>(op_);
  1061. std::vector<std::pair<const char*, std::string>> props_;
  1062. props_.emplace_back("buf", op_.buf);
  1063. props_.emplace_back("buf_size", std::to_string(op_.buf_size));
  1064. props_.emplace_back("symbol", op_.symbol);
  1065. props_.emplace_back("tensor_dim_mutable", std::to_string(op_.tensor_dim_mutable));
  1066. return props_;
  1067. }
  1068. std::string CambriconRuntime_make_name_impl(const OpDef& def_) {
  1069. auto&& op_ = def_.cast_final_safe<CambriconRuntime>();
  1070. static_cast<void>(op_);
  1071. return "CambriconRuntime";
  1072. }
  1073. } // anonymous namespace
  1074. OP_TRAIT_REG(CambriconRuntime, CambriconRuntime)
  1075. .hash(CambriconRuntime_hash_impl)
  1076. .is_same_st(CambriconRuntime_is_same_st_impl)
  1077. .props(CambriconRuntime_props_impl)
  1078. .make_name(CambriconRuntime_make_name_impl);
  1079. MGB_DYN_TYPE_OBJ_FINAL_IMPL(CheckNonFinite);
  1080. namespace {
  1081. size_t CheckNonFinite_hash_impl(const OpDef& def_) {
  1082. auto&& op_ = def_.cast_final_safe<CheckNonFinite>();
  1083. static_cast<void>(op_);
  1084. size_t val = mgb::hash(op_.dyn_typeinfo());
  1085. val = mgb::hash_pair_combine(val, mgb::hash(op_.scale));
  1086. return val;
  1087. }
  1088. bool CheckNonFinite_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  1089. auto &&a_ = lhs_.cast_final_safe<CheckNonFinite>(),
  1090. &&b_ = rhs_.cast_final_safe<CheckNonFinite>();
  1091. static_cast<void>(a_);
  1092. static_cast<void>(b_);
  1093. if (a_.scale != b_.scale) return false;
  1094. return true;
  1095. }
  1096. std::vector<std::pair<const char*, std::string>> CheckNonFinite_props_impl(const OpDef& def_) {
  1097. auto&& op_ = def_.cast_final_safe<CheckNonFinite>();
  1098. static_cast<void>(op_);
  1099. std::vector<std::pair<const char*, std::string>> props_;
  1100. props_.emplace_back("scale", std::to_string(op_.scale));
  1101. return props_;
  1102. }
  1103. std::string CheckNonFinite_make_name_impl(const OpDef& def_) {
  1104. auto&& op_ = def_.cast_final_safe<CheckNonFinite>();
  1105. static_cast<void>(op_);
  1106. return "CheckNonFinite";
  1107. }
  1108. } // anonymous namespace
  1109. OP_TRAIT_REG(CheckNonFinite, CheckNonFinite)
  1110. .hash(CheckNonFinite_hash_impl)
  1111. .is_same_st(CheckNonFinite_is_same_st_impl)
  1112. .props(CheckNonFinite_props_impl)
  1113. .make_name(CheckNonFinite_make_name_impl);
  1114. MGB_DYN_TYPE_OBJ_FINAL_IMPL(CollectiveComm);
  1115. namespace {
  1116. size_t CollectiveComm_hash_impl(const OpDef& def_) {
  1117. auto&& op_ = def_.cast_final_safe<CollectiveComm>();
  1118. static_cast<void>(op_);
  1119. size_t val = mgb::hash(op_.dyn_typeinfo());
  1120. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  1121. val = mgb::hash_pair_combine(val, mgb::hash(op_.key));
  1122. val = mgb::hash_pair_combine(val, mgb::hash(op_.nr_devices));
  1123. val = mgb::hash_pair_combine(val, mgb::hash(op_.rank));
  1124. val = mgb::hash_pair_combine(val, mgb::hash(op_.is_root));
  1125. val = mgb::hash_pair_combine(val, mgb::hash(op_.local_grad));
  1126. val = mgb::hash_pair_combine(val, mgb::hash(op_.addr));
  1127. val = mgb::hash_pair_combine(val, mgb::hash(op_.port));
  1128. val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
  1129. val = mgb::hash_pair_combine(val, mgb::hash(op_.backend));
  1130. val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
  1131. return val;
  1132. }
  1133. bool CollectiveComm_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  1134. auto &&a_ = lhs_.cast_final_safe<CollectiveComm>(),
  1135. &&b_ = rhs_.cast_final_safe<CollectiveComm>();
  1136. static_cast<void>(a_);
  1137. static_cast<void>(b_);
  1138. if (a_.mode != b_.mode) return false;
  1139. if (a_.key != b_.key) return false;
  1140. if (a_.nr_devices != b_.nr_devices) return false;
  1141. if (a_.rank != b_.rank) return false;
  1142. if (a_.is_root != b_.is_root) return false;
  1143. if (a_.local_grad != b_.local_grad) return false;
  1144. if (a_.addr != b_.addr) return false;
  1145. if (a_.port != b_.port) return false;
  1146. if (a_.dtype != b_.dtype) return false;
  1147. if (a_.backend != b_.backend) return false;
  1148. if (a_.comp_node != b_.comp_node) return false;
  1149. return true;
  1150. }
  1151. std::vector<std::pair<const char*, std::string>> CollectiveComm_props_impl(const OpDef& def_) {
  1152. auto&& op_ = def_.cast_final_safe<CollectiveComm>();
  1153. static_cast<void>(op_);
  1154. std::vector<std::pair<const char*, std::string>> props_;
  1155. switch (op_.mode){
  1156. case CollectiveComm::Mode::REDUCE_SUM:
  1157. props_.emplace_back("mode", "REDUCE_SUM");
  1158. break;
  1159. case CollectiveComm::Mode::BROADCAST:
  1160. props_.emplace_back("mode", "BROADCAST");
  1161. break;
  1162. case CollectiveComm::Mode::ALL_GATHER:
  1163. props_.emplace_back("mode", "ALL_GATHER");
  1164. break;
  1165. case CollectiveComm::Mode::REDUCE_SCATTER_SUM:
  1166. props_.emplace_back("mode", "REDUCE_SCATTER_SUM");
  1167. break;
  1168. case CollectiveComm::Mode::ALL_REDUCE_SUM:
  1169. props_.emplace_back("mode", "ALL_REDUCE_SUM");
  1170. break;
  1171. case CollectiveComm::Mode::ALL_REDUCE_MAX:
  1172. props_.emplace_back("mode", "ALL_REDUCE_MAX");
  1173. break;
  1174. case CollectiveComm::Mode::ALL_REDUCE_MIN:
  1175. props_.emplace_back("mode", "ALL_REDUCE_MIN");
  1176. break;
  1177. case CollectiveComm::Mode::ALL_REDUCE_PROD:
  1178. props_.emplace_back("mode", "ALL_REDUCE_PROD");
  1179. break;
  1180. case CollectiveComm::Mode::GATHER:
  1181. props_.emplace_back("mode", "GATHER");
  1182. break;
  1183. case CollectiveComm::Mode::SCATTER:
  1184. props_.emplace_back("mode", "SCATTER");
  1185. break;
  1186. case CollectiveComm::Mode::ALL_TO_ALL:
  1187. props_.emplace_back("mode", "ALL_TO_ALL");
  1188. break;
  1189. default:
  1190. props_.emplace_back("mode", "INVALID");
  1191. break;
  1192. }
  1193. props_.emplace_back("key", op_.key);
  1194. props_.emplace_back("nr_devices", std::to_string(op_.nr_devices));
  1195. props_.emplace_back("rank", std::to_string(op_.rank));
  1196. props_.emplace_back("is_root", std::to_string(op_.is_root));
  1197. props_.emplace_back("local_grad", std::to_string(op_.local_grad));
  1198. props_.emplace_back("addr", op_.addr);
  1199. props_.emplace_back("port", std::to_string(op_.port));
  1200. props_.emplace_back("dtype", op_.dtype.name());
  1201. props_.emplace_back("backend", op_.backend);
  1202. props_.emplace_back("comp_node", op_.comp_node);
  1203. return props_;
  1204. }
  1205. std::string CollectiveComm_make_name_impl(const OpDef& def_) {
  1206. auto&& op_ = def_.cast_final_safe<CollectiveComm>();
  1207. static_cast<void>(op_);
  1208. return "CollectiveComm";
  1209. }
  1210. } // anonymous namespace
  1211. OP_TRAIT_REG(CollectiveComm, CollectiveComm)
  1212. .hash(CollectiveComm_hash_impl)
  1213. .is_same_st(CollectiveComm_is_same_st_impl)
  1214. .props(CollectiveComm_props_impl)
  1215. .make_name(CollectiveComm_make_name_impl);
  1216. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Concat);
  1217. namespace {
  1218. size_t Concat_hash_impl(const OpDef& def_) {
  1219. auto&& op_ = def_.cast_final_safe<Concat>();
  1220. static_cast<void>(op_);
  1221. size_t val = mgb::hash(op_.dyn_typeinfo());
  1222. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  1223. val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
  1224. return val;
  1225. }
  1226. bool Concat_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  1227. auto &&a_ = lhs_.cast_final_safe<Concat>(),
  1228. &&b_ = rhs_.cast_final_safe<Concat>();
  1229. static_cast<void>(a_);
  1230. static_cast<void>(b_);
  1231. if (a_.axis != b_.axis) return false;
  1232. if (a_.comp_node != b_.comp_node) return false;
  1233. return true;
  1234. }
  1235. std::vector<std::pair<const char*, std::string>> Concat_props_impl(const OpDef& def_) {
  1236. auto&& op_ = def_.cast_final_safe<Concat>();
  1237. static_cast<void>(op_);
  1238. std::vector<std::pair<const char*, std::string>> props_;
  1239. props_.emplace_back("axis", std::to_string(op_.axis));
  1240. props_.emplace_back("comp_node", op_.comp_node.to_string());
  1241. return props_;
  1242. }
  1243. std::string Concat_make_name_impl(const OpDef& def_) {
  1244. auto&& op_ = def_.cast_final_safe<Concat>();
  1245. static_cast<void>(op_);
  1246. return "Concat";
  1247. }
  1248. } // anonymous namespace
  1249. OP_TRAIT_REG(Concat, Concat)
  1250. .hash(Concat_hash_impl)
  1251. .is_same_st(Concat_is_same_st_impl)
  1252. .props(Concat_props_impl)
  1253. .make_name(Concat_make_name_impl);
  1254. MGB_DYN_TYPE_OBJ_FINAL_IMPL(CondTake);
  1255. namespace {
  1256. size_t CondTake_hash_impl(const OpDef& def_) {
  1257. auto&& op_ = def_.cast_final_safe<CondTake>();
  1258. static_cast<void>(op_);
  1259. size_t val = mgb::hash(op_.dyn_typeinfo());
  1260. return val;
  1261. }
  1262. bool CondTake_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  1263. auto &&a_ = lhs_.cast_final_safe<CondTake>(),
  1264. &&b_ = rhs_.cast_final_safe<CondTake>();
  1265. static_cast<void>(a_);
  1266. static_cast<void>(b_);
  1267. return true;
  1268. }
  1269. std::vector<std::pair<const char*, std::string>> CondTake_props_impl(const OpDef& def_) {
  1270. auto&& op_ = def_.cast_final_safe<CondTake>();
  1271. static_cast<void>(op_);
  1272. std::vector<std::pair<const char*, std::string>> props_;
  1273. return props_;
  1274. }
  1275. std::string CondTake_make_name_impl(const OpDef& def_) {
  1276. auto&& op_ = def_.cast_final_safe<CondTake>();
  1277. static_cast<void>(op_);
  1278. return "CondTake";
  1279. }
  1280. } // anonymous namespace
  1281. OP_TRAIT_REG(CondTake, CondTake)
  1282. .hash(CondTake_hash_impl)
  1283. .is_same_st(CondTake_is_same_st_impl)
  1284. .props(CondTake_props_impl)
  1285. .make_name(CondTake_make_name_impl);
  1286. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ConvBias);
  1287. namespace {
  1288. size_t ConvBias_hash_impl(const OpDef& def_) {
  1289. auto&& op_ = def_.cast_final_safe<ConvBias>();
  1290. static_cast<void>(op_);
  1291. size_t val = mgb::hash(op_.dyn_typeinfo());
  1292. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.nonlineMode));
  1293. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  1294. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
  1295. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  1296. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  1297. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  1298. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  1299. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  1300. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
  1301. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
  1302. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
  1303. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
  1304. val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
  1305. val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
  1306. return val;
  1307. }
  1308. bool ConvBias_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  1309. auto &&a_ = lhs_.cast_final_safe<ConvBias>(),
  1310. &&b_ = rhs_.cast_final_safe<ConvBias>();
  1311. static_cast<void>(a_);
  1312. static_cast<void>(b_);
  1313. if (a_.nonlineMode != b_.nonlineMode) return false;
  1314. if (a_.mode != b_.mode) return false;
  1315. if (a_.sparse != b_.sparse) return false;
  1316. if (a_.format != b_.format) return false;
  1317. if (a_.pad_h != b_.pad_h) return false;
  1318. if (a_.pad_w != b_.pad_w) return false;
  1319. if (a_.stride_h != b_.stride_h) return false;
  1320. if (a_.stride_w != b_.stride_w) return false;
  1321. if (a_.dilate_h != b_.dilate_h) return false;
  1322. if (a_.dilate_w != b_.dilate_w) return false;
  1323. if (a_.compute_mode != b_.compute_mode) return false;
  1324. if (a_.strategy != b_.strategy) return false;
  1325. if (a_.workspace_limit != b_.workspace_limit) return false;
  1326. if (a_.dtype != b_.dtype) return false;
  1327. return true;
  1328. }
  1329. std::vector<std::pair<const char*, std::string>> ConvBias_props_impl(const OpDef& def_) {
  1330. auto&& op_ = def_.cast_final_safe<ConvBias>();
  1331. static_cast<void>(op_);
  1332. std::vector<std::pair<const char*, std::string>> props_;
  1333. switch (op_.nonlineMode){
  1334. case ConvBias::NonlineMode::IDENTITY:
  1335. props_.emplace_back("nonlineMode", "IDENTITY");
  1336. break;
  1337. case ConvBias::NonlineMode::RELU:
  1338. props_.emplace_back("nonlineMode", "RELU");
  1339. break;
  1340. case ConvBias::NonlineMode::SIGMOID:
  1341. props_.emplace_back("nonlineMode", "SIGMOID");
  1342. break;
  1343. case ConvBias::NonlineMode::H_SWISH:
  1344. props_.emplace_back("nonlineMode", "H_SWISH");
  1345. break;
  1346. default:
  1347. props_.emplace_back("nonlineMode", "INVALID");
  1348. break;
  1349. }
  1350. switch (op_.mode){
  1351. case ConvBias::Mode::CROSS_CORRELATION:
  1352. props_.emplace_back("mode", "CROSS_CORRELATION");
  1353. break;
  1354. case ConvBias::Mode::CONVOLUTION:
  1355. props_.emplace_back("mode", "CONVOLUTION");
  1356. break;
  1357. default:
  1358. props_.emplace_back("mode", "INVALID");
  1359. break;
  1360. }
  1361. switch (op_.sparse){
  1362. case ConvBias::Sparse::DENSE:
  1363. props_.emplace_back("sparse", "DENSE");
  1364. break;
  1365. case ConvBias::Sparse::GROUP:
  1366. props_.emplace_back("sparse", "GROUP");
  1367. break;
  1368. default:
  1369. props_.emplace_back("sparse", "INVALID");
  1370. break;
  1371. }
  1372. switch (op_.format){
  1373. case ConvBias::Format::NCHW:
  1374. props_.emplace_back("format", "NCHW");
  1375. break;
  1376. case ConvBias::Format::NHWC:
  1377. props_.emplace_back("format", "NHWC");
  1378. break;
  1379. case ConvBias::Format::NHWCD4:
  1380. props_.emplace_back("format", "NHWCD4");
  1381. break;
  1382. case ConvBias::Format::NCHW4:
  1383. props_.emplace_back("format", "NCHW4");
  1384. break;
  1385. case ConvBias::Format::NCHW8:
  1386. props_.emplace_back("format", "NCHW8");
  1387. break;
  1388. case ConvBias::Format::NCHW32:
  1389. props_.emplace_back("format", "NCHW32");
  1390. break;
  1391. case ConvBias::Format::NCHW88:
  1392. props_.emplace_back("format", "NCHW88");
  1393. break;
  1394. case ConvBias::Format::NCHW44:
  1395. props_.emplace_back("format", "NCHW44");
  1396. break;
  1397. case ConvBias::Format::NCHW44_DOT:
  1398. props_.emplace_back("format", "NCHW44_DOT");
  1399. break;
  1400. case ConvBias::Format::NCHW4_NCHW32:
  1401. props_.emplace_back("format", "NCHW4_NCHW32");
  1402. break;
  1403. case ConvBias::Format::NCHW32_NCHW4:
  1404. props_.emplace_back("format", "NCHW32_NCHW4");
  1405. break;
  1406. case ConvBias::Format::NCHW4_NCHW:
  1407. props_.emplace_back("format", "NCHW4_NCHW");
  1408. break;
  1409. case ConvBias::Format::NHWC_NCHW:
  1410. props_.emplace_back("format", "NHWC_NCHW");
  1411. break;
  1412. case ConvBias::Format::NHWC_NCHW4_IC_SMALL:
  1413. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  1414. break;
  1415. case ConvBias::Format::NCHW_NCHW4_IC_SMALL:
  1416. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  1417. break;
  1418. case ConvBias::Format::CHWN4:
  1419. props_.emplace_back("format", "CHWN4");
  1420. break;
  1421. case ConvBias::Format::NCHW64:
  1422. props_.emplace_back("format", "NCHW64");
  1423. break;
  1424. case ConvBias::Format::NCHW4_NHWC:
  1425. props_.emplace_back("format", "NCHW4_NHWC");
  1426. break;
  1427. default:
  1428. props_.emplace_back("format", "INVALID");
  1429. break;
  1430. }
  1431. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  1432. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  1433. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  1434. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  1435. props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
  1436. props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
  1437. switch (op_.compute_mode){
  1438. case ConvBias::ComputeMode::DEFAULT:
  1439. props_.emplace_back("compute_mode", "DEFAULT");
  1440. break;
  1441. case ConvBias::ComputeMode::FLOAT32:
  1442. props_.emplace_back("compute_mode", "FLOAT32");
  1443. break;
  1444. default:
  1445. props_.emplace_back("compute_mode", "INVALID");
  1446. break;
  1447. }
  1448. switch (op_.strategy){
  1449. case ConvBias::Strategy::HEURISTIC:
  1450. props_.emplace_back("strategy", "HEURISTIC");
  1451. break;
  1452. case ConvBias::Strategy::PROFILE:
  1453. props_.emplace_back("strategy", "PROFILE");
  1454. break;
  1455. case ConvBias::Strategy::REPRODUCIBLE:
  1456. props_.emplace_back("strategy", "REPRODUCIBLE");
  1457. break;
  1458. case ConvBias::Strategy::OPTIMIZED:
  1459. props_.emplace_back("strategy", "OPTIMIZED");
  1460. break;
  1461. default:
  1462. props_.emplace_back("strategy", "INVALID");
  1463. break;
  1464. }
  1465. props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
  1466. props_.emplace_back("dtype", op_.dtype.name());
  1467. return props_;
  1468. }
  1469. std::string ConvBias_make_name_impl(const OpDef& def_) {
  1470. auto&& op_ = def_.cast_final_safe<ConvBias>();
  1471. static_cast<void>(op_);
  1472. return "ConvBias";
  1473. }
  1474. } // anonymous namespace
  1475. OP_TRAIT_REG(ConvBias, ConvBias)
  1476. .hash(ConvBias_hash_impl)
  1477. .is_same_st(ConvBias_is_same_st_impl)
  1478. .props(ConvBias_props_impl)
  1479. .make_name(ConvBias_make_name_impl);
  1480. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Convolution);
  1481. namespace {
  1482. size_t Convolution_hash_impl(const OpDef& def_) {
  1483. auto&& op_ = def_.cast_final_safe<Convolution>();
  1484. static_cast<void>(op_);
  1485. size_t val = mgb::hash(op_.dyn_typeinfo());
  1486. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  1487. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  1488. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  1489. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  1490. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  1491. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
  1492. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
  1493. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
  1494. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  1495. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
  1496. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
  1497. val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
  1498. return val;
  1499. }
  1500. bool Convolution_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  1501. auto &&a_ = lhs_.cast_final_safe<Convolution>(),
  1502. &&b_ = rhs_.cast_final_safe<Convolution>();
  1503. static_cast<void>(a_);
  1504. static_cast<void>(b_);
  1505. if (a_.mode != b_.mode) return false;
  1506. if (a_.pad_h != b_.pad_h) return false;
  1507. if (a_.pad_w != b_.pad_w) return false;
  1508. if (a_.stride_h != b_.stride_h) return false;
  1509. if (a_.stride_w != b_.stride_w) return false;
  1510. if (a_.dilate_h != b_.dilate_h) return false;
  1511. if (a_.dilate_w != b_.dilate_w) return false;
  1512. if (a_.sparse != b_.sparse) return false;
  1513. if (a_.format != b_.format) return false;
  1514. if (a_.compute_mode != b_.compute_mode) return false;
  1515. if (a_.strategy != b_.strategy) return false;
  1516. if (a_.workspace_limit != b_.workspace_limit) return false;
  1517. return true;
  1518. }
  1519. std::vector<std::pair<const char*, std::string>> Convolution_props_impl(const OpDef& def_) {
  1520. auto&& op_ = def_.cast_final_safe<Convolution>();
  1521. static_cast<void>(op_);
  1522. std::vector<std::pair<const char*, std::string>> props_;
  1523. switch (op_.mode){
  1524. case Convolution::Mode::CROSS_CORRELATION:
  1525. props_.emplace_back("mode", "CROSS_CORRELATION");
  1526. break;
  1527. case Convolution::Mode::CONVOLUTION:
  1528. props_.emplace_back("mode", "CONVOLUTION");
  1529. break;
  1530. default:
  1531. props_.emplace_back("mode", "INVALID");
  1532. break;
  1533. }
  1534. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  1535. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  1536. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  1537. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  1538. props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
  1539. props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
  1540. switch (op_.sparse){
  1541. case Convolution::Sparse::DENSE:
  1542. props_.emplace_back("sparse", "DENSE");
  1543. break;
  1544. case Convolution::Sparse::GROUP:
  1545. props_.emplace_back("sparse", "GROUP");
  1546. break;
  1547. default:
  1548. props_.emplace_back("sparse", "INVALID");
  1549. break;
  1550. }
  1551. switch (op_.format){
  1552. case Convolution::Format::NCHW:
  1553. props_.emplace_back("format", "NCHW");
  1554. break;
  1555. case Convolution::Format::NHWC:
  1556. props_.emplace_back("format", "NHWC");
  1557. break;
  1558. case Convolution::Format::NHWCD4:
  1559. props_.emplace_back("format", "NHWCD4");
  1560. break;
  1561. case Convolution::Format::NCHW4:
  1562. props_.emplace_back("format", "NCHW4");
  1563. break;
  1564. case Convolution::Format::NCHW8:
  1565. props_.emplace_back("format", "NCHW8");
  1566. break;
  1567. case Convolution::Format::NCHW32:
  1568. props_.emplace_back("format", "NCHW32");
  1569. break;
  1570. case Convolution::Format::NCHW88:
  1571. props_.emplace_back("format", "NCHW88");
  1572. break;
  1573. case Convolution::Format::NCHW44:
  1574. props_.emplace_back("format", "NCHW44");
  1575. break;
  1576. case Convolution::Format::NCHW44_DOT:
  1577. props_.emplace_back("format", "NCHW44_DOT");
  1578. break;
  1579. case Convolution::Format::NCHW4_NCHW32:
  1580. props_.emplace_back("format", "NCHW4_NCHW32");
  1581. break;
  1582. case Convolution::Format::NCHW32_NCHW4:
  1583. props_.emplace_back("format", "NCHW32_NCHW4");
  1584. break;
  1585. case Convolution::Format::NCHW4_NCHW:
  1586. props_.emplace_back("format", "NCHW4_NCHW");
  1587. break;
  1588. case Convolution::Format::NHWC_NCHW:
  1589. props_.emplace_back("format", "NHWC_NCHW");
  1590. break;
  1591. case Convolution::Format::NHWC_NCHW4_IC_SMALL:
  1592. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  1593. break;
  1594. case Convolution::Format::NCHW_NCHW4_IC_SMALL:
  1595. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  1596. break;
  1597. case Convolution::Format::CHWN4:
  1598. props_.emplace_back("format", "CHWN4");
  1599. break;
  1600. case Convolution::Format::NCHW64:
  1601. props_.emplace_back("format", "NCHW64");
  1602. break;
  1603. case Convolution::Format::NCHW4_NHWC:
  1604. props_.emplace_back("format", "NCHW4_NHWC");
  1605. break;
  1606. default:
  1607. props_.emplace_back("format", "INVALID");
  1608. break;
  1609. }
  1610. switch (op_.compute_mode){
  1611. case Convolution::ComputeMode::DEFAULT:
  1612. props_.emplace_back("compute_mode", "DEFAULT");
  1613. break;
  1614. case Convolution::ComputeMode::FLOAT32:
  1615. props_.emplace_back("compute_mode", "FLOAT32");
  1616. break;
  1617. default:
  1618. props_.emplace_back("compute_mode", "INVALID");
  1619. break;
  1620. }
  1621. switch (op_.strategy){
  1622. case Convolution::Strategy::HEURISTIC:
  1623. props_.emplace_back("strategy", "HEURISTIC");
  1624. break;
  1625. case Convolution::Strategy::PROFILE:
  1626. props_.emplace_back("strategy", "PROFILE");
  1627. break;
  1628. case Convolution::Strategy::REPRODUCIBLE:
  1629. props_.emplace_back("strategy", "REPRODUCIBLE");
  1630. break;
  1631. case Convolution::Strategy::OPTIMIZED:
  1632. props_.emplace_back("strategy", "OPTIMIZED");
  1633. break;
  1634. default:
  1635. props_.emplace_back("strategy", "INVALID");
  1636. break;
  1637. }
  1638. props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
  1639. return props_;
  1640. }
  1641. std::string Convolution_make_name_impl(const OpDef& def_) {
  1642. auto&& op_ = def_.cast_final_safe<Convolution>();
  1643. static_cast<void>(op_);
  1644. return "Convolution";
  1645. }
  1646. } // anonymous namespace
  1647. OP_TRAIT_REG(Convolution, Convolution)
  1648. .hash(Convolution_hash_impl)
  1649. .is_same_st(Convolution_is_same_st_impl)
  1650. .props(Convolution_props_impl)
  1651. .make_name(Convolution_make_name_impl);
  1652. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Convolution3D);
  1653. namespace {
  1654. size_t Convolution3D_hash_impl(const OpDef& def_) {
  1655. auto&& op_ = def_.cast_final_safe<Convolution3D>();
  1656. static_cast<void>(op_);
  1657. size_t val = mgb::hash(op_.dyn_typeinfo());
  1658. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  1659. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_d));
  1660. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  1661. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  1662. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_d));
  1663. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  1664. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  1665. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_d));
  1666. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
  1667. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
  1668. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
  1669. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.data_type));
  1670. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  1671. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
  1672. val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
  1673. return val;
  1674. }
  1675. bool Convolution3D_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  1676. auto &&a_ = lhs_.cast_final_safe<Convolution3D>(),
  1677. &&b_ = rhs_.cast_final_safe<Convolution3D>();
  1678. static_cast<void>(a_);
  1679. static_cast<void>(b_);
  1680. if (a_.mode != b_.mode) return false;
  1681. if (a_.pad_d != b_.pad_d) return false;
  1682. if (a_.pad_h != b_.pad_h) return false;
  1683. if (a_.pad_w != b_.pad_w) return false;
  1684. if (a_.stride_d != b_.stride_d) return false;
  1685. if (a_.stride_h != b_.stride_h) return false;
  1686. if (a_.stride_w != b_.stride_w) return false;
  1687. if (a_.dilate_d != b_.dilate_d) return false;
  1688. if (a_.dilate_h != b_.dilate_h) return false;
  1689. if (a_.dilate_w != b_.dilate_w) return false;
  1690. if (a_.sparse != b_.sparse) return false;
  1691. if (a_.data_type != b_.data_type) return false;
  1692. if (a_.format != b_.format) return false;
  1693. if (a_.strategy != b_.strategy) return false;
  1694. if (a_.workspace_limit != b_.workspace_limit) return false;
  1695. return true;
  1696. }
  1697. std::vector<std::pair<const char*, std::string>> Convolution3D_props_impl(const OpDef& def_) {
  1698. auto&& op_ = def_.cast_final_safe<Convolution3D>();
  1699. static_cast<void>(op_);
  1700. std::vector<std::pair<const char*, std::string>> props_;
  1701. switch (op_.mode){
  1702. case Convolution3D::Mode::CROSS_CORRELATION:
  1703. props_.emplace_back("mode", "CROSS_CORRELATION");
  1704. break;
  1705. case Convolution3D::Mode::CONVOLUTION:
  1706. props_.emplace_back("mode", "CONVOLUTION");
  1707. break;
  1708. default:
  1709. props_.emplace_back("mode", "INVALID");
  1710. break;
  1711. }
  1712. props_.emplace_back("pad_d", std::to_string(op_.pad_d));
  1713. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  1714. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  1715. props_.emplace_back("stride_d", std::to_string(op_.stride_d));
  1716. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  1717. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  1718. props_.emplace_back("dilate_d", std::to_string(op_.dilate_d));
  1719. props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
  1720. props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
  1721. switch (op_.sparse){
  1722. case Convolution3D::Sparse::DENSE:
  1723. props_.emplace_back("sparse", "DENSE");
  1724. break;
  1725. case Convolution3D::Sparse::GROUP:
  1726. props_.emplace_back("sparse", "GROUP");
  1727. break;
  1728. default:
  1729. props_.emplace_back("sparse", "INVALID");
  1730. break;
  1731. }
  1732. switch (op_.data_type){
  1733. case Convolution3D::DataType::FLOAT:
  1734. props_.emplace_back("data_type", "FLOAT");
  1735. break;
  1736. case Convolution3D::DataType::FLOAT_IO16xC32:
  1737. props_.emplace_back("data_type", "FLOAT_IO16xC32");
  1738. break;
  1739. default:
  1740. props_.emplace_back("data_type", "INVALID");
  1741. break;
  1742. }
  1743. switch (op_.format){
  1744. case Convolution3D::Format::NCDHW:
  1745. props_.emplace_back("format", "NCDHW");
  1746. break;
  1747. case Convolution3D::Format::NDHWC:
  1748. props_.emplace_back("format", "NDHWC");
  1749. break;
  1750. default:
  1751. props_.emplace_back("format", "INVALID");
  1752. break;
  1753. }
  1754. switch (op_.strategy){
  1755. case Convolution3D::Strategy::HEURISTIC:
  1756. props_.emplace_back("strategy", "HEURISTIC");
  1757. break;
  1758. case Convolution3D::Strategy::PROFILE:
  1759. props_.emplace_back("strategy", "PROFILE");
  1760. break;
  1761. case Convolution3D::Strategy::REPRODUCIBLE:
  1762. props_.emplace_back("strategy", "REPRODUCIBLE");
  1763. break;
  1764. case Convolution3D::Strategy::OPTIMIZED:
  1765. props_.emplace_back("strategy", "OPTIMIZED");
  1766. break;
  1767. default:
  1768. props_.emplace_back("strategy", "INVALID");
  1769. break;
  1770. }
  1771. props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
  1772. return props_;
  1773. }
  1774. std::string Convolution3D_make_name_impl(const OpDef& def_) {
  1775. auto&& op_ = def_.cast_final_safe<Convolution3D>();
  1776. static_cast<void>(op_);
  1777. return "Convolution3D";
  1778. }
  1779. } // anonymous namespace
  1780. OP_TRAIT_REG(Convolution3D, Convolution3D)
  1781. .hash(Convolution3D_hash_impl)
  1782. .is_same_st(Convolution3D_is_same_st_impl)
  1783. .props(Convolution3D_props_impl)
  1784. .make_name(Convolution3D_make_name_impl);
  1785. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Convolution3DBackwardData);
  1786. namespace {
  1787. size_t Convolution3DBackwardData_hash_impl(const OpDef& def_) {
  1788. auto&& op_ = def_.cast_final_safe<Convolution3DBackwardData>();
  1789. static_cast<void>(op_);
  1790. size_t val = mgb::hash(op_.dyn_typeinfo());
  1791. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  1792. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_d));
  1793. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  1794. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  1795. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_d));
  1796. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  1797. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  1798. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_d));
  1799. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
  1800. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
  1801. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
  1802. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.data_type));
  1803. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  1804. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
  1805. val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
  1806. return val;
  1807. }
  1808. bool Convolution3DBackwardData_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  1809. auto &&a_ = lhs_.cast_final_safe<Convolution3DBackwardData>(),
  1810. &&b_ = rhs_.cast_final_safe<Convolution3DBackwardData>();
  1811. static_cast<void>(a_);
  1812. static_cast<void>(b_);
  1813. if (a_.mode != b_.mode) return false;
  1814. if (a_.pad_d != b_.pad_d) return false;
  1815. if (a_.pad_h != b_.pad_h) return false;
  1816. if (a_.pad_w != b_.pad_w) return false;
  1817. if (a_.stride_d != b_.stride_d) return false;
  1818. if (a_.stride_h != b_.stride_h) return false;
  1819. if (a_.stride_w != b_.stride_w) return false;
  1820. if (a_.dilate_d != b_.dilate_d) return false;
  1821. if (a_.dilate_h != b_.dilate_h) return false;
  1822. if (a_.dilate_w != b_.dilate_w) return false;
  1823. if (a_.sparse != b_.sparse) return false;
  1824. if (a_.data_type != b_.data_type) return false;
  1825. if (a_.format != b_.format) return false;
  1826. if (a_.strategy != b_.strategy) return false;
  1827. if (a_.workspace_limit != b_.workspace_limit) return false;
  1828. return true;
  1829. }
  1830. std::vector<std::pair<const char*, std::string>> Convolution3DBackwardData_props_impl(const OpDef& def_) {
  1831. auto&& op_ = def_.cast_final_safe<Convolution3DBackwardData>();
  1832. static_cast<void>(op_);
  1833. std::vector<std::pair<const char*, std::string>> props_;
  1834. switch (op_.mode){
  1835. case Convolution3DBackwardData::Mode::CROSS_CORRELATION:
  1836. props_.emplace_back("mode", "CROSS_CORRELATION");
  1837. break;
  1838. case Convolution3DBackwardData::Mode::CONVOLUTION:
  1839. props_.emplace_back("mode", "CONVOLUTION");
  1840. break;
  1841. default:
  1842. props_.emplace_back("mode", "INVALID");
  1843. break;
  1844. }
  1845. props_.emplace_back("pad_d", std::to_string(op_.pad_d));
  1846. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  1847. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  1848. props_.emplace_back("stride_d", std::to_string(op_.stride_d));
  1849. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  1850. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  1851. props_.emplace_back("dilate_d", std::to_string(op_.dilate_d));
  1852. props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
  1853. props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
  1854. switch (op_.sparse){
  1855. case Convolution3DBackwardData::Sparse::DENSE:
  1856. props_.emplace_back("sparse", "DENSE");
  1857. break;
  1858. case Convolution3DBackwardData::Sparse::GROUP:
  1859. props_.emplace_back("sparse", "GROUP");
  1860. break;
  1861. default:
  1862. props_.emplace_back("sparse", "INVALID");
  1863. break;
  1864. }
  1865. switch (op_.data_type){
  1866. case Convolution3DBackwardData::DataType::FLOAT:
  1867. props_.emplace_back("data_type", "FLOAT");
  1868. break;
  1869. case Convolution3DBackwardData::DataType::FLOAT_IO16xC32:
  1870. props_.emplace_back("data_type", "FLOAT_IO16xC32");
  1871. break;
  1872. default:
  1873. props_.emplace_back("data_type", "INVALID");
  1874. break;
  1875. }
  1876. switch (op_.format){
  1877. case Convolution3DBackwardData::Format::NCDHW:
  1878. props_.emplace_back("format", "NCDHW");
  1879. break;
  1880. case Convolution3DBackwardData::Format::NDHWC:
  1881. props_.emplace_back("format", "NDHWC");
  1882. break;
  1883. default:
  1884. props_.emplace_back("format", "INVALID");
  1885. break;
  1886. }
  1887. switch (op_.strategy){
  1888. case Convolution3DBackwardData::Strategy::HEURISTIC:
  1889. props_.emplace_back("strategy", "HEURISTIC");
  1890. break;
  1891. case Convolution3DBackwardData::Strategy::PROFILE:
  1892. props_.emplace_back("strategy", "PROFILE");
  1893. break;
  1894. case Convolution3DBackwardData::Strategy::REPRODUCIBLE:
  1895. props_.emplace_back("strategy", "REPRODUCIBLE");
  1896. break;
  1897. case Convolution3DBackwardData::Strategy::OPTIMIZED:
  1898. props_.emplace_back("strategy", "OPTIMIZED");
  1899. break;
  1900. default:
  1901. props_.emplace_back("strategy", "INVALID");
  1902. break;
  1903. }
  1904. props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
  1905. return props_;
  1906. }
  1907. std::string Convolution3DBackwardData_make_name_impl(const OpDef& def_) {
  1908. auto&& op_ = def_.cast_final_safe<Convolution3DBackwardData>();
  1909. static_cast<void>(op_);
  1910. return "Convolution3DBackwardData";
  1911. }
  1912. } // anonymous namespace
  1913. OP_TRAIT_REG(Convolution3DBackwardData, Convolution3DBackwardData)
  1914. .hash(Convolution3DBackwardData_hash_impl)
  1915. .is_same_st(Convolution3DBackwardData_is_same_st_impl)
  1916. .props(Convolution3DBackwardData_props_impl)
  1917. .make_name(Convolution3DBackwardData_make_name_impl);
  1918. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ConvolutionBackwardData);
  1919. namespace {
  1920. size_t ConvolutionBackwardData_hash_impl(const OpDef& def_) {
  1921. auto&& op_ = def_.cast_final_safe<ConvolutionBackwardData>();
  1922. static_cast<void>(op_);
  1923. size_t val = mgb::hash(op_.dyn_typeinfo());
  1924. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  1925. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  1926. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  1927. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  1928. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  1929. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
  1930. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
  1931. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
  1932. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  1933. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
  1934. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
  1935. val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
  1936. val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
  1937. return val;
  1938. }
  1939. bool ConvolutionBackwardData_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  1940. auto &&a_ = lhs_.cast_final_safe<ConvolutionBackwardData>(),
  1941. &&b_ = rhs_.cast_final_safe<ConvolutionBackwardData>();
  1942. static_cast<void>(a_);
  1943. static_cast<void>(b_);
  1944. if (a_.mode != b_.mode) return false;
  1945. if (a_.pad_h != b_.pad_h) return false;
  1946. if (a_.pad_w != b_.pad_w) return false;
  1947. if (a_.stride_h != b_.stride_h) return false;
  1948. if (a_.stride_w != b_.stride_w) return false;
  1949. if (a_.dilate_h != b_.dilate_h) return false;
  1950. if (a_.dilate_w != b_.dilate_w) return false;
  1951. if (a_.sparse != b_.sparse) return false;
  1952. if (a_.format != b_.format) return false;
  1953. if (a_.compute_mode != b_.compute_mode) return false;
  1954. if (a_.strategy != b_.strategy) return false;
  1955. if (a_.workspace_limit != b_.workspace_limit) return false;
  1956. if (a_.dtype != b_.dtype) return false;
  1957. return true;
  1958. }
  1959. std::vector<std::pair<const char*, std::string>> ConvolutionBackwardData_props_impl(const OpDef& def_) {
  1960. auto&& op_ = def_.cast_final_safe<ConvolutionBackwardData>();
  1961. static_cast<void>(op_);
  1962. std::vector<std::pair<const char*, std::string>> props_;
  1963. switch (op_.mode){
  1964. case ConvolutionBackwardData::Mode::CROSS_CORRELATION:
  1965. props_.emplace_back("mode", "CROSS_CORRELATION");
  1966. break;
  1967. case ConvolutionBackwardData::Mode::CONVOLUTION:
  1968. props_.emplace_back("mode", "CONVOLUTION");
  1969. break;
  1970. default:
  1971. props_.emplace_back("mode", "INVALID");
  1972. break;
  1973. }
  1974. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  1975. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  1976. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  1977. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  1978. props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
  1979. props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
  1980. switch (op_.sparse){
  1981. case ConvolutionBackwardData::Sparse::DENSE:
  1982. props_.emplace_back("sparse", "DENSE");
  1983. break;
  1984. case ConvolutionBackwardData::Sparse::GROUP:
  1985. props_.emplace_back("sparse", "GROUP");
  1986. break;
  1987. default:
  1988. props_.emplace_back("sparse", "INVALID");
  1989. break;
  1990. }
  1991. switch (op_.format){
  1992. case ConvolutionBackwardData::Format::NCHW:
  1993. props_.emplace_back("format", "NCHW");
  1994. break;
  1995. case ConvolutionBackwardData::Format::NHWC:
  1996. props_.emplace_back("format", "NHWC");
  1997. break;
  1998. case ConvolutionBackwardData::Format::NHWCD4:
  1999. props_.emplace_back("format", "NHWCD4");
  2000. break;
  2001. case ConvolutionBackwardData::Format::NCHW4:
  2002. props_.emplace_back("format", "NCHW4");
  2003. break;
  2004. case ConvolutionBackwardData::Format::NCHW8:
  2005. props_.emplace_back("format", "NCHW8");
  2006. break;
  2007. case ConvolutionBackwardData::Format::NCHW32:
  2008. props_.emplace_back("format", "NCHW32");
  2009. break;
  2010. case ConvolutionBackwardData::Format::NCHW88:
  2011. props_.emplace_back("format", "NCHW88");
  2012. break;
  2013. case ConvolutionBackwardData::Format::NCHW44:
  2014. props_.emplace_back("format", "NCHW44");
  2015. break;
  2016. case ConvolutionBackwardData::Format::NCHW44_DOT:
  2017. props_.emplace_back("format", "NCHW44_DOT");
  2018. break;
  2019. case ConvolutionBackwardData::Format::NCHW4_NCHW32:
  2020. props_.emplace_back("format", "NCHW4_NCHW32");
  2021. break;
  2022. case ConvolutionBackwardData::Format::NCHW32_NCHW4:
  2023. props_.emplace_back("format", "NCHW32_NCHW4");
  2024. break;
  2025. case ConvolutionBackwardData::Format::NCHW4_NCHW:
  2026. props_.emplace_back("format", "NCHW4_NCHW");
  2027. break;
  2028. case ConvolutionBackwardData::Format::NHWC_NCHW:
  2029. props_.emplace_back("format", "NHWC_NCHW");
  2030. break;
  2031. case ConvolutionBackwardData::Format::NHWC_NCHW4_IC_SMALL:
  2032. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  2033. break;
  2034. case ConvolutionBackwardData::Format::NCHW_NCHW4_IC_SMALL:
  2035. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  2036. break;
  2037. case ConvolutionBackwardData::Format::CHWN4:
  2038. props_.emplace_back("format", "CHWN4");
  2039. break;
  2040. case ConvolutionBackwardData::Format::NCHW64:
  2041. props_.emplace_back("format", "NCHW64");
  2042. break;
  2043. case ConvolutionBackwardData::Format::NCHW4_NHWC:
  2044. props_.emplace_back("format", "NCHW4_NHWC");
  2045. break;
  2046. default:
  2047. props_.emplace_back("format", "INVALID");
  2048. break;
  2049. }
  2050. switch (op_.compute_mode){
  2051. case ConvolutionBackwardData::ComputeMode::DEFAULT:
  2052. props_.emplace_back("compute_mode", "DEFAULT");
  2053. break;
  2054. case ConvolutionBackwardData::ComputeMode::FLOAT32:
  2055. props_.emplace_back("compute_mode", "FLOAT32");
  2056. break;
  2057. default:
  2058. props_.emplace_back("compute_mode", "INVALID");
  2059. break;
  2060. }
  2061. switch (op_.strategy){
  2062. case ConvolutionBackwardData::Strategy::HEURISTIC:
  2063. props_.emplace_back("strategy", "HEURISTIC");
  2064. break;
  2065. case ConvolutionBackwardData::Strategy::PROFILE:
  2066. props_.emplace_back("strategy", "PROFILE");
  2067. break;
  2068. case ConvolutionBackwardData::Strategy::REPRODUCIBLE:
  2069. props_.emplace_back("strategy", "REPRODUCIBLE");
  2070. break;
  2071. case ConvolutionBackwardData::Strategy::OPTIMIZED:
  2072. props_.emplace_back("strategy", "OPTIMIZED");
  2073. break;
  2074. default:
  2075. props_.emplace_back("strategy", "INVALID");
  2076. break;
  2077. }
  2078. props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
  2079. props_.emplace_back("dtype", op_.dtype.name());
  2080. return props_;
  2081. }
  2082. std::string ConvolutionBackwardData_make_name_impl(const OpDef& def_) {
  2083. auto&& op_ = def_.cast_final_safe<ConvolutionBackwardData>();
  2084. static_cast<void>(op_);
  2085. return "ConvolutionBackwardData";
  2086. }
  2087. } // anonymous namespace
  2088. OP_TRAIT_REG(ConvolutionBackwardData, ConvolutionBackwardData)
  2089. .hash(ConvolutionBackwardData_hash_impl)
  2090. .is_same_st(ConvolutionBackwardData_is_same_st_impl)
  2091. .props(ConvolutionBackwardData_props_impl)
  2092. .make_name(ConvolutionBackwardData_make_name_impl);
  2093. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Copy);
  2094. namespace {
  2095. size_t Copy_hash_impl(const OpDef& def_) {
  2096. auto&& op_ = def_.cast_final_safe<Copy>();
  2097. static_cast<void>(op_);
  2098. size_t val = mgb::hash(op_.dyn_typeinfo());
  2099. val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
  2100. return val;
  2101. }
  2102. bool Copy_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  2103. auto &&a_ = lhs_.cast_final_safe<Copy>(),
  2104. &&b_ = rhs_.cast_final_safe<Copy>();
  2105. static_cast<void>(a_);
  2106. static_cast<void>(b_);
  2107. if (a_.comp_node != b_.comp_node) return false;
  2108. return true;
  2109. }
  2110. std::vector<std::pair<const char*, std::string>> Copy_props_impl(const OpDef& def_) {
  2111. auto&& op_ = def_.cast_final_safe<Copy>();
  2112. static_cast<void>(op_);
  2113. std::vector<std::pair<const char*, std::string>> props_;
  2114. props_.emplace_back("comp_node", op_.comp_node.to_string());
  2115. return props_;
  2116. }
  2117. std::string Copy_make_name_impl(const OpDef& def_) {
  2118. auto&& op_ = def_.cast_final_safe<Copy>();
  2119. static_cast<void>(op_);
  2120. return "Copy";
  2121. }
  2122. } // anonymous namespace
  2123. OP_TRAIT_REG(Copy, Copy)
  2124. .hash(Copy_hash_impl)
  2125. .is_same_st(Copy_is_same_st_impl)
  2126. .props(Copy_props_impl)
  2127. .make_name(Copy_make_name_impl);
  2128. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Correlation);
  2129. namespace {
  2130. size_t Correlation_hash_impl(const OpDef& def_) {
  2131. auto&& op_ = def_.cast_final_safe<Correlation>();
  2132. static_cast<void>(op_);
  2133. size_t val = mgb::hash(op_.dyn_typeinfo());
  2134. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  2135. val = mgb::hash_pair_combine(val, mgb::hash(op_.kernel_size));
  2136. val = mgb::hash_pair_combine(val, mgb::hash(op_.max_displacement));
  2137. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride1));
  2138. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride2));
  2139. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_size));
  2140. val = mgb::hash_pair_combine(val, mgb::hash(op_.is_multiply));
  2141. return val;
  2142. }
  2143. bool Correlation_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  2144. auto &&a_ = lhs_.cast_final_safe<Correlation>(),
  2145. &&b_ = rhs_.cast_final_safe<Correlation>();
  2146. static_cast<void>(a_);
  2147. static_cast<void>(b_);
  2148. if (a_.format != b_.format) return false;
  2149. if (a_.kernel_size != b_.kernel_size) return false;
  2150. if (a_.max_displacement != b_.max_displacement) return false;
  2151. if (a_.stride1 != b_.stride1) return false;
  2152. if (a_.stride2 != b_.stride2) return false;
  2153. if (a_.pad_size != b_.pad_size) return false;
  2154. if (a_.is_multiply != b_.is_multiply) return false;
  2155. return true;
  2156. }
  2157. std::vector<std::pair<const char*, std::string>> Correlation_props_impl(const OpDef& def_) {
  2158. auto&& op_ = def_.cast_final_safe<Correlation>();
  2159. static_cast<void>(op_);
  2160. std::vector<std::pair<const char*, std::string>> props_;
  2161. switch (op_.format){
  2162. case Correlation::Format::NCHW:
  2163. props_.emplace_back("format", "NCHW");
  2164. break;
  2165. case Correlation::Format::NHWC:
  2166. props_.emplace_back("format", "NHWC");
  2167. break;
  2168. case Correlation::Format::NHWCD4:
  2169. props_.emplace_back("format", "NHWCD4");
  2170. break;
  2171. case Correlation::Format::NCHW4:
  2172. props_.emplace_back("format", "NCHW4");
  2173. break;
  2174. case Correlation::Format::NCHW8:
  2175. props_.emplace_back("format", "NCHW8");
  2176. break;
  2177. case Correlation::Format::NCHW32:
  2178. props_.emplace_back("format", "NCHW32");
  2179. break;
  2180. case Correlation::Format::NCHW88:
  2181. props_.emplace_back("format", "NCHW88");
  2182. break;
  2183. case Correlation::Format::NCHW44:
  2184. props_.emplace_back("format", "NCHW44");
  2185. break;
  2186. case Correlation::Format::NCHW44_DOT:
  2187. props_.emplace_back("format", "NCHW44_DOT");
  2188. break;
  2189. case Correlation::Format::NCHW_WINOGRAD:
  2190. props_.emplace_back("format", "NCHW_WINOGRAD");
  2191. break;
  2192. case Correlation::Format::NCHW88_WINOGRAD:
  2193. props_.emplace_back("format", "NCHW88_WINOGRAD");
  2194. break;
  2195. case Correlation::Format::NCHW44_WINOGRAD:
  2196. props_.emplace_back("format", "NCHW44_WINOGRAD");
  2197. break;
  2198. case Correlation::Format::NCHW4_NCHW32:
  2199. props_.emplace_back("format", "NCHW4_NCHW32");
  2200. break;
  2201. case Correlation::Format::NCHW32_NCHW4:
  2202. props_.emplace_back("format", "NCHW32_NCHW4");
  2203. break;
  2204. case Correlation::Format::NCHW4_NCHW:
  2205. props_.emplace_back("format", "NCHW4_NCHW");
  2206. break;
  2207. case Correlation::Format::NHWC_NCHW:
  2208. props_.emplace_back("format", "NHWC_NCHW");
  2209. break;
  2210. case Correlation::Format::NHWC_NCHW4_IC_SMALL:
  2211. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  2212. break;
  2213. case Correlation::Format::NCHW_NCHW4_IC_SMALL:
  2214. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  2215. break;
  2216. case Correlation::Format::CHWN4:
  2217. props_.emplace_back("format", "CHWN4");
  2218. break;
  2219. case Correlation::Format::NCHW4_NHWC:
  2220. props_.emplace_back("format", "NCHW4_NHWC");
  2221. break;
  2222. default:
  2223. props_.emplace_back("format", "INVALID");
  2224. break;
  2225. }
  2226. props_.emplace_back("kernel_size", std::to_string(op_.kernel_size));
  2227. props_.emplace_back("max_displacement", std::to_string(op_.max_displacement));
  2228. props_.emplace_back("stride1", std::to_string(op_.stride1));
  2229. props_.emplace_back("stride2", std::to_string(op_.stride2));
  2230. props_.emplace_back("pad_size", std::to_string(op_.pad_size));
  2231. props_.emplace_back("is_multiply", std::to_string(op_.is_multiply));
  2232. return props_;
  2233. }
  2234. std::string Correlation_make_name_impl(const OpDef& def_) {
  2235. auto&& op_ = def_.cast_final_safe<Correlation>();
  2236. static_cast<void>(op_);
  2237. return "Correlation";
  2238. }
  2239. } // anonymous namespace
  2240. OP_TRAIT_REG(Correlation, Correlation)
  2241. .hash(Correlation_hash_impl)
  2242. .is_same_st(Correlation_is_same_st_impl)
  2243. .props(Correlation_props_impl)
  2244. .make_name(Correlation_make_name_impl);
  2245. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Cumsum);
  2246. namespace {
  2247. size_t Cumsum_hash_impl(const OpDef& def_) {
  2248. auto&& op_ = def_.cast_final_safe<Cumsum>();
  2249. static_cast<void>(op_);
  2250. size_t val = mgb::hash(op_.dyn_typeinfo());
  2251. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  2252. val = mgb::hash_pair_combine(val, mgb::hash(op_.exclusive));
  2253. val = mgb::hash_pair_combine(val, mgb::hash(op_.reverse));
  2254. return val;
  2255. }
  2256. bool Cumsum_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  2257. auto &&a_ = lhs_.cast_final_safe<Cumsum>(),
  2258. &&b_ = rhs_.cast_final_safe<Cumsum>();
  2259. static_cast<void>(a_);
  2260. static_cast<void>(b_);
  2261. if (a_.axis != b_.axis) return false;
  2262. if (a_.exclusive != b_.exclusive) return false;
  2263. if (a_.reverse != b_.reverse) return false;
  2264. return true;
  2265. }
  2266. std::vector<std::pair<const char*, std::string>> Cumsum_props_impl(const OpDef& def_) {
  2267. auto&& op_ = def_.cast_final_safe<Cumsum>();
  2268. static_cast<void>(op_);
  2269. std::vector<std::pair<const char*, std::string>> props_;
  2270. props_.emplace_back("axis", std::to_string(op_.axis));
  2271. props_.emplace_back("exclusive", std::to_string(op_.exclusive));
  2272. props_.emplace_back("reverse", std::to_string(op_.reverse));
  2273. return props_;
  2274. }
  2275. std::string Cumsum_make_name_impl(const OpDef& def_) {
  2276. auto&& op_ = def_.cast_final_safe<Cumsum>();
  2277. static_cast<void>(op_);
  2278. return "Cumsum";
  2279. }
  2280. } // anonymous namespace
  2281. OP_TRAIT_REG(Cumsum, Cumsum)
  2282. .hash(Cumsum_hash_impl)
  2283. .is_same_st(Cumsum_is_same_st_impl)
  2284. .props(Cumsum_props_impl)
  2285. .make_name(Cumsum_make_name_impl);
  2286. MGB_DYN_TYPE_OBJ_FINAL_IMPL(CvtColor);
  2287. namespace {
  2288. size_t CvtColor_hash_impl(const OpDef& def_) {
  2289. auto&& op_ = def_.cast_final_safe<CvtColor>();
  2290. static_cast<void>(op_);
  2291. size_t val = mgb::hash(op_.dyn_typeinfo());
  2292. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  2293. return val;
  2294. }
  2295. bool CvtColor_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  2296. auto &&a_ = lhs_.cast_final_safe<CvtColor>(),
  2297. &&b_ = rhs_.cast_final_safe<CvtColor>();
  2298. static_cast<void>(a_);
  2299. static_cast<void>(b_);
  2300. if (a_.mode != b_.mode) return false;
  2301. return true;
  2302. }
  2303. std::vector<std::pair<const char*, std::string>> CvtColor_props_impl(const OpDef& def_) {
  2304. auto&& op_ = def_.cast_final_safe<CvtColor>();
  2305. static_cast<void>(op_);
  2306. std::vector<std::pair<const char*, std::string>> props_;
  2307. switch (op_.mode){
  2308. case CvtColor::Mode::RGB2GRAY:
  2309. props_.emplace_back("mode", "RGB2GRAY");
  2310. break;
  2311. case CvtColor::Mode::RGB2YUV:
  2312. props_.emplace_back("mode", "RGB2YUV");
  2313. break;
  2314. case CvtColor::Mode::YUV2RGB:
  2315. props_.emplace_back("mode", "YUV2RGB");
  2316. break;
  2317. case CvtColor::Mode::GRAY2RGB:
  2318. props_.emplace_back("mode", "GRAY2RGB");
  2319. break;
  2320. case CvtColor::Mode::RGBA2RGB:
  2321. props_.emplace_back("mode", "RGBA2RGB");
  2322. break;
  2323. case CvtColor::Mode::RGBA2BGR:
  2324. props_.emplace_back("mode", "RGBA2BGR");
  2325. break;
  2326. case CvtColor::Mode::RGBA2GRAY:
  2327. props_.emplace_back("mode", "RGBA2GRAY");
  2328. break;
  2329. case CvtColor::Mode::RGB2BGR:
  2330. props_.emplace_back("mode", "RGB2BGR");
  2331. break;
  2332. case CvtColor::Mode::BGR2GRAY:
  2333. props_.emplace_back("mode", "BGR2GRAY");
  2334. break;
  2335. case CvtColor::Mode::BGR2RGB:
  2336. props_.emplace_back("mode", "BGR2RGB");
  2337. break;
  2338. case CvtColor::Mode::YUV2GRAY_NV21:
  2339. props_.emplace_back("mode", "YUV2GRAY_NV21");
  2340. break;
  2341. case CvtColor::Mode::YUV2RGB_NV21:
  2342. props_.emplace_back("mode", "YUV2RGB_NV21");
  2343. break;
  2344. case CvtColor::Mode::YUV2BGR_NV21:
  2345. props_.emplace_back("mode", "YUV2BGR_NV21");
  2346. break;
  2347. case CvtColor::Mode::YUV2GRAY_NV12:
  2348. props_.emplace_back("mode", "YUV2GRAY_NV12");
  2349. break;
  2350. case CvtColor::Mode::YUV2RGB_NV12:
  2351. props_.emplace_back("mode", "YUV2RGB_NV12");
  2352. break;
  2353. case CvtColor::Mode::YUV2BGR_NV12:
  2354. props_.emplace_back("mode", "YUV2BGR_NV12");
  2355. break;
  2356. case CvtColor::Mode::YUV2GRAY_YV12:
  2357. props_.emplace_back("mode", "YUV2GRAY_YV12");
  2358. break;
  2359. case CvtColor::Mode::YUV2RGB_YV12:
  2360. props_.emplace_back("mode", "YUV2RGB_YV12");
  2361. break;
  2362. case CvtColor::Mode::YUV2BGR_YV12:
  2363. props_.emplace_back("mode", "YUV2BGR_YV12");
  2364. break;
  2365. case CvtColor::Mode::YUV2GRAY_YU12:
  2366. props_.emplace_back("mode", "YUV2GRAY_YU12");
  2367. break;
  2368. case CvtColor::Mode::YUV2RGB_YU12:
  2369. props_.emplace_back("mode", "YUV2RGB_YU12");
  2370. break;
  2371. case CvtColor::Mode::YUV2BGR_YU12:
  2372. props_.emplace_back("mode", "YUV2BGR_YU12");
  2373. break;
  2374. case CvtColor::Mode::YCrCb2RGB:
  2375. props_.emplace_back("mode", "YCrCb2RGB");
  2376. break;
  2377. case CvtColor::Mode::YCrCb2BGR:
  2378. props_.emplace_back("mode", "YCrCb2BGR");
  2379. break;
  2380. case CvtColor::Mode::BT601_YUV2RGB_NV21:
  2381. props_.emplace_back("mode", "BT601_YUV2RGB_NV21");
  2382. break;
  2383. case CvtColor::Mode::BT601_YUV2BGR_NV21:
  2384. props_.emplace_back("mode", "BT601_YUV2BGR_NV21");
  2385. break;
  2386. case CvtColor::Mode::BT601_YUV2RGB_NV12:
  2387. props_.emplace_back("mode", "BT601_YUV2RGB_NV12");
  2388. break;
  2389. case CvtColor::Mode::BT601_YUV2BGR_NV12:
  2390. props_.emplace_back("mode", "BT601_YUV2BGR_NV12");
  2391. break;
  2392. case CvtColor::Mode::BT601_YUV2RGB_YV12:
  2393. props_.emplace_back("mode", "BT601_YUV2RGB_YV12");
  2394. break;
  2395. case CvtColor::Mode::BT601_YUV2BGR_YV12:
  2396. props_.emplace_back("mode", "BT601_YUV2BGR_YV12");
  2397. break;
  2398. case CvtColor::Mode::BT601_YUV2RGB_YU12:
  2399. props_.emplace_back("mode", "BT601_YUV2RGB_YU12");
  2400. break;
  2401. case CvtColor::Mode::BT601_YUV2BGR_YU12:
  2402. props_.emplace_back("mode", "BT601_YUV2BGR_YU12");
  2403. break;
  2404. default:
  2405. props_.emplace_back("mode", "INVALID");
  2406. break;
  2407. }
  2408. return props_;
  2409. }
  2410. std::string CvtColor_make_name_impl(const OpDef& def_) {
  2411. auto&& op_ = def_.cast_final_safe<CvtColor>();
  2412. static_cast<void>(op_);
  2413. return "CvtColor";
  2414. }
  2415. } // anonymous namespace
  2416. OP_TRAIT_REG(CvtColor, CvtColor)
  2417. .hash(CvtColor_hash_impl)
  2418. .is_same_st(CvtColor_is_same_st_impl)
  2419. .props(CvtColor_props_impl)
  2420. .make_name(CvtColor_make_name_impl);
  2421. MGB_DYN_TYPE_OBJ_FINAL_IMPL(DeformableConv);
  2422. namespace {
  2423. size_t DeformableConv_hash_impl(const OpDef& def_) {
  2424. auto&& op_ = def_.cast_final_safe<DeformableConv>();
  2425. static_cast<void>(op_);
  2426. size_t val = mgb::hash(op_.dyn_typeinfo());
  2427. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  2428. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  2429. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  2430. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  2431. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  2432. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
  2433. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
  2434. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
  2435. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  2436. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
  2437. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
  2438. val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
  2439. return val;
  2440. }
  2441. bool DeformableConv_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  2442. auto &&a_ = lhs_.cast_final_safe<DeformableConv>(),
  2443. &&b_ = rhs_.cast_final_safe<DeformableConv>();
  2444. static_cast<void>(a_);
  2445. static_cast<void>(b_);
  2446. if (a_.mode != b_.mode) return false;
  2447. if (a_.pad_h != b_.pad_h) return false;
  2448. if (a_.pad_w != b_.pad_w) return false;
  2449. if (a_.stride_h != b_.stride_h) return false;
  2450. if (a_.stride_w != b_.stride_w) return false;
  2451. if (a_.dilate_h != b_.dilate_h) return false;
  2452. if (a_.dilate_w != b_.dilate_w) return false;
  2453. if (a_.sparse != b_.sparse) return false;
  2454. if (a_.format != b_.format) return false;
  2455. if (a_.compute_mode != b_.compute_mode) return false;
  2456. if (a_.strategy != b_.strategy) return false;
  2457. if (a_.workspace_limit != b_.workspace_limit) return false;
  2458. return true;
  2459. }
  2460. std::vector<std::pair<const char*, std::string>> DeformableConv_props_impl(const OpDef& def_) {
  2461. auto&& op_ = def_.cast_final_safe<DeformableConv>();
  2462. static_cast<void>(op_);
  2463. std::vector<std::pair<const char*, std::string>> props_;
  2464. switch (op_.mode){
  2465. case DeformableConv::Mode::CROSS_CORRELATION:
  2466. props_.emplace_back("mode", "CROSS_CORRELATION");
  2467. break;
  2468. case DeformableConv::Mode::CONVOLUTION:
  2469. props_.emplace_back("mode", "CONVOLUTION");
  2470. break;
  2471. default:
  2472. props_.emplace_back("mode", "INVALID");
  2473. break;
  2474. }
  2475. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  2476. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  2477. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  2478. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  2479. props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
  2480. props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
  2481. switch (op_.sparse){
  2482. case DeformableConv::Sparse::DENSE:
  2483. props_.emplace_back("sparse", "DENSE");
  2484. break;
  2485. case DeformableConv::Sparse::GROUP:
  2486. props_.emplace_back("sparse", "GROUP");
  2487. break;
  2488. default:
  2489. props_.emplace_back("sparse", "INVALID");
  2490. break;
  2491. }
  2492. switch (op_.format){
  2493. case DeformableConv::Format::NCHW:
  2494. props_.emplace_back("format", "NCHW");
  2495. break;
  2496. case DeformableConv::Format::NHWC:
  2497. props_.emplace_back("format", "NHWC");
  2498. break;
  2499. case DeformableConv::Format::NHWCD4:
  2500. props_.emplace_back("format", "NHWCD4");
  2501. break;
  2502. case DeformableConv::Format::NCHW4:
  2503. props_.emplace_back("format", "NCHW4");
  2504. break;
  2505. case DeformableConv::Format::NCHW8:
  2506. props_.emplace_back("format", "NCHW8");
  2507. break;
  2508. case DeformableConv::Format::NCHW32:
  2509. props_.emplace_back("format", "NCHW32");
  2510. break;
  2511. case DeformableConv::Format::NCHW88:
  2512. props_.emplace_back("format", "NCHW88");
  2513. break;
  2514. case DeformableConv::Format::NCHW44:
  2515. props_.emplace_back("format", "NCHW44");
  2516. break;
  2517. case DeformableConv::Format::NCHW44_DOT:
  2518. props_.emplace_back("format", "NCHW44_DOT");
  2519. break;
  2520. case DeformableConv::Format::NCHW4_NCHW32:
  2521. props_.emplace_back("format", "NCHW4_NCHW32");
  2522. break;
  2523. case DeformableConv::Format::NCHW32_NCHW4:
  2524. props_.emplace_back("format", "NCHW32_NCHW4");
  2525. break;
  2526. case DeformableConv::Format::NCHW4_NCHW:
  2527. props_.emplace_back("format", "NCHW4_NCHW");
  2528. break;
  2529. case DeformableConv::Format::NHWC_NCHW:
  2530. props_.emplace_back("format", "NHWC_NCHW");
  2531. break;
  2532. case DeformableConv::Format::NHWC_NCHW4_IC_SMALL:
  2533. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  2534. break;
  2535. case DeformableConv::Format::NCHW_NCHW4_IC_SMALL:
  2536. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  2537. break;
  2538. case DeformableConv::Format::CHWN4:
  2539. props_.emplace_back("format", "CHWN4");
  2540. break;
  2541. case DeformableConv::Format::NCHW64:
  2542. props_.emplace_back("format", "NCHW64");
  2543. break;
  2544. case DeformableConv::Format::NCHW4_NHWC:
  2545. props_.emplace_back("format", "NCHW4_NHWC");
  2546. break;
  2547. default:
  2548. props_.emplace_back("format", "INVALID");
  2549. break;
  2550. }
  2551. switch (op_.compute_mode){
  2552. case DeformableConv::ComputeMode::DEFAULT:
  2553. props_.emplace_back("compute_mode", "DEFAULT");
  2554. break;
  2555. case DeformableConv::ComputeMode::FLOAT32:
  2556. props_.emplace_back("compute_mode", "FLOAT32");
  2557. break;
  2558. default:
  2559. props_.emplace_back("compute_mode", "INVALID");
  2560. break;
  2561. }
  2562. switch (op_.strategy){
  2563. case DeformableConv::Strategy::HEURISTIC:
  2564. props_.emplace_back("strategy", "HEURISTIC");
  2565. break;
  2566. case DeformableConv::Strategy::PROFILE:
  2567. props_.emplace_back("strategy", "PROFILE");
  2568. break;
  2569. case DeformableConv::Strategy::REPRODUCIBLE:
  2570. props_.emplace_back("strategy", "REPRODUCIBLE");
  2571. break;
  2572. case DeformableConv::Strategy::OPTIMIZED:
  2573. props_.emplace_back("strategy", "OPTIMIZED");
  2574. break;
  2575. default:
  2576. props_.emplace_back("strategy", "INVALID");
  2577. break;
  2578. }
  2579. props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
  2580. return props_;
  2581. }
  2582. std::string DeformableConv_make_name_impl(const OpDef& def_) {
  2583. auto&& op_ = def_.cast_final_safe<DeformableConv>();
  2584. static_cast<void>(op_);
  2585. return "DeformableConv";
  2586. }
  2587. } // anonymous namespace
  2588. OP_TRAIT_REG(DeformableConv, DeformableConv)
  2589. .hash(DeformableConv_hash_impl)
  2590. .is_same_st(DeformableConv_is_same_st_impl)
  2591. .props(DeformableConv_props_impl)
  2592. .make_name(DeformableConv_make_name_impl);
  2593. MGB_DYN_TYPE_OBJ_FINAL_IMPL(DeformablePSROIPooling);
  2594. namespace {
  2595. size_t DeformablePSROIPooling_hash_impl(const OpDef& def_) {
  2596. auto&& op_ = def_.cast_final_safe<DeformablePSROIPooling>();
  2597. static_cast<void>(op_);
  2598. size_t val = mgb::hash(op_.dyn_typeinfo());
  2599. val = mgb::hash_pair_combine(val, mgb::hash(op_.no_trans));
  2600. val = mgb::hash_pair_combine(val, mgb::hash(op_.spatial_scale));
  2601. val = mgb::hash_pair_combine(val, mgb::hash(op_.trans_std));
  2602. val = mgb::hash_pair_combine(val, mgb::hash(op_.pooled_h));
  2603. val = mgb::hash_pair_combine(val, mgb::hash(op_.pooled_w));
  2604. val = mgb::hash_pair_combine(val, mgb::hash(op_.part_size));
  2605. val = mgb::hash_pair_combine(val, mgb::hash(op_.sample_per_part));
  2606. return val;
  2607. }
  2608. bool DeformablePSROIPooling_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  2609. auto &&a_ = lhs_.cast_final_safe<DeformablePSROIPooling>(),
  2610. &&b_ = rhs_.cast_final_safe<DeformablePSROIPooling>();
  2611. static_cast<void>(a_);
  2612. static_cast<void>(b_);
  2613. if (a_.no_trans != b_.no_trans) return false;
  2614. if (a_.spatial_scale != b_.spatial_scale) return false;
  2615. if (a_.trans_std != b_.trans_std) return false;
  2616. if (a_.pooled_h != b_.pooled_h) return false;
  2617. if (a_.pooled_w != b_.pooled_w) return false;
  2618. if (a_.part_size != b_.part_size) return false;
  2619. if (a_.sample_per_part != b_.sample_per_part) return false;
  2620. return true;
  2621. }
  2622. std::vector<std::pair<const char*, std::string>> DeformablePSROIPooling_props_impl(const OpDef& def_) {
  2623. auto&& op_ = def_.cast_final_safe<DeformablePSROIPooling>();
  2624. static_cast<void>(op_);
  2625. std::vector<std::pair<const char*, std::string>> props_;
  2626. props_.emplace_back("no_trans", std::to_string(op_.no_trans));
  2627. props_.emplace_back("spatial_scale", std::to_string(op_.spatial_scale));
  2628. props_.emplace_back("trans_std", std::to_string(op_.trans_std));
  2629. props_.emplace_back("pooled_h", std::to_string(op_.pooled_h));
  2630. props_.emplace_back("pooled_w", std::to_string(op_.pooled_w));
  2631. props_.emplace_back("part_size", std::to_string(op_.part_size));
  2632. props_.emplace_back("sample_per_part", std::to_string(op_.sample_per_part));
  2633. return props_;
  2634. }
  2635. std::string DeformablePSROIPooling_make_name_impl(const OpDef& def_) {
  2636. auto&& op_ = def_.cast_final_safe<DeformablePSROIPooling>();
  2637. static_cast<void>(op_);
  2638. return "DeformablePSROIPooling";
  2639. }
  2640. } // anonymous namespace
  2641. OP_TRAIT_REG(DeformablePSROIPooling, DeformablePSROIPooling)
  2642. .hash(DeformablePSROIPooling_hash_impl)
  2643. .is_same_st(DeformablePSROIPooling_is_same_st_impl)
  2644. .props(DeformablePSROIPooling_props_impl)
  2645. .make_name(DeformablePSROIPooling_make_name_impl);
  2646. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Diag);
  2647. namespace {
  2648. size_t Diag_hash_impl(const OpDef& def_) {
  2649. auto&& op_ = def_.cast_final_safe<Diag>();
  2650. static_cast<void>(op_);
  2651. size_t val = mgb::hash(op_.dyn_typeinfo());
  2652. val = mgb::hash_pair_combine(val, mgb::hash(op_.k));
  2653. return val;
  2654. }
  2655. bool Diag_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  2656. auto &&a_ = lhs_.cast_final_safe<Diag>(),
  2657. &&b_ = rhs_.cast_final_safe<Diag>();
  2658. static_cast<void>(a_);
  2659. static_cast<void>(b_);
  2660. if (a_.k != b_.k) return false;
  2661. return true;
  2662. }
  2663. std::vector<std::pair<const char*, std::string>> Diag_props_impl(const OpDef& def_) {
  2664. auto&& op_ = def_.cast_final_safe<Diag>();
  2665. static_cast<void>(op_);
  2666. std::vector<std::pair<const char*, std::string>> props_;
  2667. props_.emplace_back("k", std::to_string(op_.k));
  2668. return props_;
  2669. }
  2670. std::string Diag_make_name_impl(const OpDef& def_) {
  2671. auto&& op_ = def_.cast_final_safe<Diag>();
  2672. static_cast<void>(op_);
  2673. return "Diag";
  2674. }
  2675. } // anonymous namespace
  2676. OP_TRAIT_REG(Diag, Diag)
  2677. .hash(Diag_hash_impl)
  2678. .is_same_st(Diag_is_same_st_impl)
  2679. .props(Diag_props_impl)
  2680. .make_name(Diag_make_name_impl);
  2681. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Dimshuffle);
  2682. namespace {
  2683. size_t Dimshuffle_hash_impl(const OpDef& def_) {
  2684. auto&& op_ = def_.cast_final_safe<Dimshuffle>();
  2685. static_cast<void>(op_);
  2686. size_t val = mgb::hash(op_.dyn_typeinfo());
  2687. val = mgb::hash_pair_combine(val, mgb::hash(op_.pattern));
  2688. return val;
  2689. }
  2690. bool Dimshuffle_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  2691. auto &&a_ = lhs_.cast_final_safe<Dimshuffle>(),
  2692. &&b_ = rhs_.cast_final_safe<Dimshuffle>();
  2693. static_cast<void>(a_);
  2694. static_cast<void>(b_);
  2695. if (a_.pattern != b_.pattern) return false;
  2696. return true;
  2697. }
  2698. std::vector<std::pair<const char*, std::string>> Dimshuffle_props_impl(const OpDef& def_) {
  2699. auto&& op_ = def_.cast_final_safe<Dimshuffle>();
  2700. static_cast<void>(op_);
  2701. std::vector<std::pair<const char*, std::string>> props_;
  2702. props_.emplace_back("pattern", "{std::vector}");
  2703. return props_;
  2704. }
  2705. std::string Dimshuffle_make_name_impl(const OpDef& def_) {
  2706. auto&& op_ = def_.cast_final_safe<Dimshuffle>();
  2707. static_cast<void>(op_);
  2708. return "Dimshuffle";
  2709. }
  2710. } // anonymous namespace
  2711. OP_TRAIT_REG(Dimshuffle, Dimshuffle)
  2712. .hash(Dimshuffle_hash_impl)
  2713. .is_same_st(Dimshuffle_is_same_st_impl)
  2714. .props(Dimshuffle_props_impl)
  2715. .make_name(Dimshuffle_make_name_impl);
  2716. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Dot);
  2717. namespace {
  2718. size_t Dot_hash_impl(const OpDef& def_) {
  2719. auto&& op_ = def_.cast_final_safe<Dot>();
  2720. static_cast<void>(op_);
  2721. size_t val = mgb::hash(op_.dyn_typeinfo());
  2722. return val;
  2723. }
  2724. bool Dot_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  2725. auto &&a_ = lhs_.cast_final_safe<Dot>(),
  2726. &&b_ = rhs_.cast_final_safe<Dot>();
  2727. static_cast<void>(a_);
  2728. static_cast<void>(b_);
  2729. return true;
  2730. }
  2731. std::vector<std::pair<const char*, std::string>> Dot_props_impl(const OpDef& def_) {
  2732. auto&& op_ = def_.cast_final_safe<Dot>();
  2733. static_cast<void>(op_);
  2734. std::vector<std::pair<const char*, std::string>> props_;
  2735. return props_;
  2736. }
  2737. std::string Dot_make_name_impl(const OpDef& def_) {
  2738. auto&& op_ = def_.cast_final_safe<Dot>();
  2739. static_cast<void>(op_);
  2740. return "Dot";
  2741. }
  2742. } // anonymous namespace
  2743. OP_TRAIT_REG(Dot, Dot)
  2744. .hash(Dot_hash_impl)
  2745. .is_same_st(Dot_is_same_st_impl)
  2746. .props(Dot_props_impl)
  2747. .make_name(Dot_make_name_impl);
  2748. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Dropout);
  2749. namespace {
  2750. size_t Dropout_hash_impl(const OpDef& def_) {
  2751. auto&& op_ = def_.cast_final_safe<Dropout>();
  2752. static_cast<void>(op_);
  2753. return mgb::hash_pair_combine(
  2754. mgb::hash(op_.dyn_typeinfo()),
  2755. mgb::hash_pair_combine(
  2756. mgb::hash(op_.drop_prob),
  2757. mgb::hash(op_.handle))
  2758. );
  2759. }
  2760. bool Dropout_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  2761. auto &&a_ = lhs_.cast_final_safe<Dropout>(),
  2762. &&b_ = rhs_.cast_final_safe<Dropout>();
  2763. static_cast<void>(a_);
  2764. static_cast<void>(b_);
  2765. return a_.handle == b_.handle && a_.drop_prob == b_.drop_prob;}
  2766. std::vector<std::pair<const char*, std::string>> Dropout_props_impl(const OpDef& def_) {
  2767. auto&& op_ = def_.cast_final_safe<Dropout>();
  2768. static_cast<void>(op_);
  2769. std::vector<std::pair<const char*, std::string>> props_;
  2770. props_.emplace_back("drop_prob", std::to_string(op_.drop_prob));
  2771. props_.emplace_back("seed", std::to_string(op_.seed));
  2772. props_.emplace_back("handle", std::to_string(op_.handle));
  2773. return props_;
  2774. }
  2775. std::string Dropout_make_name_impl(const OpDef& def_) {
  2776. auto&& op_ = def_.cast_final_safe<Dropout>();
  2777. static_cast<void>(op_);
  2778. return "Dropout";
  2779. }
  2780. } // anonymous namespace
  2781. OP_TRAIT_REG(Dropout, Dropout)
  2782. .hash(Dropout_hash_impl)
  2783. .is_same_st(Dropout_is_same_st_impl)
  2784. .props(Dropout_props_impl)
  2785. .make_name(Dropout_make_name_impl);
  2786. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Elemwise);
  2787. namespace {
  2788. size_t Elemwise_hash_impl(const OpDef& def_) {
  2789. auto&& op_ = def_.cast_final_safe<Elemwise>();
  2790. static_cast<void>(op_);
  2791. size_t val = mgb::hash(op_.dyn_typeinfo());
  2792. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  2793. return val;
  2794. }
  2795. bool Elemwise_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  2796. auto &&a_ = lhs_.cast_final_safe<Elemwise>(),
  2797. &&b_ = rhs_.cast_final_safe<Elemwise>();
  2798. static_cast<void>(a_);
  2799. static_cast<void>(b_);
  2800. if (a_.mode != b_.mode) return false;
  2801. return true;
  2802. }
  2803. std::vector<std::pair<const char*, std::string>> Elemwise_props_impl(const OpDef& def_) {
  2804. auto&& op_ = def_.cast_final_safe<Elemwise>();
  2805. static_cast<void>(op_);
  2806. std::vector<std::pair<const char*, std::string>> props_;
  2807. switch (op_.mode){
  2808. case Elemwise::Mode::RELU:
  2809. props_.emplace_back("mode", "RELU");
  2810. break;
  2811. case Elemwise::Mode::ABS:
  2812. props_.emplace_back("mode", "ABS");
  2813. break;
  2814. case Elemwise::Mode::ACOS:
  2815. props_.emplace_back("mode", "ACOS");
  2816. break;
  2817. case Elemwise::Mode::ASIN:
  2818. props_.emplace_back("mode", "ASIN");
  2819. break;
  2820. case Elemwise::Mode::CEIL:
  2821. props_.emplace_back("mode", "CEIL");
  2822. break;
  2823. case Elemwise::Mode::COS:
  2824. props_.emplace_back("mode", "COS");
  2825. break;
  2826. case Elemwise::Mode::EXP:
  2827. props_.emplace_back("mode", "EXP");
  2828. break;
  2829. case Elemwise::Mode::EXPM1:
  2830. props_.emplace_back("mode", "EXPM1");
  2831. break;
  2832. case Elemwise::Mode::FLOOR:
  2833. props_.emplace_back("mode", "FLOOR");
  2834. break;
  2835. case Elemwise::Mode::LOG:
  2836. props_.emplace_back("mode", "LOG");
  2837. break;
  2838. case Elemwise::Mode::LOG1P:
  2839. props_.emplace_back("mode", "LOG1P");
  2840. break;
  2841. case Elemwise::Mode::NEGATE:
  2842. props_.emplace_back("mode", "NEGATE");
  2843. break;
  2844. case Elemwise::Mode::SIGMOID:
  2845. props_.emplace_back("mode", "SIGMOID");
  2846. break;
  2847. case Elemwise::Mode::SIN:
  2848. props_.emplace_back("mode", "SIN");
  2849. break;
  2850. case Elemwise::Mode::TANH:
  2851. props_.emplace_back("mode", "TANH");
  2852. break;
  2853. case Elemwise::Mode::ABS_GRAD:
  2854. props_.emplace_back("mode", "ABS_GRAD");
  2855. break;
  2856. case Elemwise::Mode::ADD:
  2857. props_.emplace_back("mode", "ADD");
  2858. break;
  2859. case Elemwise::Mode::FLOOR_DIV:
  2860. props_.emplace_back("mode", "FLOOR_DIV");
  2861. break;
  2862. case Elemwise::Mode::MAX:
  2863. props_.emplace_back("mode", "MAX");
  2864. break;
  2865. case Elemwise::Mode::MIN:
  2866. props_.emplace_back("mode", "MIN");
  2867. break;
  2868. case Elemwise::Mode::MOD:
  2869. props_.emplace_back("mode", "MOD");
  2870. break;
  2871. case Elemwise::Mode::MUL:
  2872. props_.emplace_back("mode", "MUL");
  2873. break;
  2874. case Elemwise::Mode::POW:
  2875. props_.emplace_back("mode", "POW");
  2876. break;
  2877. case Elemwise::Mode::SIGMOID_GRAD:
  2878. props_.emplace_back("mode", "SIGMOID_GRAD");
  2879. break;
  2880. case Elemwise::Mode::SUB:
  2881. props_.emplace_back("mode", "SUB");
  2882. break;
  2883. case Elemwise::Mode::SWITCH_GT0:
  2884. props_.emplace_back("mode", "SWITCH_GT0");
  2885. break;
  2886. case Elemwise::Mode::TANH_GRAD:
  2887. props_.emplace_back("mode", "TANH_GRAD");
  2888. break;
  2889. case Elemwise::Mode::TRUE_DIV:
  2890. props_.emplace_back("mode", "TRUE_DIV");
  2891. break;
  2892. case Elemwise::Mode::LOG_SUM_EXP:
  2893. props_.emplace_back("mode", "LOG_SUM_EXP");
  2894. break;
  2895. case Elemwise::Mode::LT:
  2896. props_.emplace_back("mode", "LT");
  2897. break;
  2898. case Elemwise::Mode::LEQ:
  2899. props_.emplace_back("mode", "LEQ");
  2900. break;
  2901. case Elemwise::Mode::EQ:
  2902. props_.emplace_back("mode", "EQ");
  2903. break;
  2904. case Elemwise::Mode::SHL:
  2905. props_.emplace_back("mode", "SHL");
  2906. break;
  2907. case Elemwise::Mode::SHR:
  2908. props_.emplace_back("mode", "SHR");
  2909. break;
  2910. case Elemwise::Mode::COND_LEQ_MOV:
  2911. props_.emplace_back("mode", "COND_LEQ_MOV");
  2912. break;
  2913. case Elemwise::Mode::FUSE_MUL_ADD3:
  2914. props_.emplace_back("mode", "FUSE_MUL_ADD3");
  2915. break;
  2916. case Elemwise::Mode::FUSE_MUL_ADD4:
  2917. props_.emplace_back("mode", "FUSE_MUL_ADD4");
  2918. break;
  2919. case Elemwise::Mode::FUSE_ADD_RELU:
  2920. props_.emplace_back("mode", "FUSE_ADD_RELU");
  2921. break;
  2922. case Elemwise::Mode::FUSE_ADD_SIGMOID:
  2923. props_.emplace_back("mode", "FUSE_ADD_SIGMOID");
  2924. break;
  2925. case Elemwise::Mode::FUSE_ADD_TANH:
  2926. props_.emplace_back("mode", "FUSE_ADD_TANH");
  2927. break;
  2928. case Elemwise::Mode::FAST_TANH:
  2929. props_.emplace_back("mode", "FAST_TANH");
  2930. break;
  2931. case Elemwise::Mode::FAST_TANH_GRAD:
  2932. props_.emplace_back("mode", "FAST_TANH_GRAD");
  2933. break;
  2934. case Elemwise::Mode::ROUND:
  2935. props_.emplace_back("mode", "ROUND");
  2936. break;
  2937. case Elemwise::Mode::RMULH:
  2938. props_.emplace_back("mode", "RMULH");
  2939. break;
  2940. case Elemwise::Mode::ATAN2:
  2941. props_.emplace_back("mode", "ATAN2");
  2942. break;
  2943. case Elemwise::Mode::ERF:
  2944. props_.emplace_back("mode", "ERF");
  2945. break;
  2946. case Elemwise::Mode::ERFINV:
  2947. props_.emplace_back("mode", "ERFINV");
  2948. break;
  2949. case Elemwise::Mode::ERFC:
  2950. props_.emplace_back("mode", "ERFC");
  2951. break;
  2952. case Elemwise::Mode::ERFCINV:
  2953. props_.emplace_back("mode", "ERFCINV");
  2954. break;
  2955. case Elemwise::Mode::H_SWISH:
  2956. props_.emplace_back("mode", "H_SWISH");
  2957. break;
  2958. case Elemwise::Mode::H_SWISH_GRAD:
  2959. props_.emplace_back("mode", "H_SWISH_GRAD");
  2960. break;
  2961. case Elemwise::Mode::FUSE_ADD_H_SWISH:
  2962. props_.emplace_back("mode", "FUSE_ADD_H_SWISH");
  2963. break;
  2964. case Elemwise::Mode::NOT:
  2965. props_.emplace_back("mode", "NOT");
  2966. break;
  2967. case Elemwise::Mode::AND:
  2968. props_.emplace_back("mode", "AND");
  2969. break;
  2970. case Elemwise::Mode::OR:
  2971. props_.emplace_back("mode", "OR");
  2972. break;
  2973. case Elemwise::Mode::XOR:
  2974. props_.emplace_back("mode", "XOR");
  2975. break;
  2976. case Elemwise::Mode::SILU:
  2977. props_.emplace_back("mode", "SILU");
  2978. break;
  2979. case Elemwise::Mode::SILU_GRAD:
  2980. props_.emplace_back("mode", "SILU_GRAD");
  2981. break;
  2982. case Elemwise::Mode::GELU:
  2983. props_.emplace_back("mode", "GELU");
  2984. break;
  2985. case Elemwise::Mode::GELU_GRAD:
  2986. props_.emplace_back("mode", "GELU_GRAD");
  2987. break;
  2988. case Elemwise::Mode::COND_LT_MOV:
  2989. props_.emplace_back("mode", "COND_LT_MOV");
  2990. break;
  2991. case Elemwise::Mode::NEQ:
  2992. props_.emplace_back("mode", "NEQ");
  2993. break;
  2994. case Elemwise::Mode::ISNAN:
  2995. props_.emplace_back("mode", "ISNAN");
  2996. break;
  2997. case Elemwise::Mode::ISINF:
  2998. props_.emplace_back("mode", "ISINF");
  2999. break;
  3000. default:
  3001. props_.emplace_back("mode", "INVALID");
  3002. break;
  3003. }
  3004. return props_;
  3005. }
  3006. std::string Elemwise_make_name_impl(const OpDef& def_) {
  3007. auto&& op_ = def_.cast_final_safe<Elemwise>();
  3008. static_cast<void>(op_);
  3009. return to_string(op_.mode);
  3010. }
  3011. } // anonymous namespace
  3012. OP_TRAIT_REG(Elemwise, Elemwise)
  3013. .hash(Elemwise_hash_impl)
  3014. .is_same_st(Elemwise_is_same_st_impl)
  3015. .props(Elemwise_props_impl)
  3016. .make_name(Elemwise_make_name_impl);
  3017. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ElemwiseMultiType);
  3018. namespace {
  3019. size_t ElemwiseMultiType_hash_impl(const OpDef& def_) {
  3020. auto&& op_ = def_.cast_final_safe<ElemwiseMultiType>();
  3021. static_cast<void>(op_);
  3022. size_t val = mgb::hash(op_.dyn_typeinfo());
  3023. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  3024. val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
  3025. return val;
  3026. }
  3027. bool ElemwiseMultiType_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3028. auto &&a_ = lhs_.cast_final_safe<ElemwiseMultiType>(),
  3029. &&b_ = rhs_.cast_final_safe<ElemwiseMultiType>();
  3030. static_cast<void>(a_);
  3031. static_cast<void>(b_);
  3032. if (a_.mode != b_.mode) return false;
  3033. if (a_.dtype != b_.dtype) return false;
  3034. return true;
  3035. }
  3036. std::vector<std::pair<const char*, std::string>> ElemwiseMultiType_props_impl(const OpDef& def_) {
  3037. auto&& op_ = def_.cast_final_safe<ElemwiseMultiType>();
  3038. static_cast<void>(op_);
  3039. std::vector<std::pair<const char*, std::string>> props_;
  3040. switch (op_.mode){
  3041. case ElemwiseMultiType::Mode::FUSE_MUL_ADD3_INT16x32x32x32:
  3042. props_.emplace_back("mode", "FUSE_MUL_ADD3_INT16x32x32x32");
  3043. break;
  3044. case ElemwiseMultiType::Mode::FUSE_MUL_ADD3_IXxF32xF32xI8:
  3045. props_.emplace_back("mode", "FUSE_MUL_ADD3_IXxF32xF32xI8");
  3046. break;
  3047. case ElemwiseMultiType::Mode::ROUND_SHR_SATURATE_IXxI8xI8:
  3048. props_.emplace_back("mode", "ROUND_SHR_SATURATE_IXxI8xI8");
  3049. break;
  3050. case ElemwiseMultiType::Mode::FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT16x16x16x8:
  3051. props_.emplace_back("mode", "FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT16x16x16x8");
  3052. break;
  3053. case ElemwiseMultiType::Mode::FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT32x32x32x8:
  3054. props_.emplace_back("mode", "FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT32x32x32x8");
  3055. break;
  3056. case ElemwiseMultiType::Mode::ROUND_SHR_SATURATE_IXxI8xI16:
  3057. props_.emplace_back("mode", "ROUND_SHR_SATURATE_IXxI8xI16");
  3058. break;
  3059. case ElemwiseMultiType::Mode::QADD:
  3060. props_.emplace_back("mode", "QADD");
  3061. break;
  3062. case ElemwiseMultiType::Mode::QFUSE_ADD_RELU:
  3063. props_.emplace_back("mode", "QFUSE_ADD_RELU");
  3064. break;
  3065. case ElemwiseMultiType::Mode::QMUL:
  3066. props_.emplace_back("mode", "QMUL");
  3067. break;
  3068. case ElemwiseMultiType::Mode::QMIN:
  3069. props_.emplace_back("mode", "QMIN");
  3070. break;
  3071. case ElemwiseMultiType::Mode::QMAX:
  3072. props_.emplace_back("mode", "QMAX");
  3073. break;
  3074. case ElemwiseMultiType::Mode::QSUB:
  3075. props_.emplace_back("mode", "QSUB");
  3076. break;
  3077. case ElemwiseMultiType::Mode::QTRUE_DIV:
  3078. props_.emplace_back("mode", "QTRUE_DIV");
  3079. break;
  3080. case ElemwiseMultiType::Mode::QFUSE_ADD_SIGMOID:
  3081. props_.emplace_back("mode", "QFUSE_ADD_SIGMOID");
  3082. break;
  3083. case ElemwiseMultiType::Mode::QFUSE_ADD_TANH:
  3084. props_.emplace_back("mode", "QFUSE_ADD_TANH");
  3085. break;
  3086. case ElemwiseMultiType::Mode::QRELU:
  3087. props_.emplace_back("mode", "QRELU");
  3088. break;
  3089. case ElemwiseMultiType::Mode::QABS:
  3090. props_.emplace_back("mode", "QABS");
  3091. break;
  3092. case ElemwiseMultiType::Mode::QSIGMOID:
  3093. props_.emplace_back("mode", "QSIGMOID");
  3094. break;
  3095. case ElemwiseMultiType::Mode::QEXP:
  3096. props_.emplace_back("mode", "QEXP");
  3097. break;
  3098. case ElemwiseMultiType::Mode::QTANH:
  3099. props_.emplace_back("mode", "QTANH");
  3100. break;
  3101. case ElemwiseMultiType::Mode::QFUSE_MUL_ADD3:
  3102. props_.emplace_back("mode", "QFUSE_MUL_ADD3");
  3103. break;
  3104. case ElemwiseMultiType::Mode::QFAST_TANH:
  3105. props_.emplace_back("mode", "QFAST_TANH");
  3106. break;
  3107. case ElemwiseMultiType::Mode::QNEGATE:
  3108. props_.emplace_back("mode", "QNEGATE");
  3109. break;
  3110. case ElemwiseMultiType::Mode::QACOS:
  3111. props_.emplace_back("mode", "QACOS");
  3112. break;
  3113. case ElemwiseMultiType::Mode::QASIN:
  3114. props_.emplace_back("mode", "QASIN");
  3115. break;
  3116. case ElemwiseMultiType::Mode::QCEIL:
  3117. props_.emplace_back("mode", "QCEIL");
  3118. break;
  3119. case ElemwiseMultiType::Mode::QCOS:
  3120. props_.emplace_back("mode", "QCOS");
  3121. break;
  3122. case ElemwiseMultiType::Mode::QEXPM1:
  3123. props_.emplace_back("mode", "QEXPM1");
  3124. break;
  3125. case ElemwiseMultiType::Mode::QFLOOR:
  3126. props_.emplace_back("mode", "QFLOOR");
  3127. break;
  3128. case ElemwiseMultiType::Mode::QLOG:
  3129. props_.emplace_back("mode", "QLOG");
  3130. break;
  3131. case ElemwiseMultiType::Mode::QLOG1P:
  3132. props_.emplace_back("mode", "QLOG1P");
  3133. break;
  3134. case ElemwiseMultiType::Mode::QSIN:
  3135. props_.emplace_back("mode", "QSIN");
  3136. break;
  3137. case ElemwiseMultiType::Mode::QROUND:
  3138. props_.emplace_back("mode", "QROUND");
  3139. break;
  3140. case ElemwiseMultiType::Mode::QERF:
  3141. props_.emplace_back("mode", "QERF");
  3142. break;
  3143. case ElemwiseMultiType::Mode::QERFINV:
  3144. props_.emplace_back("mode", "QERFINV");
  3145. break;
  3146. case ElemwiseMultiType::Mode::QERFC:
  3147. props_.emplace_back("mode", "QERFC");
  3148. break;
  3149. case ElemwiseMultiType::Mode::QERFCINV:
  3150. props_.emplace_back("mode", "QERFCINV");
  3151. break;
  3152. case ElemwiseMultiType::Mode::QABS_GRAD:
  3153. props_.emplace_back("mode", "QABS_GRAD");
  3154. break;
  3155. case ElemwiseMultiType::Mode::QFLOOR_DIV:
  3156. props_.emplace_back("mode", "QFLOOR_DIV");
  3157. break;
  3158. case ElemwiseMultiType::Mode::QMOD:
  3159. props_.emplace_back("mode", "QMOD");
  3160. break;
  3161. case ElemwiseMultiType::Mode::QSIGMOID_GRAD:
  3162. props_.emplace_back("mode", "QSIGMOID_GRAD");
  3163. break;
  3164. case ElemwiseMultiType::Mode::QSWITCH_GT0:
  3165. props_.emplace_back("mode", "QSWITCH_GT0");
  3166. break;
  3167. case ElemwiseMultiType::Mode::QTANH_GRAD:
  3168. props_.emplace_back("mode", "QTANH_GRAD");
  3169. break;
  3170. case ElemwiseMultiType::Mode::QLT:
  3171. props_.emplace_back("mode", "QLT");
  3172. break;
  3173. case ElemwiseMultiType::Mode::QLEQ:
  3174. props_.emplace_back("mode", "QLEQ");
  3175. break;
  3176. case ElemwiseMultiType::Mode::QEQ:
  3177. props_.emplace_back("mode", "QEQ");
  3178. break;
  3179. case ElemwiseMultiType::Mode::QPOW:
  3180. props_.emplace_back("mode", "QPOW");
  3181. break;
  3182. case ElemwiseMultiType::Mode::QLOG_SUM_EXP:
  3183. props_.emplace_back("mode", "QLOG_SUM_EXP");
  3184. break;
  3185. case ElemwiseMultiType::Mode::QFAST_TANH_GRAD:
  3186. props_.emplace_back("mode", "QFAST_TANH_GRAD");
  3187. break;
  3188. case ElemwiseMultiType::Mode::QATAN2:
  3189. props_.emplace_back("mode", "QATAN2");
  3190. break;
  3191. case ElemwiseMultiType::Mode::QCOND_LEQ_MOV:
  3192. props_.emplace_back("mode", "QCOND_LEQ_MOV");
  3193. break;
  3194. case ElemwiseMultiType::Mode::QH_SWISH:
  3195. props_.emplace_back("mode", "QH_SWISH");
  3196. break;
  3197. case ElemwiseMultiType::Mode::QFUSE_ADD_H_SWISH:
  3198. props_.emplace_back("mode", "QFUSE_ADD_H_SWISH");
  3199. break;
  3200. case ElemwiseMultiType::Mode::QH_SWISH_GRAD:
  3201. props_.emplace_back("mode", "QH_SWISH_GRAD");
  3202. break;
  3203. case ElemwiseMultiType::Mode::FUSE_MUL_ADD3_INT16xF32xF32xF32:
  3204. props_.emplace_back("mode", "FUSE_MUL_ADD3_INT16xF32xF32xF32");
  3205. break;
  3206. case ElemwiseMultiType::Mode::MUL_INT16xF32xF32:
  3207. props_.emplace_back("mode", "MUL_INT16xF32xF32");
  3208. break;
  3209. case ElemwiseMultiType::Mode::FUSE_MUL_ADD3_UINT8xF32xF32xF32:
  3210. props_.emplace_back("mode", "FUSE_MUL_ADD3_UINT8xF32xF32xF32");
  3211. break;
  3212. case ElemwiseMultiType::Mode::QCOND_LT_MOV:
  3213. props_.emplace_back("mode", "QCOND_LT_MOV");
  3214. break;
  3215. case ElemwiseMultiType::Mode::EQ:
  3216. props_.emplace_back("mode", "EQ");
  3217. break;
  3218. case ElemwiseMultiType::Mode::NEQ:
  3219. props_.emplace_back("mode", "NEQ");
  3220. break;
  3221. case ElemwiseMultiType::Mode::LT:
  3222. props_.emplace_back("mode", "LT");
  3223. break;
  3224. case ElemwiseMultiType::Mode::LEQ:
  3225. props_.emplace_back("mode", "LEQ");
  3226. break;
  3227. case ElemwiseMultiType::Mode::ISNAN:
  3228. props_.emplace_back("mode", "ISNAN");
  3229. break;
  3230. case ElemwiseMultiType::Mode::ISINF:
  3231. props_.emplace_back("mode", "ISINF");
  3232. break;
  3233. default:
  3234. props_.emplace_back("mode", "INVALID");
  3235. break;
  3236. }
  3237. props_.emplace_back("dtype", op_.dtype.name());
  3238. return props_;
  3239. }
  3240. std::string ElemwiseMultiType_make_name_impl(const OpDef& def_) {
  3241. auto&& op_ = def_.cast_final_safe<ElemwiseMultiType>();
  3242. static_cast<void>(op_);
  3243. return to_string(op_.mode);
  3244. }
  3245. } // anonymous namespace
  3246. OP_TRAIT_REG(ElemwiseMultiType, ElemwiseMultiType)
  3247. .hash(ElemwiseMultiType_hash_impl)
  3248. .is_same_st(ElemwiseMultiType_is_same_st_impl)
  3249. .props(ElemwiseMultiType_props_impl)
  3250. .make_name(ElemwiseMultiType_make_name_impl);
  3251. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ExternOpr);
  3252. namespace {
  3253. size_t ExternOpr_hash_impl(const OpDef& def_) {
  3254. auto&& op_ = def_.cast_final_safe<ExternOpr>();
  3255. static_cast<void>(op_);
  3256. return mgb::hash_pair_combine(
  3257. mgb::hash(op_.dyn_typeinfo()),
  3258. mgb::hash_pair_combine(
  3259. mgb::hash(op_.name),
  3260. mgb::hash(op_.data))
  3261. );
  3262. }
  3263. bool ExternOpr_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3264. auto &&a_ = lhs_.cast_final_safe<ExternOpr>(),
  3265. &&b_ = rhs_.cast_final_safe<ExternOpr>();
  3266. static_cast<void>(a_);
  3267. static_cast<void>(b_);
  3268. if (a_.output_shapes != b_.output_shapes) return false;
  3269. if (a_.name != b_.name) return false;
  3270. if (a_.data != b_.data) return false;
  3271. if (a_.data_len != b_.data_len) return false;
  3272. if (a_.output_dtypes != b_.output_dtypes) return false;
  3273. return true;
  3274. }
  3275. std::vector<std::pair<const char*, std::string>> ExternOpr_props_impl(const OpDef& def_) {
  3276. auto&& op_ = def_.cast_final_safe<ExternOpr>();
  3277. static_cast<void>(op_);
  3278. std::vector<std::pair<const char*, std::string>> props_;
  3279. props_.emplace_back("output_shapes", "{std::vector}");
  3280. props_.emplace_back("name", op_.name);
  3281. props_.emplace_back("data", op_.data);
  3282. props_.emplace_back("data_len", std::to_string(op_.data_len));
  3283. props_.emplace_back("output_dtypes", "{std::vector}");
  3284. return props_;
  3285. }
  3286. std::string ExternOpr_make_name_impl(const OpDef& def_) {
  3287. auto&& op_ = def_.cast_final_safe<ExternOpr>();
  3288. static_cast<void>(op_);
  3289. return "ExternOpr";
  3290. }
  3291. } // anonymous namespace
  3292. OP_TRAIT_REG(ExternOpr, ExternOpr)
  3293. .hash(ExternOpr_hash_impl)
  3294. .is_same_st(ExternOpr_is_same_st_impl)
  3295. .props(ExternOpr_props_impl)
  3296. .make_name(ExternOpr_make_name_impl);
  3297. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Eye);
  3298. namespace {
  3299. size_t Eye_hash_impl(const OpDef& def_) {
  3300. auto&& op_ = def_.cast_final_safe<Eye>();
  3301. static_cast<void>(op_);
  3302. size_t val = mgb::hash(op_.dyn_typeinfo());
  3303. val = mgb::hash_pair_combine(val, mgb::hash(op_.k));
  3304. val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
  3305. val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
  3306. return val;
  3307. }
  3308. bool Eye_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3309. auto &&a_ = lhs_.cast_final_safe<Eye>(),
  3310. &&b_ = rhs_.cast_final_safe<Eye>();
  3311. static_cast<void>(a_);
  3312. static_cast<void>(b_);
  3313. if (a_.k != b_.k) return false;
  3314. if (a_.dtype != b_.dtype) return false;
  3315. if (a_.comp_node != b_.comp_node) return false;
  3316. return true;
  3317. }
  3318. std::vector<std::pair<const char*, std::string>> Eye_props_impl(const OpDef& def_) {
  3319. auto&& op_ = def_.cast_final_safe<Eye>();
  3320. static_cast<void>(op_);
  3321. std::vector<std::pair<const char*, std::string>> props_;
  3322. props_.emplace_back("k", std::to_string(op_.k));
  3323. props_.emplace_back("dtype", op_.dtype.name());
  3324. props_.emplace_back("comp_node", op_.comp_node.to_string());
  3325. return props_;
  3326. }
  3327. std::string Eye_make_name_impl(const OpDef& def_) {
  3328. auto&& op_ = def_.cast_final_safe<Eye>();
  3329. static_cast<void>(op_);
  3330. return "Eye";
  3331. }
  3332. } // anonymous namespace
  3333. OP_TRAIT_REG(Eye, Eye)
  3334. .hash(Eye_hash_impl)
  3335. .is_same_st(Eye_is_same_st_impl)
  3336. .props(Eye_props_impl)
  3337. .make_name(Eye_make_name_impl);
  3338. MGB_DYN_TYPE_OBJ_FINAL_IMPL(FakeQuant);
  3339. namespace {
  3340. size_t FakeQuant_hash_impl(const OpDef& def_) {
  3341. auto&& op_ = def_.cast_final_safe<FakeQuant>();
  3342. static_cast<void>(op_);
  3343. size_t val = mgb::hash(op_.dyn_typeinfo());
  3344. val = mgb::hash_pair_combine(val, mgb::hash(op_.qmin));
  3345. val = mgb::hash_pair_combine(val, mgb::hash(op_.qmax));
  3346. return val;
  3347. }
  3348. bool FakeQuant_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3349. auto &&a_ = lhs_.cast_final_safe<FakeQuant>(),
  3350. &&b_ = rhs_.cast_final_safe<FakeQuant>();
  3351. static_cast<void>(a_);
  3352. static_cast<void>(b_);
  3353. if (a_.qmin != b_.qmin) return false;
  3354. if (a_.qmax != b_.qmax) return false;
  3355. return true;
  3356. }
  3357. std::vector<std::pair<const char*, std::string>> FakeQuant_props_impl(const OpDef& def_) {
  3358. auto&& op_ = def_.cast_final_safe<FakeQuant>();
  3359. static_cast<void>(op_);
  3360. std::vector<std::pair<const char*, std::string>> props_;
  3361. props_.emplace_back("qmin", std::to_string(op_.qmin));
  3362. props_.emplace_back("qmax", std::to_string(op_.qmax));
  3363. return props_;
  3364. }
  3365. std::string FakeQuant_make_name_impl(const OpDef& def_) {
  3366. auto&& op_ = def_.cast_final_safe<FakeQuant>();
  3367. static_cast<void>(op_);
  3368. return "FakeQuant";
  3369. }
  3370. } // anonymous namespace
  3371. OP_TRAIT_REG(FakeQuant, FakeQuant)
  3372. .hash(FakeQuant_hash_impl)
  3373. .is_same_st(FakeQuant_is_same_st_impl)
  3374. .props(FakeQuant_props_impl)
  3375. .make_name(FakeQuant_make_name_impl);
  3376. MGB_DYN_TYPE_OBJ_FINAL_IMPL(FastpathCopy);
  3377. namespace {
  3378. size_t FastpathCopy_hash_impl(const OpDef& def_) {
  3379. auto&& op_ = def_.cast_final_safe<FastpathCopy>();
  3380. static_cast<void>(op_);
  3381. size_t val = mgb::hash(op_.dyn_typeinfo());
  3382. return val;
  3383. }
  3384. bool FastpathCopy_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3385. auto &&a_ = lhs_.cast_final_safe<FastpathCopy>(),
  3386. &&b_ = rhs_.cast_final_safe<FastpathCopy>();
  3387. static_cast<void>(a_);
  3388. static_cast<void>(b_);
  3389. return true;
  3390. }
  3391. std::vector<std::pair<const char*, std::string>> FastpathCopy_props_impl(const OpDef& def_) {
  3392. auto&& op_ = def_.cast_final_safe<FastpathCopy>();
  3393. static_cast<void>(op_);
  3394. std::vector<std::pair<const char*, std::string>> props_;
  3395. return props_;
  3396. }
  3397. std::string FastpathCopy_make_name_impl(const OpDef& def_) {
  3398. auto&& op_ = def_.cast_final_safe<FastpathCopy>();
  3399. static_cast<void>(op_);
  3400. return "FastpathCopy";
  3401. }
  3402. } // anonymous namespace
  3403. OP_TRAIT_REG(FastpathCopy, FastpathCopy)
  3404. .hash(FastpathCopy_hash_impl)
  3405. .is_same_st(FastpathCopy_is_same_st_impl)
  3406. .props(FastpathCopy_props_impl)
  3407. .make_name(FastpathCopy_make_name_impl);
  3408. MGB_DYN_TYPE_OBJ_FINAL_IMPL(GammaRNG);
  3409. namespace {
  3410. size_t GammaRNG_hash_impl(const OpDef& def_) {
  3411. auto&& op_ = def_.cast_final_safe<GammaRNG>();
  3412. static_cast<void>(op_);
  3413. return mgb::hash_pair_combine(
  3414. mgb::hash(op_.dyn_typeinfo()),
  3415. mgb::hash(op_.handle)
  3416. );
  3417. }
  3418. bool GammaRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3419. auto &&a_ = lhs_.cast_final_safe<GammaRNG>(),
  3420. &&b_ = rhs_.cast_final_safe<GammaRNG>();
  3421. static_cast<void>(a_);
  3422. static_cast<void>(b_);
  3423. return a_.handle == b_.handle;}
  3424. std::vector<std::pair<const char*, std::string>> GammaRNG_props_impl(const OpDef& def_) {
  3425. auto&& op_ = def_.cast_final_safe<GammaRNG>();
  3426. static_cast<void>(op_);
  3427. std::vector<std::pair<const char*, std::string>> props_;
  3428. props_.emplace_back("seed", std::to_string(op_.seed));
  3429. props_.emplace_back("handle", std::to_string(op_.handle));
  3430. return props_;
  3431. }
  3432. std::string GammaRNG_make_name_impl(const OpDef& def_) {
  3433. auto&& op_ = def_.cast_final_safe<GammaRNG>();
  3434. static_cast<void>(op_);
  3435. return "GammaRNG";
  3436. }
  3437. } // anonymous namespace
  3438. OP_TRAIT_REG(GammaRNG, GammaRNG)
  3439. .hash(GammaRNG_hash_impl)
  3440. .is_same_st(GammaRNG_is_same_st_impl)
  3441. .props(GammaRNG_props_impl)
  3442. .make_name(GammaRNG_make_name_impl);
  3443. MGB_DYN_TYPE_OBJ_FINAL_IMPL(GaussianRNG);
  3444. namespace {
  3445. size_t GaussianRNG_hash_impl(const OpDef& def_) {
  3446. auto&& op_ = def_.cast_final_safe<GaussianRNG>();
  3447. static_cast<void>(op_);
  3448. return mgb::hash_pair_combine(
  3449. mgb::hash(op_.dyn_typeinfo()),
  3450. mgb::hash_pair_combine(
  3451. mgb::hash(op_.handle),
  3452. mgb::hash_pair_combine(
  3453. mgb::hash(op_.mean),
  3454. mgb::hash_pair_combine(
  3455. mgb::hash(op_.std),
  3456. mgb::hash(op_.dtype.enumv())
  3457. )
  3458. )
  3459. )
  3460. );
  3461. }
  3462. bool GaussianRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3463. auto &&a_ = lhs_.cast_final_safe<GaussianRNG>(),
  3464. &&b_ = rhs_.cast_final_safe<GaussianRNG>();
  3465. static_cast<void>(a_);
  3466. static_cast<void>(b_);
  3467. return a_.handle == b_.handle && a_.mean == b_.mean && a_.std == b_.std && a_.dtype == b_.dtype;}
  3468. std::vector<std::pair<const char*, std::string>> GaussianRNG_props_impl(const OpDef& def_) {
  3469. auto&& op_ = def_.cast_final_safe<GaussianRNG>();
  3470. static_cast<void>(op_);
  3471. std::vector<std::pair<const char*, std::string>> props_;
  3472. props_.emplace_back("seed", std::to_string(op_.seed));
  3473. props_.emplace_back("mean", std::to_string(op_.mean));
  3474. props_.emplace_back("std", std::to_string(op_.std));
  3475. props_.emplace_back("dtype", op_.dtype.name());
  3476. props_.emplace_back("handle", std::to_string(op_.handle));
  3477. return props_;
  3478. }
  3479. std::string GaussianRNG_make_name_impl(const OpDef& def_) {
  3480. auto&& op_ = def_.cast_final_safe<GaussianRNG>();
  3481. static_cast<void>(op_);
  3482. return "GaussianRNG";
  3483. }
  3484. } // anonymous namespace
  3485. OP_TRAIT_REG(GaussianRNG, GaussianRNG)
  3486. .hash(GaussianRNG_hash_impl)
  3487. .is_same_st(GaussianRNG_is_same_st_impl)
  3488. .props(GaussianRNG_props_impl)
  3489. .make_name(GaussianRNG_make_name_impl);
  3490. MGB_DYN_TYPE_OBJ_FINAL_IMPL(GetVarShape);
  3491. namespace {
  3492. size_t GetVarShape_hash_impl(const OpDef& def_) {
  3493. auto&& op_ = def_.cast_final_safe<GetVarShape>();
  3494. static_cast<void>(op_);
  3495. size_t val = mgb::hash(op_.dyn_typeinfo());
  3496. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  3497. return val;
  3498. }
  3499. bool GetVarShape_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3500. auto &&a_ = lhs_.cast_final_safe<GetVarShape>(),
  3501. &&b_ = rhs_.cast_final_safe<GetVarShape>();
  3502. static_cast<void>(a_);
  3503. static_cast<void>(b_);
  3504. if (a_.axis != b_.axis) return false;
  3505. return true;
  3506. }
  3507. std::vector<std::pair<const char*, std::string>> GetVarShape_props_impl(const OpDef& def_) {
  3508. auto&& op_ = def_.cast_final_safe<GetVarShape>();
  3509. static_cast<void>(op_);
  3510. std::vector<std::pair<const char*, std::string>> props_;
  3511. props_.emplace_back("axis", std::to_string(op_.axis));
  3512. return props_;
  3513. }
  3514. std::string GetVarShape_make_name_impl(const OpDef& def_) {
  3515. auto&& op_ = def_.cast_final_safe<GetVarShape>();
  3516. static_cast<void>(op_);
  3517. return "GetVarShape";
  3518. }
  3519. } // anonymous namespace
  3520. OP_TRAIT_REG(GetVarShape, GetVarShape)
  3521. .hash(GetVarShape_hash_impl)
  3522. .is_same_st(GetVarShape_is_same_st_impl)
  3523. .props(GetVarShape_props_impl)
  3524. .make_name(GetVarShape_make_name_impl);
  3525. MGB_DYN_TYPE_OBJ_FINAL_IMPL(GroupLocal);
  3526. namespace {
  3527. size_t GroupLocal_hash_impl(const OpDef& def_) {
  3528. auto&& op_ = def_.cast_final_safe<GroupLocal>();
  3529. static_cast<void>(op_);
  3530. size_t val = mgb::hash(op_.dyn_typeinfo());
  3531. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  3532. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  3533. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  3534. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  3535. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  3536. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
  3537. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
  3538. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
  3539. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  3540. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
  3541. return val;
  3542. }
  3543. bool GroupLocal_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3544. auto &&a_ = lhs_.cast_final_safe<GroupLocal>(),
  3545. &&b_ = rhs_.cast_final_safe<GroupLocal>();
  3546. static_cast<void>(a_);
  3547. static_cast<void>(b_);
  3548. if (a_.mode != b_.mode) return false;
  3549. if (a_.pad_h != b_.pad_h) return false;
  3550. if (a_.pad_w != b_.pad_w) return false;
  3551. if (a_.stride_h != b_.stride_h) return false;
  3552. if (a_.stride_w != b_.stride_w) return false;
  3553. if (a_.dilate_h != b_.dilate_h) return false;
  3554. if (a_.dilate_w != b_.dilate_w) return false;
  3555. if (a_.sparse != b_.sparse) return false;
  3556. if (a_.format != b_.format) return false;
  3557. if (a_.compute_mode != b_.compute_mode) return false;
  3558. return true;
  3559. }
  3560. std::vector<std::pair<const char*, std::string>> GroupLocal_props_impl(const OpDef& def_) {
  3561. auto&& op_ = def_.cast_final_safe<GroupLocal>();
  3562. static_cast<void>(op_);
  3563. std::vector<std::pair<const char*, std::string>> props_;
  3564. switch (op_.mode){
  3565. case GroupLocal::Mode::CROSS_CORRELATION:
  3566. props_.emplace_back("mode", "CROSS_CORRELATION");
  3567. break;
  3568. case GroupLocal::Mode::CONVOLUTION:
  3569. props_.emplace_back("mode", "CONVOLUTION");
  3570. break;
  3571. default:
  3572. props_.emplace_back("mode", "INVALID");
  3573. break;
  3574. }
  3575. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  3576. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  3577. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  3578. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  3579. props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
  3580. props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
  3581. switch (op_.sparse){
  3582. case GroupLocal::Sparse::DENSE:
  3583. props_.emplace_back("sparse", "DENSE");
  3584. break;
  3585. case GroupLocal::Sparse::GROUP:
  3586. props_.emplace_back("sparse", "GROUP");
  3587. break;
  3588. default:
  3589. props_.emplace_back("sparse", "INVALID");
  3590. break;
  3591. }
  3592. switch (op_.format){
  3593. case GroupLocal::Format::NCHW:
  3594. props_.emplace_back("format", "NCHW");
  3595. break;
  3596. case GroupLocal::Format::NHWC:
  3597. props_.emplace_back("format", "NHWC");
  3598. break;
  3599. case GroupLocal::Format::NHWCD4:
  3600. props_.emplace_back("format", "NHWCD4");
  3601. break;
  3602. case GroupLocal::Format::NCHW4:
  3603. props_.emplace_back("format", "NCHW4");
  3604. break;
  3605. case GroupLocal::Format::NCHW8:
  3606. props_.emplace_back("format", "NCHW8");
  3607. break;
  3608. case GroupLocal::Format::NCHW32:
  3609. props_.emplace_back("format", "NCHW32");
  3610. break;
  3611. case GroupLocal::Format::NCHW88:
  3612. props_.emplace_back("format", "NCHW88");
  3613. break;
  3614. case GroupLocal::Format::NCHW44:
  3615. props_.emplace_back("format", "NCHW44");
  3616. break;
  3617. case GroupLocal::Format::NCHW44_DOT:
  3618. props_.emplace_back("format", "NCHW44_DOT");
  3619. break;
  3620. case GroupLocal::Format::NCHW4_NCHW32:
  3621. props_.emplace_back("format", "NCHW4_NCHW32");
  3622. break;
  3623. case GroupLocal::Format::NCHW32_NCHW4:
  3624. props_.emplace_back("format", "NCHW32_NCHW4");
  3625. break;
  3626. case GroupLocal::Format::NCHW4_NCHW:
  3627. props_.emplace_back("format", "NCHW4_NCHW");
  3628. break;
  3629. case GroupLocal::Format::NHWC_NCHW:
  3630. props_.emplace_back("format", "NHWC_NCHW");
  3631. break;
  3632. case GroupLocal::Format::NHWC_NCHW4_IC_SMALL:
  3633. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  3634. break;
  3635. case GroupLocal::Format::NCHW_NCHW4_IC_SMALL:
  3636. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  3637. break;
  3638. case GroupLocal::Format::CHWN4:
  3639. props_.emplace_back("format", "CHWN4");
  3640. break;
  3641. case GroupLocal::Format::NCHW64:
  3642. props_.emplace_back("format", "NCHW64");
  3643. break;
  3644. case GroupLocal::Format::NCHW4_NHWC:
  3645. props_.emplace_back("format", "NCHW4_NHWC");
  3646. break;
  3647. default:
  3648. props_.emplace_back("format", "INVALID");
  3649. break;
  3650. }
  3651. switch (op_.compute_mode){
  3652. case GroupLocal::ComputeMode::DEFAULT:
  3653. props_.emplace_back("compute_mode", "DEFAULT");
  3654. break;
  3655. case GroupLocal::ComputeMode::FLOAT32:
  3656. props_.emplace_back("compute_mode", "FLOAT32");
  3657. break;
  3658. default:
  3659. props_.emplace_back("compute_mode", "INVALID");
  3660. break;
  3661. }
  3662. return props_;
  3663. }
  3664. std::string GroupLocal_make_name_impl(const OpDef& def_) {
  3665. auto&& op_ = def_.cast_final_safe<GroupLocal>();
  3666. static_cast<void>(op_);
  3667. return "GroupLocal";
  3668. }
  3669. } // anonymous namespace
  3670. OP_TRAIT_REG(GroupLocal, GroupLocal)
  3671. .hash(GroupLocal_hash_impl)
  3672. .is_same_st(GroupLocal_is_same_st_impl)
  3673. .props(GroupLocal_props_impl)
  3674. .make_name(GroupLocal_make_name_impl);
  3675. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Identity);
  3676. namespace {
  3677. size_t Identity_hash_impl(const OpDef& def_) {
  3678. auto&& op_ = def_.cast_final_safe<Identity>();
  3679. static_cast<void>(op_);
  3680. size_t val = mgb::hash(op_.dyn_typeinfo());
  3681. return val;
  3682. }
  3683. bool Identity_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3684. auto &&a_ = lhs_.cast_final_safe<Identity>(),
  3685. &&b_ = rhs_.cast_final_safe<Identity>();
  3686. static_cast<void>(a_);
  3687. static_cast<void>(b_);
  3688. return true;
  3689. }
  3690. std::vector<std::pair<const char*, std::string>> Identity_props_impl(const OpDef& def_) {
  3691. auto&& op_ = def_.cast_final_safe<Identity>();
  3692. static_cast<void>(op_);
  3693. std::vector<std::pair<const char*, std::string>> props_;
  3694. return props_;
  3695. }
  3696. std::string Identity_make_name_impl(const OpDef& def_) {
  3697. auto&& op_ = def_.cast_final_safe<Identity>();
  3698. static_cast<void>(op_);
  3699. return "Identity";
  3700. }
  3701. } // anonymous namespace
  3702. OP_TRAIT_REG(Identity, Identity)
  3703. .hash(Identity_hash_impl)
  3704. .is_same_st(Identity_is_same_st_impl)
  3705. .props(Identity_props_impl)
  3706. .make_name(Identity_make_name_impl);
  3707. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Images2Neibs);
  3708. namespace {
  3709. size_t Images2Neibs_hash_impl(const OpDef& def_) {
  3710. auto&& op_ = def_.cast_final_safe<Images2Neibs>();
  3711. static_cast<void>(op_);
  3712. size_t val = mgb::hash(op_.dyn_typeinfo());
  3713. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  3714. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  3715. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  3716. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  3717. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
  3718. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
  3719. val = mgb::hash_pair_combine(val, mgb::hash(op_.window_h));
  3720. val = mgb::hash_pair_combine(val, mgb::hash(op_.window_w));
  3721. return val;
  3722. }
  3723. bool Images2Neibs_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3724. auto &&a_ = lhs_.cast_final_safe<Images2Neibs>(),
  3725. &&b_ = rhs_.cast_final_safe<Images2Neibs>();
  3726. static_cast<void>(a_);
  3727. static_cast<void>(b_);
  3728. if (a_.pad_h != b_.pad_h) return false;
  3729. if (a_.pad_w != b_.pad_w) return false;
  3730. if (a_.stride_h != b_.stride_h) return false;
  3731. if (a_.stride_w != b_.stride_w) return false;
  3732. if (a_.dilate_h != b_.dilate_h) return false;
  3733. if (a_.dilate_w != b_.dilate_w) return false;
  3734. if (a_.window_h != b_.window_h) return false;
  3735. if (a_.window_w != b_.window_w) return false;
  3736. return true;
  3737. }
  3738. std::vector<std::pair<const char*, std::string>> Images2Neibs_props_impl(const OpDef& def_) {
  3739. auto&& op_ = def_.cast_final_safe<Images2Neibs>();
  3740. static_cast<void>(op_);
  3741. std::vector<std::pair<const char*, std::string>> props_;
  3742. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  3743. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  3744. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  3745. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  3746. props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
  3747. props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
  3748. props_.emplace_back("window_h", std::to_string(op_.window_h));
  3749. props_.emplace_back("window_w", std::to_string(op_.window_w));
  3750. return props_;
  3751. }
  3752. std::string Images2Neibs_make_name_impl(const OpDef& def_) {
  3753. auto&& op_ = def_.cast_final_safe<Images2Neibs>();
  3754. static_cast<void>(op_);
  3755. return "Images2Neibs";
  3756. }
  3757. } // anonymous namespace
  3758. OP_TRAIT_REG(Images2Neibs, Images2Neibs)
  3759. .hash(Images2Neibs_hash_impl)
  3760. .is_same_st(Images2Neibs_is_same_st_impl)
  3761. .props(Images2Neibs_props_impl)
  3762. .make_name(Images2Neibs_make_name_impl);
  3763. MGB_DYN_TYPE_OBJ_FINAL_IMPL(IncrMeshIndexing);
  3764. namespace {
  3765. size_t IncrMeshIndexing_hash_impl(const OpDef& def_) {
  3766. auto&& op_ = def_.cast_final_safe<IncrMeshIndexing>();
  3767. static_cast<void>(op_);
  3768. size_t val = mgb::hash(op_.dyn_typeinfo());
  3769. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  3770. return val;
  3771. }
  3772. bool IncrMeshIndexing_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3773. auto &&a_ = lhs_.cast_final_safe<IncrMeshIndexing>(),
  3774. &&b_ = rhs_.cast_final_safe<IncrMeshIndexing>();
  3775. static_cast<void>(a_);
  3776. static_cast<void>(b_);
  3777. if (a_.items != b_.items) return false;
  3778. return true;
  3779. }
  3780. std::vector<std::pair<const char*, std::string>> IncrMeshIndexing_props_impl(const OpDef& def_) {
  3781. auto&& op_ = def_.cast_final_safe<IncrMeshIndexing>();
  3782. static_cast<void>(op_);
  3783. std::vector<std::pair<const char*, std::string>> props_;
  3784. props_.emplace_back("items", "{std::vector}");
  3785. return props_;
  3786. }
  3787. std::string IncrMeshIndexing_make_name_impl(const OpDef& def_) {
  3788. auto&& op_ = def_.cast_final_safe<IncrMeshIndexing>();
  3789. static_cast<void>(op_);
  3790. return "IncrMeshIndexing";
  3791. }
  3792. } // anonymous namespace
  3793. OP_TRAIT_REG(IncrMeshIndexing, IncrMeshIndexing)
  3794. .hash(IncrMeshIndexing_hash_impl)
  3795. .is_same_st(IncrMeshIndexing_is_same_st_impl)
  3796. .props(IncrMeshIndexing_props_impl)
  3797. .make_name(IncrMeshIndexing_make_name_impl);
  3798. MGB_DYN_TYPE_OBJ_FINAL_IMPL(IncrSubtensor);
  3799. namespace {
  3800. size_t IncrSubtensor_hash_impl(const OpDef& def_) {
  3801. auto&& op_ = def_.cast_final_safe<IncrSubtensor>();
  3802. static_cast<void>(op_);
  3803. size_t val = mgb::hash(op_.dyn_typeinfo());
  3804. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  3805. return val;
  3806. }
  3807. bool IncrSubtensor_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3808. auto &&a_ = lhs_.cast_final_safe<IncrSubtensor>(),
  3809. &&b_ = rhs_.cast_final_safe<IncrSubtensor>();
  3810. static_cast<void>(a_);
  3811. static_cast<void>(b_);
  3812. if (a_.items != b_.items) return false;
  3813. return true;
  3814. }
  3815. std::vector<std::pair<const char*, std::string>> IncrSubtensor_props_impl(const OpDef& def_) {
  3816. auto&& op_ = def_.cast_final_safe<IncrSubtensor>();
  3817. static_cast<void>(op_);
  3818. std::vector<std::pair<const char*, std::string>> props_;
  3819. props_.emplace_back("items", "{std::vector}");
  3820. return props_;
  3821. }
  3822. std::string IncrSubtensor_make_name_impl(const OpDef& def_) {
  3823. auto&& op_ = def_.cast_final_safe<IncrSubtensor>();
  3824. static_cast<void>(op_);
  3825. return "IncrSubtensor";
  3826. }
  3827. } // anonymous namespace
  3828. OP_TRAIT_REG(IncrSubtensor, IncrSubtensor)
  3829. .hash(IncrSubtensor_hash_impl)
  3830. .is_same_st(IncrSubtensor_is_same_st_impl)
  3831. .props(IncrSubtensor_props_impl)
  3832. .make_name(IncrSubtensor_make_name_impl);
  3833. MGB_DYN_TYPE_OBJ_FINAL_IMPL(IndexingIncrMultiAxisVec);
  3834. namespace {
  3835. size_t IndexingIncrMultiAxisVec_hash_impl(const OpDef& def_) {
  3836. auto&& op_ = def_.cast_final_safe<IndexingIncrMultiAxisVec>();
  3837. static_cast<void>(op_);
  3838. size_t val = mgb::hash(op_.dyn_typeinfo());
  3839. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  3840. return val;
  3841. }
  3842. bool IndexingIncrMultiAxisVec_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3843. auto &&a_ = lhs_.cast_final_safe<IndexingIncrMultiAxisVec>(),
  3844. &&b_ = rhs_.cast_final_safe<IndexingIncrMultiAxisVec>();
  3845. static_cast<void>(a_);
  3846. static_cast<void>(b_);
  3847. if (a_.items != b_.items) return false;
  3848. return true;
  3849. }
  3850. std::vector<std::pair<const char*, std::string>> IndexingIncrMultiAxisVec_props_impl(const OpDef& def_) {
  3851. auto&& op_ = def_.cast_final_safe<IndexingIncrMultiAxisVec>();
  3852. static_cast<void>(op_);
  3853. std::vector<std::pair<const char*, std::string>> props_;
  3854. props_.emplace_back("items", "{std::vector}");
  3855. return props_;
  3856. }
  3857. std::string IndexingIncrMultiAxisVec_make_name_impl(const OpDef& def_) {
  3858. auto&& op_ = def_.cast_final_safe<IndexingIncrMultiAxisVec>();
  3859. static_cast<void>(op_);
  3860. return "IndexingIncrMultiAxisVec";
  3861. }
  3862. } // anonymous namespace
  3863. OP_TRAIT_REG(IndexingIncrMultiAxisVec, IndexingIncrMultiAxisVec)
  3864. .hash(IndexingIncrMultiAxisVec_hash_impl)
  3865. .is_same_st(IndexingIncrMultiAxisVec_is_same_st_impl)
  3866. .props(IndexingIncrMultiAxisVec_props_impl)
  3867. .make_name(IndexingIncrMultiAxisVec_make_name_impl);
  3868. MGB_DYN_TYPE_OBJ_FINAL_IMPL(IndexingMultiAxisVec);
  3869. namespace {
  3870. size_t IndexingMultiAxisVec_hash_impl(const OpDef& def_) {
  3871. auto&& op_ = def_.cast_final_safe<IndexingMultiAxisVec>();
  3872. static_cast<void>(op_);
  3873. size_t val = mgb::hash(op_.dyn_typeinfo());
  3874. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  3875. return val;
  3876. }
  3877. bool IndexingMultiAxisVec_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3878. auto &&a_ = lhs_.cast_final_safe<IndexingMultiAxisVec>(),
  3879. &&b_ = rhs_.cast_final_safe<IndexingMultiAxisVec>();
  3880. static_cast<void>(a_);
  3881. static_cast<void>(b_);
  3882. if (a_.items != b_.items) return false;
  3883. return true;
  3884. }
  3885. std::vector<std::pair<const char*, std::string>> IndexingMultiAxisVec_props_impl(const OpDef& def_) {
  3886. auto&& op_ = def_.cast_final_safe<IndexingMultiAxisVec>();
  3887. static_cast<void>(op_);
  3888. std::vector<std::pair<const char*, std::string>> props_;
  3889. props_.emplace_back("items", "{std::vector}");
  3890. return props_;
  3891. }
  3892. std::string IndexingMultiAxisVec_make_name_impl(const OpDef& def_) {
  3893. auto&& op_ = def_.cast_final_safe<IndexingMultiAxisVec>();
  3894. static_cast<void>(op_);
  3895. return "IndexingMultiAxisVec";
  3896. }
  3897. } // anonymous namespace
  3898. OP_TRAIT_REG(IndexingMultiAxisVec, IndexingMultiAxisVec)
  3899. .hash(IndexingMultiAxisVec_hash_impl)
  3900. .is_same_st(IndexingMultiAxisVec_is_same_st_impl)
  3901. .props(IndexingMultiAxisVec_props_impl)
  3902. .make_name(IndexingMultiAxisVec_make_name_impl);
  3903. MGB_DYN_TYPE_OBJ_FINAL_IMPL(IndexingOneHot);
  3904. namespace {
  3905. size_t IndexingOneHot_hash_impl(const OpDef& def_) {
  3906. auto&& op_ = def_.cast_final_safe<IndexingOneHot>();
  3907. static_cast<void>(op_);
  3908. size_t val = mgb::hash(op_.dyn_typeinfo());
  3909. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  3910. val = mgb::hash_pair_combine(val, mgb::hash(op_.ndim));
  3911. return val;
  3912. }
  3913. bool IndexingOneHot_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3914. auto &&a_ = lhs_.cast_final_safe<IndexingOneHot>(),
  3915. &&b_ = rhs_.cast_final_safe<IndexingOneHot>();
  3916. static_cast<void>(a_);
  3917. static_cast<void>(b_);
  3918. if (a_.axis != b_.axis) return false;
  3919. if (a_.ndim != b_.ndim) return false;
  3920. return true;
  3921. }
  3922. std::vector<std::pair<const char*, std::string>> IndexingOneHot_props_impl(const OpDef& def_) {
  3923. auto&& op_ = def_.cast_final_safe<IndexingOneHot>();
  3924. static_cast<void>(op_);
  3925. std::vector<std::pair<const char*, std::string>> props_;
  3926. props_.emplace_back("axis", std::to_string(op_.axis));
  3927. props_.emplace_back("ndim", std::to_string(op_.ndim));
  3928. return props_;
  3929. }
  3930. std::string IndexingOneHot_make_name_impl(const OpDef& def_) {
  3931. auto&& op_ = def_.cast_final_safe<IndexingOneHot>();
  3932. static_cast<void>(op_);
  3933. return "IndexingOneHot";
  3934. }
  3935. } // anonymous namespace
  3936. OP_TRAIT_REG(IndexingOneHot, IndexingOneHot)
  3937. .hash(IndexingOneHot_hash_impl)
  3938. .is_same_st(IndexingOneHot_is_same_st_impl)
  3939. .props(IndexingOneHot_props_impl)
  3940. .make_name(IndexingOneHot_make_name_impl);
  3941. MGB_DYN_TYPE_OBJ_FINAL_IMPL(IndexingSetMultiAxisVec);
  3942. namespace {
  3943. size_t IndexingSetMultiAxisVec_hash_impl(const OpDef& def_) {
  3944. auto&& op_ = def_.cast_final_safe<IndexingSetMultiAxisVec>();
  3945. static_cast<void>(op_);
  3946. size_t val = mgb::hash(op_.dyn_typeinfo());
  3947. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  3948. return val;
  3949. }
  3950. bool IndexingSetMultiAxisVec_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3951. auto &&a_ = lhs_.cast_final_safe<IndexingSetMultiAxisVec>(),
  3952. &&b_ = rhs_.cast_final_safe<IndexingSetMultiAxisVec>();
  3953. static_cast<void>(a_);
  3954. static_cast<void>(b_);
  3955. if (a_.items != b_.items) return false;
  3956. return true;
  3957. }
  3958. std::vector<std::pair<const char*, std::string>> IndexingSetMultiAxisVec_props_impl(const OpDef& def_) {
  3959. auto&& op_ = def_.cast_final_safe<IndexingSetMultiAxisVec>();
  3960. static_cast<void>(op_);
  3961. std::vector<std::pair<const char*, std::string>> props_;
  3962. props_.emplace_back("items", "{std::vector}");
  3963. return props_;
  3964. }
  3965. std::string IndexingSetMultiAxisVec_make_name_impl(const OpDef& def_) {
  3966. auto&& op_ = def_.cast_final_safe<IndexingSetMultiAxisVec>();
  3967. static_cast<void>(op_);
  3968. return "IndexingSetMultiAxisVec";
  3969. }
  3970. } // anonymous namespace
  3971. OP_TRAIT_REG(IndexingSetMultiAxisVec, IndexingSetMultiAxisVec)
  3972. .hash(IndexingSetMultiAxisVec_hash_impl)
  3973. .is_same_st(IndexingSetMultiAxisVec_is_same_st_impl)
  3974. .props(IndexingSetMultiAxisVec_props_impl)
  3975. .make_name(IndexingSetMultiAxisVec_make_name_impl);
  3976. MGB_DYN_TYPE_OBJ_FINAL_IMPL(IndexingSetOneHot);
  3977. namespace {
  3978. size_t IndexingSetOneHot_hash_impl(const OpDef& def_) {
  3979. auto&& op_ = def_.cast_final_safe<IndexingSetOneHot>();
  3980. static_cast<void>(op_);
  3981. size_t val = mgb::hash(op_.dyn_typeinfo());
  3982. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  3983. val = mgb::hash_pair_combine(val, mgb::hash(op_.ndim));
  3984. return val;
  3985. }
  3986. bool IndexingSetOneHot_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3987. auto &&a_ = lhs_.cast_final_safe<IndexingSetOneHot>(),
  3988. &&b_ = rhs_.cast_final_safe<IndexingSetOneHot>();
  3989. static_cast<void>(a_);
  3990. static_cast<void>(b_);
  3991. if (a_.axis != b_.axis) return false;
  3992. if (a_.ndim != b_.ndim) return false;
  3993. return true;
  3994. }
  3995. std::vector<std::pair<const char*, std::string>> IndexingSetOneHot_props_impl(const OpDef& def_) {
  3996. auto&& op_ = def_.cast_final_safe<IndexingSetOneHot>();
  3997. static_cast<void>(op_);
  3998. std::vector<std::pair<const char*, std::string>> props_;
  3999. props_.emplace_back("axis", std::to_string(op_.axis));
  4000. props_.emplace_back("ndim", std::to_string(op_.ndim));
  4001. return props_;
  4002. }
  4003. std::string IndexingSetOneHot_make_name_impl(const OpDef& def_) {
  4004. auto&& op_ = def_.cast_final_safe<IndexingSetOneHot>();
  4005. static_cast<void>(op_);
  4006. return "IndexingSetOneHot";
  4007. }
  4008. } // anonymous namespace
  4009. OP_TRAIT_REG(IndexingSetOneHot, IndexingSetOneHot)
  4010. .hash(IndexingSetOneHot_hash_impl)
  4011. .is_same_st(IndexingSetOneHot_is_same_st_impl)
  4012. .props(IndexingSetOneHot_props_impl)
  4013. .make_name(IndexingSetOneHot_make_name_impl);
  4014. MGB_DYN_TYPE_OBJ_FINAL_IMPL(InplaceAdd);
  4015. namespace {
  4016. size_t InplaceAdd_hash_impl(const OpDef& def_) {
  4017. auto&& op_ = def_.cast_final_safe<InplaceAdd>();
  4018. static_cast<void>(op_);
  4019. size_t val = mgb::hash(op_.dyn_typeinfo());
  4020. return val;
  4021. }
  4022. bool InplaceAdd_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4023. auto &&a_ = lhs_.cast_final_safe<InplaceAdd>(),
  4024. &&b_ = rhs_.cast_final_safe<InplaceAdd>();
  4025. static_cast<void>(a_);
  4026. static_cast<void>(b_);
  4027. return true;
  4028. }
  4029. std::vector<std::pair<const char*, std::string>> InplaceAdd_props_impl(const OpDef& def_) {
  4030. auto&& op_ = def_.cast_final_safe<InplaceAdd>();
  4031. static_cast<void>(op_);
  4032. std::vector<std::pair<const char*, std::string>> props_;
  4033. return props_;
  4034. }
  4035. std::string InplaceAdd_make_name_impl(const OpDef& def_) {
  4036. auto&& op_ = def_.cast_final_safe<InplaceAdd>();
  4037. static_cast<void>(op_);
  4038. return "InplaceAdd";
  4039. }
  4040. } // anonymous namespace
  4041. OP_TRAIT_REG(InplaceAdd, InplaceAdd)
  4042. .hash(InplaceAdd_hash_impl)
  4043. .is_same_st(InplaceAdd_is_same_st_impl)
  4044. .props(InplaceAdd_props_impl)
  4045. .make_name(InplaceAdd_make_name_impl);
  4046. MGB_DYN_TYPE_OBJ_FINAL_IMPL(LAMBUpdate);
  4047. namespace {
  4048. size_t LAMBUpdate_hash_impl(const OpDef& def_) {
  4049. auto&& op_ = def_.cast_final_safe<LAMBUpdate>();
  4050. static_cast<void>(op_);
  4051. size_t val = mgb::hash(op_.dyn_typeinfo());
  4052. val = mgb::hash_pair_combine(val, mgb::hash(op_.beta_1));
  4053. val = mgb::hash_pair_combine(val, mgb::hash(op_.beta_2));
  4054. val = mgb::hash_pair_combine(val, mgb::hash(op_.step));
  4055. val = mgb::hash_pair_combine(val, mgb::hash(op_.lr));
  4056. val = mgb::hash_pair_combine(val, mgb::hash(op_.weight_decay));
  4057. val = mgb::hash_pair_combine(val, mgb::hash(op_.eps));
  4058. val = mgb::hash_pair_combine(val, mgb::hash(op_.bias_correction));
  4059. val = mgb::hash_pair_combine(val, mgb::hash(op_.always_adapt));
  4060. return val;
  4061. }
  4062. bool LAMBUpdate_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4063. auto &&a_ = lhs_.cast_final_safe<LAMBUpdate>(),
  4064. &&b_ = rhs_.cast_final_safe<LAMBUpdate>();
  4065. static_cast<void>(a_);
  4066. static_cast<void>(b_);
  4067. if (a_.beta_1 != b_.beta_1) return false;
  4068. if (a_.beta_2 != b_.beta_2) return false;
  4069. if (a_.step != b_.step) return false;
  4070. if (a_.lr != b_.lr) return false;
  4071. if (a_.weight_decay != b_.weight_decay) return false;
  4072. if (a_.eps != b_.eps) return false;
  4073. if (a_.bias_correction != b_.bias_correction) return false;
  4074. if (a_.always_adapt != b_.always_adapt) return false;
  4075. return true;
  4076. }
  4077. std::vector<std::pair<const char*, std::string>> LAMBUpdate_props_impl(const OpDef& def_) {
  4078. auto&& op_ = def_.cast_final_safe<LAMBUpdate>();
  4079. static_cast<void>(op_);
  4080. std::vector<std::pair<const char*, std::string>> props_;
  4081. props_.emplace_back("beta_1", std::to_string(op_.beta_1));
  4082. props_.emplace_back("beta_2", std::to_string(op_.beta_2));
  4083. props_.emplace_back("step", std::to_string(op_.step));
  4084. props_.emplace_back("lr", std::to_string(op_.lr));
  4085. props_.emplace_back("weight_decay", std::to_string(op_.weight_decay));
  4086. props_.emplace_back("eps", std::to_string(op_.eps));
  4087. props_.emplace_back("bias_correction", std::to_string(op_.bias_correction));
  4088. props_.emplace_back("always_adapt", std::to_string(op_.always_adapt));
  4089. return props_;
  4090. }
  4091. std::string LAMBUpdate_make_name_impl(const OpDef& def_) {
  4092. auto&& op_ = def_.cast_final_safe<LAMBUpdate>();
  4093. static_cast<void>(op_);
  4094. return "LAMBUpdate";
  4095. }
  4096. } // anonymous namespace
  4097. OP_TRAIT_REG(LAMBUpdate, LAMBUpdate)
  4098. .hash(LAMBUpdate_hash_impl)
  4099. .is_same_st(LAMBUpdate_is_same_st_impl)
  4100. .props(LAMBUpdate_props_impl)
  4101. .make_name(LAMBUpdate_make_name_impl);
  4102. MGB_DYN_TYPE_OBJ_FINAL_IMPL(LRN);
  4103. namespace {
  4104. size_t LRN_hash_impl(const OpDef& def_) {
  4105. auto&& op_ = def_.cast_final_safe<LRN>();
  4106. static_cast<void>(op_);
  4107. size_t val = mgb::hash(op_.dyn_typeinfo());
  4108. val = mgb::hash_pair_combine(val, mgb::hash(op_.n));
  4109. val = mgb::hash_pair_combine(val, mgb::hash(op_.k));
  4110. val = mgb::hash_pair_combine(val, mgb::hash(op_.alpha));
  4111. val = mgb::hash_pair_combine(val, mgb::hash(op_.beta));
  4112. return val;
  4113. }
  4114. bool LRN_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4115. auto &&a_ = lhs_.cast_final_safe<LRN>(),
  4116. &&b_ = rhs_.cast_final_safe<LRN>();
  4117. static_cast<void>(a_);
  4118. static_cast<void>(b_);
  4119. if (a_.n != b_.n) return false;
  4120. if (a_.k != b_.k) return false;
  4121. if (a_.alpha != b_.alpha) return false;
  4122. if (a_.beta != b_.beta) return false;
  4123. return true;
  4124. }
  4125. std::vector<std::pair<const char*, std::string>> LRN_props_impl(const OpDef& def_) {
  4126. auto&& op_ = def_.cast_final_safe<LRN>();
  4127. static_cast<void>(op_);
  4128. std::vector<std::pair<const char*, std::string>> props_;
  4129. props_.emplace_back("n", std::to_string(op_.n));
  4130. props_.emplace_back("k", std::to_string(op_.k));
  4131. props_.emplace_back("alpha", std::to_string(op_.alpha));
  4132. props_.emplace_back("beta", std::to_string(op_.beta));
  4133. return props_;
  4134. }
  4135. std::string LRN_make_name_impl(const OpDef& def_) {
  4136. auto&& op_ = def_.cast_final_safe<LRN>();
  4137. static_cast<void>(op_);
  4138. return "LRN";
  4139. }
  4140. } // anonymous namespace
  4141. OP_TRAIT_REG(LRN, LRN)
  4142. .hash(LRN_hash_impl)
  4143. .is_same_st(LRN_is_same_st_impl)
  4144. .props(LRN_props_impl)
  4145. .make_name(LRN_make_name_impl);
  4146. MGB_DYN_TYPE_OBJ_FINAL_IMPL(LSQ);
  4147. namespace {
  4148. size_t LSQ_hash_impl(const OpDef& def_) {
  4149. auto&& op_ = def_.cast_final_safe<LSQ>();
  4150. static_cast<void>(op_);
  4151. size_t val = mgb::hash(op_.dyn_typeinfo());
  4152. val = mgb::hash_pair_combine(val, mgb::hash(op_.qmin));
  4153. val = mgb::hash_pair_combine(val, mgb::hash(op_.qmax));
  4154. return val;
  4155. }
  4156. bool LSQ_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4157. auto &&a_ = lhs_.cast_final_safe<LSQ>(),
  4158. &&b_ = rhs_.cast_final_safe<LSQ>();
  4159. static_cast<void>(a_);
  4160. static_cast<void>(b_);
  4161. if (a_.qmin != b_.qmin) return false;
  4162. if (a_.qmax != b_.qmax) return false;
  4163. return true;
  4164. }
  4165. std::vector<std::pair<const char*, std::string>> LSQ_props_impl(const OpDef& def_) {
  4166. auto&& op_ = def_.cast_final_safe<LSQ>();
  4167. static_cast<void>(op_);
  4168. std::vector<std::pair<const char*, std::string>> props_;
  4169. props_.emplace_back("qmin", std::to_string(op_.qmin));
  4170. props_.emplace_back("qmax", std::to_string(op_.qmax));
  4171. return props_;
  4172. }
  4173. std::string LSQ_make_name_impl(const OpDef& def_) {
  4174. auto&& op_ = def_.cast_final_safe<LSQ>();
  4175. static_cast<void>(op_);
  4176. return "LSQ";
  4177. }
  4178. } // anonymous namespace
  4179. OP_TRAIT_REG(LSQ, LSQ)
  4180. .hash(LSQ_hash_impl)
  4181. .is_same_st(LSQ_is_same_st_impl)
  4182. .props(LSQ_props_impl)
  4183. .make_name(LSQ_make_name_impl);
  4184. MGB_DYN_TYPE_OBJ_FINAL_IMPL(LSTM);
  4185. namespace {
  4186. size_t LSTM_hash_impl(const OpDef& def_) {
  4187. auto&& op_ = def_.cast_final_safe<LSTM>();
  4188. static_cast<void>(op_);
  4189. size_t val = mgb::hash(op_.dyn_typeinfo());
  4190. val = mgb::hash_pair_combine(val, mgb::hash(op_.num_layers));
  4191. val = mgb::hash_pair_combine(val, mgb::hash(op_.bidirectional));
  4192. val = mgb::hash_pair_combine(val, mgb::hash(op_.bias));
  4193. val = mgb::hash_pair_combine(val, mgb::hash(op_.hidden_size));
  4194. val = mgb::hash_pair_combine(val, mgb::hash(op_.proj_size));
  4195. val = mgb::hash_pair_combine(val, mgb::hash(op_.dropout));
  4196. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.fwd_mode));
  4197. return val;
  4198. }
  4199. bool LSTM_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4200. auto &&a_ = lhs_.cast_final_safe<LSTM>(),
  4201. &&b_ = rhs_.cast_final_safe<LSTM>();
  4202. static_cast<void>(a_);
  4203. static_cast<void>(b_);
  4204. if (a_.num_layers != b_.num_layers) return false;
  4205. if (a_.bidirectional != b_.bidirectional) return false;
  4206. if (a_.bias != b_.bias) return false;
  4207. if (a_.hidden_size != b_.hidden_size) return false;
  4208. if (a_.proj_size != b_.proj_size) return false;
  4209. if (a_.dropout != b_.dropout) return false;
  4210. if (a_.fwd_mode != b_.fwd_mode) return false;
  4211. return true;
  4212. }
  4213. std::vector<std::pair<const char*, std::string>> LSTM_props_impl(const OpDef& def_) {
  4214. auto&& op_ = def_.cast_final_safe<LSTM>();
  4215. static_cast<void>(op_);
  4216. std::vector<std::pair<const char*, std::string>> props_;
  4217. props_.emplace_back("num_layers", std::to_string(op_.num_layers));
  4218. props_.emplace_back("bidirectional", std::to_string(op_.bidirectional));
  4219. props_.emplace_back("bias", std::to_string(op_.bias));
  4220. props_.emplace_back("hidden_size", std::to_string(op_.hidden_size));
  4221. props_.emplace_back("proj_size", std::to_string(op_.proj_size));
  4222. props_.emplace_back("dropout", std::to_string(op_.dropout));
  4223. switch (op_.fwd_mode){
  4224. case LSTM::FwdMode::TRAINING:
  4225. props_.emplace_back("fwd_mode", "TRAINING");
  4226. break;
  4227. case LSTM::FwdMode::INFERENCE:
  4228. props_.emplace_back("fwd_mode", "INFERENCE");
  4229. break;
  4230. default:
  4231. props_.emplace_back("fwd_mode", "INVALID");
  4232. break;
  4233. }
  4234. return props_;
  4235. }
  4236. std::string LSTM_make_name_impl(const OpDef& def_) {
  4237. auto&& op_ = def_.cast_final_safe<LSTM>();
  4238. static_cast<void>(op_);
  4239. return "LSTM";
  4240. }
  4241. } // anonymous namespace
  4242. OP_TRAIT_REG(LSTM, LSTM)
  4243. .hash(LSTM_hash_impl)
  4244. .is_same_st(LSTM_is_same_st_impl)
  4245. .props(LSTM_props_impl)
  4246. .make_name(LSTM_make_name_impl);
  4247. MGB_DYN_TYPE_OBJ_FINAL_IMPL(LSTMCell);
  4248. namespace {
  4249. size_t LSTMCell_hash_impl(const OpDef& def_) {
  4250. auto&& op_ = def_.cast_final_safe<LSTMCell>();
  4251. static_cast<void>(op_);
  4252. size_t val = mgb::hash(op_.dyn_typeinfo());
  4253. return val;
  4254. }
  4255. bool LSTMCell_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4256. auto &&a_ = lhs_.cast_final_safe<LSTMCell>(),
  4257. &&b_ = rhs_.cast_final_safe<LSTMCell>();
  4258. static_cast<void>(a_);
  4259. static_cast<void>(b_);
  4260. return true;
  4261. }
  4262. std::vector<std::pair<const char*, std::string>> LSTMCell_props_impl(const OpDef& def_) {
  4263. auto&& op_ = def_.cast_final_safe<LSTMCell>();
  4264. static_cast<void>(op_);
  4265. std::vector<std::pair<const char*, std::string>> props_;
  4266. return props_;
  4267. }
  4268. std::string LSTMCell_make_name_impl(const OpDef& def_) {
  4269. auto&& op_ = def_.cast_final_safe<LSTMCell>();
  4270. static_cast<void>(op_);
  4271. return "LSTMCell";
  4272. }
  4273. } // anonymous namespace
  4274. OP_TRAIT_REG(LSTMCell, LSTMCell)
  4275. .hash(LSTMCell_hash_impl)
  4276. .is_same_st(LSTMCell_is_same_st_impl)
  4277. .props(LSTMCell_props_impl)
  4278. .make_name(LSTMCell_make_name_impl);
  4279. MGB_DYN_TYPE_OBJ_FINAL_IMPL(LayerNorm);
  4280. namespace {
  4281. size_t LayerNorm_hash_impl(const OpDef& def_) {
  4282. auto&& op_ = def_.cast_final_safe<LayerNorm>();
  4283. static_cast<void>(op_);
  4284. size_t val = mgb::hash(op_.dyn_typeinfo());
  4285. val = mgb::hash_pair_combine(val, mgb::hash(op_.affine));
  4286. val = mgb::hash_pair_combine(val, mgb::hash(op_.eps));
  4287. val = mgb::hash_pair_combine(val, mgb::hash(op_.normalized_dim));
  4288. val = mgb::hash_pair_combine(val, mgb::hash(op_.normalized_size));
  4289. return val;
  4290. }
  4291. bool LayerNorm_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4292. auto &&a_ = lhs_.cast_final_safe<LayerNorm>(),
  4293. &&b_ = rhs_.cast_final_safe<LayerNorm>();
  4294. static_cast<void>(a_);
  4295. static_cast<void>(b_);
  4296. if (a_.affine != b_.affine) return false;
  4297. if (a_.eps != b_.eps) return false;
  4298. if (a_.normalized_dim != b_.normalized_dim) return false;
  4299. if (a_.normalized_size != b_.normalized_size) return false;
  4300. return true;
  4301. }
  4302. std::vector<std::pair<const char*, std::string>> LayerNorm_props_impl(const OpDef& def_) {
  4303. auto&& op_ = def_.cast_final_safe<LayerNorm>();
  4304. static_cast<void>(op_);
  4305. std::vector<std::pair<const char*, std::string>> props_;
  4306. props_.emplace_back("affine", std::to_string(op_.affine));
  4307. props_.emplace_back("eps", std::to_string(op_.eps));
  4308. props_.emplace_back("normalized_dim", std::to_string(op_.normalized_dim));
  4309. props_.emplace_back("normalized_size", std::to_string(op_.normalized_size));
  4310. return props_;
  4311. }
  4312. std::string LayerNorm_make_name_impl(const OpDef& def_) {
  4313. auto&& op_ = def_.cast_final_safe<LayerNorm>();
  4314. static_cast<void>(op_);
  4315. return "LayerNorm";
  4316. }
  4317. } // anonymous namespace
  4318. OP_TRAIT_REG(LayerNorm, LayerNorm)
  4319. .hash(LayerNorm_hash_impl)
  4320. .is_same_st(LayerNorm_is_same_st_impl)
  4321. .props(LayerNorm_props_impl)
  4322. .make_name(LayerNorm_make_name_impl);
  4323. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Linspace);
  4324. namespace {
  4325. size_t Linspace_hash_impl(const OpDef& def_) {
  4326. auto&& op_ = def_.cast_final_safe<Linspace>();
  4327. static_cast<void>(op_);
  4328. size_t val = mgb::hash(op_.dyn_typeinfo());
  4329. val = mgb::hash_pair_combine(val, mgb::hash(op_.endpoint));
  4330. val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
  4331. return val;
  4332. }
  4333. bool Linspace_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4334. auto &&a_ = lhs_.cast_final_safe<Linspace>(),
  4335. &&b_ = rhs_.cast_final_safe<Linspace>();
  4336. static_cast<void>(a_);
  4337. static_cast<void>(b_);
  4338. if (a_.endpoint != b_.endpoint) return false;
  4339. if (a_.comp_node != b_.comp_node) return false;
  4340. return true;
  4341. }
  4342. std::vector<std::pair<const char*, std::string>> Linspace_props_impl(const OpDef& def_) {
  4343. auto&& op_ = def_.cast_final_safe<Linspace>();
  4344. static_cast<void>(op_);
  4345. std::vector<std::pair<const char*, std::string>> props_;
  4346. props_.emplace_back("endpoint", std::to_string(op_.endpoint));
  4347. props_.emplace_back("comp_node", op_.comp_node.to_string());
  4348. return props_;
  4349. }
  4350. std::string Linspace_make_name_impl(const OpDef& def_) {
  4351. auto&& op_ = def_.cast_final_safe<Linspace>();
  4352. static_cast<void>(op_);
  4353. return "Linspace";
  4354. }
  4355. } // anonymous namespace
  4356. OP_TRAIT_REG(Linspace, Linspace)
  4357. .hash(Linspace_hash_impl)
  4358. .is_same_st(Linspace_is_same_st_impl)
  4359. .props(Linspace_props_impl)
  4360. .make_name(Linspace_make_name_impl);
  4361. MGB_DYN_TYPE_OBJ_FINAL_IMPL(MagicMindRuntime);
  4362. namespace {
  4363. size_t MagicMindRuntime_hash_impl(const OpDef& def_) {
  4364. auto&& op_ = def_.cast_final_safe<MagicMindRuntime>();
  4365. static_cast<void>(op_);
  4366. size_t val = mgb::hash(op_.dyn_typeinfo());
  4367. val = mgb::hash_pair_combine(val, mgb::hash(op_.buf));
  4368. val = mgb::hash_pair_combine(val, mgb::hash(op_.buf_size));
  4369. return val;
  4370. }
  4371. bool MagicMindRuntime_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4372. auto &&a_ = lhs_.cast_final_safe<MagicMindRuntime>(),
  4373. &&b_ = rhs_.cast_final_safe<MagicMindRuntime>();
  4374. static_cast<void>(a_);
  4375. static_cast<void>(b_);
  4376. if (a_.buf != b_.buf) return false;
  4377. if (a_.buf_size != b_.buf_size) return false;
  4378. return true;
  4379. }
  4380. std::vector<std::pair<const char*, std::string>> MagicMindRuntime_props_impl(const OpDef& def_) {
  4381. auto&& op_ = def_.cast_final_safe<MagicMindRuntime>();
  4382. static_cast<void>(op_);
  4383. std::vector<std::pair<const char*, std::string>> props_;
  4384. props_.emplace_back("buf", op_.buf);
  4385. props_.emplace_back("buf_size", std::to_string(op_.buf_size));
  4386. return props_;
  4387. }
  4388. std::string MagicMindRuntime_make_name_impl(const OpDef& def_) {
  4389. auto&& op_ = def_.cast_final_safe<MagicMindRuntime>();
  4390. static_cast<void>(op_);
  4391. return "MagicMindRuntime";
  4392. }
  4393. } // anonymous namespace
  4394. OP_TRAIT_REG(MagicMindRuntime, MagicMindRuntime)
  4395. .hash(MagicMindRuntime_hash_impl)
  4396. .is_same_st(MagicMindRuntime_is_same_st_impl)
  4397. .props(MagicMindRuntime_props_impl)
  4398. .make_name(MagicMindRuntime_make_name_impl);
  4399. MGB_DYN_TYPE_OBJ_FINAL_IMPL(MatrixInverse);
  4400. namespace {
  4401. size_t MatrixInverse_hash_impl(const OpDef& def_) {
  4402. auto&& op_ = def_.cast_final_safe<MatrixInverse>();
  4403. static_cast<void>(op_);
  4404. size_t val = mgb::hash(op_.dyn_typeinfo());
  4405. return val;
  4406. }
  4407. bool MatrixInverse_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4408. auto &&a_ = lhs_.cast_final_safe<MatrixInverse>(),
  4409. &&b_ = rhs_.cast_final_safe<MatrixInverse>();
  4410. static_cast<void>(a_);
  4411. static_cast<void>(b_);
  4412. return true;
  4413. }
  4414. std::vector<std::pair<const char*, std::string>> MatrixInverse_props_impl(const OpDef& def_) {
  4415. auto&& op_ = def_.cast_final_safe<MatrixInverse>();
  4416. static_cast<void>(op_);
  4417. std::vector<std::pair<const char*, std::string>> props_;
  4418. return props_;
  4419. }
  4420. std::string MatrixInverse_make_name_impl(const OpDef& def_) {
  4421. auto&& op_ = def_.cast_final_safe<MatrixInverse>();
  4422. static_cast<void>(op_);
  4423. return "MatrixInverse";
  4424. }
  4425. } // anonymous namespace
  4426. OP_TRAIT_REG(MatrixInverse, MatrixInverse)
  4427. .hash(MatrixInverse_hash_impl)
  4428. .is_same_st(MatrixInverse_is_same_st_impl)
  4429. .props(MatrixInverse_props_impl)
  4430. .make_name(MatrixInverse_make_name_impl);
  4431. MGB_DYN_TYPE_OBJ_FINAL_IMPL(MatrixMul);
  4432. namespace {
  4433. size_t MatrixMul_hash_impl(const OpDef& def_) {
  4434. auto&& op_ = def_.cast_final_safe<MatrixMul>();
  4435. static_cast<void>(op_);
  4436. size_t val = mgb::hash(op_.dyn_typeinfo());
  4437. val = mgb::hash_pair_combine(val, mgb::hash(op_.transposeA));
  4438. val = mgb::hash_pair_combine(val, mgb::hash(op_.transposeB));
  4439. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
  4440. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  4441. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
  4442. val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
  4443. val = mgb::hash_pair_combine(val, mgb::hash(op_.dimA));
  4444. val = mgb::hash_pair_combine(val, mgb::hash(op_.dimB));
  4445. return val;
  4446. }
  4447. bool MatrixMul_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4448. auto &&a_ = lhs_.cast_final_safe<MatrixMul>(),
  4449. &&b_ = rhs_.cast_final_safe<MatrixMul>();
  4450. static_cast<void>(a_);
  4451. static_cast<void>(b_);
  4452. if (a_.transposeA != b_.transposeA) return false;
  4453. if (a_.transposeB != b_.transposeB) return false;
  4454. if (a_.compute_mode != b_.compute_mode) return false;
  4455. if (a_.format != b_.format) return false;
  4456. if (a_.strategy != b_.strategy) return false;
  4457. if (a_.workspace_limit != b_.workspace_limit) return false;
  4458. if (a_.dimA != b_.dimA) return false;
  4459. if (a_.dimB != b_.dimB) return false;
  4460. return true;
  4461. }
  4462. std::vector<std::pair<const char*, std::string>> MatrixMul_props_impl(const OpDef& def_) {
  4463. auto&& op_ = def_.cast_final_safe<MatrixMul>();
  4464. static_cast<void>(op_);
  4465. std::vector<std::pair<const char*, std::string>> props_;
  4466. props_.emplace_back("transposeA", std::to_string(op_.transposeA));
  4467. props_.emplace_back("transposeB", std::to_string(op_.transposeB));
  4468. switch (op_.compute_mode){
  4469. case MatrixMul::ComputeMode::DEFAULT:
  4470. props_.emplace_back("compute_mode", "DEFAULT");
  4471. break;
  4472. case MatrixMul::ComputeMode::FLOAT32:
  4473. props_.emplace_back("compute_mode", "FLOAT32");
  4474. break;
  4475. default:
  4476. props_.emplace_back("compute_mode", "INVALID");
  4477. break;
  4478. }
  4479. switch (op_.format){
  4480. case MatrixMul::Format::DEFAULT:
  4481. props_.emplace_back("format", "DEFAULT");
  4482. break;
  4483. case MatrixMul::Format::MK4:
  4484. props_.emplace_back("format", "MK4");
  4485. break;
  4486. case MatrixMul::Format::MK8:
  4487. props_.emplace_back("format", "MK8");
  4488. break;
  4489. case MatrixMul::Format::MK4_DOT:
  4490. props_.emplace_back("format", "MK4_DOT");
  4491. break;
  4492. case MatrixMul::Format::N32K4_DOT:
  4493. props_.emplace_back("format", "N32K4_DOT");
  4494. break;
  4495. default:
  4496. props_.emplace_back("format", "INVALID");
  4497. break;
  4498. }
  4499. switch (op_.strategy){
  4500. case MatrixMul::Strategy::HEURISTIC:
  4501. props_.emplace_back("strategy", "HEURISTIC");
  4502. break;
  4503. case MatrixMul::Strategy::PROFILE:
  4504. props_.emplace_back("strategy", "PROFILE");
  4505. break;
  4506. case MatrixMul::Strategy::REPRODUCIBLE:
  4507. props_.emplace_back("strategy", "REPRODUCIBLE");
  4508. break;
  4509. case MatrixMul::Strategy::OPTIMIZED:
  4510. props_.emplace_back("strategy", "OPTIMIZED");
  4511. break;
  4512. default:
  4513. props_.emplace_back("strategy", "INVALID");
  4514. break;
  4515. }
  4516. props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
  4517. props_.emplace_back("dimA", std::to_string(op_.dimA));
  4518. props_.emplace_back("dimB", std::to_string(op_.dimB));
  4519. return props_;
  4520. }
  4521. std::string MatrixMul_make_name_impl(const OpDef& def_) {
  4522. auto&& op_ = def_.cast_final_safe<MatrixMul>();
  4523. static_cast<void>(op_);
  4524. return "MatrixMul";
  4525. }
  4526. } // anonymous namespace
  4527. OP_TRAIT_REG(MatrixMul, MatrixMul)
  4528. .hash(MatrixMul_hash_impl)
  4529. .is_same_st(MatrixMul_is_same_st_impl)
  4530. .props(MatrixMul_props_impl)
  4531. .make_name(MatrixMul_make_name_impl);
  4532. MGB_DYN_TYPE_OBJ_FINAL_IMPL(MeshIndexing);
  4533. namespace {
  4534. size_t MeshIndexing_hash_impl(const OpDef& def_) {
  4535. auto&& op_ = def_.cast_final_safe<MeshIndexing>();
  4536. static_cast<void>(op_);
  4537. size_t val = mgb::hash(op_.dyn_typeinfo());
  4538. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  4539. return val;
  4540. }
  4541. bool MeshIndexing_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4542. auto &&a_ = lhs_.cast_final_safe<MeshIndexing>(),
  4543. &&b_ = rhs_.cast_final_safe<MeshIndexing>();
  4544. static_cast<void>(a_);
  4545. static_cast<void>(b_);
  4546. if (a_.items != b_.items) return false;
  4547. return true;
  4548. }
  4549. std::vector<std::pair<const char*, std::string>> MeshIndexing_props_impl(const OpDef& def_) {
  4550. auto&& op_ = def_.cast_final_safe<MeshIndexing>();
  4551. static_cast<void>(op_);
  4552. std::vector<std::pair<const char*, std::string>> props_;
  4553. props_.emplace_back("items", "{std::vector}");
  4554. return props_;
  4555. }
  4556. std::string MeshIndexing_make_name_impl(const OpDef& def_) {
  4557. auto&& op_ = def_.cast_final_safe<MeshIndexing>();
  4558. static_cast<void>(op_);
  4559. return "MeshIndexing";
  4560. }
  4561. } // anonymous namespace
  4562. OP_TRAIT_REG(MeshIndexing, MeshIndexing)
  4563. .hash(MeshIndexing_hash_impl)
  4564. .is_same_st(MeshIndexing_is_same_st_impl)
  4565. .props(MeshIndexing_props_impl)
  4566. .make_name(MeshIndexing_make_name_impl);
  4567. MGB_DYN_TYPE_OBJ_FINAL_IMPL(NMSKeep);
  4568. namespace {
  4569. size_t NMSKeep_hash_impl(const OpDef& def_) {
  4570. auto&& op_ = def_.cast_final_safe<NMSKeep>();
  4571. static_cast<void>(op_);
  4572. size_t val = mgb::hash(op_.dyn_typeinfo());
  4573. val = mgb::hash_pair_combine(val, mgb::hash(op_.iou_thresh));
  4574. val = mgb::hash_pair_combine(val, mgb::hash(op_.max_output));
  4575. return val;
  4576. }
  4577. bool NMSKeep_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4578. auto &&a_ = lhs_.cast_final_safe<NMSKeep>(),
  4579. &&b_ = rhs_.cast_final_safe<NMSKeep>();
  4580. static_cast<void>(a_);
  4581. static_cast<void>(b_);
  4582. if (a_.iou_thresh != b_.iou_thresh) return false;
  4583. if (a_.max_output != b_.max_output) return false;
  4584. return true;
  4585. }
  4586. std::vector<std::pair<const char*, std::string>> NMSKeep_props_impl(const OpDef& def_) {
  4587. auto&& op_ = def_.cast_final_safe<NMSKeep>();
  4588. static_cast<void>(op_);
  4589. std::vector<std::pair<const char*, std::string>> props_;
  4590. props_.emplace_back("iou_thresh", std::to_string(op_.iou_thresh));
  4591. props_.emplace_back("max_output", std::to_string(op_.max_output));
  4592. return props_;
  4593. }
  4594. std::string NMSKeep_make_name_impl(const OpDef& def_) {
  4595. auto&& op_ = def_.cast_final_safe<NMSKeep>();
  4596. static_cast<void>(op_);
  4597. return "NMSKeep";
  4598. }
  4599. } // anonymous namespace
  4600. OP_TRAIT_REG(NMSKeep, NMSKeep)
  4601. .hash(NMSKeep_hash_impl)
  4602. .is_same_st(NMSKeep_is_same_st_impl)
  4603. .props(NMSKeep_props_impl)
  4604. .make_name(NMSKeep_make_name_impl);
  4605. MGB_DYN_TYPE_OBJ_FINAL_IMPL(NvOf);
  4606. namespace {
  4607. size_t NvOf_hash_impl(const OpDef& def_) {
  4608. auto&& op_ = def_.cast_final_safe<NvOf>();
  4609. static_cast<void>(op_);
  4610. size_t val = mgb::hash(op_.dyn_typeinfo());
  4611. val = mgb::hash_pair_combine(val, mgb::hash(op_.precision));
  4612. return val;
  4613. }
  4614. bool NvOf_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4615. auto &&a_ = lhs_.cast_final_safe<NvOf>(),
  4616. &&b_ = rhs_.cast_final_safe<NvOf>();
  4617. static_cast<void>(a_);
  4618. static_cast<void>(b_);
  4619. if (a_.precision != b_.precision) return false;
  4620. return true;
  4621. }
  4622. std::vector<std::pair<const char*, std::string>> NvOf_props_impl(const OpDef& def_) {
  4623. auto&& op_ = def_.cast_final_safe<NvOf>();
  4624. static_cast<void>(op_);
  4625. std::vector<std::pair<const char*, std::string>> props_;
  4626. props_.emplace_back("precision", std::to_string(op_.precision));
  4627. return props_;
  4628. }
  4629. std::string NvOf_make_name_impl(const OpDef& def_) {
  4630. auto&& op_ = def_.cast_final_safe<NvOf>();
  4631. static_cast<void>(op_);
  4632. return "NvOf";
  4633. }
  4634. } // anonymous namespace
  4635. OP_TRAIT_REG(NvOf, NvOf)
  4636. .hash(NvOf_hash_impl)
  4637. .is_same_st(NvOf_is_same_st_impl)
  4638. .props(NvOf_props_impl)
  4639. .make_name(NvOf_make_name_impl);
  4640. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Padding);
  4641. namespace {
  4642. size_t Padding_hash_impl(const OpDef& def_) {
  4643. auto&& op_ = def_.cast_final_safe<Padding>();
  4644. static_cast<void>(op_);
  4645. size_t val = mgb::hash(op_.dyn_typeinfo());
  4646. val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim0));
  4647. val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim1));
  4648. val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim2));
  4649. val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim3));
  4650. val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim4));
  4651. val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim5));
  4652. val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim6));
  4653. val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim0));
  4654. val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim1));
  4655. val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim2));
  4656. val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim3));
  4657. val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim4));
  4658. val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim5));
  4659. val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim6));
  4660. val = mgb::hash_pair_combine(val, mgb::hash(op_.padding_val));
  4661. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.padding_mode));
  4662. return val;
  4663. }
  4664. bool Padding_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4665. auto &&a_ = lhs_.cast_final_safe<Padding>(),
  4666. &&b_ = rhs_.cast_final_safe<Padding>();
  4667. static_cast<void>(a_);
  4668. static_cast<void>(b_);
  4669. if (a_.front_offset_dim0 != b_.front_offset_dim0) return false;
  4670. if (a_.front_offset_dim1 != b_.front_offset_dim1) return false;
  4671. if (a_.front_offset_dim2 != b_.front_offset_dim2) return false;
  4672. if (a_.front_offset_dim3 != b_.front_offset_dim3) return false;
  4673. if (a_.front_offset_dim4 != b_.front_offset_dim4) return false;
  4674. if (a_.front_offset_dim5 != b_.front_offset_dim5) return false;
  4675. if (a_.front_offset_dim6 != b_.front_offset_dim6) return false;
  4676. if (a_.back_offset_dim0 != b_.back_offset_dim0) return false;
  4677. if (a_.back_offset_dim1 != b_.back_offset_dim1) return false;
  4678. if (a_.back_offset_dim2 != b_.back_offset_dim2) return false;
  4679. if (a_.back_offset_dim3 != b_.back_offset_dim3) return false;
  4680. if (a_.back_offset_dim4 != b_.back_offset_dim4) return false;
  4681. if (a_.back_offset_dim5 != b_.back_offset_dim5) return false;
  4682. if (a_.back_offset_dim6 != b_.back_offset_dim6) return false;
  4683. if (a_.padding_val != b_.padding_val) return false;
  4684. if (a_.padding_mode != b_.padding_mode) return false;
  4685. return true;
  4686. }
  4687. std::vector<std::pair<const char*, std::string>> Padding_props_impl(const OpDef& def_) {
  4688. auto&& op_ = def_.cast_final_safe<Padding>();
  4689. static_cast<void>(op_);
  4690. std::vector<std::pair<const char*, std::string>> props_;
  4691. props_.emplace_back("front_offset_dim0", std::to_string(op_.front_offset_dim0));
  4692. props_.emplace_back("front_offset_dim1", std::to_string(op_.front_offset_dim1));
  4693. props_.emplace_back("front_offset_dim2", std::to_string(op_.front_offset_dim2));
  4694. props_.emplace_back("front_offset_dim3", std::to_string(op_.front_offset_dim3));
  4695. props_.emplace_back("front_offset_dim4", std::to_string(op_.front_offset_dim4));
  4696. props_.emplace_back("front_offset_dim5", std::to_string(op_.front_offset_dim5));
  4697. props_.emplace_back("front_offset_dim6", std::to_string(op_.front_offset_dim6));
  4698. props_.emplace_back("back_offset_dim0", std::to_string(op_.back_offset_dim0));
  4699. props_.emplace_back("back_offset_dim1", std::to_string(op_.back_offset_dim1));
  4700. props_.emplace_back("back_offset_dim2", std::to_string(op_.back_offset_dim2));
  4701. props_.emplace_back("back_offset_dim3", std::to_string(op_.back_offset_dim3));
  4702. props_.emplace_back("back_offset_dim4", std::to_string(op_.back_offset_dim4));
  4703. props_.emplace_back("back_offset_dim5", std::to_string(op_.back_offset_dim5));
  4704. props_.emplace_back("back_offset_dim6", std::to_string(op_.back_offset_dim6));
  4705. props_.emplace_back("padding_val", std::to_string(op_.padding_val));
  4706. switch (op_.padding_mode){
  4707. case Padding::PaddingMode::REPLICATE:
  4708. props_.emplace_back("padding_mode", "REPLICATE");
  4709. break;
  4710. case Padding::PaddingMode::REFLECT:
  4711. props_.emplace_back("padding_mode", "REFLECT");
  4712. break;
  4713. case Padding::PaddingMode::CONSTANT:
  4714. props_.emplace_back("padding_mode", "CONSTANT");
  4715. break;
  4716. default:
  4717. props_.emplace_back("padding_mode", "INVALID");
  4718. break;
  4719. }
  4720. return props_;
  4721. }
  4722. std::string Padding_make_name_impl(const OpDef& def_) {
  4723. auto&& op_ = def_.cast_final_safe<Padding>();
  4724. static_cast<void>(op_);
  4725. return "Padding";
  4726. }
  4727. } // anonymous namespace
  4728. OP_TRAIT_REG(Padding, Padding)
  4729. .hash(Padding_hash_impl)
  4730. .is_same_st(Padding_is_same_st_impl)
  4731. .props(Padding_props_impl)
  4732. .make_name(Padding_make_name_impl);
  4733. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ParamPackConcat);
  4734. namespace {
  4735. size_t ParamPackConcat_hash_impl(const OpDef& def_) {
  4736. auto&& op_ = def_.cast_final_safe<ParamPackConcat>();
  4737. static_cast<void>(op_);
  4738. size_t val = mgb::hash(op_.dyn_typeinfo());
  4739. val = mgb::hash_pair_combine(val, mgb::hash(op_.offsets));
  4740. return val;
  4741. }
  4742. bool ParamPackConcat_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4743. auto &&a_ = lhs_.cast_final_safe<ParamPackConcat>(),
  4744. &&b_ = rhs_.cast_final_safe<ParamPackConcat>();
  4745. static_cast<void>(a_);
  4746. static_cast<void>(b_);
  4747. if (a_.offsets != b_.offsets) return false;
  4748. return true;
  4749. }
  4750. std::vector<std::pair<const char*, std::string>> ParamPackConcat_props_impl(const OpDef& def_) {
  4751. auto&& op_ = def_.cast_final_safe<ParamPackConcat>();
  4752. static_cast<void>(op_);
  4753. std::vector<std::pair<const char*, std::string>> props_;
  4754. props_.emplace_back("offsets", "{std::vector}");
  4755. return props_;
  4756. }
  4757. std::string ParamPackConcat_make_name_impl(const OpDef& def_) {
  4758. auto&& op_ = def_.cast_final_safe<ParamPackConcat>();
  4759. static_cast<void>(op_);
  4760. return "ParamPackConcat";
  4761. }
  4762. } // anonymous namespace
  4763. OP_TRAIT_REG(ParamPackConcat, ParamPackConcat)
  4764. .hash(ParamPackConcat_hash_impl)
  4765. .is_same_st(ParamPackConcat_is_same_st_impl)
  4766. .props(ParamPackConcat_props_impl)
  4767. .make_name(ParamPackConcat_make_name_impl);
  4768. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ParamPackSplit);
  4769. namespace {
  4770. size_t ParamPackSplit_hash_impl(const OpDef& def_) {
  4771. auto&& op_ = def_.cast_final_safe<ParamPackSplit>();
  4772. static_cast<void>(op_);
  4773. size_t val = mgb::hash(op_.dyn_typeinfo());
  4774. val = mgb::hash_pair_combine(val, mgb::hash(op_.offsets));
  4775. val = mgb::hash_pair_combine(val, mgb::hash(op_.shapes));
  4776. return val;
  4777. }
  4778. bool ParamPackSplit_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4779. auto &&a_ = lhs_.cast_final_safe<ParamPackSplit>(),
  4780. &&b_ = rhs_.cast_final_safe<ParamPackSplit>();
  4781. static_cast<void>(a_);
  4782. static_cast<void>(b_);
  4783. if (a_.offsets != b_.offsets) return false;
  4784. if (a_.shapes != b_.shapes) return false;
  4785. return true;
  4786. }
  4787. std::vector<std::pair<const char*, std::string>> ParamPackSplit_props_impl(const OpDef& def_) {
  4788. auto&& op_ = def_.cast_final_safe<ParamPackSplit>();
  4789. static_cast<void>(op_);
  4790. std::vector<std::pair<const char*, std::string>> props_;
  4791. props_.emplace_back("offsets", "{std::vector}");
  4792. props_.emplace_back("shapes", "{std::vector}");
  4793. return props_;
  4794. }
  4795. std::string ParamPackSplit_make_name_impl(const OpDef& def_) {
  4796. auto&& op_ = def_.cast_final_safe<ParamPackSplit>();
  4797. static_cast<void>(op_);
  4798. return "ParamPackSplit";
  4799. }
  4800. } // anonymous namespace
  4801. OP_TRAIT_REG(ParamPackSplit, ParamPackSplit)
  4802. .hash(ParamPackSplit_hash_impl)
  4803. .is_same_st(ParamPackSplit_is_same_st_impl)
  4804. .props(ParamPackSplit_props_impl)
  4805. .make_name(ParamPackSplit_make_name_impl);
  4806. MGB_DYN_TYPE_OBJ_FINAL_IMPL(PermutationRNG);
  4807. namespace {
  4808. size_t PermutationRNG_hash_impl(const OpDef& def_) {
  4809. auto&& op_ = def_.cast_final_safe<PermutationRNG>();
  4810. static_cast<void>(op_);
  4811. return mgb::hash_pair_combine(
  4812. mgb::hash(op_.dyn_typeinfo()),
  4813. mgb::hash_pair_combine(
  4814. mgb::hash(op_.handle),
  4815. mgb::hash(op_.dtype.enumv())
  4816. )
  4817. );
  4818. }
  4819. bool PermutationRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4820. auto &&a_ = lhs_.cast_final_safe<PermutationRNG>(),
  4821. &&b_ = rhs_.cast_final_safe<PermutationRNG>();
  4822. static_cast<void>(a_);
  4823. static_cast<void>(b_);
  4824. return a_.handle == b_.handle && a_.dtype == b_.dtype;}
  4825. std::vector<std::pair<const char*, std::string>> PermutationRNG_props_impl(const OpDef& def_) {
  4826. auto&& op_ = def_.cast_final_safe<PermutationRNG>();
  4827. static_cast<void>(op_);
  4828. std::vector<std::pair<const char*, std::string>> props_;
  4829. props_.emplace_back("seed", std::to_string(op_.seed));
  4830. props_.emplace_back("dtype", op_.dtype.name());
  4831. props_.emplace_back("handle", std::to_string(op_.handle));
  4832. return props_;
  4833. }
  4834. std::string PermutationRNG_make_name_impl(const OpDef& def_) {
  4835. auto&& op_ = def_.cast_final_safe<PermutationRNG>();
  4836. static_cast<void>(op_);
  4837. return "PermutationRNG";
  4838. }
  4839. } // anonymous namespace
  4840. OP_TRAIT_REG(PermutationRNG, PermutationRNG)
  4841. .hash(PermutationRNG_hash_impl)
  4842. .is_same_st(PermutationRNG_is_same_st_impl)
  4843. .props(PermutationRNG_props_impl)
  4844. .make_name(PermutationRNG_make_name_impl);
  4845. MGB_DYN_TYPE_OBJ_FINAL_IMPL(PixelShuffle);
  4846. namespace {
  4847. size_t PixelShuffle_hash_impl(const OpDef& def_) {
  4848. auto&& op_ = def_.cast_final_safe<PixelShuffle>();
  4849. static_cast<void>(op_);
  4850. size_t val = mgb::hash(op_.dyn_typeinfo());
  4851. val = mgb::hash_pair_combine(val, mgb::hash(op_.factor));
  4852. return val;
  4853. }
  4854. bool PixelShuffle_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4855. auto &&a_ = lhs_.cast_final_safe<PixelShuffle>(),
  4856. &&b_ = rhs_.cast_final_safe<PixelShuffle>();
  4857. static_cast<void>(a_);
  4858. static_cast<void>(b_);
  4859. if (a_.factor != b_.factor) return false;
  4860. return true;
  4861. }
  4862. std::vector<std::pair<const char*, std::string>> PixelShuffle_props_impl(const OpDef& def_) {
  4863. auto&& op_ = def_.cast_final_safe<PixelShuffle>();
  4864. static_cast<void>(op_);
  4865. std::vector<std::pair<const char*, std::string>> props_;
  4866. props_.emplace_back("factor", std::to_string(op_.factor));
  4867. return props_;
  4868. }
  4869. std::string PixelShuffle_make_name_impl(const OpDef& def_) {
  4870. auto&& op_ = def_.cast_final_safe<PixelShuffle>();
  4871. static_cast<void>(op_);
  4872. return "PixelShuffle";
  4873. }
  4874. } // anonymous namespace
  4875. OP_TRAIT_REG(PixelShuffle, PixelShuffle)
  4876. .hash(PixelShuffle_hash_impl)
  4877. .is_same_st(PixelShuffle_is_same_st_impl)
  4878. .props(PixelShuffle_props_impl)
  4879. .make_name(PixelShuffle_make_name_impl);
  4880. MGB_DYN_TYPE_OBJ_FINAL_IMPL(PixelShuffleBackward);
  4881. namespace {
  4882. size_t PixelShuffleBackward_hash_impl(const OpDef& def_) {
  4883. auto&& op_ = def_.cast_final_safe<PixelShuffleBackward>();
  4884. static_cast<void>(op_);
  4885. size_t val = mgb::hash(op_.dyn_typeinfo());
  4886. val = mgb::hash_pair_combine(val, mgb::hash(op_.factor));
  4887. return val;
  4888. }
  4889. bool PixelShuffleBackward_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4890. auto &&a_ = lhs_.cast_final_safe<PixelShuffleBackward>(),
  4891. &&b_ = rhs_.cast_final_safe<PixelShuffleBackward>();
  4892. static_cast<void>(a_);
  4893. static_cast<void>(b_);
  4894. if (a_.factor != b_.factor) return false;
  4895. return true;
  4896. }
  4897. std::vector<std::pair<const char*, std::string>> PixelShuffleBackward_props_impl(const OpDef& def_) {
  4898. auto&& op_ = def_.cast_final_safe<PixelShuffleBackward>();
  4899. static_cast<void>(op_);
  4900. std::vector<std::pair<const char*, std::string>> props_;
  4901. props_.emplace_back("factor", std::to_string(op_.factor));
  4902. return props_;
  4903. }
  4904. std::string PixelShuffleBackward_make_name_impl(const OpDef& def_) {
  4905. auto&& op_ = def_.cast_final_safe<PixelShuffleBackward>();
  4906. static_cast<void>(op_);
  4907. return "PixelShuffleBackward";
  4908. }
  4909. } // anonymous namespace
  4910. OP_TRAIT_REG(PixelShuffleBackward, PixelShuffleBackward)
  4911. .hash(PixelShuffleBackward_hash_impl)
  4912. .is_same_st(PixelShuffleBackward_is_same_st_impl)
  4913. .props(PixelShuffleBackward_props_impl)
  4914. .make_name(PixelShuffleBackward_make_name_impl);
  4915. MGB_DYN_TYPE_OBJ_FINAL_IMPL(PoissonRNG);
  4916. namespace {
  4917. size_t PoissonRNG_hash_impl(const OpDef& def_) {
  4918. auto&& op_ = def_.cast_final_safe<PoissonRNG>();
  4919. static_cast<void>(op_);
  4920. return mgb::hash_pair_combine(
  4921. mgb::hash(op_.dyn_typeinfo()),
  4922. mgb::hash(op_.handle)
  4923. );
  4924. }
  4925. bool PoissonRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4926. auto &&a_ = lhs_.cast_final_safe<PoissonRNG>(),
  4927. &&b_ = rhs_.cast_final_safe<PoissonRNG>();
  4928. static_cast<void>(a_);
  4929. static_cast<void>(b_);
  4930. return a_.handle == b_.handle;}
  4931. std::vector<std::pair<const char*, std::string>> PoissonRNG_props_impl(const OpDef& def_) {
  4932. auto&& op_ = def_.cast_final_safe<PoissonRNG>();
  4933. static_cast<void>(op_);
  4934. std::vector<std::pair<const char*, std::string>> props_;
  4935. props_.emplace_back("seed", std::to_string(op_.seed));
  4936. props_.emplace_back("handle", std::to_string(op_.handle));
  4937. return props_;
  4938. }
  4939. std::string PoissonRNG_make_name_impl(const OpDef& def_) {
  4940. auto&& op_ = def_.cast_final_safe<PoissonRNG>();
  4941. static_cast<void>(op_);
  4942. return "PoissonRNG";
  4943. }
  4944. } // anonymous namespace
  4945. OP_TRAIT_REG(PoissonRNG, PoissonRNG)
  4946. .hash(PoissonRNG_hash_impl)
  4947. .is_same_st(PoissonRNG_is_same_st_impl)
  4948. .props(PoissonRNG_props_impl)
  4949. .make_name(PoissonRNG_make_name_impl);
  4950. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Pooling);
  4951. namespace {
  4952. size_t Pooling_hash_impl(const OpDef& def_) {
  4953. auto&& op_ = def_.cast_final_safe<Pooling>();
  4954. static_cast<void>(op_);
  4955. size_t val = mgb::hash(op_.dyn_typeinfo());
  4956. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  4957. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  4958. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  4959. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  4960. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  4961. val = mgb::hash_pair_combine(val, mgb::hash(op_.window_h));
  4962. val = mgb::hash_pair_combine(val, mgb::hash(op_.window_w));
  4963. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  4964. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
  4965. val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
  4966. return val;
  4967. }
  4968. bool Pooling_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4969. auto &&a_ = lhs_.cast_final_safe<Pooling>(),
  4970. &&b_ = rhs_.cast_final_safe<Pooling>();
  4971. static_cast<void>(a_);
  4972. static_cast<void>(b_);
  4973. if (a_.mode != b_.mode) return false;
  4974. if (a_.pad_h != b_.pad_h) return false;
  4975. if (a_.pad_w != b_.pad_w) return false;
  4976. if (a_.stride_h != b_.stride_h) return false;
  4977. if (a_.stride_w != b_.stride_w) return false;
  4978. if (a_.window_h != b_.window_h) return false;
  4979. if (a_.window_w != b_.window_w) return false;
  4980. if (a_.format != b_.format) return false;
  4981. if (a_.strategy != b_.strategy) return false;
  4982. if (a_.workspace_limit != b_.workspace_limit) return false;
  4983. return true;
  4984. }
  4985. std::vector<std::pair<const char*, std::string>> Pooling_props_impl(const OpDef& def_) {
  4986. auto&& op_ = def_.cast_final_safe<Pooling>();
  4987. static_cast<void>(op_);
  4988. std::vector<std::pair<const char*, std::string>> props_;
  4989. switch (op_.mode){
  4990. case Pooling::Mode::MAX:
  4991. props_.emplace_back("mode", "MAX");
  4992. break;
  4993. case Pooling::Mode::AVERAGE:
  4994. props_.emplace_back("mode", "AVERAGE");
  4995. break;
  4996. case Pooling::Mode::AVERAGE_COUNT_EXCLUDE_PADDING:
  4997. props_.emplace_back("mode", "AVERAGE_COUNT_EXCLUDE_PADDING");
  4998. break;
  4999. default:
  5000. props_.emplace_back("mode", "INVALID");
  5001. break;
  5002. }
  5003. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  5004. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  5005. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  5006. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  5007. props_.emplace_back("window_h", std::to_string(op_.window_h));
  5008. props_.emplace_back("window_w", std::to_string(op_.window_w));
  5009. switch (op_.format){
  5010. case Pooling::Format::NCHW:
  5011. props_.emplace_back("format", "NCHW");
  5012. break;
  5013. case Pooling::Format::NHWC:
  5014. props_.emplace_back("format", "NHWC");
  5015. break;
  5016. case Pooling::Format::NHWCD4:
  5017. props_.emplace_back("format", "NHWCD4");
  5018. break;
  5019. case Pooling::Format::NCHW4:
  5020. props_.emplace_back("format", "NCHW4");
  5021. break;
  5022. case Pooling::Format::NCHW8:
  5023. props_.emplace_back("format", "NCHW8");
  5024. break;
  5025. case Pooling::Format::NCHW32:
  5026. props_.emplace_back("format", "NCHW32");
  5027. break;
  5028. case Pooling::Format::NCHW88:
  5029. props_.emplace_back("format", "NCHW88");
  5030. break;
  5031. case Pooling::Format::NCHW44:
  5032. props_.emplace_back("format", "NCHW44");
  5033. break;
  5034. case Pooling::Format::NCHW44_DOT:
  5035. props_.emplace_back("format", "NCHW44_DOT");
  5036. break;
  5037. case Pooling::Format::NCHW4_NCHW32:
  5038. props_.emplace_back("format", "NCHW4_NCHW32");
  5039. break;
  5040. case Pooling::Format::NCHW32_NCHW4:
  5041. props_.emplace_back("format", "NCHW32_NCHW4");
  5042. break;
  5043. case Pooling::Format::NCHW4_NCHW:
  5044. props_.emplace_back("format", "NCHW4_NCHW");
  5045. break;
  5046. case Pooling::Format::NHWC_NCHW:
  5047. props_.emplace_back("format", "NHWC_NCHW");
  5048. break;
  5049. case Pooling::Format::NHWC_NCHW4_IC_SMALL:
  5050. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  5051. break;
  5052. case Pooling::Format::NCHW_NCHW4_IC_SMALL:
  5053. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  5054. break;
  5055. case Pooling::Format::CHWN4:
  5056. props_.emplace_back("format", "CHWN4");
  5057. break;
  5058. case Pooling::Format::NCHW64:
  5059. props_.emplace_back("format", "NCHW64");
  5060. break;
  5061. case Pooling::Format::NCHW4_NHWC:
  5062. props_.emplace_back("format", "NCHW4_NHWC");
  5063. break;
  5064. default:
  5065. props_.emplace_back("format", "INVALID");
  5066. break;
  5067. }
  5068. switch (op_.strategy){
  5069. case Pooling::Strategy::HEURISTIC:
  5070. props_.emplace_back("strategy", "HEURISTIC");
  5071. break;
  5072. case Pooling::Strategy::PROFILE:
  5073. props_.emplace_back("strategy", "PROFILE");
  5074. break;
  5075. case Pooling::Strategy::REPRODUCIBLE:
  5076. props_.emplace_back("strategy", "REPRODUCIBLE");
  5077. break;
  5078. case Pooling::Strategy::OPTIMIZED:
  5079. props_.emplace_back("strategy", "OPTIMIZED");
  5080. break;
  5081. default:
  5082. props_.emplace_back("strategy", "INVALID");
  5083. break;
  5084. }
  5085. props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
  5086. return props_;
  5087. }
  5088. std::string Pooling_make_name_impl(const OpDef& def_) {
  5089. auto&& op_ = def_.cast_final_safe<Pooling>();
  5090. static_cast<void>(op_);
  5091. return "Pooling";
  5092. }
  5093. } // anonymous namespace
  5094. OP_TRAIT_REG(Pooling, Pooling)
  5095. .hash(Pooling_hash_impl)
  5096. .is_same_st(Pooling_is_same_st_impl)
  5097. .props(Pooling_props_impl)
  5098. .make_name(Pooling_make_name_impl);
  5099. MGB_DYN_TYPE_OBJ_FINAL_IMPL(RNN);
  5100. namespace {
  5101. size_t RNN_hash_impl(const OpDef& def_) {
  5102. auto&& op_ = def_.cast_final_safe<RNN>();
  5103. static_cast<void>(op_);
  5104. size_t val = mgb::hash(op_.dyn_typeinfo());
  5105. val = mgb::hash_pair_combine(val, mgb::hash(op_.num_layers));
  5106. val = mgb::hash_pair_combine(val, mgb::hash(op_.bidirectional));
  5107. val = mgb::hash_pair_combine(val, mgb::hash(op_.bias));
  5108. val = mgb::hash_pair_combine(val, mgb::hash(op_.hidden_size));
  5109. val = mgb::hash_pair_combine(val, mgb::hash(op_.dropout));
  5110. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.nonlineMode));
  5111. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.fwd_mode));
  5112. return val;
  5113. }
  5114. bool RNN_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5115. auto &&a_ = lhs_.cast_final_safe<RNN>(),
  5116. &&b_ = rhs_.cast_final_safe<RNN>();
  5117. static_cast<void>(a_);
  5118. static_cast<void>(b_);
  5119. if (a_.num_layers != b_.num_layers) return false;
  5120. if (a_.bidirectional != b_.bidirectional) return false;
  5121. if (a_.bias != b_.bias) return false;
  5122. if (a_.hidden_size != b_.hidden_size) return false;
  5123. if (a_.dropout != b_.dropout) return false;
  5124. if (a_.nonlineMode != b_.nonlineMode) return false;
  5125. if (a_.fwd_mode != b_.fwd_mode) return false;
  5126. return true;
  5127. }
  5128. std::vector<std::pair<const char*, std::string>> RNN_props_impl(const OpDef& def_) {
  5129. auto&& op_ = def_.cast_final_safe<RNN>();
  5130. static_cast<void>(op_);
  5131. std::vector<std::pair<const char*, std::string>> props_;
  5132. props_.emplace_back("num_layers", std::to_string(op_.num_layers));
  5133. props_.emplace_back("bidirectional", std::to_string(op_.bidirectional));
  5134. props_.emplace_back("bias", std::to_string(op_.bias));
  5135. props_.emplace_back("hidden_size", std::to_string(op_.hidden_size));
  5136. props_.emplace_back("dropout", std::to_string(op_.dropout));
  5137. switch (op_.nonlineMode){
  5138. case RNN::NonlineMode::IDENTITY:
  5139. props_.emplace_back("nonlineMode", "IDENTITY");
  5140. break;
  5141. case RNN::NonlineMode::RELU:
  5142. props_.emplace_back("nonlineMode", "RELU");
  5143. break;
  5144. case RNN::NonlineMode::TANH:
  5145. props_.emplace_back("nonlineMode", "TANH");
  5146. break;
  5147. default:
  5148. props_.emplace_back("nonlineMode", "INVALID");
  5149. break;
  5150. }
  5151. switch (op_.fwd_mode){
  5152. case RNN::FwdMode::TRAINING:
  5153. props_.emplace_back("fwd_mode", "TRAINING");
  5154. break;
  5155. case RNN::FwdMode::INFERENCE:
  5156. props_.emplace_back("fwd_mode", "INFERENCE");
  5157. break;
  5158. default:
  5159. props_.emplace_back("fwd_mode", "INVALID");
  5160. break;
  5161. }
  5162. return props_;
  5163. }
  5164. std::string RNN_make_name_impl(const OpDef& def_) {
  5165. auto&& op_ = def_.cast_final_safe<RNN>();
  5166. static_cast<void>(op_);
  5167. return "RNN";
  5168. }
  5169. } // anonymous namespace
  5170. OP_TRAIT_REG(RNN, RNN)
  5171. .hash(RNN_hash_impl)
  5172. .is_same_st(RNN_is_same_st_impl)
  5173. .props(RNN_props_impl)
  5174. .make_name(RNN_make_name_impl);
  5175. MGB_DYN_TYPE_OBJ_FINAL_IMPL(RNNCell);
  5176. namespace {
  5177. size_t RNNCell_hash_impl(const OpDef& def_) {
  5178. auto&& op_ = def_.cast_final_safe<RNNCell>();
  5179. static_cast<void>(op_);
  5180. size_t val = mgb::hash(op_.dyn_typeinfo());
  5181. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.nonlineMode));
  5182. return val;
  5183. }
  5184. bool RNNCell_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5185. auto &&a_ = lhs_.cast_final_safe<RNNCell>(),
  5186. &&b_ = rhs_.cast_final_safe<RNNCell>();
  5187. static_cast<void>(a_);
  5188. static_cast<void>(b_);
  5189. if (a_.nonlineMode != b_.nonlineMode) return false;
  5190. return true;
  5191. }
  5192. std::vector<std::pair<const char*, std::string>> RNNCell_props_impl(const OpDef& def_) {
  5193. auto&& op_ = def_.cast_final_safe<RNNCell>();
  5194. static_cast<void>(op_);
  5195. std::vector<std::pair<const char*, std::string>> props_;
  5196. switch (op_.nonlineMode){
  5197. case RNNCell::NonlineMode::IDENTITY:
  5198. props_.emplace_back("nonlineMode", "IDENTITY");
  5199. break;
  5200. case RNNCell::NonlineMode::RELU:
  5201. props_.emplace_back("nonlineMode", "RELU");
  5202. break;
  5203. case RNNCell::NonlineMode::TANH:
  5204. props_.emplace_back("nonlineMode", "TANH");
  5205. break;
  5206. default:
  5207. props_.emplace_back("nonlineMode", "INVALID");
  5208. break;
  5209. }
  5210. return props_;
  5211. }
  5212. std::string RNNCell_make_name_impl(const OpDef& def_) {
  5213. auto&& op_ = def_.cast_final_safe<RNNCell>();
  5214. static_cast<void>(op_);
  5215. return "RNNCell";
  5216. }
  5217. } // anonymous namespace
  5218. OP_TRAIT_REG(RNNCell, RNNCell)
  5219. .hash(RNNCell_hash_impl)
  5220. .is_same_st(RNNCell_is_same_st_impl)
  5221. .props(RNNCell_props_impl)
  5222. .make_name(RNNCell_make_name_impl);
  5223. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ROIAlign);
  5224. namespace {
  5225. size_t ROIAlign_hash_impl(const OpDef& def_) {
  5226. auto&& op_ = def_.cast_final_safe<ROIAlign>();
  5227. static_cast<void>(op_);
  5228. size_t val = mgb::hash(op_.dyn_typeinfo());
  5229. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  5230. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  5231. val = mgb::hash_pair_combine(val, mgb::hash(op_.spatial_scale));
  5232. val = mgb::hash_pair_combine(val, mgb::hash(op_.offset));
  5233. val = mgb::hash_pair_combine(val, mgb::hash(op_.pooled_height));
  5234. val = mgb::hash_pair_combine(val, mgb::hash(op_.pooled_width));
  5235. val = mgb::hash_pair_combine(val, mgb::hash(op_.sample_height));
  5236. val = mgb::hash_pair_combine(val, mgb::hash(op_.sample_width));
  5237. return val;
  5238. }
  5239. bool ROIAlign_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5240. auto &&a_ = lhs_.cast_final_safe<ROIAlign>(),
  5241. &&b_ = rhs_.cast_final_safe<ROIAlign>();
  5242. static_cast<void>(a_);
  5243. static_cast<void>(b_);
  5244. if (a_.mode != b_.mode) return false;
  5245. if (a_.format != b_.format) return false;
  5246. if (a_.spatial_scale != b_.spatial_scale) return false;
  5247. if (a_.offset != b_.offset) return false;
  5248. if (a_.pooled_height != b_.pooled_height) return false;
  5249. if (a_.pooled_width != b_.pooled_width) return false;
  5250. if (a_.sample_height != b_.sample_height) return false;
  5251. if (a_.sample_width != b_.sample_width) return false;
  5252. return true;
  5253. }
  5254. std::vector<std::pair<const char*, std::string>> ROIAlign_props_impl(const OpDef& def_) {
  5255. auto&& op_ = def_.cast_final_safe<ROIAlign>();
  5256. static_cast<void>(op_);
  5257. std::vector<std::pair<const char*, std::string>> props_;
  5258. switch (op_.mode){
  5259. case ROIAlign::Mode::MAX:
  5260. props_.emplace_back("mode", "MAX");
  5261. break;
  5262. case ROIAlign::Mode::AVERAGE:
  5263. props_.emplace_back("mode", "AVERAGE");
  5264. break;
  5265. default:
  5266. props_.emplace_back("mode", "INVALID");
  5267. break;
  5268. }
  5269. switch (op_.format){
  5270. case ROIAlign::Format::NCHW:
  5271. props_.emplace_back("format", "NCHW");
  5272. break;
  5273. case ROIAlign::Format::NHWC:
  5274. props_.emplace_back("format", "NHWC");
  5275. break;
  5276. case ROIAlign::Format::NHWCD4:
  5277. props_.emplace_back("format", "NHWCD4");
  5278. break;
  5279. case ROIAlign::Format::NCHW4:
  5280. props_.emplace_back("format", "NCHW4");
  5281. break;
  5282. case ROIAlign::Format::NCHW8:
  5283. props_.emplace_back("format", "NCHW8");
  5284. break;
  5285. case ROIAlign::Format::NCHW32:
  5286. props_.emplace_back("format", "NCHW32");
  5287. break;
  5288. case ROIAlign::Format::NCHW88:
  5289. props_.emplace_back("format", "NCHW88");
  5290. break;
  5291. case ROIAlign::Format::NCHW44:
  5292. props_.emplace_back("format", "NCHW44");
  5293. break;
  5294. case ROIAlign::Format::NCHW44_DOT:
  5295. props_.emplace_back("format", "NCHW44_DOT");
  5296. break;
  5297. case ROIAlign::Format::NCHW4_NCHW32:
  5298. props_.emplace_back("format", "NCHW4_NCHW32");
  5299. break;
  5300. case ROIAlign::Format::NCHW32_NCHW4:
  5301. props_.emplace_back("format", "NCHW32_NCHW4");
  5302. break;
  5303. case ROIAlign::Format::NCHW4_NCHW:
  5304. props_.emplace_back("format", "NCHW4_NCHW");
  5305. break;
  5306. case ROIAlign::Format::NHWC_NCHW:
  5307. props_.emplace_back("format", "NHWC_NCHW");
  5308. break;
  5309. case ROIAlign::Format::NHWC_NCHW4_IC_SMALL:
  5310. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  5311. break;
  5312. case ROIAlign::Format::NCHW_NCHW4_IC_SMALL:
  5313. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  5314. break;
  5315. case ROIAlign::Format::CHWN4:
  5316. props_.emplace_back("format", "CHWN4");
  5317. break;
  5318. case ROIAlign::Format::NCHW64:
  5319. props_.emplace_back("format", "NCHW64");
  5320. break;
  5321. case ROIAlign::Format::NCHW4_NHWC:
  5322. props_.emplace_back("format", "NCHW4_NHWC");
  5323. break;
  5324. default:
  5325. props_.emplace_back("format", "INVALID");
  5326. break;
  5327. }
  5328. props_.emplace_back("spatial_scale", std::to_string(op_.spatial_scale));
  5329. props_.emplace_back("offset", std::to_string(op_.offset));
  5330. props_.emplace_back("pooled_height", std::to_string(op_.pooled_height));
  5331. props_.emplace_back("pooled_width", std::to_string(op_.pooled_width));
  5332. props_.emplace_back("sample_height", std::to_string(op_.sample_height));
  5333. props_.emplace_back("sample_width", std::to_string(op_.sample_width));
  5334. return props_;
  5335. }
  5336. std::string ROIAlign_make_name_impl(const OpDef& def_) {
  5337. auto&& op_ = def_.cast_final_safe<ROIAlign>();
  5338. static_cast<void>(op_);
  5339. return "ROIAlign";
  5340. }
  5341. } // anonymous namespace
  5342. OP_TRAIT_REG(ROIAlign, ROIAlign)
  5343. .hash(ROIAlign_hash_impl)
  5344. .is_same_st(ROIAlign_is_same_st_impl)
  5345. .props(ROIAlign_props_impl)
  5346. .make_name(ROIAlign_make_name_impl);
  5347. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ROIPooling);
  5348. namespace {
  5349. size_t ROIPooling_hash_impl(const OpDef& def_) {
  5350. auto&& op_ = def_.cast_final_safe<ROIPooling>();
  5351. static_cast<void>(op_);
  5352. size_t val = mgb::hash(op_.dyn_typeinfo());
  5353. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  5354. val = mgb::hash_pair_combine(val, mgb::hash(op_.scale));
  5355. return val;
  5356. }
  5357. bool ROIPooling_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5358. auto &&a_ = lhs_.cast_final_safe<ROIPooling>(),
  5359. &&b_ = rhs_.cast_final_safe<ROIPooling>();
  5360. static_cast<void>(a_);
  5361. static_cast<void>(b_);
  5362. if (a_.mode != b_.mode) return false;
  5363. if (a_.scale != b_.scale) return false;
  5364. return true;
  5365. }
  5366. std::vector<std::pair<const char*, std::string>> ROIPooling_props_impl(const OpDef& def_) {
  5367. auto&& op_ = def_.cast_final_safe<ROIPooling>();
  5368. static_cast<void>(op_);
  5369. std::vector<std::pair<const char*, std::string>> props_;
  5370. switch (op_.mode){
  5371. case ROIPooling::Mode::MAX:
  5372. props_.emplace_back("mode", "MAX");
  5373. break;
  5374. case ROIPooling::Mode::AVERAGE:
  5375. props_.emplace_back("mode", "AVERAGE");
  5376. break;
  5377. default:
  5378. props_.emplace_back("mode", "INVALID");
  5379. break;
  5380. }
  5381. props_.emplace_back("scale", std::to_string(op_.scale));
  5382. return props_;
  5383. }
  5384. std::string ROIPooling_make_name_impl(const OpDef& def_) {
  5385. auto&& op_ = def_.cast_final_safe<ROIPooling>();
  5386. static_cast<void>(op_);
  5387. return "ROIPooling";
  5388. }
  5389. } // anonymous namespace
  5390. OP_TRAIT_REG(ROIPooling, ROIPooling)
  5391. .hash(ROIPooling_hash_impl)
  5392. .is_same_st(ROIPooling_is_same_st_impl)
  5393. .props(ROIPooling_props_impl)
  5394. .make_name(ROIPooling_make_name_impl);
  5395. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Reduce);
  5396. namespace {
  5397. size_t Reduce_hash_impl(const OpDef& def_) {
  5398. auto&& op_ = def_.cast_final_safe<Reduce>();
  5399. static_cast<void>(op_);
  5400. size_t val = mgb::hash(op_.dyn_typeinfo());
  5401. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  5402. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  5403. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.data_type));
  5404. val = mgb::hash_pair_combine(val, mgb::hash(op_.keepdim));
  5405. return val;
  5406. }
  5407. bool Reduce_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5408. auto &&a_ = lhs_.cast_final_safe<Reduce>(),
  5409. &&b_ = rhs_.cast_final_safe<Reduce>();
  5410. static_cast<void>(a_);
  5411. static_cast<void>(b_);
  5412. if (a_.mode != b_.mode) return false;
  5413. if (a_.axis != b_.axis) return false;
  5414. if (a_.data_type != b_.data_type) return false;
  5415. if (a_.keepdim != b_.keepdim) return false;
  5416. return true;
  5417. }
  5418. std::vector<std::pair<const char*, std::string>> Reduce_props_impl(const OpDef& def_) {
  5419. auto&& op_ = def_.cast_final_safe<Reduce>();
  5420. static_cast<void>(op_);
  5421. std::vector<std::pair<const char*, std::string>> props_;
  5422. switch (op_.mode){
  5423. case Reduce::Mode::SUM:
  5424. props_.emplace_back("mode", "SUM");
  5425. break;
  5426. case Reduce::Mode::SUM_SQR:
  5427. props_.emplace_back("mode", "SUM_SQR");
  5428. break;
  5429. case Reduce::Mode::PRODUCT:
  5430. props_.emplace_back("mode", "PRODUCT");
  5431. break;
  5432. case Reduce::Mode::MIN:
  5433. props_.emplace_back("mode", "MIN");
  5434. break;
  5435. case Reduce::Mode::MAX:
  5436. props_.emplace_back("mode", "MAX");
  5437. break;
  5438. case Reduce::Mode::MEAN:
  5439. props_.emplace_back("mode", "MEAN");
  5440. break;
  5441. default:
  5442. props_.emplace_back("mode", "INVALID");
  5443. break;
  5444. }
  5445. props_.emplace_back("axis", std::to_string(op_.axis));
  5446. switch (op_.data_type){
  5447. case Reduce::DataType::DEFAULT:
  5448. props_.emplace_back("data_type", "DEFAULT");
  5449. break;
  5450. case Reduce::DataType::FLOAT_IO16xC32:
  5451. props_.emplace_back("data_type", "FLOAT_IO16xC32");
  5452. break;
  5453. case Reduce::DataType::FLOAT_O32xC32:
  5454. props_.emplace_back("data_type", "FLOAT_O32xC32");
  5455. break;
  5456. case Reduce::DataType::FLOAT_O16xC32:
  5457. props_.emplace_back("data_type", "FLOAT_O16xC32");
  5458. break;
  5459. case Reduce::DataType::QUINT_I8xO32:
  5460. props_.emplace_back("data_type", "QUINT_I8xO32");
  5461. break;
  5462. case Reduce::DataType::QINT_I8xO32:
  5463. props_.emplace_back("data_type", "QINT_I8xO32");
  5464. break;
  5465. default:
  5466. props_.emplace_back("data_type", "INVALID");
  5467. break;
  5468. }
  5469. props_.emplace_back("keepdim", std::to_string(op_.keepdim));
  5470. return props_;
  5471. }
  5472. std::string Reduce_make_name_impl(const OpDef& def_) {
  5473. auto&& op_ = def_.cast_final_safe<Reduce>();
  5474. static_cast<void>(op_);
  5475. return "Reduce";
  5476. }
  5477. } // anonymous namespace
  5478. OP_TRAIT_REG(Reduce, Reduce)
  5479. .hash(Reduce_hash_impl)
  5480. .is_same_st(Reduce_is_same_st_impl)
  5481. .props(Reduce_props_impl)
  5482. .make_name(Reduce_make_name_impl);
  5483. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Remap);
  5484. namespace {
  5485. size_t Remap_hash_impl(const OpDef& def_) {
  5486. auto&& op_ = def_.cast_final_safe<Remap>();
  5487. static_cast<void>(op_);
  5488. size_t val = mgb::hash(op_.dyn_typeinfo());
  5489. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
  5490. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.border_type));
  5491. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  5492. val = mgb::hash_pair_combine(val, mgb::hash(op_.scalar));
  5493. return val;
  5494. }
  5495. bool Remap_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5496. auto &&a_ = lhs_.cast_final_safe<Remap>(),
  5497. &&b_ = rhs_.cast_final_safe<Remap>();
  5498. static_cast<void>(a_);
  5499. static_cast<void>(b_);
  5500. if (a_.imode != b_.imode) return false;
  5501. if (a_.border_type != b_.border_type) return false;
  5502. if (a_.format != b_.format) return false;
  5503. if (a_.scalar != b_.scalar) return false;
  5504. return true;
  5505. }
  5506. std::vector<std::pair<const char*, std::string>> Remap_props_impl(const OpDef& def_) {
  5507. auto&& op_ = def_.cast_final_safe<Remap>();
  5508. static_cast<void>(op_);
  5509. std::vector<std::pair<const char*, std::string>> props_;
  5510. switch (op_.imode){
  5511. case Remap::InterpolationMode::NEAREST:
  5512. props_.emplace_back("imode", "NEAREST");
  5513. break;
  5514. case Remap::InterpolationMode::LINEAR:
  5515. props_.emplace_back("imode", "LINEAR");
  5516. break;
  5517. case Remap::InterpolationMode::AREA:
  5518. props_.emplace_back("imode", "AREA");
  5519. break;
  5520. case Remap::InterpolationMode::CUBIC:
  5521. props_.emplace_back("imode", "CUBIC");
  5522. break;
  5523. case Remap::InterpolationMode::LANCZOS4:
  5524. props_.emplace_back("imode", "LANCZOS4");
  5525. break;
  5526. default:
  5527. props_.emplace_back("imode", "INVALID");
  5528. break;
  5529. }
  5530. switch (op_.border_type){
  5531. case Remap::BorderMode::REPLICATE:
  5532. props_.emplace_back("border_type", "REPLICATE");
  5533. break;
  5534. case Remap::BorderMode::REFLECT:
  5535. props_.emplace_back("border_type", "REFLECT");
  5536. break;
  5537. case Remap::BorderMode::REFLECT_101:
  5538. props_.emplace_back("border_type", "REFLECT_101");
  5539. break;
  5540. case Remap::BorderMode::WRAP:
  5541. props_.emplace_back("border_type", "WRAP");
  5542. break;
  5543. case Remap::BorderMode::CONSTANT:
  5544. props_.emplace_back("border_type", "CONSTANT");
  5545. break;
  5546. case Remap::BorderMode::TRANSPARENT:
  5547. props_.emplace_back("border_type", "TRANSPARENT");
  5548. break;
  5549. case Remap::BorderMode::ISOLATED:
  5550. props_.emplace_back("border_type", "ISOLATED");
  5551. break;
  5552. default:
  5553. props_.emplace_back("border_type", "INVALID");
  5554. break;
  5555. }
  5556. switch (op_.format){
  5557. case Remap::Format::NCHW:
  5558. props_.emplace_back("format", "NCHW");
  5559. break;
  5560. case Remap::Format::NHWC:
  5561. props_.emplace_back("format", "NHWC");
  5562. break;
  5563. case Remap::Format::NHWCD4:
  5564. props_.emplace_back("format", "NHWCD4");
  5565. break;
  5566. case Remap::Format::NCHW4:
  5567. props_.emplace_back("format", "NCHW4");
  5568. break;
  5569. case Remap::Format::NCHW8:
  5570. props_.emplace_back("format", "NCHW8");
  5571. break;
  5572. case Remap::Format::NCHW32:
  5573. props_.emplace_back("format", "NCHW32");
  5574. break;
  5575. case Remap::Format::NCHW88:
  5576. props_.emplace_back("format", "NCHW88");
  5577. break;
  5578. case Remap::Format::NCHW44:
  5579. props_.emplace_back("format", "NCHW44");
  5580. break;
  5581. case Remap::Format::NCHW44_DOT:
  5582. props_.emplace_back("format", "NCHW44_DOT");
  5583. break;
  5584. case Remap::Format::NCHW4_NCHW32:
  5585. props_.emplace_back("format", "NCHW4_NCHW32");
  5586. break;
  5587. case Remap::Format::NCHW32_NCHW4:
  5588. props_.emplace_back("format", "NCHW32_NCHW4");
  5589. break;
  5590. case Remap::Format::NCHW4_NCHW:
  5591. props_.emplace_back("format", "NCHW4_NCHW");
  5592. break;
  5593. case Remap::Format::NHWC_NCHW:
  5594. props_.emplace_back("format", "NHWC_NCHW");
  5595. break;
  5596. case Remap::Format::NHWC_NCHW4_IC_SMALL:
  5597. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  5598. break;
  5599. case Remap::Format::NCHW_NCHW4_IC_SMALL:
  5600. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  5601. break;
  5602. case Remap::Format::CHWN4:
  5603. props_.emplace_back("format", "CHWN4");
  5604. break;
  5605. case Remap::Format::NCHW64:
  5606. props_.emplace_back("format", "NCHW64");
  5607. break;
  5608. case Remap::Format::NCHW4_NHWC:
  5609. props_.emplace_back("format", "NCHW4_NHWC");
  5610. break;
  5611. default:
  5612. props_.emplace_back("format", "INVALID");
  5613. break;
  5614. }
  5615. props_.emplace_back("scalar", std::to_string(op_.scalar));
  5616. return props_;
  5617. }
  5618. std::string Remap_make_name_impl(const OpDef& def_) {
  5619. auto&& op_ = def_.cast_final_safe<Remap>();
  5620. static_cast<void>(op_);
  5621. return "Remap";
  5622. }
  5623. } // anonymous namespace
  5624. OP_TRAIT_REG(Remap, Remap)
  5625. .hash(Remap_hash_impl)
  5626. .is_same_st(Remap_is_same_st_impl)
  5627. .props(Remap_props_impl)
  5628. .make_name(Remap_make_name_impl);
  5629. MGB_DYN_TYPE_OBJ_FINAL_IMPL(RemoteRecv);
  5630. namespace {
  5631. size_t RemoteRecv_hash_impl(const OpDef& def_) {
  5632. auto&& op_ = def_.cast_final_safe<RemoteRecv>();
  5633. static_cast<void>(op_);
  5634. size_t val = mgb::hash(op_.dyn_typeinfo());
  5635. val = mgb::hash_pair_combine(val, mgb::hash(op_.key));
  5636. val = mgb::hash_pair_combine(val, mgb::hash(op_.addr));
  5637. val = mgb::hash_pair_combine(val, mgb::hash(op_.port));
  5638. val = mgb::hash_pair_combine(val, mgb::hash(op_.rank_from));
  5639. val = mgb::hash_pair_combine(val, mgb::hash(op_.cn));
  5640. val = mgb::hash_pair_combine(val, mgb::hash(op_.shape));
  5641. val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
  5642. val = mgb::hash_pair_combine(val, mgb::hash(op_.backend));
  5643. return val;
  5644. }
  5645. bool RemoteRecv_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5646. auto &&a_ = lhs_.cast_final_safe<RemoteRecv>(),
  5647. &&b_ = rhs_.cast_final_safe<RemoteRecv>();
  5648. static_cast<void>(a_);
  5649. static_cast<void>(b_);
  5650. if (a_.key != b_.key) return false;
  5651. if (a_.addr != b_.addr) return false;
  5652. if (a_.port != b_.port) return false;
  5653. if (a_.rank_from != b_.rank_from) return false;
  5654. if (a_.cn != b_.cn) return false;
  5655. if (a_.shape != b_.shape) return false;
  5656. if (a_.dtype != b_.dtype) return false;
  5657. if (a_.backend != b_.backend) return false;
  5658. return true;
  5659. }
  5660. std::vector<std::pair<const char*, std::string>> RemoteRecv_props_impl(const OpDef& def_) {
  5661. auto&& op_ = def_.cast_final_safe<RemoteRecv>();
  5662. static_cast<void>(op_);
  5663. std::vector<std::pair<const char*, std::string>> props_;
  5664. props_.emplace_back("key", op_.key);
  5665. props_.emplace_back("addr", op_.addr);
  5666. props_.emplace_back("port", std::to_string(op_.port));
  5667. props_.emplace_back("rank_from", std::to_string(op_.rank_from));
  5668. props_.emplace_back("cn", op_.cn.to_string());
  5669. props_.emplace_back("shape", "{std::vector}");
  5670. props_.emplace_back("dtype", op_.dtype.name());
  5671. props_.emplace_back("backend", op_.backend);
  5672. return props_;
  5673. }
  5674. std::string RemoteRecv_make_name_impl(const OpDef& def_) {
  5675. auto&& op_ = def_.cast_final_safe<RemoteRecv>();
  5676. static_cast<void>(op_);
  5677. return "RemoteRecv";
  5678. }
  5679. } // anonymous namespace
  5680. OP_TRAIT_REG(RemoteRecv, RemoteRecv)
  5681. .hash(RemoteRecv_hash_impl)
  5682. .is_same_st(RemoteRecv_is_same_st_impl)
  5683. .props(RemoteRecv_props_impl)
  5684. .make_name(RemoteRecv_make_name_impl);
  5685. MGB_DYN_TYPE_OBJ_FINAL_IMPL(RemoteSend);
  5686. namespace {
  5687. size_t RemoteSend_hash_impl(const OpDef& def_) {
  5688. auto&& op_ = def_.cast_final_safe<RemoteSend>();
  5689. static_cast<void>(op_);
  5690. size_t val = mgb::hash(op_.dyn_typeinfo());
  5691. val = mgb::hash_pair_combine(val, mgb::hash(op_.key));
  5692. val = mgb::hash_pair_combine(val, mgb::hash(op_.addr));
  5693. val = mgb::hash_pair_combine(val, mgb::hash(op_.port));
  5694. val = mgb::hash_pair_combine(val, mgb::hash(op_.rank_to));
  5695. val = mgb::hash_pair_combine(val, mgb::hash(op_.backend));
  5696. return val;
  5697. }
  5698. bool RemoteSend_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5699. auto &&a_ = lhs_.cast_final_safe<RemoteSend>(),
  5700. &&b_ = rhs_.cast_final_safe<RemoteSend>();
  5701. static_cast<void>(a_);
  5702. static_cast<void>(b_);
  5703. if (a_.key != b_.key) return false;
  5704. if (a_.addr != b_.addr) return false;
  5705. if (a_.port != b_.port) return false;
  5706. if (a_.rank_to != b_.rank_to) return false;
  5707. if (a_.backend != b_.backend) return false;
  5708. return true;
  5709. }
  5710. std::vector<std::pair<const char*, std::string>> RemoteSend_props_impl(const OpDef& def_) {
  5711. auto&& op_ = def_.cast_final_safe<RemoteSend>();
  5712. static_cast<void>(op_);
  5713. std::vector<std::pair<const char*, std::string>> props_;
  5714. props_.emplace_back("key", op_.key);
  5715. props_.emplace_back("addr", op_.addr);
  5716. props_.emplace_back("port", std::to_string(op_.port));
  5717. props_.emplace_back("rank_to", std::to_string(op_.rank_to));
  5718. props_.emplace_back("backend", op_.backend);
  5719. return props_;
  5720. }
  5721. std::string RemoteSend_make_name_impl(const OpDef& def_) {
  5722. auto&& op_ = def_.cast_final_safe<RemoteSend>();
  5723. static_cast<void>(op_);
  5724. return "RemoteSend";
  5725. }
  5726. } // anonymous namespace
  5727. OP_TRAIT_REG(RemoteSend, RemoteSend)
  5728. .hash(RemoteSend_hash_impl)
  5729. .is_same_st(RemoteSend_is_same_st_impl)
  5730. .props(RemoteSend_props_impl)
  5731. .make_name(RemoteSend_make_name_impl);
  5732. MGB_DYN_TYPE_OBJ_FINAL_IMPL(RemoveAxis);
  5733. namespace {
  5734. size_t RemoveAxis_hash_impl(const OpDef& def_) {
  5735. auto&& op_ = def_.cast_final_safe<RemoveAxis>();
  5736. static_cast<void>(op_);
  5737. size_t val = mgb::hash(op_.dyn_typeinfo());
  5738. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  5739. return val;
  5740. }
  5741. bool RemoveAxis_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5742. auto &&a_ = lhs_.cast_final_safe<RemoveAxis>(),
  5743. &&b_ = rhs_.cast_final_safe<RemoveAxis>();
  5744. static_cast<void>(a_);
  5745. static_cast<void>(b_);
  5746. if (a_.axis != b_.axis) return false;
  5747. return true;
  5748. }
  5749. std::vector<std::pair<const char*, std::string>> RemoveAxis_props_impl(const OpDef& def_) {
  5750. auto&& op_ = def_.cast_final_safe<RemoveAxis>();
  5751. static_cast<void>(op_);
  5752. std::vector<std::pair<const char*, std::string>> props_;
  5753. props_.emplace_back("axis", "{std::vector}");
  5754. return props_;
  5755. }
  5756. std::string RemoveAxis_make_name_impl(const OpDef& def_) {
  5757. auto&& op_ = def_.cast_final_safe<RemoveAxis>();
  5758. static_cast<void>(op_);
  5759. return "RemoveAxis";
  5760. }
  5761. } // anonymous namespace
  5762. OP_TRAIT_REG(RemoveAxis, RemoveAxis)
  5763. .hash(RemoveAxis_hash_impl)
  5764. .is_same_st(RemoveAxis_is_same_st_impl)
  5765. .props(RemoveAxis_props_impl)
  5766. .make_name(RemoveAxis_make_name_impl);
  5767. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Reshape);
  5768. namespace {
  5769. size_t Reshape_hash_impl(const OpDef& def_) {
  5770. auto&& op_ = def_.cast_final_safe<Reshape>();
  5771. static_cast<void>(op_);
  5772. size_t val = mgb::hash(op_.dyn_typeinfo());
  5773. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  5774. val = mgb::hash_pair_combine(val, mgb::hash(op_.shape));
  5775. return val;
  5776. }
  5777. bool Reshape_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5778. auto &&a_ = lhs_.cast_final_safe<Reshape>(),
  5779. &&b_ = rhs_.cast_final_safe<Reshape>();
  5780. static_cast<void>(a_);
  5781. static_cast<void>(b_);
  5782. if (a_.axis != b_.axis) return false;
  5783. if (a_.shape != b_.shape) return false;
  5784. return true;
  5785. }
  5786. std::vector<std::pair<const char*, std::string>> Reshape_props_impl(const OpDef& def_) {
  5787. auto&& op_ = def_.cast_final_safe<Reshape>();
  5788. static_cast<void>(op_);
  5789. std::vector<std::pair<const char*, std::string>> props_;
  5790. props_.emplace_back("axis", std::to_string(op_.axis));
  5791. props_.emplace_back("shape", "{std::vector}");
  5792. return props_;
  5793. }
  5794. std::string Reshape_make_name_impl(const OpDef& def_) {
  5795. auto&& op_ = def_.cast_final_safe<Reshape>();
  5796. static_cast<void>(op_);
  5797. return "Reshape";
  5798. }
  5799. } // anonymous namespace
  5800. OP_TRAIT_REG(Reshape, Reshape)
  5801. .hash(Reshape_hash_impl)
  5802. .is_same_st(Reshape_is_same_st_impl)
  5803. .props(Reshape_props_impl)
  5804. .make_name(Reshape_make_name_impl);
  5805. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Resize);
  5806. namespace {
  5807. size_t Resize_hash_impl(const OpDef& def_) {
  5808. auto&& op_ = def_.cast_final_safe<Resize>();
  5809. static_cast<void>(op_);
  5810. size_t val = mgb::hash(op_.dyn_typeinfo());
  5811. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
  5812. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  5813. return val;
  5814. }
  5815. bool Resize_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5816. auto &&a_ = lhs_.cast_final_safe<Resize>(),
  5817. &&b_ = rhs_.cast_final_safe<Resize>();
  5818. static_cast<void>(a_);
  5819. static_cast<void>(b_);
  5820. if (a_.imode != b_.imode) return false;
  5821. if (a_.format != b_.format) return false;
  5822. return true;
  5823. }
  5824. std::vector<std::pair<const char*, std::string>> Resize_props_impl(const OpDef& def_) {
  5825. auto&& op_ = def_.cast_final_safe<Resize>();
  5826. static_cast<void>(op_);
  5827. std::vector<std::pair<const char*, std::string>> props_;
  5828. switch (op_.imode){
  5829. case Resize::InterpolationMode::NEAREST:
  5830. props_.emplace_back("imode", "NEAREST");
  5831. break;
  5832. case Resize::InterpolationMode::LINEAR:
  5833. props_.emplace_back("imode", "LINEAR");
  5834. break;
  5835. case Resize::InterpolationMode::AREA:
  5836. props_.emplace_back("imode", "AREA");
  5837. break;
  5838. case Resize::InterpolationMode::CUBIC:
  5839. props_.emplace_back("imode", "CUBIC");
  5840. break;
  5841. case Resize::InterpolationMode::LANCZOS4:
  5842. props_.emplace_back("imode", "LANCZOS4");
  5843. break;
  5844. default:
  5845. props_.emplace_back("imode", "INVALID");
  5846. break;
  5847. }
  5848. switch (op_.format){
  5849. case Resize::Format::NCHW:
  5850. props_.emplace_back("format", "NCHW");
  5851. break;
  5852. case Resize::Format::NHWC:
  5853. props_.emplace_back("format", "NHWC");
  5854. break;
  5855. case Resize::Format::NHWCD4:
  5856. props_.emplace_back("format", "NHWCD4");
  5857. break;
  5858. case Resize::Format::NCHW4:
  5859. props_.emplace_back("format", "NCHW4");
  5860. break;
  5861. case Resize::Format::NCHW8:
  5862. props_.emplace_back("format", "NCHW8");
  5863. break;
  5864. case Resize::Format::NCHW32:
  5865. props_.emplace_back("format", "NCHW32");
  5866. break;
  5867. case Resize::Format::NCHW88:
  5868. props_.emplace_back("format", "NCHW88");
  5869. break;
  5870. case Resize::Format::NCHW44:
  5871. props_.emplace_back("format", "NCHW44");
  5872. break;
  5873. case Resize::Format::NCHW44_DOT:
  5874. props_.emplace_back("format", "NCHW44_DOT");
  5875. break;
  5876. case Resize::Format::NCHW4_NCHW32:
  5877. props_.emplace_back("format", "NCHW4_NCHW32");
  5878. break;
  5879. case Resize::Format::NCHW32_NCHW4:
  5880. props_.emplace_back("format", "NCHW32_NCHW4");
  5881. break;
  5882. case Resize::Format::NCHW4_NCHW:
  5883. props_.emplace_back("format", "NCHW4_NCHW");
  5884. break;
  5885. case Resize::Format::NHWC_NCHW:
  5886. props_.emplace_back("format", "NHWC_NCHW");
  5887. break;
  5888. case Resize::Format::NHWC_NCHW4_IC_SMALL:
  5889. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  5890. break;
  5891. case Resize::Format::NCHW_NCHW4_IC_SMALL:
  5892. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  5893. break;
  5894. case Resize::Format::CHWN4:
  5895. props_.emplace_back("format", "CHWN4");
  5896. break;
  5897. case Resize::Format::NCHW64:
  5898. props_.emplace_back("format", "NCHW64");
  5899. break;
  5900. case Resize::Format::NCHW4_NHWC:
  5901. props_.emplace_back("format", "NCHW4_NHWC");
  5902. break;
  5903. default:
  5904. props_.emplace_back("format", "INVALID");
  5905. break;
  5906. }
  5907. return props_;
  5908. }
  5909. std::string Resize_make_name_impl(const OpDef& def_) {
  5910. auto&& op_ = def_.cast_final_safe<Resize>();
  5911. static_cast<void>(op_);
  5912. return "Resize";
  5913. }
  5914. } // anonymous namespace
  5915. OP_TRAIT_REG(Resize, Resize)
  5916. .hash(Resize_hash_impl)
  5917. .is_same_st(Resize_is_same_st_impl)
  5918. .props(Resize_props_impl)
  5919. .make_name(Resize_make_name_impl);
  5920. MGB_DYN_TYPE_OBJ_FINAL_IMPL(SVD);
  5921. namespace {
  5922. size_t SVD_hash_impl(const OpDef& def_) {
  5923. auto&& op_ = def_.cast_final_safe<SVD>();
  5924. static_cast<void>(op_);
  5925. size_t val = mgb::hash(op_.dyn_typeinfo());
  5926. val = mgb::hash_pair_combine(val, mgb::hash(op_.full_matrices));
  5927. val = mgb::hash_pair_combine(val, mgb::hash(op_.compute_uv));
  5928. return val;
  5929. }
  5930. bool SVD_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5931. auto &&a_ = lhs_.cast_final_safe<SVD>(),
  5932. &&b_ = rhs_.cast_final_safe<SVD>();
  5933. static_cast<void>(a_);
  5934. static_cast<void>(b_);
  5935. if (a_.full_matrices != b_.full_matrices) return false;
  5936. if (a_.compute_uv != b_.compute_uv) return false;
  5937. return true;
  5938. }
  5939. std::vector<std::pair<const char*, std::string>> SVD_props_impl(const OpDef& def_) {
  5940. auto&& op_ = def_.cast_final_safe<SVD>();
  5941. static_cast<void>(op_);
  5942. std::vector<std::pair<const char*, std::string>> props_;
  5943. props_.emplace_back("full_matrices", std::to_string(op_.full_matrices));
  5944. props_.emplace_back("compute_uv", std::to_string(op_.compute_uv));
  5945. return props_;
  5946. }
  5947. std::string SVD_make_name_impl(const OpDef& def_) {
  5948. auto&& op_ = def_.cast_final_safe<SVD>();
  5949. static_cast<void>(op_);
  5950. return "SVD";
  5951. }
  5952. } // anonymous namespace
  5953. OP_TRAIT_REG(SVD, SVD)
  5954. .hash(SVD_hash_impl)
  5955. .is_same_st(SVD_is_same_st_impl)
  5956. .props(SVD_props_impl)
  5957. .make_name(SVD_make_name_impl);
  5958. MGB_DYN_TYPE_OBJ_FINAL_IMPL(SetMeshIndexing);
  5959. namespace {
  5960. size_t SetMeshIndexing_hash_impl(const OpDef& def_) {
  5961. auto&& op_ = def_.cast_final_safe<SetMeshIndexing>();
  5962. static_cast<void>(op_);
  5963. size_t val = mgb::hash(op_.dyn_typeinfo());
  5964. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  5965. return val;
  5966. }
  5967. bool SetMeshIndexing_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5968. auto &&a_ = lhs_.cast_final_safe<SetMeshIndexing>(),
  5969. &&b_ = rhs_.cast_final_safe<SetMeshIndexing>();
  5970. static_cast<void>(a_);
  5971. static_cast<void>(b_);
  5972. if (a_.items != b_.items) return false;
  5973. return true;
  5974. }
  5975. std::vector<std::pair<const char*, std::string>> SetMeshIndexing_props_impl(const OpDef& def_) {
  5976. auto&& op_ = def_.cast_final_safe<SetMeshIndexing>();
  5977. static_cast<void>(op_);
  5978. std::vector<std::pair<const char*, std::string>> props_;
  5979. props_.emplace_back("items", "{std::vector}");
  5980. return props_;
  5981. }
  5982. std::string SetMeshIndexing_make_name_impl(const OpDef& def_) {
  5983. auto&& op_ = def_.cast_final_safe<SetMeshIndexing>();
  5984. static_cast<void>(op_);
  5985. return "SetMeshIndexing";
  5986. }
  5987. } // anonymous namespace
  5988. OP_TRAIT_REG(SetMeshIndexing, SetMeshIndexing)
  5989. .hash(SetMeshIndexing_hash_impl)
  5990. .is_same_st(SetMeshIndexing_is_same_st_impl)
  5991. .props(SetMeshIndexing_props_impl)
  5992. .make_name(SetMeshIndexing_make_name_impl);
  5993. MGB_DYN_TYPE_OBJ_FINAL_IMPL(SetSubtensor);
  5994. namespace {
  5995. size_t SetSubtensor_hash_impl(const OpDef& def_) {
  5996. auto&& op_ = def_.cast_final_safe<SetSubtensor>();
  5997. static_cast<void>(op_);
  5998. size_t val = mgb::hash(op_.dyn_typeinfo());
  5999. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  6000. return val;
  6001. }
  6002. bool SetSubtensor_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6003. auto &&a_ = lhs_.cast_final_safe<SetSubtensor>(),
  6004. &&b_ = rhs_.cast_final_safe<SetSubtensor>();
  6005. static_cast<void>(a_);
  6006. static_cast<void>(b_);
  6007. if (a_.items != b_.items) return false;
  6008. return true;
  6009. }
  6010. std::vector<std::pair<const char*, std::string>> SetSubtensor_props_impl(const OpDef& def_) {
  6011. auto&& op_ = def_.cast_final_safe<SetSubtensor>();
  6012. static_cast<void>(op_);
  6013. std::vector<std::pair<const char*, std::string>> props_;
  6014. props_.emplace_back("items", "{std::vector}");
  6015. return props_;
  6016. }
  6017. std::string SetSubtensor_make_name_impl(const OpDef& def_) {
  6018. auto&& op_ = def_.cast_final_safe<SetSubtensor>();
  6019. static_cast<void>(op_);
  6020. return "SetSubtensor";
  6021. }
  6022. } // anonymous namespace
  6023. OP_TRAIT_REG(SetSubtensor, SetSubtensor)
  6024. .hash(SetSubtensor_hash_impl)
  6025. .is_same_st(SetSubtensor_is_same_st_impl)
  6026. .props(SetSubtensor_props_impl)
  6027. .make_name(SetSubtensor_make_name_impl);
  6028. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ShuffleRNG);
  6029. namespace {
  6030. size_t ShuffleRNG_hash_impl(const OpDef& def_) {
  6031. auto&& op_ = def_.cast_final_safe<ShuffleRNG>();
  6032. static_cast<void>(op_);
  6033. return mgb::hash_pair_combine(
  6034. mgb::hash(op_.dyn_typeinfo()),
  6035. mgb::hash(op_.handle)
  6036. );
  6037. }
  6038. bool ShuffleRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6039. auto &&a_ = lhs_.cast_final_safe<ShuffleRNG>(),
  6040. &&b_ = rhs_.cast_final_safe<ShuffleRNG>();
  6041. static_cast<void>(a_);
  6042. static_cast<void>(b_);
  6043. return a_.handle == b_.handle;}
  6044. std::vector<std::pair<const char*, std::string>> ShuffleRNG_props_impl(const OpDef& def_) {
  6045. auto&& op_ = def_.cast_final_safe<ShuffleRNG>();
  6046. static_cast<void>(op_);
  6047. std::vector<std::pair<const char*, std::string>> props_;
  6048. props_.emplace_back("seed", std::to_string(op_.seed));
  6049. props_.emplace_back("handle", std::to_string(op_.handle));
  6050. return props_;
  6051. }
  6052. std::string ShuffleRNG_make_name_impl(const OpDef& def_) {
  6053. auto&& op_ = def_.cast_final_safe<ShuffleRNG>();
  6054. static_cast<void>(op_);
  6055. return "ShuffleRNG";
  6056. }
  6057. } // anonymous namespace
  6058. OP_TRAIT_REG(ShuffleRNG, ShuffleRNG)
  6059. .hash(ShuffleRNG_hash_impl)
  6060. .is_same_st(ShuffleRNG_is_same_st_impl)
  6061. .props(ShuffleRNG_props_impl)
  6062. .make_name(ShuffleRNG_make_name_impl);
  6063. MGB_DYN_TYPE_OBJ_FINAL_IMPL(SlidingWindowTranspose);
  6064. namespace {
  6065. size_t SlidingWindowTranspose_hash_impl(const OpDef& def_) {
  6066. auto&& op_ = def_.cast_final_safe<SlidingWindowTranspose>();
  6067. static_cast<void>(op_);
  6068. size_t val = mgb::hash(op_.dyn_typeinfo());
  6069. val = mgb::hash_pair_combine(val, mgb::hash(op_.out_h));
  6070. val = mgb::hash_pair_combine(val, mgb::hash(op_.out_w));
  6071. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  6072. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  6073. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  6074. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  6075. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
  6076. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
  6077. val = mgb::hash_pair_combine(val, mgb::hash(op_.window_h));
  6078. val = mgb::hash_pair_combine(val, mgb::hash(op_.window_w));
  6079. return val;
  6080. }
  6081. bool SlidingWindowTranspose_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6082. auto &&a_ = lhs_.cast_final_safe<SlidingWindowTranspose>(),
  6083. &&b_ = rhs_.cast_final_safe<SlidingWindowTranspose>();
  6084. static_cast<void>(a_);
  6085. static_cast<void>(b_);
  6086. if (a_.out_h != b_.out_h) return false;
  6087. if (a_.out_w != b_.out_w) return false;
  6088. if (a_.pad_h != b_.pad_h) return false;
  6089. if (a_.pad_w != b_.pad_w) return false;
  6090. if (a_.stride_h != b_.stride_h) return false;
  6091. if (a_.stride_w != b_.stride_w) return false;
  6092. if (a_.dilate_h != b_.dilate_h) return false;
  6093. if (a_.dilate_w != b_.dilate_w) return false;
  6094. if (a_.window_h != b_.window_h) return false;
  6095. if (a_.window_w != b_.window_w) return false;
  6096. return true;
  6097. }
  6098. std::vector<std::pair<const char*, std::string>> SlidingWindowTranspose_props_impl(const OpDef& def_) {
  6099. auto&& op_ = def_.cast_final_safe<SlidingWindowTranspose>();
  6100. static_cast<void>(op_);
  6101. std::vector<std::pair<const char*, std::string>> props_;
  6102. props_.emplace_back("out_h", std::to_string(op_.out_h));
  6103. props_.emplace_back("out_w", std::to_string(op_.out_w));
  6104. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  6105. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  6106. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  6107. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  6108. props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
  6109. props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
  6110. props_.emplace_back("window_h", std::to_string(op_.window_h));
  6111. props_.emplace_back("window_w", std::to_string(op_.window_w));
  6112. return props_;
  6113. }
  6114. std::string SlidingWindowTranspose_make_name_impl(const OpDef& def_) {
  6115. auto&& op_ = def_.cast_final_safe<SlidingWindowTranspose>();
  6116. static_cast<void>(op_);
  6117. return "SlidingWindowTranspose";
  6118. }
  6119. } // anonymous namespace
  6120. OP_TRAIT_REG(SlidingWindowTranspose, SlidingWindowTranspose)
  6121. .hash(SlidingWindowTranspose_hash_impl)
  6122. .is_same_st(SlidingWindowTranspose_is_same_st_impl)
  6123. .props(SlidingWindowTranspose_props_impl)
  6124. .make_name(SlidingWindowTranspose_make_name_impl);
  6125. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Softmax);
  6126. namespace {
  6127. size_t Softmax_hash_impl(const OpDef& def_) {
  6128. auto&& op_ = def_.cast_final_safe<Softmax>();
  6129. static_cast<void>(op_);
  6130. size_t val = mgb::hash(op_.dyn_typeinfo());
  6131. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  6132. return val;
  6133. }
  6134. bool Softmax_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6135. auto &&a_ = lhs_.cast_final_safe<Softmax>(),
  6136. &&b_ = rhs_.cast_final_safe<Softmax>();
  6137. static_cast<void>(a_);
  6138. static_cast<void>(b_);
  6139. if (a_.axis != b_.axis) return false;
  6140. return true;
  6141. }
  6142. std::vector<std::pair<const char*, std::string>> Softmax_props_impl(const OpDef& def_) {
  6143. auto&& op_ = def_.cast_final_safe<Softmax>();
  6144. static_cast<void>(op_);
  6145. std::vector<std::pair<const char*, std::string>> props_;
  6146. props_.emplace_back("axis", std::to_string(op_.axis));
  6147. return props_;
  6148. }
  6149. std::string Softmax_make_name_impl(const OpDef& def_) {
  6150. auto&& op_ = def_.cast_final_safe<Softmax>();
  6151. static_cast<void>(op_);
  6152. return "Softmax";
  6153. }
  6154. } // anonymous namespace
  6155. OP_TRAIT_REG(Softmax, Softmax)
  6156. .hash(Softmax_hash_impl)
  6157. .is_same_st(Softmax_is_same_st_impl)
  6158. .props(Softmax_props_impl)
  6159. .make_name(Softmax_make_name_impl);
  6160. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Split);
  6161. namespace {
  6162. size_t Split_hash_impl(const OpDef& def_) {
  6163. auto&& op_ = def_.cast_final_safe<Split>();
  6164. static_cast<void>(op_);
  6165. size_t val = mgb::hash(op_.dyn_typeinfo());
  6166. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  6167. val = mgb::hash_pair_combine(val, mgb::hash(op_.nsections));
  6168. return val;
  6169. }
  6170. bool Split_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6171. auto &&a_ = lhs_.cast_final_safe<Split>(),
  6172. &&b_ = rhs_.cast_final_safe<Split>();
  6173. static_cast<void>(a_);
  6174. static_cast<void>(b_);
  6175. if (a_.axis != b_.axis) return false;
  6176. if (a_.nsections != b_.nsections) return false;
  6177. return true;
  6178. }
  6179. std::vector<std::pair<const char*, std::string>> Split_props_impl(const OpDef& def_) {
  6180. auto&& op_ = def_.cast_final_safe<Split>();
  6181. static_cast<void>(op_);
  6182. std::vector<std::pair<const char*, std::string>> props_;
  6183. props_.emplace_back("axis", std::to_string(op_.axis));
  6184. props_.emplace_back("nsections", std::to_string(op_.nsections));
  6185. return props_;
  6186. }
  6187. std::string Split_make_name_impl(const OpDef& def_) {
  6188. auto&& op_ = def_.cast_final_safe<Split>();
  6189. static_cast<void>(op_);
  6190. return "Split";
  6191. }
  6192. } // anonymous namespace
  6193. OP_TRAIT_REG(Split, Split)
  6194. .hash(Split_hash_impl)
  6195. .is_same_st(Split_is_same_st_impl)
  6196. .props(Split_props_impl)
  6197. .make_name(Split_make_name_impl);
  6198. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Subtensor);
  6199. namespace {
  6200. size_t Subtensor_hash_impl(const OpDef& def_) {
  6201. auto&& op_ = def_.cast_final_safe<Subtensor>();
  6202. static_cast<void>(op_);
  6203. size_t val = mgb::hash(op_.dyn_typeinfo());
  6204. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  6205. return val;
  6206. }
  6207. bool Subtensor_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6208. auto &&a_ = lhs_.cast_final_safe<Subtensor>(),
  6209. &&b_ = rhs_.cast_final_safe<Subtensor>();
  6210. static_cast<void>(a_);
  6211. static_cast<void>(b_);
  6212. if (a_.items != b_.items) return false;
  6213. return true;
  6214. }
  6215. std::vector<std::pair<const char*, std::string>> Subtensor_props_impl(const OpDef& def_) {
  6216. auto&& op_ = def_.cast_final_safe<Subtensor>();
  6217. static_cast<void>(op_);
  6218. std::vector<std::pair<const char*, std::string>> props_;
  6219. props_.emplace_back("items", "{std::vector}");
  6220. return props_;
  6221. }
  6222. std::string Subtensor_make_name_impl(const OpDef& def_) {
  6223. auto&& op_ = def_.cast_final_safe<Subtensor>();
  6224. static_cast<void>(op_);
  6225. return "Subtensor";
  6226. }
  6227. } // anonymous namespace
  6228. OP_TRAIT_REG(Subtensor, Subtensor)
  6229. .hash(Subtensor_hash_impl)
  6230. .is_same_st(Subtensor_is_same_st_impl)
  6231. .props(Subtensor_props_impl)
  6232. .make_name(Subtensor_make_name_impl);
  6233. MGB_DYN_TYPE_OBJ_FINAL_IMPL(TQT);
  6234. namespace {
  6235. size_t TQT_hash_impl(const OpDef& def_) {
  6236. auto&& op_ = def_.cast_final_safe<TQT>();
  6237. static_cast<void>(op_);
  6238. size_t val = mgb::hash(op_.dyn_typeinfo());
  6239. val = mgb::hash_pair_combine(val, mgb::hash(op_.qmin));
  6240. val = mgb::hash_pair_combine(val, mgb::hash(op_.qmax));
  6241. return val;
  6242. }
  6243. bool TQT_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6244. auto &&a_ = lhs_.cast_final_safe<TQT>(),
  6245. &&b_ = rhs_.cast_final_safe<TQT>();
  6246. static_cast<void>(a_);
  6247. static_cast<void>(b_);
  6248. if (a_.qmin != b_.qmin) return false;
  6249. if (a_.qmax != b_.qmax) return false;
  6250. return true;
  6251. }
  6252. std::vector<std::pair<const char*, std::string>> TQT_props_impl(const OpDef& def_) {
  6253. auto&& op_ = def_.cast_final_safe<TQT>();
  6254. static_cast<void>(op_);
  6255. std::vector<std::pair<const char*, std::string>> props_;
  6256. props_.emplace_back("qmin", std::to_string(op_.qmin));
  6257. props_.emplace_back("qmax", std::to_string(op_.qmax));
  6258. return props_;
  6259. }
  6260. std::string TQT_make_name_impl(const OpDef& def_) {
  6261. auto&& op_ = def_.cast_final_safe<TQT>();
  6262. static_cast<void>(op_);
  6263. return "TQT";
  6264. }
  6265. } // anonymous namespace
  6266. OP_TRAIT_REG(TQT, TQT)
  6267. .hash(TQT_hash_impl)
  6268. .is_same_st(TQT_is_same_st_impl)
  6269. .props(TQT_props_impl)
  6270. .make_name(TQT_make_name_impl);
  6271. MGB_DYN_TYPE_OBJ_FINAL_IMPL(TensorRTRuntime);
  6272. namespace {
  6273. size_t TensorRTRuntime_hash_impl(const OpDef& def_) {
  6274. auto&& op_ = def_.cast_final_safe<TensorRTRuntime>();
  6275. static_cast<void>(op_);
  6276. size_t val = mgb::hash(op_.dyn_typeinfo());
  6277. val = mgb::hash_pair_combine(val, mgb::hash(op_.buf));
  6278. val = mgb::hash_pair_combine(val, mgb::hash(op_.buf_size));
  6279. return val;
  6280. }
  6281. bool TensorRTRuntime_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6282. auto &&a_ = lhs_.cast_final_safe<TensorRTRuntime>(),
  6283. &&b_ = rhs_.cast_final_safe<TensorRTRuntime>();
  6284. static_cast<void>(a_);
  6285. static_cast<void>(b_);
  6286. if (a_.buf != b_.buf) return false;
  6287. if (a_.buf_size != b_.buf_size) return false;
  6288. return true;
  6289. }
  6290. std::vector<std::pair<const char*, std::string>> TensorRTRuntime_props_impl(const OpDef& def_) {
  6291. auto&& op_ = def_.cast_final_safe<TensorRTRuntime>();
  6292. static_cast<void>(op_);
  6293. std::vector<std::pair<const char*, std::string>> props_;
  6294. props_.emplace_back("buf", op_.buf);
  6295. props_.emplace_back("buf_size", std::to_string(op_.buf_size));
  6296. return props_;
  6297. }
  6298. std::string TensorRTRuntime_make_name_impl(const OpDef& def_) {
  6299. auto&& op_ = def_.cast_final_safe<TensorRTRuntime>();
  6300. static_cast<void>(op_);
  6301. return "TensorRTRuntime";
  6302. }
  6303. } // anonymous namespace
  6304. OP_TRAIT_REG(TensorRTRuntime, TensorRTRuntime)
  6305. .hash(TensorRTRuntime_hash_impl)
  6306. .is_same_st(TensorRTRuntime_is_same_st_impl)
  6307. .props(TensorRTRuntime_props_impl)
  6308. .make_name(TensorRTRuntime_make_name_impl);
  6309. MGB_DYN_TYPE_OBJ_FINAL_IMPL(TopK);
  6310. namespace {
  6311. size_t TopK_hash_impl(const OpDef& def_) {
  6312. auto&& op_ = def_.cast_final_safe<TopK>();
  6313. static_cast<void>(op_);
  6314. size_t val = mgb::hash(op_.dyn_typeinfo());
  6315. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  6316. return val;
  6317. }
  6318. bool TopK_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6319. auto &&a_ = lhs_.cast_final_safe<TopK>(),
  6320. &&b_ = rhs_.cast_final_safe<TopK>();
  6321. static_cast<void>(a_);
  6322. static_cast<void>(b_);
  6323. if (a_.mode != b_.mode) return false;
  6324. return true;
  6325. }
  6326. std::vector<std::pair<const char*, std::string>> TopK_props_impl(const OpDef& def_) {
  6327. auto&& op_ = def_.cast_final_safe<TopK>();
  6328. static_cast<void>(op_);
  6329. std::vector<std::pair<const char*, std::string>> props_;
  6330. switch (op_.mode){
  6331. case TopK::Mode::KTH_ONLY:
  6332. props_.emplace_back("mode", "KTH_ONLY");
  6333. break;
  6334. case TopK::Mode::VALUE_IDX_NOSORT:
  6335. props_.emplace_back("mode", "VALUE_IDX_NOSORT");
  6336. break;
  6337. case TopK::Mode::VALUE_IDX_SORTED:
  6338. props_.emplace_back("mode", "VALUE_IDX_SORTED");
  6339. break;
  6340. default:
  6341. props_.emplace_back("mode", "INVALID");
  6342. break;
  6343. }
  6344. return props_;
  6345. }
  6346. std::string TopK_make_name_impl(const OpDef& def_) {
  6347. auto&& op_ = def_.cast_final_safe<TopK>();
  6348. static_cast<void>(op_);
  6349. return "TopK";
  6350. }
  6351. } // anonymous namespace
  6352. OP_TRAIT_REG(TopK, TopK)
  6353. .hash(TopK_hash_impl)
  6354. .is_same_st(TopK_is_same_st_impl)
  6355. .props(TopK_props_impl)
  6356. .make_name(TopK_make_name_impl);
  6357. MGB_DYN_TYPE_OBJ_FINAL_IMPL(TypeCvt);
  6358. namespace {
  6359. size_t TypeCvt_hash_impl(const OpDef& def_) {
  6360. auto&& op_ = def_.cast_final_safe<TypeCvt>();
  6361. static_cast<void>(op_);
  6362. size_t val = mgb::hash(op_.dyn_typeinfo());
  6363. val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
  6364. return val;
  6365. }
  6366. bool TypeCvt_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6367. auto &&a_ = lhs_.cast_final_safe<TypeCvt>(),
  6368. &&b_ = rhs_.cast_final_safe<TypeCvt>();
  6369. static_cast<void>(a_);
  6370. static_cast<void>(b_);
  6371. if (a_.dtype != b_.dtype) return false;
  6372. return true;
  6373. }
  6374. std::vector<std::pair<const char*, std::string>> TypeCvt_props_impl(const OpDef& def_) {
  6375. auto&& op_ = def_.cast_final_safe<TypeCvt>();
  6376. static_cast<void>(op_);
  6377. std::vector<std::pair<const char*, std::string>> props_;
  6378. props_.emplace_back("dtype", op_.dtype.name());
  6379. return props_;
  6380. }
  6381. std::string TypeCvt_make_name_impl(const OpDef& def_) {
  6382. auto&& op_ = def_.cast_final_safe<TypeCvt>();
  6383. static_cast<void>(op_);
  6384. return "TypeCvt";
  6385. }
  6386. } // anonymous namespace
  6387. OP_TRAIT_REG(TypeCvt, TypeCvt)
  6388. .hash(TypeCvt_hash_impl)
  6389. .is_same_st(TypeCvt_is_same_st_impl)
  6390. .props(TypeCvt_props_impl)
  6391. .make_name(TypeCvt_make_name_impl);
  6392. MGB_DYN_TYPE_OBJ_FINAL_IMPL(UniformRNG);
  6393. namespace {
  6394. size_t UniformRNG_hash_impl(const OpDef& def_) {
  6395. auto&& op_ = def_.cast_final_safe<UniformRNG>();
  6396. static_cast<void>(op_);
  6397. return mgb::hash_pair_combine(
  6398. mgb::hash(op_.dyn_typeinfo()),
  6399. mgb::hash_pair_combine(
  6400. mgb::hash(op_.handle),
  6401. mgb::hash(op_.dtype.enumv())
  6402. )
  6403. );
  6404. }
  6405. bool UniformRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6406. auto &&a_ = lhs_.cast_final_safe<UniformRNG>(),
  6407. &&b_ = rhs_.cast_final_safe<UniformRNG>();
  6408. static_cast<void>(a_);
  6409. static_cast<void>(b_);
  6410. return a_.handle == b_.handle && a_.dtype == b_.dtype;}
  6411. std::vector<std::pair<const char*, std::string>> UniformRNG_props_impl(const OpDef& def_) {
  6412. auto&& op_ = def_.cast_final_safe<UniformRNG>();
  6413. static_cast<void>(op_);
  6414. std::vector<std::pair<const char*, std::string>> props_;
  6415. props_.emplace_back("seed", std::to_string(op_.seed));
  6416. props_.emplace_back("dtype", op_.dtype.name());
  6417. props_.emplace_back("handle", std::to_string(op_.handle));
  6418. return props_;
  6419. }
  6420. std::string UniformRNG_make_name_impl(const OpDef& def_) {
  6421. auto&& op_ = def_.cast_final_safe<UniformRNG>();
  6422. static_cast<void>(op_);
  6423. return "UniformRNG";
  6424. }
  6425. } // anonymous namespace
  6426. OP_TRAIT_REG(UniformRNG, UniformRNG)
  6427. .hash(UniformRNG_hash_impl)
  6428. .is_same_st(UniformRNG_is_same_st_impl)
  6429. .props(UniformRNG_props_impl)
  6430. .make_name(UniformRNG_make_name_impl);
  6431. MGB_DYN_TYPE_OBJ_FINAL_IMPL(WarpAffine);
  6432. namespace {
  6433. size_t WarpAffine_hash_impl(const OpDef& def_) {
  6434. auto&& op_ = def_.cast_final_safe<WarpAffine>();
  6435. static_cast<void>(op_);
  6436. size_t val = mgb::hash(op_.dyn_typeinfo());
  6437. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
  6438. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.border_mode));
  6439. val = mgb::hash_pair_combine(val, mgb::hash(op_.border_val));
  6440. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  6441. return val;
  6442. }
  6443. bool WarpAffine_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6444. auto &&a_ = lhs_.cast_final_safe<WarpAffine>(),
  6445. &&b_ = rhs_.cast_final_safe<WarpAffine>();
  6446. static_cast<void>(a_);
  6447. static_cast<void>(b_);
  6448. if (a_.imode != b_.imode) return false;
  6449. if (a_.border_mode != b_.border_mode) return false;
  6450. if (a_.border_val != b_.border_val) return false;
  6451. if (a_.format != b_.format) return false;
  6452. return true;
  6453. }
  6454. std::vector<std::pair<const char*, std::string>> WarpAffine_props_impl(const OpDef& def_) {
  6455. auto&& op_ = def_.cast_final_safe<WarpAffine>();
  6456. static_cast<void>(op_);
  6457. std::vector<std::pair<const char*, std::string>> props_;
  6458. switch (op_.imode){
  6459. case WarpAffine::InterpolationMode::NEAREST:
  6460. props_.emplace_back("imode", "NEAREST");
  6461. break;
  6462. case WarpAffine::InterpolationMode::LINEAR:
  6463. props_.emplace_back("imode", "LINEAR");
  6464. break;
  6465. case WarpAffine::InterpolationMode::AREA:
  6466. props_.emplace_back("imode", "AREA");
  6467. break;
  6468. case WarpAffine::InterpolationMode::CUBIC:
  6469. props_.emplace_back("imode", "CUBIC");
  6470. break;
  6471. case WarpAffine::InterpolationMode::LANCZOS4:
  6472. props_.emplace_back("imode", "LANCZOS4");
  6473. break;
  6474. default:
  6475. props_.emplace_back("imode", "INVALID");
  6476. break;
  6477. }
  6478. switch (op_.border_mode){
  6479. case WarpAffine::BorderMode::REPLICATE:
  6480. props_.emplace_back("border_mode", "REPLICATE");
  6481. break;
  6482. case WarpAffine::BorderMode::REFLECT:
  6483. props_.emplace_back("border_mode", "REFLECT");
  6484. break;
  6485. case WarpAffine::BorderMode::REFLECT_101:
  6486. props_.emplace_back("border_mode", "REFLECT_101");
  6487. break;
  6488. case WarpAffine::BorderMode::WRAP:
  6489. props_.emplace_back("border_mode", "WRAP");
  6490. break;
  6491. case WarpAffine::BorderMode::CONSTANT:
  6492. props_.emplace_back("border_mode", "CONSTANT");
  6493. break;
  6494. case WarpAffine::BorderMode::TRANSPARENT:
  6495. props_.emplace_back("border_mode", "TRANSPARENT");
  6496. break;
  6497. case WarpAffine::BorderMode::ISOLATED:
  6498. props_.emplace_back("border_mode", "ISOLATED");
  6499. break;
  6500. default:
  6501. props_.emplace_back("border_mode", "INVALID");
  6502. break;
  6503. }
  6504. props_.emplace_back("border_val", std::to_string(op_.border_val));
  6505. switch (op_.format){
  6506. case WarpAffine::Format::NCHW:
  6507. props_.emplace_back("format", "NCHW");
  6508. break;
  6509. case WarpAffine::Format::NHWC:
  6510. props_.emplace_back("format", "NHWC");
  6511. break;
  6512. case WarpAffine::Format::NHWCD4:
  6513. props_.emplace_back("format", "NHWCD4");
  6514. break;
  6515. case WarpAffine::Format::NCHW4:
  6516. props_.emplace_back("format", "NCHW4");
  6517. break;
  6518. case WarpAffine::Format::NCHW8:
  6519. props_.emplace_back("format", "NCHW8");
  6520. break;
  6521. case WarpAffine::Format::NCHW32:
  6522. props_.emplace_back("format", "NCHW32");
  6523. break;
  6524. case WarpAffine::Format::NCHW88:
  6525. props_.emplace_back("format", "NCHW88");
  6526. break;
  6527. case WarpAffine::Format::NCHW44:
  6528. props_.emplace_back("format", "NCHW44");
  6529. break;
  6530. case WarpAffine::Format::NCHW44_DOT:
  6531. props_.emplace_back("format", "NCHW44_DOT");
  6532. break;
  6533. case WarpAffine::Format::NCHW4_NCHW32:
  6534. props_.emplace_back("format", "NCHW4_NCHW32");
  6535. break;
  6536. case WarpAffine::Format::NCHW32_NCHW4:
  6537. props_.emplace_back("format", "NCHW32_NCHW4");
  6538. break;
  6539. case WarpAffine::Format::NCHW4_NCHW:
  6540. props_.emplace_back("format", "NCHW4_NCHW");
  6541. break;
  6542. case WarpAffine::Format::NHWC_NCHW:
  6543. props_.emplace_back("format", "NHWC_NCHW");
  6544. break;
  6545. case WarpAffine::Format::NHWC_NCHW4_IC_SMALL:
  6546. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  6547. break;
  6548. case WarpAffine::Format::NCHW_NCHW4_IC_SMALL:
  6549. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  6550. break;
  6551. case WarpAffine::Format::CHWN4:
  6552. props_.emplace_back("format", "CHWN4");
  6553. break;
  6554. case WarpAffine::Format::NCHW64:
  6555. props_.emplace_back("format", "NCHW64");
  6556. break;
  6557. case WarpAffine::Format::NCHW4_NHWC:
  6558. props_.emplace_back("format", "NCHW4_NHWC");
  6559. break;
  6560. default:
  6561. props_.emplace_back("format", "INVALID");
  6562. break;
  6563. }
  6564. return props_;
  6565. }
  6566. std::string WarpAffine_make_name_impl(const OpDef& def_) {
  6567. auto&& op_ = def_.cast_final_safe<WarpAffine>();
  6568. static_cast<void>(op_);
  6569. return "WarpAffine";
  6570. }
  6571. } // anonymous namespace
  6572. OP_TRAIT_REG(WarpAffine, WarpAffine)
  6573. .hash(WarpAffine_hash_impl)
  6574. .is_same_st(WarpAffine_is_same_st_impl)
  6575. .props(WarpAffine_props_impl)
  6576. .make_name(WarpAffine_make_name_impl);
  6577. MGB_DYN_TYPE_OBJ_FINAL_IMPL(WarpPerspective);
  6578. namespace {
  6579. size_t WarpPerspective_hash_impl(const OpDef& def_) {
  6580. auto&& op_ = def_.cast_final_safe<WarpPerspective>();
  6581. static_cast<void>(op_);
  6582. size_t val = mgb::hash(op_.dyn_typeinfo());
  6583. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
  6584. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.bmode));
  6585. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  6586. val = mgb::hash_pair_combine(val, mgb::hash(op_.border_val));
  6587. return val;
  6588. }
  6589. bool WarpPerspective_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6590. auto &&a_ = lhs_.cast_final_safe<WarpPerspective>(),
  6591. &&b_ = rhs_.cast_final_safe<WarpPerspective>();
  6592. static_cast<void>(a_);
  6593. static_cast<void>(b_);
  6594. if (a_.imode != b_.imode) return false;
  6595. if (a_.bmode != b_.bmode) return false;
  6596. if (a_.format != b_.format) return false;
  6597. if (a_.border_val != b_.border_val) return false;
  6598. return true;
  6599. }
  6600. std::vector<std::pair<const char*, std::string>> WarpPerspective_props_impl(const OpDef& def_) {
  6601. auto&& op_ = def_.cast_final_safe<WarpPerspective>();
  6602. static_cast<void>(op_);
  6603. std::vector<std::pair<const char*, std::string>> props_;
  6604. switch (op_.imode){
  6605. case WarpPerspective::InterpolationMode::NEAREST:
  6606. props_.emplace_back("imode", "NEAREST");
  6607. break;
  6608. case WarpPerspective::InterpolationMode::LINEAR:
  6609. props_.emplace_back("imode", "LINEAR");
  6610. break;
  6611. case WarpPerspective::InterpolationMode::AREA:
  6612. props_.emplace_back("imode", "AREA");
  6613. break;
  6614. case WarpPerspective::InterpolationMode::CUBIC:
  6615. props_.emplace_back("imode", "CUBIC");
  6616. break;
  6617. case WarpPerspective::InterpolationMode::LANCZOS4:
  6618. props_.emplace_back("imode", "LANCZOS4");
  6619. break;
  6620. default:
  6621. props_.emplace_back("imode", "INVALID");
  6622. break;
  6623. }
  6624. switch (op_.bmode){
  6625. case WarpPerspective::BorderMode::REPLICATE:
  6626. props_.emplace_back("bmode", "REPLICATE");
  6627. break;
  6628. case WarpPerspective::BorderMode::REFLECT:
  6629. props_.emplace_back("bmode", "REFLECT");
  6630. break;
  6631. case WarpPerspective::BorderMode::REFLECT_101:
  6632. props_.emplace_back("bmode", "REFLECT_101");
  6633. break;
  6634. case WarpPerspective::BorderMode::WRAP:
  6635. props_.emplace_back("bmode", "WRAP");
  6636. break;
  6637. case WarpPerspective::BorderMode::CONSTANT:
  6638. props_.emplace_back("bmode", "CONSTANT");
  6639. break;
  6640. case WarpPerspective::BorderMode::TRANSPARENT:
  6641. props_.emplace_back("bmode", "TRANSPARENT");
  6642. break;
  6643. case WarpPerspective::BorderMode::ISOLATED:
  6644. props_.emplace_back("bmode", "ISOLATED");
  6645. break;
  6646. default:
  6647. props_.emplace_back("bmode", "INVALID");
  6648. break;
  6649. }
  6650. switch (op_.format){
  6651. case WarpPerspective::Format::NCHW:
  6652. props_.emplace_back("format", "NCHW");
  6653. break;
  6654. case WarpPerspective::Format::NHWC:
  6655. props_.emplace_back("format", "NHWC");
  6656. break;
  6657. case WarpPerspective::Format::NHWCD4:
  6658. props_.emplace_back("format", "NHWCD4");
  6659. break;
  6660. case WarpPerspective::Format::NCHW4:
  6661. props_.emplace_back("format", "NCHW4");
  6662. break;
  6663. case WarpPerspective::Format::NCHW8:
  6664. props_.emplace_back("format", "NCHW8");
  6665. break;
  6666. case WarpPerspective::Format::NCHW32:
  6667. props_.emplace_back("format", "NCHW32");
  6668. break;
  6669. case WarpPerspective::Format::NCHW88:
  6670. props_.emplace_back("format", "NCHW88");
  6671. break;
  6672. case WarpPerspective::Format::NCHW44:
  6673. props_.emplace_back("format", "NCHW44");
  6674. break;
  6675. case WarpPerspective::Format::NCHW44_DOT:
  6676. props_.emplace_back("format", "NCHW44_DOT");
  6677. break;
  6678. case WarpPerspective::Format::NCHW4_NCHW32:
  6679. props_.emplace_back("format", "NCHW4_NCHW32");
  6680. break;
  6681. case WarpPerspective::Format::NCHW32_NCHW4:
  6682. props_.emplace_back("format", "NCHW32_NCHW4");
  6683. break;
  6684. case WarpPerspective::Format::NCHW4_NCHW:
  6685. props_.emplace_back("format", "NCHW4_NCHW");
  6686. break;
  6687. case WarpPerspective::Format::NHWC_NCHW:
  6688. props_.emplace_back("format", "NHWC_NCHW");
  6689. break;
  6690. case WarpPerspective::Format::NHWC_NCHW4_IC_SMALL:
  6691. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  6692. break;
  6693. case WarpPerspective::Format::NCHW_NCHW4_IC_SMALL:
  6694. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  6695. break;
  6696. case WarpPerspective::Format::CHWN4:
  6697. props_.emplace_back("format", "CHWN4");
  6698. break;
  6699. case WarpPerspective::Format::NCHW64:
  6700. props_.emplace_back("format", "NCHW64");
  6701. break;
  6702. case WarpPerspective::Format::NCHW4_NHWC:
  6703. props_.emplace_back("format", "NCHW4_NHWC");
  6704. break;
  6705. default:
  6706. props_.emplace_back("format", "INVALID");
  6707. break;
  6708. }
  6709. props_.emplace_back("border_val", std::to_string(op_.border_val));
  6710. return props_;
  6711. }
  6712. std::string WarpPerspective_make_name_impl(const OpDef& def_) {
  6713. auto&& op_ = def_.cast_final_safe<WarpPerspective>();
  6714. static_cast<void>(op_);
  6715. return "WarpPerspective";
  6716. }
  6717. } // anonymous namespace
  6718. OP_TRAIT_REG(WarpPerspective, WarpPerspective)
  6719. .hash(WarpPerspective_hash_impl)
  6720. .is_same_st(WarpPerspective_is_same_st_impl)
  6721. .props(WarpPerspective_props_impl)
  6722. .make_name(WarpPerspective_make_name_impl);
  6723. MGB_DYN_TYPE_OBJ_FINAL_IMPL(WarpPerspectiveBackwardData);
  6724. namespace {
  6725. size_t WarpPerspectiveBackwardData_hash_impl(const OpDef& def_) {
  6726. auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardData>();
  6727. static_cast<void>(op_);
  6728. size_t val = mgb::hash(op_.dyn_typeinfo());
  6729. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
  6730. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.bmode));
  6731. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  6732. val = mgb::hash_pair_combine(val, mgb::hash(op_.border_val));
  6733. return val;
  6734. }
  6735. bool WarpPerspectiveBackwardData_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6736. auto &&a_ = lhs_.cast_final_safe<WarpPerspectiveBackwardData>(),
  6737. &&b_ = rhs_.cast_final_safe<WarpPerspectiveBackwardData>();
  6738. static_cast<void>(a_);
  6739. static_cast<void>(b_);
  6740. if (a_.imode != b_.imode) return false;
  6741. if (a_.bmode != b_.bmode) return false;
  6742. if (a_.format != b_.format) return false;
  6743. if (a_.border_val != b_.border_val) return false;
  6744. return true;
  6745. }
  6746. std::vector<std::pair<const char*, std::string>> WarpPerspectiveBackwardData_props_impl(const OpDef& def_) {
  6747. auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardData>();
  6748. static_cast<void>(op_);
  6749. std::vector<std::pair<const char*, std::string>> props_;
  6750. switch (op_.imode){
  6751. case WarpPerspectiveBackwardData::InterpolationMode::NEAREST:
  6752. props_.emplace_back("imode", "NEAREST");
  6753. break;
  6754. case WarpPerspectiveBackwardData::InterpolationMode::LINEAR:
  6755. props_.emplace_back("imode", "LINEAR");
  6756. break;
  6757. case WarpPerspectiveBackwardData::InterpolationMode::AREA:
  6758. props_.emplace_back("imode", "AREA");
  6759. break;
  6760. case WarpPerspectiveBackwardData::InterpolationMode::CUBIC:
  6761. props_.emplace_back("imode", "CUBIC");
  6762. break;
  6763. case WarpPerspectiveBackwardData::InterpolationMode::LANCZOS4:
  6764. props_.emplace_back("imode", "LANCZOS4");
  6765. break;
  6766. default:
  6767. props_.emplace_back("imode", "INVALID");
  6768. break;
  6769. }
  6770. switch (op_.bmode){
  6771. case WarpPerspectiveBackwardData::BorderMode::REPLICATE:
  6772. props_.emplace_back("bmode", "REPLICATE");
  6773. break;
  6774. case WarpPerspectiveBackwardData::BorderMode::REFLECT:
  6775. props_.emplace_back("bmode", "REFLECT");
  6776. break;
  6777. case WarpPerspectiveBackwardData::BorderMode::REFLECT_101:
  6778. props_.emplace_back("bmode", "REFLECT_101");
  6779. break;
  6780. case WarpPerspectiveBackwardData::BorderMode::WRAP:
  6781. props_.emplace_back("bmode", "WRAP");
  6782. break;
  6783. case WarpPerspectiveBackwardData::BorderMode::CONSTANT:
  6784. props_.emplace_back("bmode", "CONSTANT");
  6785. break;
  6786. case WarpPerspectiveBackwardData::BorderMode::TRANSPARENT:
  6787. props_.emplace_back("bmode", "TRANSPARENT");
  6788. break;
  6789. case WarpPerspectiveBackwardData::BorderMode::ISOLATED:
  6790. props_.emplace_back("bmode", "ISOLATED");
  6791. break;
  6792. default:
  6793. props_.emplace_back("bmode", "INVALID");
  6794. break;
  6795. }
  6796. switch (op_.format){
  6797. case WarpPerspectiveBackwardData::Format::NCHW:
  6798. props_.emplace_back("format", "NCHW");
  6799. break;
  6800. case WarpPerspectiveBackwardData::Format::NHWC:
  6801. props_.emplace_back("format", "NHWC");
  6802. break;
  6803. case WarpPerspectiveBackwardData::Format::NHWCD4:
  6804. props_.emplace_back("format", "NHWCD4");
  6805. break;
  6806. case WarpPerspectiveBackwardData::Format::NCHW4:
  6807. props_.emplace_back("format", "NCHW4");
  6808. break;
  6809. case WarpPerspectiveBackwardData::Format::NCHW8:
  6810. props_.emplace_back("format", "NCHW8");
  6811. break;
  6812. case WarpPerspectiveBackwardData::Format::NCHW32:
  6813. props_.emplace_back("format", "NCHW32");
  6814. break;
  6815. case WarpPerspectiveBackwardData::Format::NCHW88:
  6816. props_.emplace_back("format", "NCHW88");
  6817. break;
  6818. case WarpPerspectiveBackwardData::Format::NCHW44:
  6819. props_.emplace_back("format", "NCHW44");
  6820. break;
  6821. case WarpPerspectiveBackwardData::Format::NCHW44_DOT:
  6822. props_.emplace_back("format", "NCHW44_DOT");
  6823. break;
  6824. case WarpPerspectiveBackwardData::Format::NCHW4_NCHW32:
  6825. props_.emplace_back("format", "NCHW4_NCHW32");
  6826. break;
  6827. case WarpPerspectiveBackwardData::Format::NCHW32_NCHW4:
  6828. props_.emplace_back("format", "NCHW32_NCHW4");
  6829. break;
  6830. case WarpPerspectiveBackwardData::Format::NCHW4_NCHW:
  6831. props_.emplace_back("format", "NCHW4_NCHW");
  6832. break;
  6833. case WarpPerspectiveBackwardData::Format::NHWC_NCHW:
  6834. props_.emplace_back("format", "NHWC_NCHW");
  6835. break;
  6836. case WarpPerspectiveBackwardData::Format::NHWC_NCHW4_IC_SMALL:
  6837. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  6838. break;
  6839. case WarpPerspectiveBackwardData::Format::NCHW_NCHW4_IC_SMALL:
  6840. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  6841. break;
  6842. case WarpPerspectiveBackwardData::Format::CHWN4:
  6843. props_.emplace_back("format", "CHWN4");
  6844. break;
  6845. case WarpPerspectiveBackwardData::Format::NCHW64:
  6846. props_.emplace_back("format", "NCHW64");
  6847. break;
  6848. case WarpPerspectiveBackwardData::Format::NCHW4_NHWC:
  6849. props_.emplace_back("format", "NCHW4_NHWC");
  6850. break;
  6851. default:
  6852. props_.emplace_back("format", "INVALID");
  6853. break;
  6854. }
  6855. props_.emplace_back("border_val", std::to_string(op_.border_val));
  6856. return props_;
  6857. }
  6858. std::string WarpPerspectiveBackwardData_make_name_impl(const OpDef& def_) {
  6859. auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardData>();
  6860. static_cast<void>(op_);
  6861. return "WarpPerspectiveBackwardData";
  6862. }
  6863. } // anonymous namespace
  6864. OP_TRAIT_REG(WarpPerspectiveBackwardData, WarpPerspectiveBackwardData)
  6865. .hash(WarpPerspectiveBackwardData_hash_impl)
  6866. .is_same_st(WarpPerspectiveBackwardData_is_same_st_impl)
  6867. .props(WarpPerspectiveBackwardData_props_impl)
  6868. .make_name(WarpPerspectiveBackwardData_make_name_impl);
  6869. MGB_DYN_TYPE_OBJ_FINAL_IMPL(WarpPerspectiveBackwardMat);
  6870. namespace {
  6871. size_t WarpPerspectiveBackwardMat_hash_impl(const OpDef& def_) {
  6872. auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardMat>();
  6873. static_cast<void>(op_);
  6874. size_t val = mgb::hash(op_.dyn_typeinfo());
  6875. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
  6876. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.bmode));
  6877. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  6878. val = mgb::hash_pair_combine(val, mgb::hash(op_.border_val));
  6879. return val;
  6880. }
  6881. bool WarpPerspectiveBackwardMat_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6882. auto &&a_ = lhs_.cast_final_safe<WarpPerspectiveBackwardMat>(),
  6883. &&b_ = rhs_.cast_final_safe<WarpPerspectiveBackwardMat>();
  6884. static_cast<void>(a_);
  6885. static_cast<void>(b_);
  6886. if (a_.imode != b_.imode) return false;
  6887. if (a_.bmode != b_.bmode) return false;
  6888. if (a_.format != b_.format) return false;
  6889. if (a_.border_val != b_.border_val) return false;
  6890. return true;
  6891. }
  6892. std::vector<std::pair<const char*, std::string>> WarpPerspectiveBackwardMat_props_impl(const OpDef& def_) {
  6893. auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardMat>();
  6894. static_cast<void>(op_);
  6895. std::vector<std::pair<const char*, std::string>> props_;
  6896. switch (op_.imode){
  6897. case WarpPerspectiveBackwardMat::InterpolationMode::NEAREST:
  6898. props_.emplace_back("imode", "NEAREST");
  6899. break;
  6900. case WarpPerspectiveBackwardMat::InterpolationMode::LINEAR:
  6901. props_.emplace_back("imode", "LINEAR");
  6902. break;
  6903. case WarpPerspectiveBackwardMat::InterpolationMode::AREA:
  6904. props_.emplace_back("imode", "AREA");
  6905. break;
  6906. case WarpPerspectiveBackwardMat::InterpolationMode::CUBIC:
  6907. props_.emplace_back("imode", "CUBIC");
  6908. break;
  6909. case WarpPerspectiveBackwardMat::InterpolationMode::LANCZOS4:
  6910. props_.emplace_back("imode", "LANCZOS4");
  6911. break;
  6912. default:
  6913. props_.emplace_back("imode", "INVALID");
  6914. break;
  6915. }
  6916. switch (op_.bmode){
  6917. case WarpPerspectiveBackwardMat::BorderMode::REPLICATE:
  6918. props_.emplace_back("bmode", "REPLICATE");
  6919. break;
  6920. case WarpPerspectiveBackwardMat::BorderMode::REFLECT:
  6921. props_.emplace_back("bmode", "REFLECT");
  6922. break;
  6923. case WarpPerspectiveBackwardMat::BorderMode::REFLECT_101:
  6924. props_.emplace_back("bmode", "REFLECT_101");
  6925. break;
  6926. case WarpPerspectiveBackwardMat::BorderMode::WRAP:
  6927. props_.emplace_back("bmode", "WRAP");
  6928. break;
  6929. case WarpPerspectiveBackwardMat::BorderMode::CONSTANT:
  6930. props_.emplace_back("bmode", "CONSTANT");
  6931. break;
  6932. case WarpPerspectiveBackwardMat::BorderMode::TRANSPARENT:
  6933. props_.emplace_back("bmode", "TRANSPARENT");
  6934. break;
  6935. case WarpPerspectiveBackwardMat::BorderMode::ISOLATED:
  6936. props_.emplace_back("bmode", "ISOLATED");
  6937. break;
  6938. default:
  6939. props_.emplace_back("bmode", "INVALID");
  6940. break;
  6941. }
  6942. switch (op_.format){
  6943. case WarpPerspectiveBackwardMat::Format::NCHW:
  6944. props_.emplace_back("format", "NCHW");
  6945. break;
  6946. case WarpPerspectiveBackwardMat::Format::NHWC:
  6947. props_.emplace_back("format", "NHWC");
  6948. break;
  6949. case WarpPerspectiveBackwardMat::Format::NHWCD4:
  6950. props_.emplace_back("format", "NHWCD4");
  6951. break;
  6952. case WarpPerspectiveBackwardMat::Format::NCHW4:
  6953. props_.emplace_back("format", "NCHW4");
  6954. break;
  6955. case WarpPerspectiveBackwardMat::Format::NCHW8:
  6956. props_.emplace_back("format", "NCHW8");
  6957. break;
  6958. case WarpPerspectiveBackwardMat::Format::NCHW32:
  6959. props_.emplace_back("format", "NCHW32");
  6960. break;
  6961. case WarpPerspectiveBackwardMat::Format::NCHW88:
  6962. props_.emplace_back("format", "NCHW88");
  6963. break;
  6964. case WarpPerspectiveBackwardMat::Format::NCHW44:
  6965. props_.emplace_back("format", "NCHW44");
  6966. break;
  6967. case WarpPerspectiveBackwardMat::Format::NCHW44_DOT:
  6968. props_.emplace_back("format", "NCHW44_DOT");
  6969. break;
  6970. case WarpPerspectiveBackwardMat::Format::NCHW4_NCHW32:
  6971. props_.emplace_back("format", "NCHW4_NCHW32");
  6972. break;
  6973. case WarpPerspectiveBackwardMat::Format::NCHW32_NCHW4:
  6974. props_.emplace_back("format", "NCHW32_NCHW4");
  6975. break;
  6976. case WarpPerspectiveBackwardMat::Format::NCHW4_NCHW:
  6977. props_.emplace_back("format", "NCHW4_NCHW");
  6978. break;
  6979. case WarpPerspectiveBackwardMat::Format::NHWC_NCHW:
  6980. props_.emplace_back("format", "NHWC_NCHW");
  6981. break;
  6982. case WarpPerspectiveBackwardMat::Format::NHWC_NCHW4_IC_SMALL:
  6983. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  6984. break;
  6985. case WarpPerspectiveBackwardMat::Format::NCHW_NCHW4_IC_SMALL:
  6986. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  6987. break;
  6988. case WarpPerspectiveBackwardMat::Format::CHWN4:
  6989. props_.emplace_back("format", "CHWN4");
  6990. break;
  6991. case WarpPerspectiveBackwardMat::Format::NCHW64:
  6992. props_.emplace_back("format", "NCHW64");
  6993. break;
  6994. case WarpPerspectiveBackwardMat::Format::NCHW4_NHWC:
  6995. props_.emplace_back("format", "NCHW4_NHWC");
  6996. break;
  6997. default:
  6998. props_.emplace_back("format", "INVALID");
  6999. break;
  7000. }
  7001. props_.emplace_back("border_val", std::to_string(op_.border_val));
  7002. return props_;
  7003. }
  7004. std::string WarpPerspectiveBackwardMat_make_name_impl(const OpDef& def_) {
  7005. auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardMat>();
  7006. static_cast<void>(op_);
  7007. return "WarpPerspectiveBackwardMat";
  7008. }
  7009. } // anonymous namespace
  7010. OP_TRAIT_REG(WarpPerspectiveBackwardMat, WarpPerspectiveBackwardMat)
  7011. .hash(WarpPerspectiveBackwardMat_hash_impl)
  7012. .is_same_st(WarpPerspectiveBackwardMat_is_same_st_impl)
  7013. .props(WarpPerspectiveBackwardMat_props_impl)
  7014. .make_name(WarpPerspectiveBackwardMat_make_name_impl);
  7015. // clang-format on