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 292 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751
  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. case Elemwise::Mode::SINH:
  3001. props_.emplace_back("mode", "SINH");
  3002. break;
  3003. case Elemwise::Mode::COSH:
  3004. props_.emplace_back("mode", "COSH");
  3005. break;
  3006. case Elemwise::Mode::ASINH:
  3007. props_.emplace_back("mode", "ASINH");
  3008. break;
  3009. case Elemwise::Mode::ACOSH:
  3010. props_.emplace_back("mode", "ACOSH");
  3011. break;
  3012. case Elemwise::Mode::ATANH:
  3013. props_.emplace_back("mode", "ATANH");
  3014. break;
  3015. case Elemwise::Mode::TAN:
  3016. props_.emplace_back("mode", "TAN");
  3017. break;
  3018. case Elemwise::Mode::ASINH_GRAD:
  3019. props_.emplace_back("mode", "ASINH_GRAD");
  3020. break;
  3021. case Elemwise::Mode::ACOSH_GRAD:
  3022. props_.emplace_back("mode", "ACOSH_GRAD");
  3023. break;
  3024. case Elemwise::Mode::ATANH_GRAD:
  3025. props_.emplace_back("mode", "ATANH_GRAD");
  3026. break;
  3027. case Elemwise::Mode::PRELU:
  3028. props_.emplace_back("mode", "PRELU");
  3029. break;
  3030. case Elemwise::Mode::CLIP:
  3031. props_.emplace_back("mode", "CLIP");
  3032. break;
  3033. case Elemwise::Mode::PRELU_GRAD:
  3034. props_.emplace_back("mode", "PRELU_GRAD");
  3035. break;
  3036. case Elemwise::Mode::SOFTPLUS:
  3037. props_.emplace_back("mode", "SOFTPLUS");
  3038. break;
  3039. case Elemwise::Mode::SOFTPLUS_GRAD:
  3040. props_.emplace_back("mode", "SOFTPLUS_GRAD");
  3041. break;
  3042. case Elemwise::Mode::RELU6:
  3043. props_.emplace_back("mode", "RELU6");
  3044. break;
  3045. case Elemwise::Mode::RELU6_GRAD:
  3046. props_.emplace_back("mode", "RELU6_GRAD");
  3047. break;
  3048. case Elemwise::Mode::HSIGMOID:
  3049. props_.emplace_back("mode", "HSIGMOID");
  3050. break;
  3051. case Elemwise::Mode::HSIGMOID_GRAD:
  3052. props_.emplace_back("mode", "HSIGMOID_GRAD");
  3053. break;
  3054. case Elemwise::Mode::LOGSIGMOID:
  3055. props_.emplace_back("mode", "LOGSIGMOID");
  3056. break;
  3057. case Elemwise::Mode::SQRT:
  3058. props_.emplace_back("mode", "SQRT");
  3059. break;
  3060. case Elemwise::Mode::SQUARE:
  3061. props_.emplace_back("mode", "SQUARE");
  3062. break;
  3063. case Elemwise::Mode::SIGN:
  3064. props_.emplace_back("mode", "SIGN");
  3065. break;
  3066. default:
  3067. props_.emplace_back("mode", "INVALID");
  3068. break;
  3069. }
  3070. return props_;
  3071. }
  3072. std::string Elemwise_make_name_impl(const OpDef& def_) {
  3073. auto&& op_ = def_.cast_final_safe<Elemwise>();
  3074. static_cast<void>(op_);
  3075. return to_string(op_.mode);
  3076. }
  3077. } // anonymous namespace
  3078. OP_TRAIT_REG(Elemwise, Elemwise)
  3079. .hash(Elemwise_hash_impl)
  3080. .is_same_st(Elemwise_is_same_st_impl)
  3081. .props(Elemwise_props_impl)
  3082. .make_name(Elemwise_make_name_impl);
  3083. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ElemwiseMultiType);
  3084. namespace {
  3085. size_t ElemwiseMultiType_hash_impl(const OpDef& def_) {
  3086. auto&& op_ = def_.cast_final_safe<ElemwiseMultiType>();
  3087. static_cast<void>(op_);
  3088. size_t val = mgb::hash(op_.dyn_typeinfo());
  3089. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  3090. val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
  3091. return val;
  3092. }
  3093. bool ElemwiseMultiType_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3094. auto &&a_ = lhs_.cast_final_safe<ElemwiseMultiType>(),
  3095. &&b_ = rhs_.cast_final_safe<ElemwiseMultiType>();
  3096. static_cast<void>(a_);
  3097. static_cast<void>(b_);
  3098. if (a_.mode != b_.mode) return false;
  3099. if (a_.dtype != b_.dtype) return false;
  3100. return true;
  3101. }
  3102. std::vector<std::pair<const char*, std::string>> ElemwiseMultiType_props_impl(const OpDef& def_) {
  3103. auto&& op_ = def_.cast_final_safe<ElemwiseMultiType>();
  3104. static_cast<void>(op_);
  3105. std::vector<std::pair<const char*, std::string>> props_;
  3106. switch (op_.mode){
  3107. case ElemwiseMultiType::Mode::FUSE_MUL_ADD3_INT16x32x32x32:
  3108. props_.emplace_back("mode", "FUSE_MUL_ADD3_INT16x32x32x32");
  3109. break;
  3110. case ElemwiseMultiType::Mode::FUSE_MUL_ADD3_IXxF32xF32xI8:
  3111. props_.emplace_back("mode", "FUSE_MUL_ADD3_IXxF32xF32xI8");
  3112. break;
  3113. case ElemwiseMultiType::Mode::ROUND_SHR_SATURATE_IXxI8xI8:
  3114. props_.emplace_back("mode", "ROUND_SHR_SATURATE_IXxI8xI8");
  3115. break;
  3116. case ElemwiseMultiType::Mode::FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT16x16x16x8:
  3117. props_.emplace_back("mode", "FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT16x16x16x8");
  3118. break;
  3119. case ElemwiseMultiType::Mode::FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT32x32x32x8:
  3120. props_.emplace_back("mode", "FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT32x32x32x8");
  3121. break;
  3122. case ElemwiseMultiType::Mode::ROUND_SHR_SATURATE_IXxI8xI16:
  3123. props_.emplace_back("mode", "ROUND_SHR_SATURATE_IXxI8xI16");
  3124. break;
  3125. case ElemwiseMultiType::Mode::QADD:
  3126. props_.emplace_back("mode", "QADD");
  3127. break;
  3128. case ElemwiseMultiType::Mode::QFUSE_ADD_RELU:
  3129. props_.emplace_back("mode", "QFUSE_ADD_RELU");
  3130. break;
  3131. case ElemwiseMultiType::Mode::QMUL:
  3132. props_.emplace_back("mode", "QMUL");
  3133. break;
  3134. case ElemwiseMultiType::Mode::QMIN:
  3135. props_.emplace_back("mode", "QMIN");
  3136. break;
  3137. case ElemwiseMultiType::Mode::QMAX:
  3138. props_.emplace_back("mode", "QMAX");
  3139. break;
  3140. case ElemwiseMultiType::Mode::QSUB:
  3141. props_.emplace_back("mode", "QSUB");
  3142. break;
  3143. case ElemwiseMultiType::Mode::QTRUE_DIV:
  3144. props_.emplace_back("mode", "QTRUE_DIV");
  3145. break;
  3146. case ElemwiseMultiType::Mode::QFUSE_ADD_SIGMOID:
  3147. props_.emplace_back("mode", "QFUSE_ADD_SIGMOID");
  3148. break;
  3149. case ElemwiseMultiType::Mode::QFUSE_ADD_TANH:
  3150. props_.emplace_back("mode", "QFUSE_ADD_TANH");
  3151. break;
  3152. case ElemwiseMultiType::Mode::QRELU:
  3153. props_.emplace_back("mode", "QRELU");
  3154. break;
  3155. case ElemwiseMultiType::Mode::QABS:
  3156. props_.emplace_back("mode", "QABS");
  3157. break;
  3158. case ElemwiseMultiType::Mode::QSIGMOID:
  3159. props_.emplace_back("mode", "QSIGMOID");
  3160. break;
  3161. case ElemwiseMultiType::Mode::QEXP:
  3162. props_.emplace_back("mode", "QEXP");
  3163. break;
  3164. case ElemwiseMultiType::Mode::QTANH:
  3165. props_.emplace_back("mode", "QTANH");
  3166. break;
  3167. case ElemwiseMultiType::Mode::QFUSE_MUL_ADD3:
  3168. props_.emplace_back("mode", "QFUSE_MUL_ADD3");
  3169. break;
  3170. case ElemwiseMultiType::Mode::QFAST_TANH:
  3171. props_.emplace_back("mode", "QFAST_TANH");
  3172. break;
  3173. case ElemwiseMultiType::Mode::QNEGATE:
  3174. props_.emplace_back("mode", "QNEGATE");
  3175. break;
  3176. case ElemwiseMultiType::Mode::QACOS:
  3177. props_.emplace_back("mode", "QACOS");
  3178. break;
  3179. case ElemwiseMultiType::Mode::QASIN:
  3180. props_.emplace_back("mode", "QASIN");
  3181. break;
  3182. case ElemwiseMultiType::Mode::QCEIL:
  3183. props_.emplace_back("mode", "QCEIL");
  3184. break;
  3185. case ElemwiseMultiType::Mode::QCOS:
  3186. props_.emplace_back("mode", "QCOS");
  3187. break;
  3188. case ElemwiseMultiType::Mode::QEXPM1:
  3189. props_.emplace_back("mode", "QEXPM1");
  3190. break;
  3191. case ElemwiseMultiType::Mode::QFLOOR:
  3192. props_.emplace_back("mode", "QFLOOR");
  3193. break;
  3194. case ElemwiseMultiType::Mode::QLOG:
  3195. props_.emplace_back("mode", "QLOG");
  3196. break;
  3197. case ElemwiseMultiType::Mode::QLOG1P:
  3198. props_.emplace_back("mode", "QLOG1P");
  3199. break;
  3200. case ElemwiseMultiType::Mode::QSIN:
  3201. props_.emplace_back("mode", "QSIN");
  3202. break;
  3203. case ElemwiseMultiType::Mode::QROUND:
  3204. props_.emplace_back("mode", "QROUND");
  3205. break;
  3206. case ElemwiseMultiType::Mode::QERF:
  3207. props_.emplace_back("mode", "QERF");
  3208. break;
  3209. case ElemwiseMultiType::Mode::QERFINV:
  3210. props_.emplace_back("mode", "QERFINV");
  3211. break;
  3212. case ElemwiseMultiType::Mode::QERFC:
  3213. props_.emplace_back("mode", "QERFC");
  3214. break;
  3215. case ElemwiseMultiType::Mode::QERFCINV:
  3216. props_.emplace_back("mode", "QERFCINV");
  3217. break;
  3218. case ElemwiseMultiType::Mode::QABS_GRAD:
  3219. props_.emplace_back("mode", "QABS_GRAD");
  3220. break;
  3221. case ElemwiseMultiType::Mode::QFLOOR_DIV:
  3222. props_.emplace_back("mode", "QFLOOR_DIV");
  3223. break;
  3224. case ElemwiseMultiType::Mode::QMOD:
  3225. props_.emplace_back("mode", "QMOD");
  3226. break;
  3227. case ElemwiseMultiType::Mode::QSIGMOID_GRAD:
  3228. props_.emplace_back("mode", "QSIGMOID_GRAD");
  3229. break;
  3230. case ElemwiseMultiType::Mode::QSWITCH_GT0:
  3231. props_.emplace_back("mode", "QSWITCH_GT0");
  3232. break;
  3233. case ElemwiseMultiType::Mode::QTANH_GRAD:
  3234. props_.emplace_back("mode", "QTANH_GRAD");
  3235. break;
  3236. case ElemwiseMultiType::Mode::QLT:
  3237. props_.emplace_back("mode", "QLT");
  3238. break;
  3239. case ElemwiseMultiType::Mode::QLEQ:
  3240. props_.emplace_back("mode", "QLEQ");
  3241. break;
  3242. case ElemwiseMultiType::Mode::QEQ:
  3243. props_.emplace_back("mode", "QEQ");
  3244. break;
  3245. case ElemwiseMultiType::Mode::QPOW:
  3246. props_.emplace_back("mode", "QPOW");
  3247. break;
  3248. case ElemwiseMultiType::Mode::QLOG_SUM_EXP:
  3249. props_.emplace_back("mode", "QLOG_SUM_EXP");
  3250. break;
  3251. case ElemwiseMultiType::Mode::QFAST_TANH_GRAD:
  3252. props_.emplace_back("mode", "QFAST_TANH_GRAD");
  3253. break;
  3254. case ElemwiseMultiType::Mode::QATAN2:
  3255. props_.emplace_back("mode", "QATAN2");
  3256. break;
  3257. case ElemwiseMultiType::Mode::QCOND_LEQ_MOV:
  3258. props_.emplace_back("mode", "QCOND_LEQ_MOV");
  3259. break;
  3260. case ElemwiseMultiType::Mode::QH_SWISH:
  3261. props_.emplace_back("mode", "QH_SWISH");
  3262. break;
  3263. case ElemwiseMultiType::Mode::QFUSE_ADD_H_SWISH:
  3264. props_.emplace_back("mode", "QFUSE_ADD_H_SWISH");
  3265. break;
  3266. case ElemwiseMultiType::Mode::QH_SWISH_GRAD:
  3267. props_.emplace_back("mode", "QH_SWISH_GRAD");
  3268. break;
  3269. case ElemwiseMultiType::Mode::FUSE_MUL_ADD3_INT16xF32xF32xF32:
  3270. props_.emplace_back("mode", "FUSE_MUL_ADD3_INT16xF32xF32xF32");
  3271. break;
  3272. case ElemwiseMultiType::Mode::MUL_INT16xF32xF32:
  3273. props_.emplace_back("mode", "MUL_INT16xF32xF32");
  3274. break;
  3275. case ElemwiseMultiType::Mode::FUSE_MUL_ADD3_UINT8xF32xF32xF32:
  3276. props_.emplace_back("mode", "FUSE_MUL_ADD3_UINT8xF32xF32xF32");
  3277. break;
  3278. case ElemwiseMultiType::Mode::QCOND_LT_MOV:
  3279. props_.emplace_back("mode", "QCOND_LT_MOV");
  3280. break;
  3281. case ElemwiseMultiType::Mode::EQ:
  3282. props_.emplace_back("mode", "EQ");
  3283. break;
  3284. case ElemwiseMultiType::Mode::NEQ:
  3285. props_.emplace_back("mode", "NEQ");
  3286. break;
  3287. case ElemwiseMultiType::Mode::LT:
  3288. props_.emplace_back("mode", "LT");
  3289. break;
  3290. case ElemwiseMultiType::Mode::LEQ:
  3291. props_.emplace_back("mode", "LEQ");
  3292. break;
  3293. case ElemwiseMultiType::Mode::ISNAN:
  3294. props_.emplace_back("mode", "ISNAN");
  3295. break;
  3296. case ElemwiseMultiType::Mode::ISINF:
  3297. props_.emplace_back("mode", "ISINF");
  3298. break;
  3299. default:
  3300. props_.emplace_back("mode", "INVALID");
  3301. break;
  3302. }
  3303. props_.emplace_back("dtype", op_.dtype.name());
  3304. return props_;
  3305. }
  3306. std::string ElemwiseMultiType_make_name_impl(const OpDef& def_) {
  3307. auto&& op_ = def_.cast_final_safe<ElemwiseMultiType>();
  3308. static_cast<void>(op_);
  3309. return to_string(op_.mode);
  3310. }
  3311. } // anonymous namespace
  3312. OP_TRAIT_REG(ElemwiseMultiType, ElemwiseMultiType)
  3313. .hash(ElemwiseMultiType_hash_impl)
  3314. .is_same_st(ElemwiseMultiType_is_same_st_impl)
  3315. .props(ElemwiseMultiType_props_impl)
  3316. .make_name(ElemwiseMultiType_make_name_impl);
  3317. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ExternOpr);
  3318. namespace {
  3319. size_t ExternOpr_hash_impl(const OpDef& def_) {
  3320. auto&& op_ = def_.cast_final_safe<ExternOpr>();
  3321. static_cast<void>(op_);
  3322. return mgb::hash_pair_combine(
  3323. mgb::hash(op_.dyn_typeinfo()),
  3324. mgb::hash_pair_combine(
  3325. mgb::hash(op_.name),
  3326. mgb::hash(op_.data))
  3327. );
  3328. }
  3329. bool ExternOpr_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3330. auto &&a_ = lhs_.cast_final_safe<ExternOpr>(),
  3331. &&b_ = rhs_.cast_final_safe<ExternOpr>();
  3332. static_cast<void>(a_);
  3333. static_cast<void>(b_);
  3334. if (a_.output_shapes != b_.output_shapes) return false;
  3335. if (a_.name != b_.name) return false;
  3336. if (a_.data != b_.data) return false;
  3337. if (a_.data_len != b_.data_len) return false;
  3338. if (a_.output_dtypes != b_.output_dtypes) return false;
  3339. return true;
  3340. }
  3341. std::vector<std::pair<const char*, std::string>> ExternOpr_props_impl(const OpDef& def_) {
  3342. auto&& op_ = def_.cast_final_safe<ExternOpr>();
  3343. static_cast<void>(op_);
  3344. std::vector<std::pair<const char*, std::string>> props_;
  3345. props_.emplace_back("output_shapes", "{std::vector}");
  3346. props_.emplace_back("name", op_.name);
  3347. props_.emplace_back("data", op_.data);
  3348. props_.emplace_back("data_len", std::to_string(op_.data_len));
  3349. props_.emplace_back("output_dtypes", "{std::vector}");
  3350. return props_;
  3351. }
  3352. std::string ExternOpr_make_name_impl(const OpDef& def_) {
  3353. auto&& op_ = def_.cast_final_safe<ExternOpr>();
  3354. static_cast<void>(op_);
  3355. return "ExternOpr";
  3356. }
  3357. } // anonymous namespace
  3358. OP_TRAIT_REG(ExternOpr, ExternOpr)
  3359. .hash(ExternOpr_hash_impl)
  3360. .is_same_st(ExternOpr_is_same_st_impl)
  3361. .props(ExternOpr_props_impl)
  3362. .make_name(ExternOpr_make_name_impl);
  3363. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Eye);
  3364. namespace {
  3365. size_t Eye_hash_impl(const OpDef& def_) {
  3366. auto&& op_ = def_.cast_final_safe<Eye>();
  3367. static_cast<void>(op_);
  3368. size_t val = mgb::hash(op_.dyn_typeinfo());
  3369. val = mgb::hash_pair_combine(val, mgb::hash(op_.k));
  3370. val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
  3371. val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
  3372. return val;
  3373. }
  3374. bool Eye_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3375. auto &&a_ = lhs_.cast_final_safe<Eye>(),
  3376. &&b_ = rhs_.cast_final_safe<Eye>();
  3377. static_cast<void>(a_);
  3378. static_cast<void>(b_);
  3379. if (a_.k != b_.k) return false;
  3380. if (a_.dtype != b_.dtype) return false;
  3381. if (a_.comp_node != b_.comp_node) return false;
  3382. return true;
  3383. }
  3384. std::vector<std::pair<const char*, std::string>> Eye_props_impl(const OpDef& def_) {
  3385. auto&& op_ = def_.cast_final_safe<Eye>();
  3386. static_cast<void>(op_);
  3387. std::vector<std::pair<const char*, std::string>> props_;
  3388. props_.emplace_back("k", std::to_string(op_.k));
  3389. props_.emplace_back("dtype", op_.dtype.name());
  3390. props_.emplace_back("comp_node", op_.comp_node.to_string());
  3391. return props_;
  3392. }
  3393. std::string Eye_make_name_impl(const OpDef& def_) {
  3394. auto&& op_ = def_.cast_final_safe<Eye>();
  3395. static_cast<void>(op_);
  3396. return "Eye";
  3397. }
  3398. } // anonymous namespace
  3399. OP_TRAIT_REG(Eye, Eye)
  3400. .hash(Eye_hash_impl)
  3401. .is_same_st(Eye_is_same_st_impl)
  3402. .props(Eye_props_impl)
  3403. .make_name(Eye_make_name_impl);
  3404. MGB_DYN_TYPE_OBJ_FINAL_IMPL(FakeQuant);
  3405. namespace {
  3406. size_t FakeQuant_hash_impl(const OpDef& def_) {
  3407. auto&& op_ = def_.cast_final_safe<FakeQuant>();
  3408. static_cast<void>(op_);
  3409. size_t val = mgb::hash(op_.dyn_typeinfo());
  3410. val = mgb::hash_pair_combine(val, mgb::hash(op_.qmin));
  3411. val = mgb::hash_pair_combine(val, mgb::hash(op_.qmax));
  3412. return val;
  3413. }
  3414. bool FakeQuant_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3415. auto &&a_ = lhs_.cast_final_safe<FakeQuant>(),
  3416. &&b_ = rhs_.cast_final_safe<FakeQuant>();
  3417. static_cast<void>(a_);
  3418. static_cast<void>(b_);
  3419. if (a_.qmin != b_.qmin) return false;
  3420. if (a_.qmax != b_.qmax) return false;
  3421. return true;
  3422. }
  3423. std::vector<std::pair<const char*, std::string>> FakeQuant_props_impl(const OpDef& def_) {
  3424. auto&& op_ = def_.cast_final_safe<FakeQuant>();
  3425. static_cast<void>(op_);
  3426. std::vector<std::pair<const char*, std::string>> props_;
  3427. props_.emplace_back("qmin", std::to_string(op_.qmin));
  3428. props_.emplace_back("qmax", std::to_string(op_.qmax));
  3429. return props_;
  3430. }
  3431. std::string FakeQuant_make_name_impl(const OpDef& def_) {
  3432. auto&& op_ = def_.cast_final_safe<FakeQuant>();
  3433. static_cast<void>(op_);
  3434. return "FakeQuant";
  3435. }
  3436. } // anonymous namespace
  3437. OP_TRAIT_REG(FakeQuant, FakeQuant)
  3438. .hash(FakeQuant_hash_impl)
  3439. .is_same_st(FakeQuant_is_same_st_impl)
  3440. .props(FakeQuant_props_impl)
  3441. .make_name(FakeQuant_make_name_impl);
  3442. MGB_DYN_TYPE_OBJ_FINAL_IMPL(FastpathCopy);
  3443. namespace {
  3444. size_t FastpathCopy_hash_impl(const OpDef& def_) {
  3445. auto&& op_ = def_.cast_final_safe<FastpathCopy>();
  3446. static_cast<void>(op_);
  3447. size_t val = mgb::hash(op_.dyn_typeinfo());
  3448. return val;
  3449. }
  3450. bool FastpathCopy_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3451. auto &&a_ = lhs_.cast_final_safe<FastpathCopy>(),
  3452. &&b_ = rhs_.cast_final_safe<FastpathCopy>();
  3453. static_cast<void>(a_);
  3454. static_cast<void>(b_);
  3455. return true;
  3456. }
  3457. std::vector<std::pair<const char*, std::string>> FastpathCopy_props_impl(const OpDef& def_) {
  3458. auto&& op_ = def_.cast_final_safe<FastpathCopy>();
  3459. static_cast<void>(op_);
  3460. std::vector<std::pair<const char*, std::string>> props_;
  3461. return props_;
  3462. }
  3463. std::string FastpathCopy_make_name_impl(const OpDef& def_) {
  3464. auto&& op_ = def_.cast_final_safe<FastpathCopy>();
  3465. static_cast<void>(op_);
  3466. return "FastpathCopy";
  3467. }
  3468. } // anonymous namespace
  3469. OP_TRAIT_REG(FastpathCopy, FastpathCopy)
  3470. .hash(FastpathCopy_hash_impl)
  3471. .is_same_st(FastpathCopy_is_same_st_impl)
  3472. .props(FastpathCopy_props_impl)
  3473. .make_name(FastpathCopy_make_name_impl);
  3474. MGB_DYN_TYPE_OBJ_FINAL_IMPL(GammaRNG);
  3475. namespace {
  3476. size_t GammaRNG_hash_impl(const OpDef& def_) {
  3477. auto&& op_ = def_.cast_final_safe<GammaRNG>();
  3478. static_cast<void>(op_);
  3479. return mgb::hash_pair_combine(
  3480. mgb::hash(op_.dyn_typeinfo()),
  3481. mgb::hash(op_.handle)
  3482. );
  3483. }
  3484. bool GammaRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3485. auto &&a_ = lhs_.cast_final_safe<GammaRNG>(),
  3486. &&b_ = rhs_.cast_final_safe<GammaRNG>();
  3487. static_cast<void>(a_);
  3488. static_cast<void>(b_);
  3489. return a_.handle == b_.handle;}
  3490. std::vector<std::pair<const char*, std::string>> GammaRNG_props_impl(const OpDef& def_) {
  3491. auto&& op_ = def_.cast_final_safe<GammaRNG>();
  3492. static_cast<void>(op_);
  3493. std::vector<std::pair<const char*, std::string>> props_;
  3494. props_.emplace_back("seed", std::to_string(op_.seed));
  3495. props_.emplace_back("handle", std::to_string(op_.handle));
  3496. return props_;
  3497. }
  3498. std::string GammaRNG_make_name_impl(const OpDef& def_) {
  3499. auto&& op_ = def_.cast_final_safe<GammaRNG>();
  3500. static_cast<void>(op_);
  3501. return "GammaRNG";
  3502. }
  3503. } // anonymous namespace
  3504. OP_TRAIT_REG(GammaRNG, GammaRNG)
  3505. .hash(GammaRNG_hash_impl)
  3506. .is_same_st(GammaRNG_is_same_st_impl)
  3507. .props(GammaRNG_props_impl)
  3508. .make_name(GammaRNG_make_name_impl);
  3509. MGB_DYN_TYPE_OBJ_FINAL_IMPL(GaussianRNG);
  3510. namespace {
  3511. size_t GaussianRNG_hash_impl(const OpDef& def_) {
  3512. auto&& op_ = def_.cast_final_safe<GaussianRNG>();
  3513. static_cast<void>(op_);
  3514. return mgb::hash_pair_combine(
  3515. mgb::hash(op_.dyn_typeinfo()),
  3516. mgb::hash_pair_combine(
  3517. mgb::hash(op_.handle),
  3518. mgb::hash_pair_combine(
  3519. mgb::hash(op_.mean),
  3520. mgb::hash_pair_combine(
  3521. mgb::hash(op_.std),
  3522. mgb::hash(op_.dtype.enumv())
  3523. )
  3524. )
  3525. )
  3526. );
  3527. }
  3528. bool GaussianRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3529. auto &&a_ = lhs_.cast_final_safe<GaussianRNG>(),
  3530. &&b_ = rhs_.cast_final_safe<GaussianRNG>();
  3531. static_cast<void>(a_);
  3532. static_cast<void>(b_);
  3533. return a_.handle == b_.handle && a_.mean == b_.mean && a_.std == b_.std && a_.dtype == b_.dtype;}
  3534. std::vector<std::pair<const char*, std::string>> GaussianRNG_props_impl(const OpDef& def_) {
  3535. auto&& op_ = def_.cast_final_safe<GaussianRNG>();
  3536. static_cast<void>(op_);
  3537. std::vector<std::pair<const char*, std::string>> props_;
  3538. props_.emplace_back("seed", std::to_string(op_.seed));
  3539. props_.emplace_back("mean", std::to_string(op_.mean));
  3540. props_.emplace_back("std", std::to_string(op_.std));
  3541. props_.emplace_back("dtype", op_.dtype.name());
  3542. props_.emplace_back("handle", std::to_string(op_.handle));
  3543. return props_;
  3544. }
  3545. std::string GaussianRNG_make_name_impl(const OpDef& def_) {
  3546. auto&& op_ = def_.cast_final_safe<GaussianRNG>();
  3547. static_cast<void>(op_);
  3548. return "GaussianRNG";
  3549. }
  3550. } // anonymous namespace
  3551. OP_TRAIT_REG(GaussianRNG, GaussianRNG)
  3552. .hash(GaussianRNG_hash_impl)
  3553. .is_same_st(GaussianRNG_is_same_st_impl)
  3554. .props(GaussianRNG_props_impl)
  3555. .make_name(GaussianRNG_make_name_impl);
  3556. MGB_DYN_TYPE_OBJ_FINAL_IMPL(GetVarShape);
  3557. namespace {
  3558. size_t GetVarShape_hash_impl(const OpDef& def_) {
  3559. auto&& op_ = def_.cast_final_safe<GetVarShape>();
  3560. static_cast<void>(op_);
  3561. size_t val = mgb::hash(op_.dyn_typeinfo());
  3562. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  3563. return val;
  3564. }
  3565. bool GetVarShape_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3566. auto &&a_ = lhs_.cast_final_safe<GetVarShape>(),
  3567. &&b_ = rhs_.cast_final_safe<GetVarShape>();
  3568. static_cast<void>(a_);
  3569. static_cast<void>(b_);
  3570. if (a_.axis != b_.axis) return false;
  3571. return true;
  3572. }
  3573. std::vector<std::pair<const char*, std::string>> GetVarShape_props_impl(const OpDef& def_) {
  3574. auto&& op_ = def_.cast_final_safe<GetVarShape>();
  3575. static_cast<void>(op_);
  3576. std::vector<std::pair<const char*, std::string>> props_;
  3577. props_.emplace_back("axis", std::to_string(op_.axis));
  3578. return props_;
  3579. }
  3580. std::string GetVarShape_make_name_impl(const OpDef& def_) {
  3581. auto&& op_ = def_.cast_final_safe<GetVarShape>();
  3582. static_cast<void>(op_);
  3583. return "GetVarShape";
  3584. }
  3585. } // anonymous namespace
  3586. OP_TRAIT_REG(GetVarShape, GetVarShape)
  3587. .hash(GetVarShape_hash_impl)
  3588. .is_same_st(GetVarShape_is_same_st_impl)
  3589. .props(GetVarShape_props_impl)
  3590. .make_name(GetVarShape_make_name_impl);
  3591. MGB_DYN_TYPE_OBJ_FINAL_IMPL(GroupLocal);
  3592. namespace {
  3593. size_t GroupLocal_hash_impl(const OpDef& def_) {
  3594. auto&& op_ = def_.cast_final_safe<GroupLocal>();
  3595. static_cast<void>(op_);
  3596. size_t val = mgb::hash(op_.dyn_typeinfo());
  3597. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  3598. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  3599. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  3600. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  3601. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  3602. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
  3603. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
  3604. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
  3605. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  3606. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
  3607. return val;
  3608. }
  3609. bool GroupLocal_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3610. auto &&a_ = lhs_.cast_final_safe<GroupLocal>(),
  3611. &&b_ = rhs_.cast_final_safe<GroupLocal>();
  3612. static_cast<void>(a_);
  3613. static_cast<void>(b_);
  3614. if (a_.mode != b_.mode) return false;
  3615. if (a_.pad_h != b_.pad_h) return false;
  3616. if (a_.pad_w != b_.pad_w) return false;
  3617. if (a_.stride_h != b_.stride_h) return false;
  3618. if (a_.stride_w != b_.stride_w) return false;
  3619. if (a_.dilate_h != b_.dilate_h) return false;
  3620. if (a_.dilate_w != b_.dilate_w) return false;
  3621. if (a_.sparse != b_.sparse) return false;
  3622. if (a_.format != b_.format) return false;
  3623. if (a_.compute_mode != b_.compute_mode) return false;
  3624. return true;
  3625. }
  3626. std::vector<std::pair<const char*, std::string>> GroupLocal_props_impl(const OpDef& def_) {
  3627. auto&& op_ = def_.cast_final_safe<GroupLocal>();
  3628. static_cast<void>(op_);
  3629. std::vector<std::pair<const char*, std::string>> props_;
  3630. switch (op_.mode){
  3631. case GroupLocal::Mode::CROSS_CORRELATION:
  3632. props_.emplace_back("mode", "CROSS_CORRELATION");
  3633. break;
  3634. case GroupLocal::Mode::CONVOLUTION:
  3635. props_.emplace_back("mode", "CONVOLUTION");
  3636. break;
  3637. default:
  3638. props_.emplace_back("mode", "INVALID");
  3639. break;
  3640. }
  3641. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  3642. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  3643. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  3644. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  3645. props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
  3646. props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
  3647. switch (op_.sparse){
  3648. case GroupLocal::Sparse::DENSE:
  3649. props_.emplace_back("sparse", "DENSE");
  3650. break;
  3651. case GroupLocal::Sparse::GROUP:
  3652. props_.emplace_back("sparse", "GROUP");
  3653. break;
  3654. default:
  3655. props_.emplace_back("sparse", "INVALID");
  3656. break;
  3657. }
  3658. switch (op_.format){
  3659. case GroupLocal::Format::NCHW:
  3660. props_.emplace_back("format", "NCHW");
  3661. break;
  3662. case GroupLocal::Format::NHWC:
  3663. props_.emplace_back("format", "NHWC");
  3664. break;
  3665. case GroupLocal::Format::NHWCD4:
  3666. props_.emplace_back("format", "NHWCD4");
  3667. break;
  3668. case GroupLocal::Format::NCHW4:
  3669. props_.emplace_back("format", "NCHW4");
  3670. break;
  3671. case GroupLocal::Format::NCHW8:
  3672. props_.emplace_back("format", "NCHW8");
  3673. break;
  3674. case GroupLocal::Format::NCHW32:
  3675. props_.emplace_back("format", "NCHW32");
  3676. break;
  3677. case GroupLocal::Format::NCHW88:
  3678. props_.emplace_back("format", "NCHW88");
  3679. break;
  3680. case GroupLocal::Format::NCHW44:
  3681. props_.emplace_back("format", "NCHW44");
  3682. break;
  3683. case GroupLocal::Format::NCHW44_DOT:
  3684. props_.emplace_back("format", "NCHW44_DOT");
  3685. break;
  3686. case GroupLocal::Format::NCHW4_NCHW32:
  3687. props_.emplace_back("format", "NCHW4_NCHW32");
  3688. break;
  3689. case GroupLocal::Format::NCHW32_NCHW4:
  3690. props_.emplace_back("format", "NCHW32_NCHW4");
  3691. break;
  3692. case GroupLocal::Format::NCHW4_NCHW:
  3693. props_.emplace_back("format", "NCHW4_NCHW");
  3694. break;
  3695. case GroupLocal::Format::NHWC_NCHW:
  3696. props_.emplace_back("format", "NHWC_NCHW");
  3697. break;
  3698. case GroupLocal::Format::NHWC_NCHW4_IC_SMALL:
  3699. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  3700. break;
  3701. case GroupLocal::Format::NCHW_NCHW4_IC_SMALL:
  3702. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  3703. break;
  3704. case GroupLocal::Format::CHWN4:
  3705. props_.emplace_back("format", "CHWN4");
  3706. break;
  3707. case GroupLocal::Format::NCHW64:
  3708. props_.emplace_back("format", "NCHW64");
  3709. break;
  3710. case GroupLocal::Format::NCHW4_NHWC:
  3711. props_.emplace_back("format", "NCHW4_NHWC");
  3712. break;
  3713. default:
  3714. props_.emplace_back("format", "INVALID");
  3715. break;
  3716. }
  3717. switch (op_.compute_mode){
  3718. case GroupLocal::ComputeMode::DEFAULT:
  3719. props_.emplace_back("compute_mode", "DEFAULT");
  3720. break;
  3721. case GroupLocal::ComputeMode::FLOAT32:
  3722. props_.emplace_back("compute_mode", "FLOAT32");
  3723. break;
  3724. default:
  3725. props_.emplace_back("compute_mode", "INVALID");
  3726. break;
  3727. }
  3728. return props_;
  3729. }
  3730. std::string GroupLocal_make_name_impl(const OpDef& def_) {
  3731. auto&& op_ = def_.cast_final_safe<GroupLocal>();
  3732. static_cast<void>(op_);
  3733. return "GroupLocal";
  3734. }
  3735. } // anonymous namespace
  3736. OP_TRAIT_REG(GroupLocal, GroupLocal)
  3737. .hash(GroupLocal_hash_impl)
  3738. .is_same_st(GroupLocal_is_same_st_impl)
  3739. .props(GroupLocal_props_impl)
  3740. .make_name(GroupLocal_make_name_impl);
  3741. MGB_DYN_TYPE_OBJ_FINAL_IMPL(GroupNorm);
  3742. namespace {
  3743. size_t GroupNorm_hash_impl(const OpDef& def_) {
  3744. auto&& op_ = def_.cast_final_safe<GroupNorm>();
  3745. static_cast<void>(op_);
  3746. size_t val = mgb::hash(op_.dyn_typeinfo());
  3747. val = mgb::hash_pair_combine(val, mgb::hash(op_.affine));
  3748. val = mgb::hash_pair_combine(val, mgb::hash(op_.eps));
  3749. val = mgb::hash_pair_combine(val, mgb::hash(op_.group));
  3750. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  3751. return val;
  3752. }
  3753. bool GroupNorm_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3754. auto &&a_ = lhs_.cast_final_safe<GroupNorm>(),
  3755. &&b_ = rhs_.cast_final_safe<GroupNorm>();
  3756. static_cast<void>(a_);
  3757. static_cast<void>(b_);
  3758. if (a_.affine != b_.affine) return false;
  3759. if (a_.eps != b_.eps) return false;
  3760. if (a_.group != b_.group) return false;
  3761. if (a_.format != b_.format) return false;
  3762. return true;
  3763. }
  3764. std::vector<std::pair<const char*, std::string>> GroupNorm_props_impl(const OpDef& def_) {
  3765. auto&& op_ = def_.cast_final_safe<GroupNorm>();
  3766. static_cast<void>(op_);
  3767. std::vector<std::pair<const char*, std::string>> props_;
  3768. props_.emplace_back("affine", std::to_string(op_.affine));
  3769. props_.emplace_back("eps", std::to_string(op_.eps));
  3770. props_.emplace_back("group", std::to_string(op_.group));
  3771. switch (op_.format){
  3772. case GroupNorm::Format::NCHW:
  3773. props_.emplace_back("format", "NCHW");
  3774. break;
  3775. case GroupNorm::Format::NHWC:
  3776. props_.emplace_back("format", "NHWC");
  3777. break;
  3778. case GroupNorm::Format::NHWCD4:
  3779. props_.emplace_back("format", "NHWCD4");
  3780. break;
  3781. case GroupNorm::Format::NCHW4:
  3782. props_.emplace_back("format", "NCHW4");
  3783. break;
  3784. case GroupNorm::Format::NCHW8:
  3785. props_.emplace_back("format", "NCHW8");
  3786. break;
  3787. case GroupNorm::Format::NCHW32:
  3788. props_.emplace_back("format", "NCHW32");
  3789. break;
  3790. case GroupNorm::Format::NCHW88:
  3791. props_.emplace_back("format", "NCHW88");
  3792. break;
  3793. case GroupNorm::Format::NCHW44:
  3794. props_.emplace_back("format", "NCHW44");
  3795. break;
  3796. case GroupNorm::Format::NCHW44_DOT:
  3797. props_.emplace_back("format", "NCHW44_DOT");
  3798. break;
  3799. case GroupNorm::Format::NCHW4_NCHW32:
  3800. props_.emplace_back("format", "NCHW4_NCHW32");
  3801. break;
  3802. case GroupNorm::Format::NCHW32_NCHW4:
  3803. props_.emplace_back("format", "NCHW32_NCHW4");
  3804. break;
  3805. case GroupNorm::Format::NCHW4_NCHW:
  3806. props_.emplace_back("format", "NCHW4_NCHW");
  3807. break;
  3808. case GroupNorm::Format::NHWC_NCHW:
  3809. props_.emplace_back("format", "NHWC_NCHW");
  3810. break;
  3811. case GroupNorm::Format::NHWC_NCHW4_IC_SMALL:
  3812. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  3813. break;
  3814. case GroupNorm::Format::NCHW_NCHW4_IC_SMALL:
  3815. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  3816. break;
  3817. case GroupNorm::Format::CHWN4:
  3818. props_.emplace_back("format", "CHWN4");
  3819. break;
  3820. case GroupNorm::Format::NCHW64:
  3821. props_.emplace_back("format", "NCHW64");
  3822. break;
  3823. case GroupNorm::Format::NCHW4_NHWC:
  3824. props_.emplace_back("format", "NCHW4_NHWC");
  3825. break;
  3826. default:
  3827. props_.emplace_back("format", "INVALID");
  3828. break;
  3829. }
  3830. return props_;
  3831. }
  3832. std::string GroupNorm_make_name_impl(const OpDef& def_) {
  3833. auto&& op_ = def_.cast_final_safe<GroupNorm>();
  3834. static_cast<void>(op_);
  3835. return "GroupNorm";
  3836. }
  3837. } // anonymous namespace
  3838. OP_TRAIT_REG(GroupNorm, GroupNorm)
  3839. .hash(GroupNorm_hash_impl)
  3840. .is_same_st(GroupNorm_is_same_st_impl)
  3841. .props(GroupNorm_props_impl)
  3842. .make_name(GroupNorm_make_name_impl);
  3843. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Identity);
  3844. namespace {
  3845. size_t Identity_hash_impl(const OpDef& def_) {
  3846. auto&& op_ = def_.cast_final_safe<Identity>();
  3847. static_cast<void>(op_);
  3848. size_t val = mgb::hash(op_.dyn_typeinfo());
  3849. return val;
  3850. }
  3851. bool Identity_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3852. auto &&a_ = lhs_.cast_final_safe<Identity>(),
  3853. &&b_ = rhs_.cast_final_safe<Identity>();
  3854. static_cast<void>(a_);
  3855. static_cast<void>(b_);
  3856. return true;
  3857. }
  3858. std::vector<std::pair<const char*, std::string>> Identity_props_impl(const OpDef& def_) {
  3859. auto&& op_ = def_.cast_final_safe<Identity>();
  3860. static_cast<void>(op_);
  3861. std::vector<std::pair<const char*, std::string>> props_;
  3862. return props_;
  3863. }
  3864. std::string Identity_make_name_impl(const OpDef& def_) {
  3865. auto&& op_ = def_.cast_final_safe<Identity>();
  3866. static_cast<void>(op_);
  3867. return "Identity";
  3868. }
  3869. } // anonymous namespace
  3870. OP_TRAIT_REG(Identity, Identity)
  3871. .hash(Identity_hash_impl)
  3872. .is_same_st(Identity_is_same_st_impl)
  3873. .props(Identity_props_impl)
  3874. .make_name(Identity_make_name_impl);
  3875. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Images2Neibs);
  3876. namespace {
  3877. size_t Images2Neibs_hash_impl(const OpDef& def_) {
  3878. auto&& op_ = def_.cast_final_safe<Images2Neibs>();
  3879. static_cast<void>(op_);
  3880. size_t val = mgb::hash(op_.dyn_typeinfo());
  3881. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  3882. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  3883. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  3884. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  3885. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
  3886. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
  3887. val = mgb::hash_pair_combine(val, mgb::hash(op_.window_h));
  3888. val = mgb::hash_pair_combine(val, mgb::hash(op_.window_w));
  3889. return val;
  3890. }
  3891. bool Images2Neibs_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3892. auto &&a_ = lhs_.cast_final_safe<Images2Neibs>(),
  3893. &&b_ = rhs_.cast_final_safe<Images2Neibs>();
  3894. static_cast<void>(a_);
  3895. static_cast<void>(b_);
  3896. if (a_.pad_h != b_.pad_h) return false;
  3897. if (a_.pad_w != b_.pad_w) return false;
  3898. if (a_.stride_h != b_.stride_h) return false;
  3899. if (a_.stride_w != b_.stride_w) return false;
  3900. if (a_.dilate_h != b_.dilate_h) return false;
  3901. if (a_.dilate_w != b_.dilate_w) return false;
  3902. if (a_.window_h != b_.window_h) return false;
  3903. if (a_.window_w != b_.window_w) return false;
  3904. return true;
  3905. }
  3906. std::vector<std::pair<const char*, std::string>> Images2Neibs_props_impl(const OpDef& def_) {
  3907. auto&& op_ = def_.cast_final_safe<Images2Neibs>();
  3908. static_cast<void>(op_);
  3909. std::vector<std::pair<const char*, std::string>> props_;
  3910. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  3911. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  3912. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  3913. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  3914. props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
  3915. props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
  3916. props_.emplace_back("window_h", std::to_string(op_.window_h));
  3917. props_.emplace_back("window_w", std::to_string(op_.window_w));
  3918. return props_;
  3919. }
  3920. std::string Images2Neibs_make_name_impl(const OpDef& def_) {
  3921. auto&& op_ = def_.cast_final_safe<Images2Neibs>();
  3922. static_cast<void>(op_);
  3923. return "Images2Neibs";
  3924. }
  3925. } // anonymous namespace
  3926. OP_TRAIT_REG(Images2Neibs, Images2Neibs)
  3927. .hash(Images2Neibs_hash_impl)
  3928. .is_same_st(Images2Neibs_is_same_st_impl)
  3929. .props(Images2Neibs_props_impl)
  3930. .make_name(Images2Neibs_make_name_impl);
  3931. MGB_DYN_TYPE_OBJ_FINAL_IMPL(IncrMeshIndexing);
  3932. namespace {
  3933. size_t IncrMeshIndexing_hash_impl(const OpDef& def_) {
  3934. auto&& op_ = def_.cast_final_safe<IncrMeshIndexing>();
  3935. static_cast<void>(op_);
  3936. size_t val = mgb::hash(op_.dyn_typeinfo());
  3937. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  3938. return val;
  3939. }
  3940. bool IncrMeshIndexing_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3941. auto &&a_ = lhs_.cast_final_safe<IncrMeshIndexing>(),
  3942. &&b_ = rhs_.cast_final_safe<IncrMeshIndexing>();
  3943. static_cast<void>(a_);
  3944. static_cast<void>(b_);
  3945. if (a_.items != b_.items) return false;
  3946. return true;
  3947. }
  3948. std::vector<std::pair<const char*, std::string>> IncrMeshIndexing_props_impl(const OpDef& def_) {
  3949. auto&& op_ = def_.cast_final_safe<IncrMeshIndexing>();
  3950. static_cast<void>(op_);
  3951. std::vector<std::pair<const char*, std::string>> props_;
  3952. props_.emplace_back("items", "{std::vector}");
  3953. return props_;
  3954. }
  3955. std::string IncrMeshIndexing_make_name_impl(const OpDef& def_) {
  3956. auto&& op_ = def_.cast_final_safe<IncrMeshIndexing>();
  3957. static_cast<void>(op_);
  3958. return "IncrMeshIndexing";
  3959. }
  3960. } // anonymous namespace
  3961. OP_TRAIT_REG(IncrMeshIndexing, IncrMeshIndexing)
  3962. .hash(IncrMeshIndexing_hash_impl)
  3963. .is_same_st(IncrMeshIndexing_is_same_st_impl)
  3964. .props(IncrMeshIndexing_props_impl)
  3965. .make_name(IncrMeshIndexing_make_name_impl);
  3966. MGB_DYN_TYPE_OBJ_FINAL_IMPL(IncrSubtensor);
  3967. namespace {
  3968. size_t IncrSubtensor_hash_impl(const OpDef& def_) {
  3969. auto&& op_ = def_.cast_final_safe<IncrSubtensor>();
  3970. static_cast<void>(op_);
  3971. size_t val = mgb::hash(op_.dyn_typeinfo());
  3972. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  3973. return val;
  3974. }
  3975. bool IncrSubtensor_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  3976. auto &&a_ = lhs_.cast_final_safe<IncrSubtensor>(),
  3977. &&b_ = rhs_.cast_final_safe<IncrSubtensor>();
  3978. static_cast<void>(a_);
  3979. static_cast<void>(b_);
  3980. if (a_.items != b_.items) return false;
  3981. return true;
  3982. }
  3983. std::vector<std::pair<const char*, std::string>> IncrSubtensor_props_impl(const OpDef& def_) {
  3984. auto&& op_ = def_.cast_final_safe<IncrSubtensor>();
  3985. static_cast<void>(op_);
  3986. std::vector<std::pair<const char*, std::string>> props_;
  3987. props_.emplace_back("items", "{std::vector}");
  3988. return props_;
  3989. }
  3990. std::string IncrSubtensor_make_name_impl(const OpDef& def_) {
  3991. auto&& op_ = def_.cast_final_safe<IncrSubtensor>();
  3992. static_cast<void>(op_);
  3993. return "IncrSubtensor";
  3994. }
  3995. } // anonymous namespace
  3996. OP_TRAIT_REG(IncrSubtensor, IncrSubtensor)
  3997. .hash(IncrSubtensor_hash_impl)
  3998. .is_same_st(IncrSubtensor_is_same_st_impl)
  3999. .props(IncrSubtensor_props_impl)
  4000. .make_name(IncrSubtensor_make_name_impl);
  4001. MGB_DYN_TYPE_OBJ_FINAL_IMPL(IndexingIncrMultiAxisVec);
  4002. namespace {
  4003. size_t IndexingIncrMultiAxisVec_hash_impl(const OpDef& def_) {
  4004. auto&& op_ = def_.cast_final_safe<IndexingIncrMultiAxisVec>();
  4005. static_cast<void>(op_);
  4006. size_t val = mgb::hash(op_.dyn_typeinfo());
  4007. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  4008. return val;
  4009. }
  4010. bool IndexingIncrMultiAxisVec_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4011. auto &&a_ = lhs_.cast_final_safe<IndexingIncrMultiAxisVec>(),
  4012. &&b_ = rhs_.cast_final_safe<IndexingIncrMultiAxisVec>();
  4013. static_cast<void>(a_);
  4014. static_cast<void>(b_);
  4015. if (a_.items != b_.items) return false;
  4016. return true;
  4017. }
  4018. std::vector<std::pair<const char*, std::string>> IndexingIncrMultiAxisVec_props_impl(const OpDef& def_) {
  4019. auto&& op_ = def_.cast_final_safe<IndexingIncrMultiAxisVec>();
  4020. static_cast<void>(op_);
  4021. std::vector<std::pair<const char*, std::string>> props_;
  4022. props_.emplace_back("items", "{std::vector}");
  4023. return props_;
  4024. }
  4025. std::string IndexingIncrMultiAxisVec_make_name_impl(const OpDef& def_) {
  4026. auto&& op_ = def_.cast_final_safe<IndexingIncrMultiAxisVec>();
  4027. static_cast<void>(op_);
  4028. return "IndexingIncrMultiAxisVec";
  4029. }
  4030. } // anonymous namespace
  4031. OP_TRAIT_REG(IndexingIncrMultiAxisVec, IndexingIncrMultiAxisVec)
  4032. .hash(IndexingIncrMultiAxisVec_hash_impl)
  4033. .is_same_st(IndexingIncrMultiAxisVec_is_same_st_impl)
  4034. .props(IndexingIncrMultiAxisVec_props_impl)
  4035. .make_name(IndexingIncrMultiAxisVec_make_name_impl);
  4036. MGB_DYN_TYPE_OBJ_FINAL_IMPL(IndexingMultiAxisVec);
  4037. namespace {
  4038. size_t IndexingMultiAxisVec_hash_impl(const OpDef& def_) {
  4039. auto&& op_ = def_.cast_final_safe<IndexingMultiAxisVec>();
  4040. static_cast<void>(op_);
  4041. size_t val = mgb::hash(op_.dyn_typeinfo());
  4042. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  4043. return val;
  4044. }
  4045. bool IndexingMultiAxisVec_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4046. auto &&a_ = lhs_.cast_final_safe<IndexingMultiAxisVec>(),
  4047. &&b_ = rhs_.cast_final_safe<IndexingMultiAxisVec>();
  4048. static_cast<void>(a_);
  4049. static_cast<void>(b_);
  4050. if (a_.items != b_.items) return false;
  4051. return true;
  4052. }
  4053. std::vector<std::pair<const char*, std::string>> IndexingMultiAxisVec_props_impl(const OpDef& def_) {
  4054. auto&& op_ = def_.cast_final_safe<IndexingMultiAxisVec>();
  4055. static_cast<void>(op_);
  4056. std::vector<std::pair<const char*, std::string>> props_;
  4057. props_.emplace_back("items", "{std::vector}");
  4058. return props_;
  4059. }
  4060. std::string IndexingMultiAxisVec_make_name_impl(const OpDef& def_) {
  4061. auto&& op_ = def_.cast_final_safe<IndexingMultiAxisVec>();
  4062. static_cast<void>(op_);
  4063. return "IndexingMultiAxisVec";
  4064. }
  4065. } // anonymous namespace
  4066. OP_TRAIT_REG(IndexingMultiAxisVec, IndexingMultiAxisVec)
  4067. .hash(IndexingMultiAxisVec_hash_impl)
  4068. .is_same_st(IndexingMultiAxisVec_is_same_st_impl)
  4069. .props(IndexingMultiAxisVec_props_impl)
  4070. .make_name(IndexingMultiAxisVec_make_name_impl);
  4071. MGB_DYN_TYPE_OBJ_FINAL_IMPL(IndexingOneHot);
  4072. namespace {
  4073. size_t IndexingOneHot_hash_impl(const OpDef& def_) {
  4074. auto&& op_ = def_.cast_final_safe<IndexingOneHot>();
  4075. static_cast<void>(op_);
  4076. size_t val = mgb::hash(op_.dyn_typeinfo());
  4077. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  4078. val = mgb::hash_pair_combine(val, mgb::hash(op_.ndim));
  4079. return val;
  4080. }
  4081. bool IndexingOneHot_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4082. auto &&a_ = lhs_.cast_final_safe<IndexingOneHot>(),
  4083. &&b_ = rhs_.cast_final_safe<IndexingOneHot>();
  4084. static_cast<void>(a_);
  4085. static_cast<void>(b_);
  4086. if (a_.axis != b_.axis) return false;
  4087. if (a_.ndim != b_.ndim) return false;
  4088. return true;
  4089. }
  4090. std::vector<std::pair<const char*, std::string>> IndexingOneHot_props_impl(const OpDef& def_) {
  4091. auto&& op_ = def_.cast_final_safe<IndexingOneHot>();
  4092. static_cast<void>(op_);
  4093. std::vector<std::pair<const char*, std::string>> props_;
  4094. props_.emplace_back("axis", std::to_string(op_.axis));
  4095. props_.emplace_back("ndim", std::to_string(op_.ndim));
  4096. return props_;
  4097. }
  4098. std::string IndexingOneHot_make_name_impl(const OpDef& def_) {
  4099. auto&& op_ = def_.cast_final_safe<IndexingOneHot>();
  4100. static_cast<void>(op_);
  4101. return "IndexingOneHot";
  4102. }
  4103. } // anonymous namespace
  4104. OP_TRAIT_REG(IndexingOneHot, IndexingOneHot)
  4105. .hash(IndexingOneHot_hash_impl)
  4106. .is_same_st(IndexingOneHot_is_same_st_impl)
  4107. .props(IndexingOneHot_props_impl)
  4108. .make_name(IndexingOneHot_make_name_impl);
  4109. MGB_DYN_TYPE_OBJ_FINAL_IMPL(IndexingSetMultiAxisVec);
  4110. namespace {
  4111. size_t IndexingSetMultiAxisVec_hash_impl(const OpDef& def_) {
  4112. auto&& op_ = def_.cast_final_safe<IndexingSetMultiAxisVec>();
  4113. static_cast<void>(op_);
  4114. size_t val = mgb::hash(op_.dyn_typeinfo());
  4115. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  4116. return val;
  4117. }
  4118. bool IndexingSetMultiAxisVec_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4119. auto &&a_ = lhs_.cast_final_safe<IndexingSetMultiAxisVec>(),
  4120. &&b_ = rhs_.cast_final_safe<IndexingSetMultiAxisVec>();
  4121. static_cast<void>(a_);
  4122. static_cast<void>(b_);
  4123. if (a_.items != b_.items) return false;
  4124. return true;
  4125. }
  4126. std::vector<std::pair<const char*, std::string>> IndexingSetMultiAxisVec_props_impl(const OpDef& def_) {
  4127. auto&& op_ = def_.cast_final_safe<IndexingSetMultiAxisVec>();
  4128. static_cast<void>(op_);
  4129. std::vector<std::pair<const char*, std::string>> props_;
  4130. props_.emplace_back("items", "{std::vector}");
  4131. return props_;
  4132. }
  4133. std::string IndexingSetMultiAxisVec_make_name_impl(const OpDef& def_) {
  4134. auto&& op_ = def_.cast_final_safe<IndexingSetMultiAxisVec>();
  4135. static_cast<void>(op_);
  4136. return "IndexingSetMultiAxisVec";
  4137. }
  4138. } // anonymous namespace
  4139. OP_TRAIT_REG(IndexingSetMultiAxisVec, IndexingSetMultiAxisVec)
  4140. .hash(IndexingSetMultiAxisVec_hash_impl)
  4141. .is_same_st(IndexingSetMultiAxisVec_is_same_st_impl)
  4142. .props(IndexingSetMultiAxisVec_props_impl)
  4143. .make_name(IndexingSetMultiAxisVec_make_name_impl);
  4144. MGB_DYN_TYPE_OBJ_FINAL_IMPL(IndexingSetOneHot);
  4145. namespace {
  4146. size_t IndexingSetOneHot_hash_impl(const OpDef& def_) {
  4147. auto&& op_ = def_.cast_final_safe<IndexingSetOneHot>();
  4148. static_cast<void>(op_);
  4149. size_t val = mgb::hash(op_.dyn_typeinfo());
  4150. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  4151. val = mgb::hash_pair_combine(val, mgb::hash(op_.ndim));
  4152. return val;
  4153. }
  4154. bool IndexingSetOneHot_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4155. auto &&a_ = lhs_.cast_final_safe<IndexingSetOneHot>(),
  4156. &&b_ = rhs_.cast_final_safe<IndexingSetOneHot>();
  4157. static_cast<void>(a_);
  4158. static_cast<void>(b_);
  4159. if (a_.axis != b_.axis) return false;
  4160. if (a_.ndim != b_.ndim) return false;
  4161. return true;
  4162. }
  4163. std::vector<std::pair<const char*, std::string>> IndexingSetOneHot_props_impl(const OpDef& def_) {
  4164. auto&& op_ = def_.cast_final_safe<IndexingSetOneHot>();
  4165. static_cast<void>(op_);
  4166. std::vector<std::pair<const char*, std::string>> props_;
  4167. props_.emplace_back("axis", std::to_string(op_.axis));
  4168. props_.emplace_back("ndim", std::to_string(op_.ndim));
  4169. return props_;
  4170. }
  4171. std::string IndexingSetOneHot_make_name_impl(const OpDef& def_) {
  4172. auto&& op_ = def_.cast_final_safe<IndexingSetOneHot>();
  4173. static_cast<void>(op_);
  4174. return "IndexingSetOneHot";
  4175. }
  4176. } // anonymous namespace
  4177. OP_TRAIT_REG(IndexingSetOneHot, IndexingSetOneHot)
  4178. .hash(IndexingSetOneHot_hash_impl)
  4179. .is_same_st(IndexingSetOneHot_is_same_st_impl)
  4180. .props(IndexingSetOneHot_props_impl)
  4181. .make_name(IndexingSetOneHot_make_name_impl);
  4182. MGB_DYN_TYPE_OBJ_FINAL_IMPL(InplaceAdd);
  4183. namespace {
  4184. size_t InplaceAdd_hash_impl(const OpDef& def_) {
  4185. auto&& op_ = def_.cast_final_safe<InplaceAdd>();
  4186. static_cast<void>(op_);
  4187. size_t val = mgb::hash(op_.dyn_typeinfo());
  4188. return val;
  4189. }
  4190. bool InplaceAdd_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4191. auto &&a_ = lhs_.cast_final_safe<InplaceAdd>(),
  4192. &&b_ = rhs_.cast_final_safe<InplaceAdd>();
  4193. static_cast<void>(a_);
  4194. static_cast<void>(b_);
  4195. return true;
  4196. }
  4197. std::vector<std::pair<const char*, std::string>> InplaceAdd_props_impl(const OpDef& def_) {
  4198. auto&& op_ = def_.cast_final_safe<InplaceAdd>();
  4199. static_cast<void>(op_);
  4200. std::vector<std::pair<const char*, std::string>> props_;
  4201. return props_;
  4202. }
  4203. std::string InplaceAdd_make_name_impl(const OpDef& def_) {
  4204. auto&& op_ = def_.cast_final_safe<InplaceAdd>();
  4205. static_cast<void>(op_);
  4206. return "InplaceAdd";
  4207. }
  4208. } // anonymous namespace
  4209. OP_TRAIT_REG(InplaceAdd, InplaceAdd)
  4210. .hash(InplaceAdd_hash_impl)
  4211. .is_same_st(InplaceAdd_is_same_st_impl)
  4212. .props(InplaceAdd_props_impl)
  4213. .make_name(InplaceAdd_make_name_impl);
  4214. MGB_DYN_TYPE_OBJ_FINAL_IMPL(LAMBUpdate);
  4215. namespace {
  4216. size_t LAMBUpdate_hash_impl(const OpDef& def_) {
  4217. auto&& op_ = def_.cast_final_safe<LAMBUpdate>();
  4218. static_cast<void>(op_);
  4219. size_t val = mgb::hash(op_.dyn_typeinfo());
  4220. val = mgb::hash_pair_combine(val, mgb::hash(op_.beta_1));
  4221. val = mgb::hash_pair_combine(val, mgb::hash(op_.beta_2));
  4222. val = mgb::hash_pair_combine(val, mgb::hash(op_.step));
  4223. val = mgb::hash_pair_combine(val, mgb::hash(op_.lr));
  4224. val = mgb::hash_pair_combine(val, mgb::hash(op_.weight_decay));
  4225. val = mgb::hash_pair_combine(val, mgb::hash(op_.eps));
  4226. val = mgb::hash_pair_combine(val, mgb::hash(op_.bias_correction));
  4227. val = mgb::hash_pair_combine(val, mgb::hash(op_.always_adapt));
  4228. return val;
  4229. }
  4230. bool LAMBUpdate_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4231. auto &&a_ = lhs_.cast_final_safe<LAMBUpdate>(),
  4232. &&b_ = rhs_.cast_final_safe<LAMBUpdate>();
  4233. static_cast<void>(a_);
  4234. static_cast<void>(b_);
  4235. if (a_.beta_1 != b_.beta_1) return false;
  4236. if (a_.beta_2 != b_.beta_2) return false;
  4237. if (a_.step != b_.step) return false;
  4238. if (a_.lr != b_.lr) return false;
  4239. if (a_.weight_decay != b_.weight_decay) return false;
  4240. if (a_.eps != b_.eps) return false;
  4241. if (a_.bias_correction != b_.bias_correction) return false;
  4242. if (a_.always_adapt != b_.always_adapt) return false;
  4243. return true;
  4244. }
  4245. std::vector<std::pair<const char*, std::string>> LAMBUpdate_props_impl(const OpDef& def_) {
  4246. auto&& op_ = def_.cast_final_safe<LAMBUpdate>();
  4247. static_cast<void>(op_);
  4248. std::vector<std::pair<const char*, std::string>> props_;
  4249. props_.emplace_back("beta_1", std::to_string(op_.beta_1));
  4250. props_.emplace_back("beta_2", std::to_string(op_.beta_2));
  4251. props_.emplace_back("step", std::to_string(op_.step));
  4252. props_.emplace_back("lr", std::to_string(op_.lr));
  4253. props_.emplace_back("weight_decay", std::to_string(op_.weight_decay));
  4254. props_.emplace_back("eps", std::to_string(op_.eps));
  4255. props_.emplace_back("bias_correction", std::to_string(op_.bias_correction));
  4256. props_.emplace_back("always_adapt", std::to_string(op_.always_adapt));
  4257. return props_;
  4258. }
  4259. std::string LAMBUpdate_make_name_impl(const OpDef& def_) {
  4260. auto&& op_ = def_.cast_final_safe<LAMBUpdate>();
  4261. static_cast<void>(op_);
  4262. return "LAMBUpdate";
  4263. }
  4264. } // anonymous namespace
  4265. OP_TRAIT_REG(LAMBUpdate, LAMBUpdate)
  4266. .hash(LAMBUpdate_hash_impl)
  4267. .is_same_st(LAMBUpdate_is_same_st_impl)
  4268. .props(LAMBUpdate_props_impl)
  4269. .make_name(LAMBUpdate_make_name_impl);
  4270. MGB_DYN_TYPE_OBJ_FINAL_IMPL(LRN);
  4271. namespace {
  4272. size_t LRN_hash_impl(const OpDef& def_) {
  4273. auto&& op_ = def_.cast_final_safe<LRN>();
  4274. static_cast<void>(op_);
  4275. size_t val = mgb::hash(op_.dyn_typeinfo());
  4276. val = mgb::hash_pair_combine(val, mgb::hash(op_.n));
  4277. val = mgb::hash_pair_combine(val, mgb::hash(op_.k));
  4278. val = mgb::hash_pair_combine(val, mgb::hash(op_.alpha));
  4279. val = mgb::hash_pair_combine(val, mgb::hash(op_.beta));
  4280. return val;
  4281. }
  4282. bool LRN_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4283. auto &&a_ = lhs_.cast_final_safe<LRN>(),
  4284. &&b_ = rhs_.cast_final_safe<LRN>();
  4285. static_cast<void>(a_);
  4286. static_cast<void>(b_);
  4287. if (a_.n != b_.n) return false;
  4288. if (a_.k != b_.k) return false;
  4289. if (a_.alpha != b_.alpha) return false;
  4290. if (a_.beta != b_.beta) return false;
  4291. return true;
  4292. }
  4293. std::vector<std::pair<const char*, std::string>> LRN_props_impl(const OpDef& def_) {
  4294. auto&& op_ = def_.cast_final_safe<LRN>();
  4295. static_cast<void>(op_);
  4296. std::vector<std::pair<const char*, std::string>> props_;
  4297. props_.emplace_back("n", std::to_string(op_.n));
  4298. props_.emplace_back("k", std::to_string(op_.k));
  4299. props_.emplace_back("alpha", std::to_string(op_.alpha));
  4300. props_.emplace_back("beta", std::to_string(op_.beta));
  4301. return props_;
  4302. }
  4303. std::string LRN_make_name_impl(const OpDef& def_) {
  4304. auto&& op_ = def_.cast_final_safe<LRN>();
  4305. static_cast<void>(op_);
  4306. return "LRN";
  4307. }
  4308. } // anonymous namespace
  4309. OP_TRAIT_REG(LRN, LRN)
  4310. .hash(LRN_hash_impl)
  4311. .is_same_st(LRN_is_same_st_impl)
  4312. .props(LRN_props_impl)
  4313. .make_name(LRN_make_name_impl);
  4314. MGB_DYN_TYPE_OBJ_FINAL_IMPL(LSQ);
  4315. namespace {
  4316. size_t LSQ_hash_impl(const OpDef& def_) {
  4317. auto&& op_ = def_.cast_final_safe<LSQ>();
  4318. static_cast<void>(op_);
  4319. size_t val = mgb::hash(op_.dyn_typeinfo());
  4320. val = mgb::hash_pair_combine(val, mgb::hash(op_.qmin));
  4321. val = mgb::hash_pair_combine(val, mgb::hash(op_.qmax));
  4322. return val;
  4323. }
  4324. bool LSQ_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4325. auto &&a_ = lhs_.cast_final_safe<LSQ>(),
  4326. &&b_ = rhs_.cast_final_safe<LSQ>();
  4327. static_cast<void>(a_);
  4328. static_cast<void>(b_);
  4329. if (a_.qmin != b_.qmin) return false;
  4330. if (a_.qmax != b_.qmax) return false;
  4331. return true;
  4332. }
  4333. std::vector<std::pair<const char*, std::string>> LSQ_props_impl(const OpDef& def_) {
  4334. auto&& op_ = def_.cast_final_safe<LSQ>();
  4335. static_cast<void>(op_);
  4336. std::vector<std::pair<const char*, std::string>> props_;
  4337. props_.emplace_back("qmin", std::to_string(op_.qmin));
  4338. props_.emplace_back("qmax", std::to_string(op_.qmax));
  4339. return props_;
  4340. }
  4341. std::string LSQ_make_name_impl(const OpDef& def_) {
  4342. auto&& op_ = def_.cast_final_safe<LSQ>();
  4343. static_cast<void>(op_);
  4344. return "LSQ";
  4345. }
  4346. } // anonymous namespace
  4347. OP_TRAIT_REG(LSQ, LSQ)
  4348. .hash(LSQ_hash_impl)
  4349. .is_same_st(LSQ_is_same_st_impl)
  4350. .props(LSQ_props_impl)
  4351. .make_name(LSQ_make_name_impl);
  4352. MGB_DYN_TYPE_OBJ_FINAL_IMPL(LSTM);
  4353. namespace {
  4354. size_t LSTM_hash_impl(const OpDef& def_) {
  4355. auto&& op_ = def_.cast_final_safe<LSTM>();
  4356. static_cast<void>(op_);
  4357. size_t val = mgb::hash(op_.dyn_typeinfo());
  4358. val = mgb::hash_pair_combine(val, mgb::hash(op_.num_layers));
  4359. val = mgb::hash_pair_combine(val, mgb::hash(op_.bidirectional));
  4360. val = mgb::hash_pair_combine(val, mgb::hash(op_.bias));
  4361. val = mgb::hash_pair_combine(val, mgb::hash(op_.hidden_size));
  4362. val = mgb::hash_pair_combine(val, mgb::hash(op_.proj_size));
  4363. val = mgb::hash_pair_combine(val, mgb::hash(op_.dropout));
  4364. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.fwd_mode));
  4365. return val;
  4366. }
  4367. bool LSTM_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4368. auto &&a_ = lhs_.cast_final_safe<LSTM>(),
  4369. &&b_ = rhs_.cast_final_safe<LSTM>();
  4370. static_cast<void>(a_);
  4371. static_cast<void>(b_);
  4372. if (a_.num_layers != b_.num_layers) return false;
  4373. if (a_.bidirectional != b_.bidirectional) return false;
  4374. if (a_.bias != b_.bias) return false;
  4375. if (a_.hidden_size != b_.hidden_size) return false;
  4376. if (a_.proj_size != b_.proj_size) return false;
  4377. if (a_.dropout != b_.dropout) return false;
  4378. if (a_.fwd_mode != b_.fwd_mode) return false;
  4379. return true;
  4380. }
  4381. std::vector<std::pair<const char*, std::string>> LSTM_props_impl(const OpDef& def_) {
  4382. auto&& op_ = def_.cast_final_safe<LSTM>();
  4383. static_cast<void>(op_);
  4384. std::vector<std::pair<const char*, std::string>> props_;
  4385. props_.emplace_back("num_layers", std::to_string(op_.num_layers));
  4386. props_.emplace_back("bidirectional", std::to_string(op_.bidirectional));
  4387. props_.emplace_back("bias", std::to_string(op_.bias));
  4388. props_.emplace_back("hidden_size", std::to_string(op_.hidden_size));
  4389. props_.emplace_back("proj_size", std::to_string(op_.proj_size));
  4390. props_.emplace_back("dropout", std::to_string(op_.dropout));
  4391. switch (op_.fwd_mode){
  4392. case LSTM::FwdMode::TRAINING:
  4393. props_.emplace_back("fwd_mode", "TRAINING");
  4394. break;
  4395. case LSTM::FwdMode::INFERENCE:
  4396. props_.emplace_back("fwd_mode", "INFERENCE");
  4397. break;
  4398. default:
  4399. props_.emplace_back("fwd_mode", "INVALID");
  4400. break;
  4401. }
  4402. return props_;
  4403. }
  4404. std::string LSTM_make_name_impl(const OpDef& def_) {
  4405. auto&& op_ = def_.cast_final_safe<LSTM>();
  4406. static_cast<void>(op_);
  4407. return "LSTM";
  4408. }
  4409. } // anonymous namespace
  4410. OP_TRAIT_REG(LSTM, LSTM)
  4411. .hash(LSTM_hash_impl)
  4412. .is_same_st(LSTM_is_same_st_impl)
  4413. .props(LSTM_props_impl)
  4414. .make_name(LSTM_make_name_impl);
  4415. MGB_DYN_TYPE_OBJ_FINAL_IMPL(LSTMCell);
  4416. namespace {
  4417. size_t LSTMCell_hash_impl(const OpDef& def_) {
  4418. auto&& op_ = def_.cast_final_safe<LSTMCell>();
  4419. static_cast<void>(op_);
  4420. size_t val = mgb::hash(op_.dyn_typeinfo());
  4421. return val;
  4422. }
  4423. bool LSTMCell_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4424. auto &&a_ = lhs_.cast_final_safe<LSTMCell>(),
  4425. &&b_ = rhs_.cast_final_safe<LSTMCell>();
  4426. static_cast<void>(a_);
  4427. static_cast<void>(b_);
  4428. return true;
  4429. }
  4430. std::vector<std::pair<const char*, std::string>> LSTMCell_props_impl(const OpDef& def_) {
  4431. auto&& op_ = def_.cast_final_safe<LSTMCell>();
  4432. static_cast<void>(op_);
  4433. std::vector<std::pair<const char*, std::string>> props_;
  4434. return props_;
  4435. }
  4436. std::string LSTMCell_make_name_impl(const OpDef& def_) {
  4437. auto&& op_ = def_.cast_final_safe<LSTMCell>();
  4438. static_cast<void>(op_);
  4439. return "LSTMCell";
  4440. }
  4441. } // anonymous namespace
  4442. OP_TRAIT_REG(LSTMCell, LSTMCell)
  4443. .hash(LSTMCell_hash_impl)
  4444. .is_same_st(LSTMCell_is_same_st_impl)
  4445. .props(LSTMCell_props_impl)
  4446. .make_name(LSTMCell_make_name_impl);
  4447. MGB_DYN_TYPE_OBJ_FINAL_IMPL(LayerNorm);
  4448. namespace {
  4449. size_t LayerNorm_hash_impl(const OpDef& def_) {
  4450. auto&& op_ = def_.cast_final_safe<LayerNorm>();
  4451. static_cast<void>(op_);
  4452. size_t val = mgb::hash(op_.dyn_typeinfo());
  4453. val = mgb::hash_pair_combine(val, mgb::hash(op_.affine));
  4454. val = mgb::hash_pair_combine(val, mgb::hash(op_.eps));
  4455. val = mgb::hash_pair_combine(val, mgb::hash(op_.normalized_dim));
  4456. val = mgb::hash_pair_combine(val, mgb::hash(op_.normalized_size));
  4457. return val;
  4458. }
  4459. bool LayerNorm_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4460. auto &&a_ = lhs_.cast_final_safe<LayerNorm>(),
  4461. &&b_ = rhs_.cast_final_safe<LayerNorm>();
  4462. static_cast<void>(a_);
  4463. static_cast<void>(b_);
  4464. if (a_.affine != b_.affine) return false;
  4465. if (a_.eps != b_.eps) return false;
  4466. if (a_.normalized_dim != b_.normalized_dim) return false;
  4467. if (a_.normalized_size != b_.normalized_size) return false;
  4468. return true;
  4469. }
  4470. std::vector<std::pair<const char*, std::string>> LayerNorm_props_impl(const OpDef& def_) {
  4471. auto&& op_ = def_.cast_final_safe<LayerNorm>();
  4472. static_cast<void>(op_);
  4473. std::vector<std::pair<const char*, std::string>> props_;
  4474. props_.emplace_back("affine", std::to_string(op_.affine));
  4475. props_.emplace_back("eps", std::to_string(op_.eps));
  4476. props_.emplace_back("normalized_dim", std::to_string(op_.normalized_dim));
  4477. props_.emplace_back("normalized_size", std::to_string(op_.normalized_size));
  4478. return props_;
  4479. }
  4480. std::string LayerNorm_make_name_impl(const OpDef& def_) {
  4481. auto&& op_ = def_.cast_final_safe<LayerNorm>();
  4482. static_cast<void>(op_);
  4483. return "LayerNorm";
  4484. }
  4485. } // anonymous namespace
  4486. OP_TRAIT_REG(LayerNorm, LayerNorm)
  4487. .hash(LayerNorm_hash_impl)
  4488. .is_same_st(LayerNorm_is_same_st_impl)
  4489. .props(LayerNorm_props_impl)
  4490. .make_name(LayerNorm_make_name_impl);
  4491. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Linspace);
  4492. namespace {
  4493. size_t Linspace_hash_impl(const OpDef& def_) {
  4494. auto&& op_ = def_.cast_final_safe<Linspace>();
  4495. static_cast<void>(op_);
  4496. size_t val = mgb::hash(op_.dyn_typeinfo());
  4497. val = mgb::hash_pair_combine(val, mgb::hash(op_.endpoint));
  4498. val = mgb::hash_pair_combine(val, mgb::hash(op_.comp_node));
  4499. return val;
  4500. }
  4501. bool Linspace_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4502. auto &&a_ = lhs_.cast_final_safe<Linspace>(),
  4503. &&b_ = rhs_.cast_final_safe<Linspace>();
  4504. static_cast<void>(a_);
  4505. static_cast<void>(b_);
  4506. if (a_.endpoint != b_.endpoint) return false;
  4507. if (a_.comp_node != b_.comp_node) return false;
  4508. return true;
  4509. }
  4510. std::vector<std::pair<const char*, std::string>> Linspace_props_impl(const OpDef& def_) {
  4511. auto&& op_ = def_.cast_final_safe<Linspace>();
  4512. static_cast<void>(op_);
  4513. std::vector<std::pair<const char*, std::string>> props_;
  4514. props_.emplace_back("endpoint", std::to_string(op_.endpoint));
  4515. props_.emplace_back("comp_node", op_.comp_node.to_string());
  4516. return props_;
  4517. }
  4518. std::string Linspace_make_name_impl(const OpDef& def_) {
  4519. auto&& op_ = def_.cast_final_safe<Linspace>();
  4520. static_cast<void>(op_);
  4521. return "Linspace";
  4522. }
  4523. } // anonymous namespace
  4524. OP_TRAIT_REG(Linspace, Linspace)
  4525. .hash(Linspace_hash_impl)
  4526. .is_same_st(Linspace_is_same_st_impl)
  4527. .props(Linspace_props_impl)
  4528. .make_name(Linspace_make_name_impl);
  4529. MGB_DYN_TYPE_OBJ_FINAL_IMPL(MagicMindRuntime);
  4530. namespace {
  4531. size_t MagicMindRuntime_hash_impl(const OpDef& def_) {
  4532. auto&& op_ = def_.cast_final_safe<MagicMindRuntime>();
  4533. static_cast<void>(op_);
  4534. size_t val = mgb::hash(op_.dyn_typeinfo());
  4535. val = mgb::hash_pair_combine(val, mgb::hash(op_.buf));
  4536. val = mgb::hash_pair_combine(val, mgb::hash(op_.buf_size));
  4537. return val;
  4538. }
  4539. bool MagicMindRuntime_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4540. auto &&a_ = lhs_.cast_final_safe<MagicMindRuntime>(),
  4541. &&b_ = rhs_.cast_final_safe<MagicMindRuntime>();
  4542. static_cast<void>(a_);
  4543. static_cast<void>(b_);
  4544. if (a_.buf != b_.buf) return false;
  4545. if (a_.buf_size != b_.buf_size) return false;
  4546. return true;
  4547. }
  4548. std::vector<std::pair<const char*, std::string>> MagicMindRuntime_props_impl(const OpDef& def_) {
  4549. auto&& op_ = def_.cast_final_safe<MagicMindRuntime>();
  4550. static_cast<void>(op_);
  4551. std::vector<std::pair<const char*, std::string>> props_;
  4552. props_.emplace_back("buf", op_.buf);
  4553. props_.emplace_back("buf_size", std::to_string(op_.buf_size));
  4554. return props_;
  4555. }
  4556. std::string MagicMindRuntime_make_name_impl(const OpDef& def_) {
  4557. auto&& op_ = def_.cast_final_safe<MagicMindRuntime>();
  4558. static_cast<void>(op_);
  4559. return "MagicMindRuntime";
  4560. }
  4561. } // anonymous namespace
  4562. OP_TRAIT_REG(MagicMindRuntime, MagicMindRuntime)
  4563. .hash(MagicMindRuntime_hash_impl)
  4564. .is_same_st(MagicMindRuntime_is_same_st_impl)
  4565. .props(MagicMindRuntime_props_impl)
  4566. .make_name(MagicMindRuntime_make_name_impl);
  4567. MGB_DYN_TYPE_OBJ_FINAL_IMPL(MatrixInverse);
  4568. namespace {
  4569. size_t MatrixInverse_hash_impl(const OpDef& def_) {
  4570. auto&& op_ = def_.cast_final_safe<MatrixInverse>();
  4571. static_cast<void>(op_);
  4572. size_t val = mgb::hash(op_.dyn_typeinfo());
  4573. return val;
  4574. }
  4575. bool MatrixInverse_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4576. auto &&a_ = lhs_.cast_final_safe<MatrixInverse>(),
  4577. &&b_ = rhs_.cast_final_safe<MatrixInverse>();
  4578. static_cast<void>(a_);
  4579. static_cast<void>(b_);
  4580. return true;
  4581. }
  4582. std::vector<std::pair<const char*, std::string>> MatrixInverse_props_impl(const OpDef& def_) {
  4583. auto&& op_ = def_.cast_final_safe<MatrixInverse>();
  4584. static_cast<void>(op_);
  4585. std::vector<std::pair<const char*, std::string>> props_;
  4586. return props_;
  4587. }
  4588. std::string MatrixInverse_make_name_impl(const OpDef& def_) {
  4589. auto&& op_ = def_.cast_final_safe<MatrixInverse>();
  4590. static_cast<void>(op_);
  4591. return "MatrixInverse";
  4592. }
  4593. } // anonymous namespace
  4594. OP_TRAIT_REG(MatrixInverse, MatrixInverse)
  4595. .hash(MatrixInverse_hash_impl)
  4596. .is_same_st(MatrixInverse_is_same_st_impl)
  4597. .props(MatrixInverse_props_impl)
  4598. .make_name(MatrixInverse_make_name_impl);
  4599. MGB_DYN_TYPE_OBJ_FINAL_IMPL(MatrixMul);
  4600. namespace {
  4601. size_t MatrixMul_hash_impl(const OpDef& def_) {
  4602. auto&& op_ = def_.cast_final_safe<MatrixMul>();
  4603. static_cast<void>(op_);
  4604. size_t val = mgb::hash(op_.dyn_typeinfo());
  4605. val = mgb::hash_pair_combine(val, mgb::hash(op_.transposeA));
  4606. val = mgb::hash_pair_combine(val, mgb::hash(op_.transposeB));
  4607. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
  4608. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  4609. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
  4610. val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
  4611. val = mgb::hash_pair_combine(val, mgb::hash(op_.dimA));
  4612. val = mgb::hash_pair_combine(val, mgb::hash(op_.dimB));
  4613. return val;
  4614. }
  4615. bool MatrixMul_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4616. auto &&a_ = lhs_.cast_final_safe<MatrixMul>(),
  4617. &&b_ = rhs_.cast_final_safe<MatrixMul>();
  4618. static_cast<void>(a_);
  4619. static_cast<void>(b_);
  4620. if (a_.transposeA != b_.transposeA) return false;
  4621. if (a_.transposeB != b_.transposeB) return false;
  4622. if (a_.compute_mode != b_.compute_mode) return false;
  4623. if (a_.format != b_.format) return false;
  4624. if (a_.strategy != b_.strategy) return false;
  4625. if (a_.workspace_limit != b_.workspace_limit) return false;
  4626. if (a_.dimA != b_.dimA) return false;
  4627. if (a_.dimB != b_.dimB) return false;
  4628. return true;
  4629. }
  4630. std::vector<std::pair<const char*, std::string>> MatrixMul_props_impl(const OpDef& def_) {
  4631. auto&& op_ = def_.cast_final_safe<MatrixMul>();
  4632. static_cast<void>(op_);
  4633. std::vector<std::pair<const char*, std::string>> props_;
  4634. props_.emplace_back("transposeA", std::to_string(op_.transposeA));
  4635. props_.emplace_back("transposeB", std::to_string(op_.transposeB));
  4636. switch (op_.compute_mode){
  4637. case MatrixMul::ComputeMode::DEFAULT:
  4638. props_.emplace_back("compute_mode", "DEFAULT");
  4639. break;
  4640. case MatrixMul::ComputeMode::FLOAT32:
  4641. props_.emplace_back("compute_mode", "FLOAT32");
  4642. break;
  4643. default:
  4644. props_.emplace_back("compute_mode", "INVALID");
  4645. break;
  4646. }
  4647. switch (op_.format){
  4648. case MatrixMul::Format::DEFAULT:
  4649. props_.emplace_back("format", "DEFAULT");
  4650. break;
  4651. case MatrixMul::Format::MK4:
  4652. props_.emplace_back("format", "MK4");
  4653. break;
  4654. case MatrixMul::Format::MK8:
  4655. props_.emplace_back("format", "MK8");
  4656. break;
  4657. case MatrixMul::Format::MK4_DOT:
  4658. props_.emplace_back("format", "MK4_DOT");
  4659. break;
  4660. case MatrixMul::Format::N32K4_DOT:
  4661. props_.emplace_back("format", "N32K4_DOT");
  4662. break;
  4663. default:
  4664. props_.emplace_back("format", "INVALID");
  4665. break;
  4666. }
  4667. switch (op_.strategy){
  4668. case MatrixMul::Strategy::HEURISTIC:
  4669. props_.emplace_back("strategy", "HEURISTIC");
  4670. break;
  4671. case MatrixMul::Strategy::PROFILE:
  4672. props_.emplace_back("strategy", "PROFILE");
  4673. break;
  4674. case MatrixMul::Strategy::REPRODUCIBLE:
  4675. props_.emplace_back("strategy", "REPRODUCIBLE");
  4676. break;
  4677. case MatrixMul::Strategy::OPTIMIZED:
  4678. props_.emplace_back("strategy", "OPTIMIZED");
  4679. break;
  4680. default:
  4681. props_.emplace_back("strategy", "INVALID");
  4682. break;
  4683. }
  4684. props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
  4685. props_.emplace_back("dimA", std::to_string(op_.dimA));
  4686. props_.emplace_back("dimB", std::to_string(op_.dimB));
  4687. return props_;
  4688. }
  4689. std::string MatrixMul_make_name_impl(const OpDef& def_) {
  4690. auto&& op_ = def_.cast_final_safe<MatrixMul>();
  4691. static_cast<void>(op_);
  4692. return "MatrixMul";
  4693. }
  4694. } // anonymous namespace
  4695. OP_TRAIT_REG(MatrixMul, MatrixMul)
  4696. .hash(MatrixMul_hash_impl)
  4697. .is_same_st(MatrixMul_is_same_st_impl)
  4698. .props(MatrixMul_props_impl)
  4699. .make_name(MatrixMul_make_name_impl);
  4700. MGB_DYN_TYPE_OBJ_FINAL_IMPL(MeshGrid);
  4701. namespace {
  4702. size_t MeshGrid_hash_impl(const OpDef& def_) {
  4703. auto&& op_ = def_.cast_final_safe<MeshGrid>();
  4704. static_cast<void>(op_);
  4705. size_t val = mgb::hash(op_.dyn_typeinfo());
  4706. val = mgb::hash_pair_combine(val, mgb::hash(op_.indexing));
  4707. return val;
  4708. }
  4709. bool MeshGrid_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4710. auto &&a_ = lhs_.cast_final_safe<MeshGrid>(),
  4711. &&b_ = rhs_.cast_final_safe<MeshGrid>();
  4712. static_cast<void>(a_);
  4713. static_cast<void>(b_);
  4714. if (a_.indexing != b_.indexing) return false;
  4715. return true;
  4716. }
  4717. std::vector<std::pair<const char*, std::string>> MeshGrid_props_impl(const OpDef& def_) {
  4718. auto&& op_ = def_.cast_final_safe<MeshGrid>();
  4719. static_cast<void>(op_);
  4720. std::vector<std::pair<const char*, std::string>> props_;
  4721. props_.emplace_back("indexing", op_.indexing);
  4722. return props_;
  4723. }
  4724. std::string MeshGrid_make_name_impl(const OpDef& def_) {
  4725. auto&& op_ = def_.cast_final_safe<MeshGrid>();
  4726. static_cast<void>(op_);
  4727. return "MeshGrid";
  4728. }
  4729. } // anonymous namespace
  4730. OP_TRAIT_REG(MeshGrid, MeshGrid)
  4731. .hash(MeshGrid_hash_impl)
  4732. .is_same_st(MeshGrid_is_same_st_impl)
  4733. .props(MeshGrid_props_impl)
  4734. .make_name(MeshGrid_make_name_impl);
  4735. MGB_DYN_TYPE_OBJ_FINAL_IMPL(MeshIndexing);
  4736. namespace {
  4737. size_t MeshIndexing_hash_impl(const OpDef& def_) {
  4738. auto&& op_ = def_.cast_final_safe<MeshIndexing>();
  4739. static_cast<void>(op_);
  4740. size_t val = mgb::hash(op_.dyn_typeinfo());
  4741. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  4742. return val;
  4743. }
  4744. bool MeshIndexing_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4745. auto &&a_ = lhs_.cast_final_safe<MeshIndexing>(),
  4746. &&b_ = rhs_.cast_final_safe<MeshIndexing>();
  4747. static_cast<void>(a_);
  4748. static_cast<void>(b_);
  4749. if (a_.items != b_.items) return false;
  4750. return true;
  4751. }
  4752. std::vector<std::pair<const char*, std::string>> MeshIndexing_props_impl(const OpDef& def_) {
  4753. auto&& op_ = def_.cast_final_safe<MeshIndexing>();
  4754. static_cast<void>(op_);
  4755. std::vector<std::pair<const char*, std::string>> props_;
  4756. props_.emplace_back("items", "{std::vector}");
  4757. return props_;
  4758. }
  4759. std::string MeshIndexing_make_name_impl(const OpDef& def_) {
  4760. auto&& op_ = def_.cast_final_safe<MeshIndexing>();
  4761. static_cast<void>(op_);
  4762. return "MeshIndexing";
  4763. }
  4764. } // anonymous namespace
  4765. OP_TRAIT_REG(MeshIndexing, MeshIndexing)
  4766. .hash(MeshIndexing_hash_impl)
  4767. .is_same_st(MeshIndexing_is_same_st_impl)
  4768. .props(MeshIndexing_props_impl)
  4769. .make_name(MeshIndexing_make_name_impl);
  4770. MGB_DYN_TYPE_OBJ_FINAL_IMPL(NMSKeep);
  4771. namespace {
  4772. size_t NMSKeep_hash_impl(const OpDef& def_) {
  4773. auto&& op_ = def_.cast_final_safe<NMSKeep>();
  4774. static_cast<void>(op_);
  4775. size_t val = mgb::hash(op_.dyn_typeinfo());
  4776. val = mgb::hash_pair_combine(val, mgb::hash(op_.iou_thresh));
  4777. val = mgb::hash_pair_combine(val, mgb::hash(op_.max_output));
  4778. return val;
  4779. }
  4780. bool NMSKeep_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4781. auto &&a_ = lhs_.cast_final_safe<NMSKeep>(),
  4782. &&b_ = rhs_.cast_final_safe<NMSKeep>();
  4783. static_cast<void>(a_);
  4784. static_cast<void>(b_);
  4785. if (a_.iou_thresh != b_.iou_thresh) return false;
  4786. if (a_.max_output != b_.max_output) return false;
  4787. return true;
  4788. }
  4789. std::vector<std::pair<const char*, std::string>> NMSKeep_props_impl(const OpDef& def_) {
  4790. auto&& op_ = def_.cast_final_safe<NMSKeep>();
  4791. static_cast<void>(op_);
  4792. std::vector<std::pair<const char*, std::string>> props_;
  4793. props_.emplace_back("iou_thresh", std::to_string(op_.iou_thresh));
  4794. props_.emplace_back("max_output", std::to_string(op_.max_output));
  4795. return props_;
  4796. }
  4797. std::string NMSKeep_make_name_impl(const OpDef& def_) {
  4798. auto&& op_ = def_.cast_final_safe<NMSKeep>();
  4799. static_cast<void>(op_);
  4800. return "NMSKeep";
  4801. }
  4802. } // anonymous namespace
  4803. OP_TRAIT_REG(NMSKeep, NMSKeep)
  4804. .hash(NMSKeep_hash_impl)
  4805. .is_same_st(NMSKeep_is_same_st_impl)
  4806. .props(NMSKeep_props_impl)
  4807. .make_name(NMSKeep_make_name_impl);
  4808. MGB_DYN_TYPE_OBJ_FINAL_IMPL(NvOf);
  4809. namespace {
  4810. size_t NvOf_hash_impl(const OpDef& def_) {
  4811. auto&& op_ = def_.cast_final_safe<NvOf>();
  4812. static_cast<void>(op_);
  4813. size_t val = mgb::hash(op_.dyn_typeinfo());
  4814. val = mgb::hash_pair_combine(val, mgb::hash(op_.precision));
  4815. return val;
  4816. }
  4817. bool NvOf_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4818. auto &&a_ = lhs_.cast_final_safe<NvOf>(),
  4819. &&b_ = rhs_.cast_final_safe<NvOf>();
  4820. static_cast<void>(a_);
  4821. static_cast<void>(b_);
  4822. if (a_.precision != b_.precision) return false;
  4823. return true;
  4824. }
  4825. std::vector<std::pair<const char*, std::string>> NvOf_props_impl(const OpDef& def_) {
  4826. auto&& op_ = def_.cast_final_safe<NvOf>();
  4827. static_cast<void>(op_);
  4828. std::vector<std::pair<const char*, std::string>> props_;
  4829. props_.emplace_back("precision", std::to_string(op_.precision));
  4830. return props_;
  4831. }
  4832. std::string NvOf_make_name_impl(const OpDef& def_) {
  4833. auto&& op_ = def_.cast_final_safe<NvOf>();
  4834. static_cast<void>(op_);
  4835. return "NvOf";
  4836. }
  4837. } // anonymous namespace
  4838. OP_TRAIT_REG(NvOf, NvOf)
  4839. .hash(NvOf_hash_impl)
  4840. .is_same_st(NvOf_is_same_st_impl)
  4841. .props(NvOf_props_impl)
  4842. .make_name(NvOf_make_name_impl);
  4843. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Padding);
  4844. namespace {
  4845. size_t Padding_hash_impl(const OpDef& def_) {
  4846. auto&& op_ = def_.cast_final_safe<Padding>();
  4847. static_cast<void>(op_);
  4848. size_t val = mgb::hash(op_.dyn_typeinfo());
  4849. val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim0));
  4850. val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim1));
  4851. val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim2));
  4852. val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim3));
  4853. val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim4));
  4854. val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim5));
  4855. val = mgb::hash_pair_combine(val, mgb::hash(op_.front_offset_dim6));
  4856. val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim0));
  4857. val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim1));
  4858. val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim2));
  4859. val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim3));
  4860. val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim4));
  4861. val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim5));
  4862. val = mgb::hash_pair_combine(val, mgb::hash(op_.back_offset_dim6));
  4863. val = mgb::hash_pair_combine(val, mgb::hash(op_.padding_val));
  4864. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.padding_mode));
  4865. return val;
  4866. }
  4867. bool Padding_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4868. auto &&a_ = lhs_.cast_final_safe<Padding>(),
  4869. &&b_ = rhs_.cast_final_safe<Padding>();
  4870. static_cast<void>(a_);
  4871. static_cast<void>(b_);
  4872. if (a_.front_offset_dim0 != b_.front_offset_dim0) return false;
  4873. if (a_.front_offset_dim1 != b_.front_offset_dim1) return false;
  4874. if (a_.front_offset_dim2 != b_.front_offset_dim2) return false;
  4875. if (a_.front_offset_dim3 != b_.front_offset_dim3) return false;
  4876. if (a_.front_offset_dim4 != b_.front_offset_dim4) return false;
  4877. if (a_.front_offset_dim5 != b_.front_offset_dim5) return false;
  4878. if (a_.front_offset_dim6 != b_.front_offset_dim6) return false;
  4879. if (a_.back_offset_dim0 != b_.back_offset_dim0) return false;
  4880. if (a_.back_offset_dim1 != b_.back_offset_dim1) return false;
  4881. if (a_.back_offset_dim2 != b_.back_offset_dim2) return false;
  4882. if (a_.back_offset_dim3 != b_.back_offset_dim3) return false;
  4883. if (a_.back_offset_dim4 != b_.back_offset_dim4) return false;
  4884. if (a_.back_offset_dim5 != b_.back_offset_dim5) return false;
  4885. if (a_.back_offset_dim6 != b_.back_offset_dim6) return false;
  4886. if (a_.padding_val != b_.padding_val) return false;
  4887. if (a_.padding_mode != b_.padding_mode) return false;
  4888. return true;
  4889. }
  4890. std::vector<std::pair<const char*, std::string>> Padding_props_impl(const OpDef& def_) {
  4891. auto&& op_ = def_.cast_final_safe<Padding>();
  4892. static_cast<void>(op_);
  4893. std::vector<std::pair<const char*, std::string>> props_;
  4894. props_.emplace_back("front_offset_dim0", std::to_string(op_.front_offset_dim0));
  4895. props_.emplace_back("front_offset_dim1", std::to_string(op_.front_offset_dim1));
  4896. props_.emplace_back("front_offset_dim2", std::to_string(op_.front_offset_dim2));
  4897. props_.emplace_back("front_offset_dim3", std::to_string(op_.front_offset_dim3));
  4898. props_.emplace_back("front_offset_dim4", std::to_string(op_.front_offset_dim4));
  4899. props_.emplace_back("front_offset_dim5", std::to_string(op_.front_offset_dim5));
  4900. props_.emplace_back("front_offset_dim6", std::to_string(op_.front_offset_dim6));
  4901. props_.emplace_back("back_offset_dim0", std::to_string(op_.back_offset_dim0));
  4902. props_.emplace_back("back_offset_dim1", std::to_string(op_.back_offset_dim1));
  4903. props_.emplace_back("back_offset_dim2", std::to_string(op_.back_offset_dim2));
  4904. props_.emplace_back("back_offset_dim3", std::to_string(op_.back_offset_dim3));
  4905. props_.emplace_back("back_offset_dim4", std::to_string(op_.back_offset_dim4));
  4906. props_.emplace_back("back_offset_dim5", std::to_string(op_.back_offset_dim5));
  4907. props_.emplace_back("back_offset_dim6", std::to_string(op_.back_offset_dim6));
  4908. props_.emplace_back("padding_val", std::to_string(op_.padding_val));
  4909. switch (op_.padding_mode){
  4910. case Padding::PaddingMode::REPLICATE:
  4911. props_.emplace_back("padding_mode", "REPLICATE");
  4912. break;
  4913. case Padding::PaddingMode::REFLECT:
  4914. props_.emplace_back("padding_mode", "REFLECT");
  4915. break;
  4916. case Padding::PaddingMode::CONSTANT:
  4917. props_.emplace_back("padding_mode", "CONSTANT");
  4918. break;
  4919. default:
  4920. props_.emplace_back("padding_mode", "INVALID");
  4921. break;
  4922. }
  4923. return props_;
  4924. }
  4925. std::string Padding_make_name_impl(const OpDef& def_) {
  4926. auto&& op_ = def_.cast_final_safe<Padding>();
  4927. static_cast<void>(op_);
  4928. return "Padding";
  4929. }
  4930. } // anonymous namespace
  4931. OP_TRAIT_REG(Padding, Padding)
  4932. .hash(Padding_hash_impl)
  4933. .is_same_st(Padding_is_same_st_impl)
  4934. .props(Padding_props_impl)
  4935. .make_name(Padding_make_name_impl);
  4936. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ParamPackConcat);
  4937. namespace {
  4938. size_t ParamPackConcat_hash_impl(const OpDef& def_) {
  4939. auto&& op_ = def_.cast_final_safe<ParamPackConcat>();
  4940. static_cast<void>(op_);
  4941. size_t val = mgb::hash(op_.dyn_typeinfo());
  4942. val = mgb::hash_pair_combine(val, mgb::hash(op_.offsets));
  4943. return val;
  4944. }
  4945. bool ParamPackConcat_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4946. auto &&a_ = lhs_.cast_final_safe<ParamPackConcat>(),
  4947. &&b_ = rhs_.cast_final_safe<ParamPackConcat>();
  4948. static_cast<void>(a_);
  4949. static_cast<void>(b_);
  4950. if (a_.offsets != b_.offsets) return false;
  4951. return true;
  4952. }
  4953. std::vector<std::pair<const char*, std::string>> ParamPackConcat_props_impl(const OpDef& def_) {
  4954. auto&& op_ = def_.cast_final_safe<ParamPackConcat>();
  4955. static_cast<void>(op_);
  4956. std::vector<std::pair<const char*, std::string>> props_;
  4957. props_.emplace_back("offsets", "{std::vector}");
  4958. return props_;
  4959. }
  4960. std::string ParamPackConcat_make_name_impl(const OpDef& def_) {
  4961. auto&& op_ = def_.cast_final_safe<ParamPackConcat>();
  4962. static_cast<void>(op_);
  4963. return "ParamPackConcat";
  4964. }
  4965. } // anonymous namespace
  4966. OP_TRAIT_REG(ParamPackConcat, ParamPackConcat)
  4967. .hash(ParamPackConcat_hash_impl)
  4968. .is_same_st(ParamPackConcat_is_same_st_impl)
  4969. .props(ParamPackConcat_props_impl)
  4970. .make_name(ParamPackConcat_make_name_impl);
  4971. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ParamPackSplit);
  4972. namespace {
  4973. size_t ParamPackSplit_hash_impl(const OpDef& def_) {
  4974. auto&& op_ = def_.cast_final_safe<ParamPackSplit>();
  4975. static_cast<void>(op_);
  4976. size_t val = mgb::hash(op_.dyn_typeinfo());
  4977. val = mgb::hash_pair_combine(val, mgb::hash(op_.offsets));
  4978. val = mgb::hash_pair_combine(val, mgb::hash(op_.shapes));
  4979. return val;
  4980. }
  4981. bool ParamPackSplit_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  4982. auto &&a_ = lhs_.cast_final_safe<ParamPackSplit>(),
  4983. &&b_ = rhs_.cast_final_safe<ParamPackSplit>();
  4984. static_cast<void>(a_);
  4985. static_cast<void>(b_);
  4986. if (a_.offsets != b_.offsets) return false;
  4987. if (a_.shapes != b_.shapes) return false;
  4988. return true;
  4989. }
  4990. std::vector<std::pair<const char*, std::string>> ParamPackSplit_props_impl(const OpDef& def_) {
  4991. auto&& op_ = def_.cast_final_safe<ParamPackSplit>();
  4992. static_cast<void>(op_);
  4993. std::vector<std::pair<const char*, std::string>> props_;
  4994. props_.emplace_back("offsets", "{std::vector}");
  4995. props_.emplace_back("shapes", "{std::vector}");
  4996. return props_;
  4997. }
  4998. std::string ParamPackSplit_make_name_impl(const OpDef& def_) {
  4999. auto&& op_ = def_.cast_final_safe<ParamPackSplit>();
  5000. static_cast<void>(op_);
  5001. return "ParamPackSplit";
  5002. }
  5003. } // anonymous namespace
  5004. OP_TRAIT_REG(ParamPackSplit, ParamPackSplit)
  5005. .hash(ParamPackSplit_hash_impl)
  5006. .is_same_st(ParamPackSplit_is_same_st_impl)
  5007. .props(ParamPackSplit_props_impl)
  5008. .make_name(ParamPackSplit_make_name_impl);
  5009. MGB_DYN_TYPE_OBJ_FINAL_IMPL(PermutationRNG);
  5010. namespace {
  5011. size_t PermutationRNG_hash_impl(const OpDef& def_) {
  5012. auto&& op_ = def_.cast_final_safe<PermutationRNG>();
  5013. static_cast<void>(op_);
  5014. return mgb::hash_pair_combine(
  5015. mgb::hash(op_.dyn_typeinfo()),
  5016. mgb::hash_pair_combine(
  5017. mgb::hash(op_.handle),
  5018. mgb::hash(op_.dtype.enumv())
  5019. )
  5020. );
  5021. }
  5022. bool PermutationRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5023. auto &&a_ = lhs_.cast_final_safe<PermutationRNG>(),
  5024. &&b_ = rhs_.cast_final_safe<PermutationRNG>();
  5025. static_cast<void>(a_);
  5026. static_cast<void>(b_);
  5027. return a_.handle == b_.handle && a_.dtype == b_.dtype;}
  5028. std::vector<std::pair<const char*, std::string>> PermutationRNG_props_impl(const OpDef& def_) {
  5029. auto&& op_ = def_.cast_final_safe<PermutationRNG>();
  5030. static_cast<void>(op_);
  5031. std::vector<std::pair<const char*, std::string>> props_;
  5032. props_.emplace_back("seed", std::to_string(op_.seed));
  5033. props_.emplace_back("dtype", op_.dtype.name());
  5034. props_.emplace_back("handle", std::to_string(op_.handle));
  5035. return props_;
  5036. }
  5037. std::string PermutationRNG_make_name_impl(const OpDef& def_) {
  5038. auto&& op_ = def_.cast_final_safe<PermutationRNG>();
  5039. static_cast<void>(op_);
  5040. return "PermutationRNG";
  5041. }
  5042. } // anonymous namespace
  5043. OP_TRAIT_REG(PermutationRNG, PermutationRNG)
  5044. .hash(PermutationRNG_hash_impl)
  5045. .is_same_st(PermutationRNG_is_same_st_impl)
  5046. .props(PermutationRNG_props_impl)
  5047. .make_name(PermutationRNG_make_name_impl);
  5048. MGB_DYN_TYPE_OBJ_FINAL_IMPL(PixelShuffle);
  5049. namespace {
  5050. size_t PixelShuffle_hash_impl(const OpDef& def_) {
  5051. auto&& op_ = def_.cast_final_safe<PixelShuffle>();
  5052. static_cast<void>(op_);
  5053. size_t val = mgb::hash(op_.dyn_typeinfo());
  5054. val = mgb::hash_pair_combine(val, mgb::hash(op_.factor));
  5055. return val;
  5056. }
  5057. bool PixelShuffle_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5058. auto &&a_ = lhs_.cast_final_safe<PixelShuffle>(),
  5059. &&b_ = rhs_.cast_final_safe<PixelShuffle>();
  5060. static_cast<void>(a_);
  5061. static_cast<void>(b_);
  5062. if (a_.factor != b_.factor) return false;
  5063. return true;
  5064. }
  5065. std::vector<std::pair<const char*, std::string>> PixelShuffle_props_impl(const OpDef& def_) {
  5066. auto&& op_ = def_.cast_final_safe<PixelShuffle>();
  5067. static_cast<void>(op_);
  5068. std::vector<std::pair<const char*, std::string>> props_;
  5069. props_.emplace_back("factor", std::to_string(op_.factor));
  5070. return props_;
  5071. }
  5072. std::string PixelShuffle_make_name_impl(const OpDef& def_) {
  5073. auto&& op_ = def_.cast_final_safe<PixelShuffle>();
  5074. static_cast<void>(op_);
  5075. return "PixelShuffle";
  5076. }
  5077. } // anonymous namespace
  5078. OP_TRAIT_REG(PixelShuffle, PixelShuffle)
  5079. .hash(PixelShuffle_hash_impl)
  5080. .is_same_st(PixelShuffle_is_same_st_impl)
  5081. .props(PixelShuffle_props_impl)
  5082. .make_name(PixelShuffle_make_name_impl);
  5083. MGB_DYN_TYPE_OBJ_FINAL_IMPL(PixelShuffleBackward);
  5084. namespace {
  5085. size_t PixelShuffleBackward_hash_impl(const OpDef& def_) {
  5086. auto&& op_ = def_.cast_final_safe<PixelShuffleBackward>();
  5087. static_cast<void>(op_);
  5088. size_t val = mgb::hash(op_.dyn_typeinfo());
  5089. val = mgb::hash_pair_combine(val, mgb::hash(op_.factor));
  5090. return val;
  5091. }
  5092. bool PixelShuffleBackward_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5093. auto &&a_ = lhs_.cast_final_safe<PixelShuffleBackward>(),
  5094. &&b_ = rhs_.cast_final_safe<PixelShuffleBackward>();
  5095. static_cast<void>(a_);
  5096. static_cast<void>(b_);
  5097. if (a_.factor != b_.factor) return false;
  5098. return true;
  5099. }
  5100. std::vector<std::pair<const char*, std::string>> PixelShuffleBackward_props_impl(const OpDef& def_) {
  5101. auto&& op_ = def_.cast_final_safe<PixelShuffleBackward>();
  5102. static_cast<void>(op_);
  5103. std::vector<std::pair<const char*, std::string>> props_;
  5104. props_.emplace_back("factor", std::to_string(op_.factor));
  5105. return props_;
  5106. }
  5107. std::string PixelShuffleBackward_make_name_impl(const OpDef& def_) {
  5108. auto&& op_ = def_.cast_final_safe<PixelShuffleBackward>();
  5109. static_cast<void>(op_);
  5110. return "PixelShuffleBackward";
  5111. }
  5112. } // anonymous namespace
  5113. OP_TRAIT_REG(PixelShuffleBackward, PixelShuffleBackward)
  5114. .hash(PixelShuffleBackward_hash_impl)
  5115. .is_same_st(PixelShuffleBackward_is_same_st_impl)
  5116. .props(PixelShuffleBackward_props_impl)
  5117. .make_name(PixelShuffleBackward_make_name_impl);
  5118. MGB_DYN_TYPE_OBJ_FINAL_IMPL(PoissonRNG);
  5119. namespace {
  5120. size_t PoissonRNG_hash_impl(const OpDef& def_) {
  5121. auto&& op_ = def_.cast_final_safe<PoissonRNG>();
  5122. static_cast<void>(op_);
  5123. return mgb::hash_pair_combine(
  5124. mgb::hash(op_.dyn_typeinfo()),
  5125. mgb::hash(op_.handle)
  5126. );
  5127. }
  5128. bool PoissonRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5129. auto &&a_ = lhs_.cast_final_safe<PoissonRNG>(),
  5130. &&b_ = rhs_.cast_final_safe<PoissonRNG>();
  5131. static_cast<void>(a_);
  5132. static_cast<void>(b_);
  5133. return a_.handle == b_.handle;}
  5134. std::vector<std::pair<const char*, std::string>> PoissonRNG_props_impl(const OpDef& def_) {
  5135. auto&& op_ = def_.cast_final_safe<PoissonRNG>();
  5136. static_cast<void>(op_);
  5137. std::vector<std::pair<const char*, std::string>> props_;
  5138. props_.emplace_back("seed", std::to_string(op_.seed));
  5139. props_.emplace_back("handle", std::to_string(op_.handle));
  5140. return props_;
  5141. }
  5142. std::string PoissonRNG_make_name_impl(const OpDef& def_) {
  5143. auto&& op_ = def_.cast_final_safe<PoissonRNG>();
  5144. static_cast<void>(op_);
  5145. return "PoissonRNG";
  5146. }
  5147. } // anonymous namespace
  5148. OP_TRAIT_REG(PoissonRNG, PoissonRNG)
  5149. .hash(PoissonRNG_hash_impl)
  5150. .is_same_st(PoissonRNG_is_same_st_impl)
  5151. .props(PoissonRNG_props_impl)
  5152. .make_name(PoissonRNG_make_name_impl);
  5153. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Pooling);
  5154. namespace {
  5155. size_t Pooling_hash_impl(const OpDef& def_) {
  5156. auto&& op_ = def_.cast_final_safe<Pooling>();
  5157. static_cast<void>(op_);
  5158. size_t val = mgb::hash(op_.dyn_typeinfo());
  5159. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  5160. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  5161. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  5162. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  5163. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  5164. val = mgb::hash_pair_combine(val, mgb::hash(op_.window_h));
  5165. val = mgb::hash_pair_combine(val, mgb::hash(op_.window_w));
  5166. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  5167. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.strategy));
  5168. val = mgb::hash_pair_combine(val, mgb::hash(op_.workspace_limit));
  5169. return val;
  5170. }
  5171. bool Pooling_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5172. auto &&a_ = lhs_.cast_final_safe<Pooling>(),
  5173. &&b_ = rhs_.cast_final_safe<Pooling>();
  5174. static_cast<void>(a_);
  5175. static_cast<void>(b_);
  5176. if (a_.mode != b_.mode) return false;
  5177. if (a_.pad_h != b_.pad_h) return false;
  5178. if (a_.pad_w != b_.pad_w) return false;
  5179. if (a_.stride_h != b_.stride_h) return false;
  5180. if (a_.stride_w != b_.stride_w) return false;
  5181. if (a_.window_h != b_.window_h) return false;
  5182. if (a_.window_w != b_.window_w) return false;
  5183. if (a_.format != b_.format) return false;
  5184. if (a_.strategy != b_.strategy) return false;
  5185. if (a_.workspace_limit != b_.workspace_limit) return false;
  5186. return true;
  5187. }
  5188. std::vector<std::pair<const char*, std::string>> Pooling_props_impl(const OpDef& def_) {
  5189. auto&& op_ = def_.cast_final_safe<Pooling>();
  5190. static_cast<void>(op_);
  5191. std::vector<std::pair<const char*, std::string>> props_;
  5192. switch (op_.mode){
  5193. case Pooling::Mode::MAX:
  5194. props_.emplace_back("mode", "MAX");
  5195. break;
  5196. case Pooling::Mode::AVERAGE:
  5197. props_.emplace_back("mode", "AVERAGE");
  5198. break;
  5199. case Pooling::Mode::AVERAGE_COUNT_EXCLUDE_PADDING:
  5200. props_.emplace_back("mode", "AVERAGE_COUNT_EXCLUDE_PADDING");
  5201. break;
  5202. default:
  5203. props_.emplace_back("mode", "INVALID");
  5204. break;
  5205. }
  5206. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  5207. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  5208. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  5209. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  5210. props_.emplace_back("window_h", std::to_string(op_.window_h));
  5211. props_.emplace_back("window_w", std::to_string(op_.window_w));
  5212. switch (op_.format){
  5213. case Pooling::Format::NCHW:
  5214. props_.emplace_back("format", "NCHW");
  5215. break;
  5216. case Pooling::Format::NHWC:
  5217. props_.emplace_back("format", "NHWC");
  5218. break;
  5219. case Pooling::Format::NHWCD4:
  5220. props_.emplace_back("format", "NHWCD4");
  5221. break;
  5222. case Pooling::Format::NCHW4:
  5223. props_.emplace_back("format", "NCHW4");
  5224. break;
  5225. case Pooling::Format::NCHW8:
  5226. props_.emplace_back("format", "NCHW8");
  5227. break;
  5228. case Pooling::Format::NCHW32:
  5229. props_.emplace_back("format", "NCHW32");
  5230. break;
  5231. case Pooling::Format::NCHW88:
  5232. props_.emplace_back("format", "NCHW88");
  5233. break;
  5234. case Pooling::Format::NCHW44:
  5235. props_.emplace_back("format", "NCHW44");
  5236. break;
  5237. case Pooling::Format::NCHW44_DOT:
  5238. props_.emplace_back("format", "NCHW44_DOT");
  5239. break;
  5240. case Pooling::Format::NCHW4_NCHW32:
  5241. props_.emplace_back("format", "NCHW4_NCHW32");
  5242. break;
  5243. case Pooling::Format::NCHW32_NCHW4:
  5244. props_.emplace_back("format", "NCHW32_NCHW4");
  5245. break;
  5246. case Pooling::Format::NCHW4_NCHW:
  5247. props_.emplace_back("format", "NCHW4_NCHW");
  5248. break;
  5249. case Pooling::Format::NHWC_NCHW:
  5250. props_.emplace_back("format", "NHWC_NCHW");
  5251. break;
  5252. case Pooling::Format::NHWC_NCHW4_IC_SMALL:
  5253. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  5254. break;
  5255. case Pooling::Format::NCHW_NCHW4_IC_SMALL:
  5256. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  5257. break;
  5258. case Pooling::Format::CHWN4:
  5259. props_.emplace_back("format", "CHWN4");
  5260. break;
  5261. case Pooling::Format::NCHW64:
  5262. props_.emplace_back("format", "NCHW64");
  5263. break;
  5264. case Pooling::Format::NCHW4_NHWC:
  5265. props_.emplace_back("format", "NCHW4_NHWC");
  5266. break;
  5267. default:
  5268. props_.emplace_back("format", "INVALID");
  5269. break;
  5270. }
  5271. switch (op_.strategy){
  5272. case Pooling::Strategy::HEURISTIC:
  5273. props_.emplace_back("strategy", "HEURISTIC");
  5274. break;
  5275. case Pooling::Strategy::PROFILE:
  5276. props_.emplace_back("strategy", "PROFILE");
  5277. break;
  5278. case Pooling::Strategy::REPRODUCIBLE:
  5279. props_.emplace_back("strategy", "REPRODUCIBLE");
  5280. break;
  5281. case Pooling::Strategy::OPTIMIZED:
  5282. props_.emplace_back("strategy", "OPTIMIZED");
  5283. break;
  5284. default:
  5285. props_.emplace_back("strategy", "INVALID");
  5286. break;
  5287. }
  5288. props_.emplace_back("workspace_limit", std::to_string(op_.workspace_limit));
  5289. return props_;
  5290. }
  5291. std::string Pooling_make_name_impl(const OpDef& def_) {
  5292. auto&& op_ = def_.cast_final_safe<Pooling>();
  5293. static_cast<void>(op_);
  5294. return "Pooling";
  5295. }
  5296. } // anonymous namespace
  5297. OP_TRAIT_REG(Pooling, Pooling)
  5298. .hash(Pooling_hash_impl)
  5299. .is_same_st(Pooling_is_same_st_impl)
  5300. .props(Pooling_props_impl)
  5301. .make_name(Pooling_make_name_impl);
  5302. MGB_DYN_TYPE_OBJ_FINAL_IMPL(RNN);
  5303. namespace {
  5304. size_t RNN_hash_impl(const OpDef& def_) {
  5305. auto&& op_ = def_.cast_final_safe<RNN>();
  5306. static_cast<void>(op_);
  5307. size_t val = mgb::hash(op_.dyn_typeinfo());
  5308. val = mgb::hash_pair_combine(val, mgb::hash(op_.num_layers));
  5309. val = mgb::hash_pair_combine(val, mgb::hash(op_.bidirectional));
  5310. val = mgb::hash_pair_combine(val, mgb::hash(op_.bias));
  5311. val = mgb::hash_pair_combine(val, mgb::hash(op_.hidden_size));
  5312. val = mgb::hash_pair_combine(val, mgb::hash(op_.dropout));
  5313. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.nonlineMode));
  5314. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.fwd_mode));
  5315. return val;
  5316. }
  5317. bool RNN_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5318. auto &&a_ = lhs_.cast_final_safe<RNN>(),
  5319. &&b_ = rhs_.cast_final_safe<RNN>();
  5320. static_cast<void>(a_);
  5321. static_cast<void>(b_);
  5322. if (a_.num_layers != b_.num_layers) return false;
  5323. if (a_.bidirectional != b_.bidirectional) return false;
  5324. if (a_.bias != b_.bias) return false;
  5325. if (a_.hidden_size != b_.hidden_size) return false;
  5326. if (a_.dropout != b_.dropout) return false;
  5327. if (a_.nonlineMode != b_.nonlineMode) return false;
  5328. if (a_.fwd_mode != b_.fwd_mode) return false;
  5329. return true;
  5330. }
  5331. std::vector<std::pair<const char*, std::string>> RNN_props_impl(const OpDef& def_) {
  5332. auto&& op_ = def_.cast_final_safe<RNN>();
  5333. static_cast<void>(op_);
  5334. std::vector<std::pair<const char*, std::string>> props_;
  5335. props_.emplace_back("num_layers", std::to_string(op_.num_layers));
  5336. props_.emplace_back("bidirectional", std::to_string(op_.bidirectional));
  5337. props_.emplace_back("bias", std::to_string(op_.bias));
  5338. props_.emplace_back("hidden_size", std::to_string(op_.hidden_size));
  5339. props_.emplace_back("dropout", std::to_string(op_.dropout));
  5340. switch (op_.nonlineMode){
  5341. case RNN::NonlineMode::IDENTITY:
  5342. props_.emplace_back("nonlineMode", "IDENTITY");
  5343. break;
  5344. case RNN::NonlineMode::RELU:
  5345. props_.emplace_back("nonlineMode", "RELU");
  5346. break;
  5347. case RNN::NonlineMode::TANH:
  5348. props_.emplace_back("nonlineMode", "TANH");
  5349. break;
  5350. default:
  5351. props_.emplace_back("nonlineMode", "INVALID");
  5352. break;
  5353. }
  5354. switch (op_.fwd_mode){
  5355. case RNN::FwdMode::TRAINING:
  5356. props_.emplace_back("fwd_mode", "TRAINING");
  5357. break;
  5358. case RNN::FwdMode::INFERENCE:
  5359. props_.emplace_back("fwd_mode", "INFERENCE");
  5360. break;
  5361. default:
  5362. props_.emplace_back("fwd_mode", "INVALID");
  5363. break;
  5364. }
  5365. return props_;
  5366. }
  5367. std::string RNN_make_name_impl(const OpDef& def_) {
  5368. auto&& op_ = def_.cast_final_safe<RNN>();
  5369. static_cast<void>(op_);
  5370. return "RNN";
  5371. }
  5372. } // anonymous namespace
  5373. OP_TRAIT_REG(RNN, RNN)
  5374. .hash(RNN_hash_impl)
  5375. .is_same_st(RNN_is_same_st_impl)
  5376. .props(RNN_props_impl)
  5377. .make_name(RNN_make_name_impl);
  5378. MGB_DYN_TYPE_OBJ_FINAL_IMPL(RNNCell);
  5379. namespace {
  5380. size_t RNNCell_hash_impl(const OpDef& def_) {
  5381. auto&& op_ = def_.cast_final_safe<RNNCell>();
  5382. static_cast<void>(op_);
  5383. size_t val = mgb::hash(op_.dyn_typeinfo());
  5384. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.nonlineMode));
  5385. return val;
  5386. }
  5387. bool RNNCell_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5388. auto &&a_ = lhs_.cast_final_safe<RNNCell>(),
  5389. &&b_ = rhs_.cast_final_safe<RNNCell>();
  5390. static_cast<void>(a_);
  5391. static_cast<void>(b_);
  5392. if (a_.nonlineMode != b_.nonlineMode) return false;
  5393. return true;
  5394. }
  5395. std::vector<std::pair<const char*, std::string>> RNNCell_props_impl(const OpDef& def_) {
  5396. auto&& op_ = def_.cast_final_safe<RNNCell>();
  5397. static_cast<void>(op_);
  5398. std::vector<std::pair<const char*, std::string>> props_;
  5399. switch (op_.nonlineMode){
  5400. case RNNCell::NonlineMode::IDENTITY:
  5401. props_.emplace_back("nonlineMode", "IDENTITY");
  5402. break;
  5403. case RNNCell::NonlineMode::RELU:
  5404. props_.emplace_back("nonlineMode", "RELU");
  5405. break;
  5406. case RNNCell::NonlineMode::TANH:
  5407. props_.emplace_back("nonlineMode", "TANH");
  5408. break;
  5409. default:
  5410. props_.emplace_back("nonlineMode", "INVALID");
  5411. break;
  5412. }
  5413. return props_;
  5414. }
  5415. std::string RNNCell_make_name_impl(const OpDef& def_) {
  5416. auto&& op_ = def_.cast_final_safe<RNNCell>();
  5417. static_cast<void>(op_);
  5418. return "RNNCell";
  5419. }
  5420. } // anonymous namespace
  5421. OP_TRAIT_REG(RNNCell, RNNCell)
  5422. .hash(RNNCell_hash_impl)
  5423. .is_same_st(RNNCell_is_same_st_impl)
  5424. .props(RNNCell_props_impl)
  5425. .make_name(RNNCell_make_name_impl);
  5426. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ROIAlign);
  5427. namespace {
  5428. size_t ROIAlign_hash_impl(const OpDef& def_) {
  5429. auto&& op_ = def_.cast_final_safe<ROIAlign>();
  5430. static_cast<void>(op_);
  5431. size_t val = mgb::hash(op_.dyn_typeinfo());
  5432. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  5433. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  5434. val = mgb::hash_pair_combine(val, mgb::hash(op_.spatial_scale));
  5435. val = mgb::hash_pair_combine(val, mgb::hash(op_.offset));
  5436. val = mgb::hash_pair_combine(val, mgb::hash(op_.pooled_height));
  5437. val = mgb::hash_pair_combine(val, mgb::hash(op_.pooled_width));
  5438. val = mgb::hash_pair_combine(val, mgb::hash(op_.sample_height));
  5439. val = mgb::hash_pair_combine(val, mgb::hash(op_.sample_width));
  5440. return val;
  5441. }
  5442. bool ROIAlign_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5443. auto &&a_ = lhs_.cast_final_safe<ROIAlign>(),
  5444. &&b_ = rhs_.cast_final_safe<ROIAlign>();
  5445. static_cast<void>(a_);
  5446. static_cast<void>(b_);
  5447. if (a_.mode != b_.mode) return false;
  5448. if (a_.format != b_.format) return false;
  5449. if (a_.spatial_scale != b_.spatial_scale) return false;
  5450. if (a_.offset != b_.offset) return false;
  5451. if (a_.pooled_height != b_.pooled_height) return false;
  5452. if (a_.pooled_width != b_.pooled_width) return false;
  5453. if (a_.sample_height != b_.sample_height) return false;
  5454. if (a_.sample_width != b_.sample_width) return false;
  5455. return true;
  5456. }
  5457. std::vector<std::pair<const char*, std::string>> ROIAlign_props_impl(const OpDef& def_) {
  5458. auto&& op_ = def_.cast_final_safe<ROIAlign>();
  5459. static_cast<void>(op_);
  5460. std::vector<std::pair<const char*, std::string>> props_;
  5461. switch (op_.mode){
  5462. case ROIAlign::Mode::MAX:
  5463. props_.emplace_back("mode", "MAX");
  5464. break;
  5465. case ROIAlign::Mode::AVERAGE:
  5466. props_.emplace_back("mode", "AVERAGE");
  5467. break;
  5468. default:
  5469. props_.emplace_back("mode", "INVALID");
  5470. break;
  5471. }
  5472. switch (op_.format){
  5473. case ROIAlign::Format::NCHW:
  5474. props_.emplace_back("format", "NCHW");
  5475. break;
  5476. case ROIAlign::Format::NHWC:
  5477. props_.emplace_back("format", "NHWC");
  5478. break;
  5479. case ROIAlign::Format::NHWCD4:
  5480. props_.emplace_back("format", "NHWCD4");
  5481. break;
  5482. case ROIAlign::Format::NCHW4:
  5483. props_.emplace_back("format", "NCHW4");
  5484. break;
  5485. case ROIAlign::Format::NCHW8:
  5486. props_.emplace_back("format", "NCHW8");
  5487. break;
  5488. case ROIAlign::Format::NCHW32:
  5489. props_.emplace_back("format", "NCHW32");
  5490. break;
  5491. case ROIAlign::Format::NCHW88:
  5492. props_.emplace_back("format", "NCHW88");
  5493. break;
  5494. case ROIAlign::Format::NCHW44:
  5495. props_.emplace_back("format", "NCHW44");
  5496. break;
  5497. case ROIAlign::Format::NCHW44_DOT:
  5498. props_.emplace_back("format", "NCHW44_DOT");
  5499. break;
  5500. case ROIAlign::Format::NCHW4_NCHW32:
  5501. props_.emplace_back("format", "NCHW4_NCHW32");
  5502. break;
  5503. case ROIAlign::Format::NCHW32_NCHW4:
  5504. props_.emplace_back("format", "NCHW32_NCHW4");
  5505. break;
  5506. case ROIAlign::Format::NCHW4_NCHW:
  5507. props_.emplace_back("format", "NCHW4_NCHW");
  5508. break;
  5509. case ROIAlign::Format::NHWC_NCHW:
  5510. props_.emplace_back("format", "NHWC_NCHW");
  5511. break;
  5512. case ROIAlign::Format::NHWC_NCHW4_IC_SMALL:
  5513. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  5514. break;
  5515. case ROIAlign::Format::NCHW_NCHW4_IC_SMALL:
  5516. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  5517. break;
  5518. case ROIAlign::Format::CHWN4:
  5519. props_.emplace_back("format", "CHWN4");
  5520. break;
  5521. case ROIAlign::Format::NCHW64:
  5522. props_.emplace_back("format", "NCHW64");
  5523. break;
  5524. case ROIAlign::Format::NCHW4_NHWC:
  5525. props_.emplace_back("format", "NCHW4_NHWC");
  5526. break;
  5527. default:
  5528. props_.emplace_back("format", "INVALID");
  5529. break;
  5530. }
  5531. props_.emplace_back("spatial_scale", std::to_string(op_.spatial_scale));
  5532. props_.emplace_back("offset", std::to_string(op_.offset));
  5533. props_.emplace_back("pooled_height", std::to_string(op_.pooled_height));
  5534. props_.emplace_back("pooled_width", std::to_string(op_.pooled_width));
  5535. props_.emplace_back("sample_height", std::to_string(op_.sample_height));
  5536. props_.emplace_back("sample_width", std::to_string(op_.sample_width));
  5537. return props_;
  5538. }
  5539. std::string ROIAlign_make_name_impl(const OpDef& def_) {
  5540. auto&& op_ = def_.cast_final_safe<ROIAlign>();
  5541. static_cast<void>(op_);
  5542. return "ROIAlign";
  5543. }
  5544. } // anonymous namespace
  5545. OP_TRAIT_REG(ROIAlign, ROIAlign)
  5546. .hash(ROIAlign_hash_impl)
  5547. .is_same_st(ROIAlign_is_same_st_impl)
  5548. .props(ROIAlign_props_impl)
  5549. .make_name(ROIAlign_make_name_impl);
  5550. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ROIPooling);
  5551. namespace {
  5552. size_t ROIPooling_hash_impl(const OpDef& def_) {
  5553. auto&& op_ = def_.cast_final_safe<ROIPooling>();
  5554. static_cast<void>(op_);
  5555. size_t val = mgb::hash(op_.dyn_typeinfo());
  5556. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  5557. val = mgb::hash_pair_combine(val, mgb::hash(op_.scale));
  5558. return val;
  5559. }
  5560. bool ROIPooling_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5561. auto &&a_ = lhs_.cast_final_safe<ROIPooling>(),
  5562. &&b_ = rhs_.cast_final_safe<ROIPooling>();
  5563. static_cast<void>(a_);
  5564. static_cast<void>(b_);
  5565. if (a_.mode != b_.mode) return false;
  5566. if (a_.scale != b_.scale) return false;
  5567. return true;
  5568. }
  5569. std::vector<std::pair<const char*, std::string>> ROIPooling_props_impl(const OpDef& def_) {
  5570. auto&& op_ = def_.cast_final_safe<ROIPooling>();
  5571. static_cast<void>(op_);
  5572. std::vector<std::pair<const char*, std::string>> props_;
  5573. switch (op_.mode){
  5574. case ROIPooling::Mode::MAX:
  5575. props_.emplace_back("mode", "MAX");
  5576. break;
  5577. case ROIPooling::Mode::AVERAGE:
  5578. props_.emplace_back("mode", "AVERAGE");
  5579. break;
  5580. default:
  5581. props_.emplace_back("mode", "INVALID");
  5582. break;
  5583. }
  5584. props_.emplace_back("scale", std::to_string(op_.scale));
  5585. return props_;
  5586. }
  5587. std::string ROIPooling_make_name_impl(const OpDef& def_) {
  5588. auto&& op_ = def_.cast_final_safe<ROIPooling>();
  5589. static_cast<void>(op_);
  5590. return "ROIPooling";
  5591. }
  5592. } // anonymous namespace
  5593. OP_TRAIT_REG(ROIPooling, ROIPooling)
  5594. .hash(ROIPooling_hash_impl)
  5595. .is_same_st(ROIPooling_is_same_st_impl)
  5596. .props(ROIPooling_props_impl)
  5597. .make_name(ROIPooling_make_name_impl);
  5598. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Reduce);
  5599. namespace {
  5600. size_t Reduce_hash_impl(const OpDef& def_) {
  5601. auto&& op_ = def_.cast_final_safe<Reduce>();
  5602. static_cast<void>(op_);
  5603. size_t val = mgb::hash(op_.dyn_typeinfo());
  5604. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  5605. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  5606. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.data_type));
  5607. val = mgb::hash_pair_combine(val, mgb::hash(op_.keepdim));
  5608. return val;
  5609. }
  5610. bool Reduce_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5611. auto &&a_ = lhs_.cast_final_safe<Reduce>(),
  5612. &&b_ = rhs_.cast_final_safe<Reduce>();
  5613. static_cast<void>(a_);
  5614. static_cast<void>(b_);
  5615. if (a_.mode != b_.mode) return false;
  5616. if (a_.axis != b_.axis) return false;
  5617. if (a_.data_type != b_.data_type) return false;
  5618. if (a_.keepdim != b_.keepdim) return false;
  5619. return true;
  5620. }
  5621. std::vector<std::pair<const char*, std::string>> Reduce_props_impl(const OpDef& def_) {
  5622. auto&& op_ = def_.cast_final_safe<Reduce>();
  5623. static_cast<void>(op_);
  5624. std::vector<std::pair<const char*, std::string>> props_;
  5625. switch (op_.mode){
  5626. case Reduce::Mode::SUM:
  5627. props_.emplace_back("mode", "SUM");
  5628. break;
  5629. case Reduce::Mode::SUM_SQR:
  5630. props_.emplace_back("mode", "SUM_SQR");
  5631. break;
  5632. case Reduce::Mode::PRODUCT:
  5633. props_.emplace_back("mode", "PRODUCT");
  5634. break;
  5635. case Reduce::Mode::MIN:
  5636. props_.emplace_back("mode", "MIN");
  5637. break;
  5638. case Reduce::Mode::MAX:
  5639. props_.emplace_back("mode", "MAX");
  5640. break;
  5641. case Reduce::Mode::MEAN:
  5642. props_.emplace_back("mode", "MEAN");
  5643. break;
  5644. default:
  5645. props_.emplace_back("mode", "INVALID");
  5646. break;
  5647. }
  5648. props_.emplace_back("axis", std::to_string(op_.axis));
  5649. switch (op_.data_type){
  5650. case Reduce::DataType::DEFAULT:
  5651. props_.emplace_back("data_type", "DEFAULT");
  5652. break;
  5653. case Reduce::DataType::FLOAT_IO16xC32:
  5654. props_.emplace_back("data_type", "FLOAT_IO16xC32");
  5655. break;
  5656. case Reduce::DataType::FLOAT_O32xC32:
  5657. props_.emplace_back("data_type", "FLOAT_O32xC32");
  5658. break;
  5659. case Reduce::DataType::FLOAT_O16xC32:
  5660. props_.emplace_back("data_type", "FLOAT_O16xC32");
  5661. break;
  5662. case Reduce::DataType::QUINT_I8xO32:
  5663. props_.emplace_back("data_type", "QUINT_I8xO32");
  5664. break;
  5665. case Reduce::DataType::QINT_I8xO32:
  5666. props_.emplace_back("data_type", "QINT_I8xO32");
  5667. break;
  5668. default:
  5669. props_.emplace_back("data_type", "INVALID");
  5670. break;
  5671. }
  5672. props_.emplace_back("keepdim", std::to_string(op_.keepdim));
  5673. return props_;
  5674. }
  5675. std::string Reduce_make_name_impl(const OpDef& def_) {
  5676. auto&& op_ = def_.cast_final_safe<Reduce>();
  5677. static_cast<void>(op_);
  5678. return "Reduce";
  5679. }
  5680. } // anonymous namespace
  5681. OP_TRAIT_REG(Reduce, Reduce)
  5682. .hash(Reduce_hash_impl)
  5683. .is_same_st(Reduce_is_same_st_impl)
  5684. .props(Reduce_props_impl)
  5685. .make_name(Reduce_make_name_impl);
  5686. MGB_DYN_TYPE_OBJ_FINAL_IMPL(RegionRestrictedConvolution);
  5687. namespace {
  5688. size_t RegionRestrictedConvolution_hash_impl(const OpDef& def_) {
  5689. auto&& op_ = def_.cast_final_safe<RegionRestrictedConvolution>();
  5690. static_cast<void>(op_);
  5691. size_t val = mgb::hash(op_.dyn_typeinfo());
  5692. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  5693. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  5694. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  5695. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  5696. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  5697. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
  5698. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
  5699. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
  5700. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  5701. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
  5702. return val;
  5703. }
  5704. bool RegionRestrictedConvolution_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5705. auto &&a_ = lhs_.cast_final_safe<RegionRestrictedConvolution>(),
  5706. &&b_ = rhs_.cast_final_safe<RegionRestrictedConvolution>();
  5707. static_cast<void>(a_);
  5708. static_cast<void>(b_);
  5709. if (a_.mode != b_.mode) return false;
  5710. if (a_.pad_h != b_.pad_h) return false;
  5711. if (a_.pad_w != b_.pad_w) return false;
  5712. if (a_.stride_h != b_.stride_h) return false;
  5713. if (a_.stride_w != b_.stride_w) return false;
  5714. if (a_.dilate_h != b_.dilate_h) return false;
  5715. if (a_.dilate_w != b_.dilate_w) return false;
  5716. if (a_.sparse != b_.sparse) return false;
  5717. if (a_.format != b_.format) return false;
  5718. if (a_.compute_mode != b_.compute_mode) return false;
  5719. return true;
  5720. }
  5721. std::vector<std::pair<const char*, std::string>> RegionRestrictedConvolution_props_impl(const OpDef& def_) {
  5722. auto&& op_ = def_.cast_final_safe<RegionRestrictedConvolution>();
  5723. static_cast<void>(op_);
  5724. std::vector<std::pair<const char*, std::string>> props_;
  5725. switch (op_.mode){
  5726. case RegionRestrictedConvolution::Mode::CROSS_CORRELATION:
  5727. props_.emplace_back("mode", "CROSS_CORRELATION");
  5728. break;
  5729. case RegionRestrictedConvolution::Mode::CONVOLUTION:
  5730. props_.emplace_back("mode", "CONVOLUTION");
  5731. break;
  5732. default:
  5733. props_.emplace_back("mode", "INVALID");
  5734. break;
  5735. }
  5736. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  5737. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  5738. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  5739. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  5740. props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
  5741. props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
  5742. switch (op_.sparse){
  5743. case RegionRestrictedConvolution::Sparse::DENSE:
  5744. props_.emplace_back("sparse", "DENSE");
  5745. break;
  5746. case RegionRestrictedConvolution::Sparse::GROUP:
  5747. props_.emplace_back("sparse", "GROUP");
  5748. break;
  5749. default:
  5750. props_.emplace_back("sparse", "INVALID");
  5751. break;
  5752. }
  5753. switch (op_.format){
  5754. case RegionRestrictedConvolution::Format::NCHW:
  5755. props_.emplace_back("format", "NCHW");
  5756. break;
  5757. case RegionRestrictedConvolution::Format::NHWC:
  5758. props_.emplace_back("format", "NHWC");
  5759. break;
  5760. case RegionRestrictedConvolution::Format::NHWCD4:
  5761. props_.emplace_back("format", "NHWCD4");
  5762. break;
  5763. case RegionRestrictedConvolution::Format::NCHW4:
  5764. props_.emplace_back("format", "NCHW4");
  5765. break;
  5766. case RegionRestrictedConvolution::Format::NCHW8:
  5767. props_.emplace_back("format", "NCHW8");
  5768. break;
  5769. case RegionRestrictedConvolution::Format::NCHW32:
  5770. props_.emplace_back("format", "NCHW32");
  5771. break;
  5772. case RegionRestrictedConvolution::Format::NCHW88:
  5773. props_.emplace_back("format", "NCHW88");
  5774. break;
  5775. case RegionRestrictedConvolution::Format::NCHW44:
  5776. props_.emplace_back("format", "NCHW44");
  5777. break;
  5778. case RegionRestrictedConvolution::Format::NCHW44_DOT:
  5779. props_.emplace_back("format", "NCHW44_DOT");
  5780. break;
  5781. case RegionRestrictedConvolution::Format::NCHW4_NCHW32:
  5782. props_.emplace_back("format", "NCHW4_NCHW32");
  5783. break;
  5784. case RegionRestrictedConvolution::Format::NCHW32_NCHW4:
  5785. props_.emplace_back("format", "NCHW32_NCHW4");
  5786. break;
  5787. case RegionRestrictedConvolution::Format::NCHW4_NCHW:
  5788. props_.emplace_back("format", "NCHW4_NCHW");
  5789. break;
  5790. case RegionRestrictedConvolution::Format::NHWC_NCHW:
  5791. props_.emplace_back("format", "NHWC_NCHW");
  5792. break;
  5793. case RegionRestrictedConvolution::Format::NHWC_NCHW4_IC_SMALL:
  5794. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  5795. break;
  5796. case RegionRestrictedConvolution::Format::NCHW_NCHW4_IC_SMALL:
  5797. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  5798. break;
  5799. case RegionRestrictedConvolution::Format::CHWN4:
  5800. props_.emplace_back("format", "CHWN4");
  5801. break;
  5802. case RegionRestrictedConvolution::Format::NCHW64:
  5803. props_.emplace_back("format", "NCHW64");
  5804. break;
  5805. case RegionRestrictedConvolution::Format::NCHW4_NHWC:
  5806. props_.emplace_back("format", "NCHW4_NHWC");
  5807. break;
  5808. default:
  5809. props_.emplace_back("format", "INVALID");
  5810. break;
  5811. }
  5812. switch (op_.compute_mode){
  5813. case RegionRestrictedConvolution::ComputeMode::DEFAULT:
  5814. props_.emplace_back("compute_mode", "DEFAULT");
  5815. break;
  5816. case RegionRestrictedConvolution::ComputeMode::FLOAT32:
  5817. props_.emplace_back("compute_mode", "FLOAT32");
  5818. break;
  5819. default:
  5820. props_.emplace_back("compute_mode", "INVALID");
  5821. break;
  5822. }
  5823. return props_;
  5824. }
  5825. std::string RegionRestrictedConvolution_make_name_impl(const OpDef& def_) {
  5826. auto&& op_ = def_.cast_final_safe<RegionRestrictedConvolution>();
  5827. static_cast<void>(op_);
  5828. return "RegionRestrictedConvolution";
  5829. }
  5830. } // anonymous namespace
  5831. OP_TRAIT_REG(RegionRestrictedConvolution, RegionRestrictedConvolution)
  5832. .hash(RegionRestrictedConvolution_hash_impl)
  5833. .is_same_st(RegionRestrictedConvolution_is_same_st_impl)
  5834. .props(RegionRestrictedConvolution_props_impl)
  5835. .make_name(RegionRestrictedConvolution_make_name_impl);
  5836. MGB_DYN_TYPE_OBJ_FINAL_IMPL(RegionRestrictedConvolutionBackwardData);
  5837. namespace {
  5838. size_t RegionRestrictedConvolutionBackwardData_hash_impl(const OpDef& def_) {
  5839. auto&& op_ = def_.cast_final_safe<RegionRestrictedConvolutionBackwardData>();
  5840. static_cast<void>(op_);
  5841. size_t val = mgb::hash(op_.dyn_typeinfo());
  5842. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  5843. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  5844. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  5845. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  5846. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  5847. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
  5848. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
  5849. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.sparse));
  5850. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  5851. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.compute_mode));
  5852. return val;
  5853. }
  5854. bool RegionRestrictedConvolutionBackwardData_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5855. auto &&a_ = lhs_.cast_final_safe<RegionRestrictedConvolutionBackwardData>(),
  5856. &&b_ = rhs_.cast_final_safe<RegionRestrictedConvolutionBackwardData>();
  5857. static_cast<void>(a_);
  5858. static_cast<void>(b_);
  5859. if (a_.mode != b_.mode) return false;
  5860. if (a_.pad_h != b_.pad_h) return false;
  5861. if (a_.pad_w != b_.pad_w) return false;
  5862. if (a_.stride_h != b_.stride_h) return false;
  5863. if (a_.stride_w != b_.stride_w) return false;
  5864. if (a_.dilate_h != b_.dilate_h) return false;
  5865. if (a_.dilate_w != b_.dilate_w) return false;
  5866. if (a_.sparse != b_.sparse) return false;
  5867. if (a_.format != b_.format) return false;
  5868. if (a_.compute_mode != b_.compute_mode) return false;
  5869. return true;
  5870. }
  5871. std::vector<std::pair<const char*, std::string>> RegionRestrictedConvolutionBackwardData_props_impl(const OpDef& def_) {
  5872. auto&& op_ = def_.cast_final_safe<RegionRestrictedConvolutionBackwardData>();
  5873. static_cast<void>(op_);
  5874. std::vector<std::pair<const char*, std::string>> props_;
  5875. switch (op_.mode){
  5876. case RegionRestrictedConvolutionBackwardData::Mode::CROSS_CORRELATION:
  5877. props_.emplace_back("mode", "CROSS_CORRELATION");
  5878. break;
  5879. case RegionRestrictedConvolutionBackwardData::Mode::CONVOLUTION:
  5880. props_.emplace_back("mode", "CONVOLUTION");
  5881. break;
  5882. default:
  5883. props_.emplace_back("mode", "INVALID");
  5884. break;
  5885. }
  5886. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  5887. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  5888. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  5889. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  5890. props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
  5891. props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
  5892. switch (op_.sparse){
  5893. case RegionRestrictedConvolutionBackwardData::Sparse::DENSE:
  5894. props_.emplace_back("sparse", "DENSE");
  5895. break;
  5896. case RegionRestrictedConvolutionBackwardData::Sparse::GROUP:
  5897. props_.emplace_back("sparse", "GROUP");
  5898. break;
  5899. default:
  5900. props_.emplace_back("sparse", "INVALID");
  5901. break;
  5902. }
  5903. switch (op_.format){
  5904. case RegionRestrictedConvolutionBackwardData::Format::NCHW:
  5905. props_.emplace_back("format", "NCHW");
  5906. break;
  5907. case RegionRestrictedConvolutionBackwardData::Format::NHWC:
  5908. props_.emplace_back("format", "NHWC");
  5909. break;
  5910. case RegionRestrictedConvolutionBackwardData::Format::NHWCD4:
  5911. props_.emplace_back("format", "NHWCD4");
  5912. break;
  5913. case RegionRestrictedConvolutionBackwardData::Format::NCHW4:
  5914. props_.emplace_back("format", "NCHW4");
  5915. break;
  5916. case RegionRestrictedConvolutionBackwardData::Format::NCHW8:
  5917. props_.emplace_back("format", "NCHW8");
  5918. break;
  5919. case RegionRestrictedConvolutionBackwardData::Format::NCHW32:
  5920. props_.emplace_back("format", "NCHW32");
  5921. break;
  5922. case RegionRestrictedConvolutionBackwardData::Format::NCHW88:
  5923. props_.emplace_back("format", "NCHW88");
  5924. break;
  5925. case RegionRestrictedConvolutionBackwardData::Format::NCHW44:
  5926. props_.emplace_back("format", "NCHW44");
  5927. break;
  5928. case RegionRestrictedConvolutionBackwardData::Format::NCHW44_DOT:
  5929. props_.emplace_back("format", "NCHW44_DOT");
  5930. break;
  5931. case RegionRestrictedConvolutionBackwardData::Format::NCHW4_NCHW32:
  5932. props_.emplace_back("format", "NCHW4_NCHW32");
  5933. break;
  5934. case RegionRestrictedConvolutionBackwardData::Format::NCHW32_NCHW4:
  5935. props_.emplace_back("format", "NCHW32_NCHW4");
  5936. break;
  5937. case RegionRestrictedConvolutionBackwardData::Format::NCHW4_NCHW:
  5938. props_.emplace_back("format", "NCHW4_NCHW");
  5939. break;
  5940. case RegionRestrictedConvolutionBackwardData::Format::NHWC_NCHW:
  5941. props_.emplace_back("format", "NHWC_NCHW");
  5942. break;
  5943. case RegionRestrictedConvolutionBackwardData::Format::NHWC_NCHW4_IC_SMALL:
  5944. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  5945. break;
  5946. case RegionRestrictedConvolutionBackwardData::Format::NCHW_NCHW4_IC_SMALL:
  5947. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  5948. break;
  5949. case RegionRestrictedConvolutionBackwardData::Format::CHWN4:
  5950. props_.emplace_back("format", "CHWN4");
  5951. break;
  5952. case RegionRestrictedConvolutionBackwardData::Format::NCHW64:
  5953. props_.emplace_back("format", "NCHW64");
  5954. break;
  5955. case RegionRestrictedConvolutionBackwardData::Format::NCHW4_NHWC:
  5956. props_.emplace_back("format", "NCHW4_NHWC");
  5957. break;
  5958. default:
  5959. props_.emplace_back("format", "INVALID");
  5960. break;
  5961. }
  5962. switch (op_.compute_mode){
  5963. case RegionRestrictedConvolutionBackwardData::ComputeMode::DEFAULT:
  5964. props_.emplace_back("compute_mode", "DEFAULT");
  5965. break;
  5966. case RegionRestrictedConvolutionBackwardData::ComputeMode::FLOAT32:
  5967. props_.emplace_back("compute_mode", "FLOAT32");
  5968. break;
  5969. default:
  5970. props_.emplace_back("compute_mode", "INVALID");
  5971. break;
  5972. }
  5973. return props_;
  5974. }
  5975. std::string RegionRestrictedConvolutionBackwardData_make_name_impl(const OpDef& def_) {
  5976. auto&& op_ = def_.cast_final_safe<RegionRestrictedConvolutionBackwardData>();
  5977. static_cast<void>(op_);
  5978. return "RegionRestrictedConvolutionBackwardData";
  5979. }
  5980. } // anonymous namespace
  5981. OP_TRAIT_REG(RegionRestrictedConvolutionBackwardData, RegionRestrictedConvolutionBackwardData)
  5982. .hash(RegionRestrictedConvolutionBackwardData_hash_impl)
  5983. .is_same_st(RegionRestrictedConvolutionBackwardData_is_same_st_impl)
  5984. .props(RegionRestrictedConvolutionBackwardData_props_impl)
  5985. .make_name(RegionRestrictedConvolutionBackwardData_make_name_impl);
  5986. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Remap);
  5987. namespace {
  5988. size_t Remap_hash_impl(const OpDef& def_) {
  5989. auto&& op_ = def_.cast_final_safe<Remap>();
  5990. static_cast<void>(op_);
  5991. size_t val = mgb::hash(op_.dyn_typeinfo());
  5992. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
  5993. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.border_type));
  5994. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  5995. val = mgb::hash_pair_combine(val, mgb::hash(op_.scalar));
  5996. return val;
  5997. }
  5998. bool Remap_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  5999. auto &&a_ = lhs_.cast_final_safe<Remap>(),
  6000. &&b_ = rhs_.cast_final_safe<Remap>();
  6001. static_cast<void>(a_);
  6002. static_cast<void>(b_);
  6003. if (a_.imode != b_.imode) return false;
  6004. if (a_.border_type != b_.border_type) return false;
  6005. if (a_.format != b_.format) return false;
  6006. if (a_.scalar != b_.scalar) return false;
  6007. return true;
  6008. }
  6009. std::vector<std::pair<const char*, std::string>> Remap_props_impl(const OpDef& def_) {
  6010. auto&& op_ = def_.cast_final_safe<Remap>();
  6011. static_cast<void>(op_);
  6012. std::vector<std::pair<const char*, std::string>> props_;
  6013. switch (op_.imode){
  6014. case Remap::InterpolationMode::NEAREST:
  6015. props_.emplace_back("imode", "NEAREST");
  6016. break;
  6017. case Remap::InterpolationMode::LINEAR:
  6018. props_.emplace_back("imode", "LINEAR");
  6019. break;
  6020. case Remap::InterpolationMode::AREA:
  6021. props_.emplace_back("imode", "AREA");
  6022. break;
  6023. case Remap::InterpolationMode::CUBIC:
  6024. props_.emplace_back("imode", "CUBIC");
  6025. break;
  6026. case Remap::InterpolationMode::LANCZOS4:
  6027. props_.emplace_back("imode", "LANCZOS4");
  6028. break;
  6029. default:
  6030. props_.emplace_back("imode", "INVALID");
  6031. break;
  6032. }
  6033. switch (op_.border_type){
  6034. case Remap::BorderMode::REPLICATE:
  6035. props_.emplace_back("border_type", "REPLICATE");
  6036. break;
  6037. case Remap::BorderMode::REFLECT:
  6038. props_.emplace_back("border_type", "REFLECT");
  6039. break;
  6040. case Remap::BorderMode::REFLECT_101:
  6041. props_.emplace_back("border_type", "REFLECT_101");
  6042. break;
  6043. case Remap::BorderMode::WRAP:
  6044. props_.emplace_back("border_type", "WRAP");
  6045. break;
  6046. case Remap::BorderMode::CONSTANT:
  6047. props_.emplace_back("border_type", "CONSTANT");
  6048. break;
  6049. case Remap::BorderMode::TRANSPARENT:
  6050. props_.emplace_back("border_type", "TRANSPARENT");
  6051. break;
  6052. case Remap::BorderMode::ISOLATED:
  6053. props_.emplace_back("border_type", "ISOLATED");
  6054. break;
  6055. default:
  6056. props_.emplace_back("border_type", "INVALID");
  6057. break;
  6058. }
  6059. switch (op_.format){
  6060. case Remap::Format::NCHW:
  6061. props_.emplace_back("format", "NCHW");
  6062. break;
  6063. case Remap::Format::NHWC:
  6064. props_.emplace_back("format", "NHWC");
  6065. break;
  6066. case Remap::Format::NHWCD4:
  6067. props_.emplace_back("format", "NHWCD4");
  6068. break;
  6069. case Remap::Format::NCHW4:
  6070. props_.emplace_back("format", "NCHW4");
  6071. break;
  6072. case Remap::Format::NCHW8:
  6073. props_.emplace_back("format", "NCHW8");
  6074. break;
  6075. case Remap::Format::NCHW32:
  6076. props_.emplace_back("format", "NCHW32");
  6077. break;
  6078. case Remap::Format::NCHW88:
  6079. props_.emplace_back("format", "NCHW88");
  6080. break;
  6081. case Remap::Format::NCHW44:
  6082. props_.emplace_back("format", "NCHW44");
  6083. break;
  6084. case Remap::Format::NCHW44_DOT:
  6085. props_.emplace_back("format", "NCHW44_DOT");
  6086. break;
  6087. case Remap::Format::NCHW4_NCHW32:
  6088. props_.emplace_back("format", "NCHW4_NCHW32");
  6089. break;
  6090. case Remap::Format::NCHW32_NCHW4:
  6091. props_.emplace_back("format", "NCHW32_NCHW4");
  6092. break;
  6093. case Remap::Format::NCHW4_NCHW:
  6094. props_.emplace_back("format", "NCHW4_NCHW");
  6095. break;
  6096. case Remap::Format::NHWC_NCHW:
  6097. props_.emplace_back("format", "NHWC_NCHW");
  6098. break;
  6099. case Remap::Format::NHWC_NCHW4_IC_SMALL:
  6100. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  6101. break;
  6102. case Remap::Format::NCHW_NCHW4_IC_SMALL:
  6103. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  6104. break;
  6105. case Remap::Format::CHWN4:
  6106. props_.emplace_back("format", "CHWN4");
  6107. break;
  6108. case Remap::Format::NCHW64:
  6109. props_.emplace_back("format", "NCHW64");
  6110. break;
  6111. case Remap::Format::NCHW4_NHWC:
  6112. props_.emplace_back("format", "NCHW4_NHWC");
  6113. break;
  6114. default:
  6115. props_.emplace_back("format", "INVALID");
  6116. break;
  6117. }
  6118. props_.emplace_back("scalar", std::to_string(op_.scalar));
  6119. return props_;
  6120. }
  6121. std::string Remap_make_name_impl(const OpDef& def_) {
  6122. auto&& op_ = def_.cast_final_safe<Remap>();
  6123. static_cast<void>(op_);
  6124. return "Remap";
  6125. }
  6126. } // anonymous namespace
  6127. OP_TRAIT_REG(Remap, Remap)
  6128. .hash(Remap_hash_impl)
  6129. .is_same_st(Remap_is_same_st_impl)
  6130. .props(Remap_props_impl)
  6131. .make_name(Remap_make_name_impl);
  6132. MGB_DYN_TYPE_OBJ_FINAL_IMPL(RemoteRecv);
  6133. namespace {
  6134. size_t RemoteRecv_hash_impl(const OpDef& def_) {
  6135. auto&& op_ = def_.cast_final_safe<RemoteRecv>();
  6136. static_cast<void>(op_);
  6137. size_t val = mgb::hash(op_.dyn_typeinfo());
  6138. val = mgb::hash_pair_combine(val, mgb::hash(op_.key));
  6139. val = mgb::hash_pair_combine(val, mgb::hash(op_.addr));
  6140. val = mgb::hash_pair_combine(val, mgb::hash(op_.port));
  6141. val = mgb::hash_pair_combine(val, mgb::hash(op_.rank_from));
  6142. val = mgb::hash_pair_combine(val, mgb::hash(op_.cn));
  6143. val = mgb::hash_pair_combine(val, mgb::hash(op_.shape));
  6144. val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
  6145. val = mgb::hash_pair_combine(val, mgb::hash(op_.backend));
  6146. return val;
  6147. }
  6148. bool RemoteRecv_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6149. auto &&a_ = lhs_.cast_final_safe<RemoteRecv>(),
  6150. &&b_ = rhs_.cast_final_safe<RemoteRecv>();
  6151. static_cast<void>(a_);
  6152. static_cast<void>(b_);
  6153. if (a_.key != b_.key) return false;
  6154. if (a_.addr != b_.addr) return false;
  6155. if (a_.port != b_.port) return false;
  6156. if (a_.rank_from != b_.rank_from) return false;
  6157. if (a_.cn != b_.cn) return false;
  6158. if (a_.shape != b_.shape) return false;
  6159. if (a_.dtype != b_.dtype) return false;
  6160. if (a_.backend != b_.backend) return false;
  6161. return true;
  6162. }
  6163. std::vector<std::pair<const char*, std::string>> RemoteRecv_props_impl(const OpDef& def_) {
  6164. auto&& op_ = def_.cast_final_safe<RemoteRecv>();
  6165. static_cast<void>(op_);
  6166. std::vector<std::pair<const char*, std::string>> props_;
  6167. props_.emplace_back("key", op_.key);
  6168. props_.emplace_back("addr", op_.addr);
  6169. props_.emplace_back("port", std::to_string(op_.port));
  6170. props_.emplace_back("rank_from", std::to_string(op_.rank_from));
  6171. props_.emplace_back("cn", op_.cn.to_string());
  6172. props_.emplace_back("shape", "{std::vector}");
  6173. props_.emplace_back("dtype", op_.dtype.name());
  6174. props_.emplace_back("backend", op_.backend);
  6175. return props_;
  6176. }
  6177. std::string RemoteRecv_make_name_impl(const OpDef& def_) {
  6178. auto&& op_ = def_.cast_final_safe<RemoteRecv>();
  6179. static_cast<void>(op_);
  6180. return "RemoteRecv";
  6181. }
  6182. } // anonymous namespace
  6183. OP_TRAIT_REG(RemoteRecv, RemoteRecv)
  6184. .hash(RemoteRecv_hash_impl)
  6185. .is_same_st(RemoteRecv_is_same_st_impl)
  6186. .props(RemoteRecv_props_impl)
  6187. .make_name(RemoteRecv_make_name_impl);
  6188. MGB_DYN_TYPE_OBJ_FINAL_IMPL(RemoteSend);
  6189. namespace {
  6190. size_t RemoteSend_hash_impl(const OpDef& def_) {
  6191. auto&& op_ = def_.cast_final_safe<RemoteSend>();
  6192. static_cast<void>(op_);
  6193. size_t val = mgb::hash(op_.dyn_typeinfo());
  6194. val = mgb::hash_pair_combine(val, mgb::hash(op_.key));
  6195. val = mgb::hash_pair_combine(val, mgb::hash(op_.addr));
  6196. val = mgb::hash_pair_combine(val, mgb::hash(op_.port));
  6197. val = mgb::hash_pair_combine(val, mgb::hash(op_.rank_to));
  6198. val = mgb::hash_pair_combine(val, mgb::hash(op_.backend));
  6199. return val;
  6200. }
  6201. bool RemoteSend_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6202. auto &&a_ = lhs_.cast_final_safe<RemoteSend>(),
  6203. &&b_ = rhs_.cast_final_safe<RemoteSend>();
  6204. static_cast<void>(a_);
  6205. static_cast<void>(b_);
  6206. if (a_.key != b_.key) return false;
  6207. if (a_.addr != b_.addr) return false;
  6208. if (a_.port != b_.port) return false;
  6209. if (a_.rank_to != b_.rank_to) return false;
  6210. if (a_.backend != b_.backend) return false;
  6211. return true;
  6212. }
  6213. std::vector<std::pair<const char*, std::string>> RemoteSend_props_impl(const OpDef& def_) {
  6214. auto&& op_ = def_.cast_final_safe<RemoteSend>();
  6215. static_cast<void>(op_);
  6216. std::vector<std::pair<const char*, std::string>> props_;
  6217. props_.emplace_back("key", op_.key);
  6218. props_.emplace_back("addr", op_.addr);
  6219. props_.emplace_back("port", std::to_string(op_.port));
  6220. props_.emplace_back("rank_to", std::to_string(op_.rank_to));
  6221. props_.emplace_back("backend", op_.backend);
  6222. return props_;
  6223. }
  6224. std::string RemoteSend_make_name_impl(const OpDef& def_) {
  6225. auto&& op_ = def_.cast_final_safe<RemoteSend>();
  6226. static_cast<void>(op_);
  6227. return "RemoteSend";
  6228. }
  6229. } // anonymous namespace
  6230. OP_TRAIT_REG(RemoteSend, RemoteSend)
  6231. .hash(RemoteSend_hash_impl)
  6232. .is_same_st(RemoteSend_is_same_st_impl)
  6233. .props(RemoteSend_props_impl)
  6234. .make_name(RemoteSend_make_name_impl);
  6235. MGB_DYN_TYPE_OBJ_FINAL_IMPL(RemoveAxis);
  6236. namespace {
  6237. size_t RemoveAxis_hash_impl(const OpDef& def_) {
  6238. auto&& op_ = def_.cast_final_safe<RemoveAxis>();
  6239. static_cast<void>(op_);
  6240. size_t val = mgb::hash(op_.dyn_typeinfo());
  6241. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  6242. return val;
  6243. }
  6244. bool RemoveAxis_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6245. auto &&a_ = lhs_.cast_final_safe<RemoveAxis>(),
  6246. &&b_ = rhs_.cast_final_safe<RemoveAxis>();
  6247. static_cast<void>(a_);
  6248. static_cast<void>(b_);
  6249. if (a_.axis != b_.axis) return false;
  6250. return true;
  6251. }
  6252. std::vector<std::pair<const char*, std::string>> RemoveAxis_props_impl(const OpDef& def_) {
  6253. auto&& op_ = def_.cast_final_safe<RemoveAxis>();
  6254. static_cast<void>(op_);
  6255. std::vector<std::pair<const char*, std::string>> props_;
  6256. props_.emplace_back("axis", "{std::vector}");
  6257. return props_;
  6258. }
  6259. std::string RemoveAxis_make_name_impl(const OpDef& def_) {
  6260. auto&& op_ = def_.cast_final_safe<RemoveAxis>();
  6261. static_cast<void>(op_);
  6262. return "RemoveAxis";
  6263. }
  6264. } // anonymous namespace
  6265. OP_TRAIT_REG(RemoveAxis, RemoveAxis)
  6266. .hash(RemoveAxis_hash_impl)
  6267. .is_same_st(RemoveAxis_is_same_st_impl)
  6268. .props(RemoveAxis_props_impl)
  6269. .make_name(RemoveAxis_make_name_impl);
  6270. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Reshape);
  6271. namespace {
  6272. size_t Reshape_hash_impl(const OpDef& def_) {
  6273. auto&& op_ = def_.cast_final_safe<Reshape>();
  6274. static_cast<void>(op_);
  6275. size_t val = mgb::hash(op_.dyn_typeinfo());
  6276. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  6277. val = mgb::hash_pair_combine(val, mgb::hash(op_.shape));
  6278. return val;
  6279. }
  6280. bool Reshape_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6281. auto &&a_ = lhs_.cast_final_safe<Reshape>(),
  6282. &&b_ = rhs_.cast_final_safe<Reshape>();
  6283. static_cast<void>(a_);
  6284. static_cast<void>(b_);
  6285. if (a_.axis != b_.axis) return false;
  6286. if (a_.shape != b_.shape) return false;
  6287. return true;
  6288. }
  6289. std::vector<std::pair<const char*, std::string>> Reshape_props_impl(const OpDef& def_) {
  6290. auto&& op_ = def_.cast_final_safe<Reshape>();
  6291. static_cast<void>(op_);
  6292. std::vector<std::pair<const char*, std::string>> props_;
  6293. props_.emplace_back("axis", std::to_string(op_.axis));
  6294. props_.emplace_back("shape", "{std::vector}");
  6295. return props_;
  6296. }
  6297. std::string Reshape_make_name_impl(const OpDef& def_) {
  6298. auto&& op_ = def_.cast_final_safe<Reshape>();
  6299. static_cast<void>(op_);
  6300. return "Reshape";
  6301. }
  6302. } // anonymous namespace
  6303. OP_TRAIT_REG(Reshape, Reshape)
  6304. .hash(Reshape_hash_impl)
  6305. .is_same_st(Reshape_is_same_st_impl)
  6306. .props(Reshape_props_impl)
  6307. .make_name(Reshape_make_name_impl);
  6308. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Resize);
  6309. namespace {
  6310. size_t Resize_hash_impl(const OpDef& def_) {
  6311. auto&& op_ = def_.cast_final_safe<Resize>();
  6312. static_cast<void>(op_);
  6313. size_t val = mgb::hash(op_.dyn_typeinfo());
  6314. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
  6315. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  6316. return val;
  6317. }
  6318. bool Resize_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6319. auto &&a_ = lhs_.cast_final_safe<Resize>(),
  6320. &&b_ = rhs_.cast_final_safe<Resize>();
  6321. static_cast<void>(a_);
  6322. static_cast<void>(b_);
  6323. if (a_.imode != b_.imode) return false;
  6324. if (a_.format != b_.format) return false;
  6325. return true;
  6326. }
  6327. std::vector<std::pair<const char*, std::string>> Resize_props_impl(const OpDef& def_) {
  6328. auto&& op_ = def_.cast_final_safe<Resize>();
  6329. static_cast<void>(op_);
  6330. std::vector<std::pair<const char*, std::string>> props_;
  6331. switch (op_.imode){
  6332. case Resize::InterpolationMode::NEAREST:
  6333. props_.emplace_back("imode", "NEAREST");
  6334. break;
  6335. case Resize::InterpolationMode::LINEAR:
  6336. props_.emplace_back("imode", "LINEAR");
  6337. break;
  6338. case Resize::InterpolationMode::AREA:
  6339. props_.emplace_back("imode", "AREA");
  6340. break;
  6341. case Resize::InterpolationMode::CUBIC:
  6342. props_.emplace_back("imode", "CUBIC");
  6343. break;
  6344. case Resize::InterpolationMode::LANCZOS4:
  6345. props_.emplace_back("imode", "LANCZOS4");
  6346. break;
  6347. default:
  6348. props_.emplace_back("imode", "INVALID");
  6349. break;
  6350. }
  6351. switch (op_.format){
  6352. case Resize::Format::NCHW:
  6353. props_.emplace_back("format", "NCHW");
  6354. break;
  6355. case Resize::Format::NHWC:
  6356. props_.emplace_back("format", "NHWC");
  6357. break;
  6358. case Resize::Format::NHWCD4:
  6359. props_.emplace_back("format", "NHWCD4");
  6360. break;
  6361. case Resize::Format::NCHW4:
  6362. props_.emplace_back("format", "NCHW4");
  6363. break;
  6364. case Resize::Format::NCHW8:
  6365. props_.emplace_back("format", "NCHW8");
  6366. break;
  6367. case Resize::Format::NCHW32:
  6368. props_.emplace_back("format", "NCHW32");
  6369. break;
  6370. case Resize::Format::NCHW88:
  6371. props_.emplace_back("format", "NCHW88");
  6372. break;
  6373. case Resize::Format::NCHW44:
  6374. props_.emplace_back("format", "NCHW44");
  6375. break;
  6376. case Resize::Format::NCHW44_DOT:
  6377. props_.emplace_back("format", "NCHW44_DOT");
  6378. break;
  6379. case Resize::Format::NCHW4_NCHW32:
  6380. props_.emplace_back("format", "NCHW4_NCHW32");
  6381. break;
  6382. case Resize::Format::NCHW32_NCHW4:
  6383. props_.emplace_back("format", "NCHW32_NCHW4");
  6384. break;
  6385. case Resize::Format::NCHW4_NCHW:
  6386. props_.emplace_back("format", "NCHW4_NCHW");
  6387. break;
  6388. case Resize::Format::NHWC_NCHW:
  6389. props_.emplace_back("format", "NHWC_NCHW");
  6390. break;
  6391. case Resize::Format::NHWC_NCHW4_IC_SMALL:
  6392. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  6393. break;
  6394. case Resize::Format::NCHW_NCHW4_IC_SMALL:
  6395. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  6396. break;
  6397. case Resize::Format::CHWN4:
  6398. props_.emplace_back("format", "CHWN4");
  6399. break;
  6400. case Resize::Format::NCHW64:
  6401. props_.emplace_back("format", "NCHW64");
  6402. break;
  6403. case Resize::Format::NCHW4_NHWC:
  6404. props_.emplace_back("format", "NCHW4_NHWC");
  6405. break;
  6406. default:
  6407. props_.emplace_back("format", "INVALID");
  6408. break;
  6409. }
  6410. return props_;
  6411. }
  6412. std::string Resize_make_name_impl(const OpDef& def_) {
  6413. auto&& op_ = def_.cast_final_safe<Resize>();
  6414. static_cast<void>(op_);
  6415. return "Resize";
  6416. }
  6417. } // anonymous namespace
  6418. OP_TRAIT_REG(Resize, Resize)
  6419. .hash(Resize_hash_impl)
  6420. .is_same_st(Resize_is_same_st_impl)
  6421. .props(Resize_props_impl)
  6422. .make_name(Resize_make_name_impl);
  6423. MGB_DYN_TYPE_OBJ_FINAL_IMPL(SVD);
  6424. namespace {
  6425. size_t SVD_hash_impl(const OpDef& def_) {
  6426. auto&& op_ = def_.cast_final_safe<SVD>();
  6427. static_cast<void>(op_);
  6428. size_t val = mgb::hash(op_.dyn_typeinfo());
  6429. val = mgb::hash_pair_combine(val, mgb::hash(op_.full_matrices));
  6430. val = mgb::hash_pair_combine(val, mgb::hash(op_.compute_uv));
  6431. return val;
  6432. }
  6433. bool SVD_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6434. auto &&a_ = lhs_.cast_final_safe<SVD>(),
  6435. &&b_ = rhs_.cast_final_safe<SVD>();
  6436. static_cast<void>(a_);
  6437. static_cast<void>(b_);
  6438. if (a_.full_matrices != b_.full_matrices) return false;
  6439. if (a_.compute_uv != b_.compute_uv) return false;
  6440. return true;
  6441. }
  6442. std::vector<std::pair<const char*, std::string>> SVD_props_impl(const OpDef& def_) {
  6443. auto&& op_ = def_.cast_final_safe<SVD>();
  6444. static_cast<void>(op_);
  6445. std::vector<std::pair<const char*, std::string>> props_;
  6446. props_.emplace_back("full_matrices", std::to_string(op_.full_matrices));
  6447. props_.emplace_back("compute_uv", std::to_string(op_.compute_uv));
  6448. return props_;
  6449. }
  6450. std::string SVD_make_name_impl(const OpDef& def_) {
  6451. auto&& op_ = def_.cast_final_safe<SVD>();
  6452. static_cast<void>(op_);
  6453. return "SVD";
  6454. }
  6455. } // anonymous namespace
  6456. OP_TRAIT_REG(SVD, SVD)
  6457. .hash(SVD_hash_impl)
  6458. .is_same_st(SVD_is_same_st_impl)
  6459. .props(SVD_props_impl)
  6460. .make_name(SVD_make_name_impl);
  6461. MGB_DYN_TYPE_OBJ_FINAL_IMPL(SetMeshIndexing);
  6462. namespace {
  6463. size_t SetMeshIndexing_hash_impl(const OpDef& def_) {
  6464. auto&& op_ = def_.cast_final_safe<SetMeshIndexing>();
  6465. static_cast<void>(op_);
  6466. size_t val = mgb::hash(op_.dyn_typeinfo());
  6467. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  6468. return val;
  6469. }
  6470. bool SetMeshIndexing_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6471. auto &&a_ = lhs_.cast_final_safe<SetMeshIndexing>(),
  6472. &&b_ = rhs_.cast_final_safe<SetMeshIndexing>();
  6473. static_cast<void>(a_);
  6474. static_cast<void>(b_);
  6475. if (a_.items != b_.items) return false;
  6476. return true;
  6477. }
  6478. std::vector<std::pair<const char*, std::string>> SetMeshIndexing_props_impl(const OpDef& def_) {
  6479. auto&& op_ = def_.cast_final_safe<SetMeshIndexing>();
  6480. static_cast<void>(op_);
  6481. std::vector<std::pair<const char*, std::string>> props_;
  6482. props_.emplace_back("items", "{std::vector}");
  6483. return props_;
  6484. }
  6485. std::string SetMeshIndexing_make_name_impl(const OpDef& def_) {
  6486. auto&& op_ = def_.cast_final_safe<SetMeshIndexing>();
  6487. static_cast<void>(op_);
  6488. return "SetMeshIndexing";
  6489. }
  6490. } // anonymous namespace
  6491. OP_TRAIT_REG(SetMeshIndexing, SetMeshIndexing)
  6492. .hash(SetMeshIndexing_hash_impl)
  6493. .is_same_st(SetMeshIndexing_is_same_st_impl)
  6494. .props(SetMeshIndexing_props_impl)
  6495. .make_name(SetMeshIndexing_make_name_impl);
  6496. MGB_DYN_TYPE_OBJ_FINAL_IMPL(SetSubtensor);
  6497. namespace {
  6498. size_t SetSubtensor_hash_impl(const OpDef& def_) {
  6499. auto&& op_ = def_.cast_final_safe<SetSubtensor>();
  6500. static_cast<void>(op_);
  6501. size_t val = mgb::hash(op_.dyn_typeinfo());
  6502. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  6503. return val;
  6504. }
  6505. bool SetSubtensor_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6506. auto &&a_ = lhs_.cast_final_safe<SetSubtensor>(),
  6507. &&b_ = rhs_.cast_final_safe<SetSubtensor>();
  6508. static_cast<void>(a_);
  6509. static_cast<void>(b_);
  6510. if (a_.items != b_.items) return false;
  6511. return true;
  6512. }
  6513. std::vector<std::pair<const char*, std::string>> SetSubtensor_props_impl(const OpDef& def_) {
  6514. auto&& op_ = def_.cast_final_safe<SetSubtensor>();
  6515. static_cast<void>(op_);
  6516. std::vector<std::pair<const char*, std::string>> props_;
  6517. props_.emplace_back("items", "{std::vector}");
  6518. return props_;
  6519. }
  6520. std::string SetSubtensor_make_name_impl(const OpDef& def_) {
  6521. auto&& op_ = def_.cast_final_safe<SetSubtensor>();
  6522. static_cast<void>(op_);
  6523. return "SetSubtensor";
  6524. }
  6525. } // anonymous namespace
  6526. OP_TRAIT_REG(SetSubtensor, SetSubtensor)
  6527. .hash(SetSubtensor_hash_impl)
  6528. .is_same_st(SetSubtensor_is_same_st_impl)
  6529. .props(SetSubtensor_props_impl)
  6530. .make_name(SetSubtensor_make_name_impl);
  6531. MGB_DYN_TYPE_OBJ_FINAL_IMPL(ShuffleRNG);
  6532. namespace {
  6533. size_t ShuffleRNG_hash_impl(const OpDef& def_) {
  6534. auto&& op_ = def_.cast_final_safe<ShuffleRNG>();
  6535. static_cast<void>(op_);
  6536. return mgb::hash_pair_combine(
  6537. mgb::hash(op_.dyn_typeinfo()),
  6538. mgb::hash(op_.handle)
  6539. );
  6540. }
  6541. bool ShuffleRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6542. auto &&a_ = lhs_.cast_final_safe<ShuffleRNG>(),
  6543. &&b_ = rhs_.cast_final_safe<ShuffleRNG>();
  6544. static_cast<void>(a_);
  6545. static_cast<void>(b_);
  6546. return a_.handle == b_.handle;}
  6547. std::vector<std::pair<const char*, std::string>> ShuffleRNG_props_impl(const OpDef& def_) {
  6548. auto&& op_ = def_.cast_final_safe<ShuffleRNG>();
  6549. static_cast<void>(op_);
  6550. std::vector<std::pair<const char*, std::string>> props_;
  6551. props_.emplace_back("seed", std::to_string(op_.seed));
  6552. props_.emplace_back("handle", std::to_string(op_.handle));
  6553. return props_;
  6554. }
  6555. std::string ShuffleRNG_make_name_impl(const OpDef& def_) {
  6556. auto&& op_ = def_.cast_final_safe<ShuffleRNG>();
  6557. static_cast<void>(op_);
  6558. return "ShuffleRNG";
  6559. }
  6560. } // anonymous namespace
  6561. OP_TRAIT_REG(ShuffleRNG, ShuffleRNG)
  6562. .hash(ShuffleRNG_hash_impl)
  6563. .is_same_st(ShuffleRNG_is_same_st_impl)
  6564. .props(ShuffleRNG_props_impl)
  6565. .make_name(ShuffleRNG_make_name_impl);
  6566. MGB_DYN_TYPE_OBJ_FINAL_IMPL(SlidingWindowTranspose);
  6567. namespace {
  6568. size_t SlidingWindowTranspose_hash_impl(const OpDef& def_) {
  6569. auto&& op_ = def_.cast_final_safe<SlidingWindowTranspose>();
  6570. static_cast<void>(op_);
  6571. size_t val = mgb::hash(op_.dyn_typeinfo());
  6572. val = mgb::hash_pair_combine(val, mgb::hash(op_.out_h));
  6573. val = mgb::hash_pair_combine(val, mgb::hash(op_.out_w));
  6574. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_h));
  6575. val = mgb::hash_pair_combine(val, mgb::hash(op_.pad_w));
  6576. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_h));
  6577. val = mgb::hash_pair_combine(val, mgb::hash(op_.stride_w));
  6578. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_h));
  6579. val = mgb::hash_pair_combine(val, mgb::hash(op_.dilate_w));
  6580. val = mgb::hash_pair_combine(val, mgb::hash(op_.window_h));
  6581. val = mgb::hash_pair_combine(val, mgb::hash(op_.window_w));
  6582. return val;
  6583. }
  6584. bool SlidingWindowTranspose_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6585. auto &&a_ = lhs_.cast_final_safe<SlidingWindowTranspose>(),
  6586. &&b_ = rhs_.cast_final_safe<SlidingWindowTranspose>();
  6587. static_cast<void>(a_);
  6588. static_cast<void>(b_);
  6589. if (a_.out_h != b_.out_h) return false;
  6590. if (a_.out_w != b_.out_w) return false;
  6591. if (a_.pad_h != b_.pad_h) return false;
  6592. if (a_.pad_w != b_.pad_w) return false;
  6593. if (a_.stride_h != b_.stride_h) return false;
  6594. if (a_.stride_w != b_.stride_w) return false;
  6595. if (a_.dilate_h != b_.dilate_h) return false;
  6596. if (a_.dilate_w != b_.dilate_w) return false;
  6597. if (a_.window_h != b_.window_h) return false;
  6598. if (a_.window_w != b_.window_w) return false;
  6599. return true;
  6600. }
  6601. std::vector<std::pair<const char*, std::string>> SlidingWindowTranspose_props_impl(const OpDef& def_) {
  6602. auto&& op_ = def_.cast_final_safe<SlidingWindowTranspose>();
  6603. static_cast<void>(op_);
  6604. std::vector<std::pair<const char*, std::string>> props_;
  6605. props_.emplace_back("out_h", std::to_string(op_.out_h));
  6606. props_.emplace_back("out_w", std::to_string(op_.out_w));
  6607. props_.emplace_back("pad_h", std::to_string(op_.pad_h));
  6608. props_.emplace_back("pad_w", std::to_string(op_.pad_w));
  6609. props_.emplace_back("stride_h", std::to_string(op_.stride_h));
  6610. props_.emplace_back("stride_w", std::to_string(op_.stride_w));
  6611. props_.emplace_back("dilate_h", std::to_string(op_.dilate_h));
  6612. props_.emplace_back("dilate_w", std::to_string(op_.dilate_w));
  6613. props_.emplace_back("window_h", std::to_string(op_.window_h));
  6614. props_.emplace_back("window_w", std::to_string(op_.window_w));
  6615. return props_;
  6616. }
  6617. std::string SlidingWindowTranspose_make_name_impl(const OpDef& def_) {
  6618. auto&& op_ = def_.cast_final_safe<SlidingWindowTranspose>();
  6619. static_cast<void>(op_);
  6620. return "SlidingWindowTranspose";
  6621. }
  6622. } // anonymous namespace
  6623. OP_TRAIT_REG(SlidingWindowTranspose, SlidingWindowTranspose)
  6624. .hash(SlidingWindowTranspose_hash_impl)
  6625. .is_same_st(SlidingWindowTranspose_is_same_st_impl)
  6626. .props(SlidingWindowTranspose_props_impl)
  6627. .make_name(SlidingWindowTranspose_make_name_impl);
  6628. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Softmax);
  6629. namespace {
  6630. size_t Softmax_hash_impl(const OpDef& def_) {
  6631. auto&& op_ = def_.cast_final_safe<Softmax>();
  6632. static_cast<void>(op_);
  6633. size_t val = mgb::hash(op_.dyn_typeinfo());
  6634. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  6635. return val;
  6636. }
  6637. bool Softmax_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6638. auto &&a_ = lhs_.cast_final_safe<Softmax>(),
  6639. &&b_ = rhs_.cast_final_safe<Softmax>();
  6640. static_cast<void>(a_);
  6641. static_cast<void>(b_);
  6642. if (a_.axis != b_.axis) return false;
  6643. return true;
  6644. }
  6645. std::vector<std::pair<const char*, std::string>> Softmax_props_impl(const OpDef& def_) {
  6646. auto&& op_ = def_.cast_final_safe<Softmax>();
  6647. static_cast<void>(op_);
  6648. std::vector<std::pair<const char*, std::string>> props_;
  6649. props_.emplace_back("axis", std::to_string(op_.axis));
  6650. return props_;
  6651. }
  6652. std::string Softmax_make_name_impl(const OpDef& def_) {
  6653. auto&& op_ = def_.cast_final_safe<Softmax>();
  6654. static_cast<void>(op_);
  6655. return "Softmax";
  6656. }
  6657. } // anonymous namespace
  6658. OP_TRAIT_REG(Softmax, Softmax)
  6659. .hash(Softmax_hash_impl)
  6660. .is_same_st(Softmax_is_same_st_impl)
  6661. .props(Softmax_props_impl)
  6662. .make_name(Softmax_make_name_impl);
  6663. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Split);
  6664. namespace {
  6665. size_t Split_hash_impl(const OpDef& def_) {
  6666. auto&& op_ = def_.cast_final_safe<Split>();
  6667. static_cast<void>(op_);
  6668. size_t val = mgb::hash(op_.dyn_typeinfo());
  6669. val = mgb::hash_pair_combine(val, mgb::hash(op_.axis));
  6670. val = mgb::hash_pair_combine(val, mgb::hash(op_.nsections));
  6671. return val;
  6672. }
  6673. bool Split_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6674. auto &&a_ = lhs_.cast_final_safe<Split>(),
  6675. &&b_ = rhs_.cast_final_safe<Split>();
  6676. static_cast<void>(a_);
  6677. static_cast<void>(b_);
  6678. if (a_.axis != b_.axis) return false;
  6679. if (a_.nsections != b_.nsections) return false;
  6680. return true;
  6681. }
  6682. std::vector<std::pair<const char*, std::string>> Split_props_impl(const OpDef& def_) {
  6683. auto&& op_ = def_.cast_final_safe<Split>();
  6684. static_cast<void>(op_);
  6685. std::vector<std::pair<const char*, std::string>> props_;
  6686. props_.emplace_back("axis", std::to_string(op_.axis));
  6687. props_.emplace_back("nsections", std::to_string(op_.nsections));
  6688. return props_;
  6689. }
  6690. std::string Split_make_name_impl(const OpDef& def_) {
  6691. auto&& op_ = def_.cast_final_safe<Split>();
  6692. static_cast<void>(op_);
  6693. return "Split";
  6694. }
  6695. } // anonymous namespace
  6696. OP_TRAIT_REG(Split, Split)
  6697. .hash(Split_hash_impl)
  6698. .is_same_st(Split_is_same_st_impl)
  6699. .props(Split_props_impl)
  6700. .make_name(Split_make_name_impl);
  6701. MGB_DYN_TYPE_OBJ_FINAL_IMPL(Subtensor);
  6702. namespace {
  6703. size_t Subtensor_hash_impl(const OpDef& def_) {
  6704. auto&& op_ = def_.cast_final_safe<Subtensor>();
  6705. static_cast<void>(op_);
  6706. size_t val = mgb::hash(op_.dyn_typeinfo());
  6707. val = mgb::hash_pair_combine(val, mgb::hash(op_.items));
  6708. return val;
  6709. }
  6710. bool Subtensor_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6711. auto &&a_ = lhs_.cast_final_safe<Subtensor>(),
  6712. &&b_ = rhs_.cast_final_safe<Subtensor>();
  6713. static_cast<void>(a_);
  6714. static_cast<void>(b_);
  6715. if (a_.items != b_.items) return false;
  6716. return true;
  6717. }
  6718. std::vector<std::pair<const char*, std::string>> Subtensor_props_impl(const OpDef& def_) {
  6719. auto&& op_ = def_.cast_final_safe<Subtensor>();
  6720. static_cast<void>(op_);
  6721. std::vector<std::pair<const char*, std::string>> props_;
  6722. props_.emplace_back("items", "{std::vector}");
  6723. return props_;
  6724. }
  6725. std::string Subtensor_make_name_impl(const OpDef& def_) {
  6726. auto&& op_ = def_.cast_final_safe<Subtensor>();
  6727. static_cast<void>(op_);
  6728. return "Subtensor";
  6729. }
  6730. } // anonymous namespace
  6731. OP_TRAIT_REG(Subtensor, Subtensor)
  6732. .hash(Subtensor_hash_impl)
  6733. .is_same_st(Subtensor_is_same_st_impl)
  6734. .props(Subtensor_props_impl)
  6735. .make_name(Subtensor_make_name_impl);
  6736. MGB_DYN_TYPE_OBJ_FINAL_IMPL(TQT);
  6737. namespace {
  6738. size_t TQT_hash_impl(const OpDef& def_) {
  6739. auto&& op_ = def_.cast_final_safe<TQT>();
  6740. static_cast<void>(op_);
  6741. size_t val = mgb::hash(op_.dyn_typeinfo());
  6742. val = mgb::hash_pair_combine(val, mgb::hash(op_.qmin));
  6743. val = mgb::hash_pair_combine(val, mgb::hash(op_.qmax));
  6744. return val;
  6745. }
  6746. bool TQT_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6747. auto &&a_ = lhs_.cast_final_safe<TQT>(),
  6748. &&b_ = rhs_.cast_final_safe<TQT>();
  6749. static_cast<void>(a_);
  6750. static_cast<void>(b_);
  6751. if (a_.qmin != b_.qmin) return false;
  6752. if (a_.qmax != b_.qmax) return false;
  6753. return true;
  6754. }
  6755. std::vector<std::pair<const char*, std::string>> TQT_props_impl(const OpDef& def_) {
  6756. auto&& op_ = def_.cast_final_safe<TQT>();
  6757. static_cast<void>(op_);
  6758. std::vector<std::pair<const char*, std::string>> props_;
  6759. props_.emplace_back("qmin", std::to_string(op_.qmin));
  6760. props_.emplace_back("qmax", std::to_string(op_.qmax));
  6761. return props_;
  6762. }
  6763. std::string TQT_make_name_impl(const OpDef& def_) {
  6764. auto&& op_ = def_.cast_final_safe<TQT>();
  6765. static_cast<void>(op_);
  6766. return "TQT";
  6767. }
  6768. } // anonymous namespace
  6769. OP_TRAIT_REG(TQT, TQT)
  6770. .hash(TQT_hash_impl)
  6771. .is_same_st(TQT_is_same_st_impl)
  6772. .props(TQT_props_impl)
  6773. .make_name(TQT_make_name_impl);
  6774. MGB_DYN_TYPE_OBJ_FINAL_IMPL(TensorRTRuntime);
  6775. namespace {
  6776. size_t TensorRTRuntime_hash_impl(const OpDef& def_) {
  6777. auto&& op_ = def_.cast_final_safe<TensorRTRuntime>();
  6778. static_cast<void>(op_);
  6779. size_t val = mgb::hash(op_.dyn_typeinfo());
  6780. val = mgb::hash_pair_combine(val, mgb::hash(op_.buf));
  6781. val = mgb::hash_pair_combine(val, mgb::hash(op_.buf_size));
  6782. return val;
  6783. }
  6784. bool TensorRTRuntime_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6785. auto &&a_ = lhs_.cast_final_safe<TensorRTRuntime>(),
  6786. &&b_ = rhs_.cast_final_safe<TensorRTRuntime>();
  6787. static_cast<void>(a_);
  6788. static_cast<void>(b_);
  6789. if (a_.buf != b_.buf) return false;
  6790. if (a_.buf_size != b_.buf_size) return false;
  6791. return true;
  6792. }
  6793. std::vector<std::pair<const char*, std::string>> TensorRTRuntime_props_impl(const OpDef& def_) {
  6794. auto&& op_ = def_.cast_final_safe<TensorRTRuntime>();
  6795. static_cast<void>(op_);
  6796. std::vector<std::pair<const char*, std::string>> props_;
  6797. props_.emplace_back("buf", op_.buf);
  6798. props_.emplace_back("buf_size", std::to_string(op_.buf_size));
  6799. return props_;
  6800. }
  6801. std::string TensorRTRuntime_make_name_impl(const OpDef& def_) {
  6802. auto&& op_ = def_.cast_final_safe<TensorRTRuntime>();
  6803. static_cast<void>(op_);
  6804. return "TensorRTRuntime";
  6805. }
  6806. } // anonymous namespace
  6807. OP_TRAIT_REG(TensorRTRuntime, TensorRTRuntime)
  6808. .hash(TensorRTRuntime_hash_impl)
  6809. .is_same_st(TensorRTRuntime_is_same_st_impl)
  6810. .props(TensorRTRuntime_props_impl)
  6811. .make_name(TensorRTRuntime_make_name_impl);
  6812. MGB_DYN_TYPE_OBJ_FINAL_IMPL(TopK);
  6813. namespace {
  6814. size_t TopK_hash_impl(const OpDef& def_) {
  6815. auto&& op_ = def_.cast_final_safe<TopK>();
  6816. static_cast<void>(op_);
  6817. size_t val = mgb::hash(op_.dyn_typeinfo());
  6818. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.mode));
  6819. return val;
  6820. }
  6821. bool TopK_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6822. auto &&a_ = lhs_.cast_final_safe<TopK>(),
  6823. &&b_ = rhs_.cast_final_safe<TopK>();
  6824. static_cast<void>(a_);
  6825. static_cast<void>(b_);
  6826. if (a_.mode != b_.mode) return false;
  6827. return true;
  6828. }
  6829. std::vector<std::pair<const char*, std::string>> TopK_props_impl(const OpDef& def_) {
  6830. auto&& op_ = def_.cast_final_safe<TopK>();
  6831. static_cast<void>(op_);
  6832. std::vector<std::pair<const char*, std::string>> props_;
  6833. switch (op_.mode){
  6834. case TopK::Mode::KTH_ONLY:
  6835. props_.emplace_back("mode", "KTH_ONLY");
  6836. break;
  6837. case TopK::Mode::VALUE_IDX_NOSORT:
  6838. props_.emplace_back("mode", "VALUE_IDX_NOSORT");
  6839. break;
  6840. case TopK::Mode::VALUE_IDX_SORTED:
  6841. props_.emplace_back("mode", "VALUE_IDX_SORTED");
  6842. break;
  6843. default:
  6844. props_.emplace_back("mode", "INVALID");
  6845. break;
  6846. }
  6847. return props_;
  6848. }
  6849. std::string TopK_make_name_impl(const OpDef& def_) {
  6850. auto&& op_ = def_.cast_final_safe<TopK>();
  6851. static_cast<void>(op_);
  6852. return "TopK";
  6853. }
  6854. } // anonymous namespace
  6855. OP_TRAIT_REG(TopK, TopK)
  6856. .hash(TopK_hash_impl)
  6857. .is_same_st(TopK_is_same_st_impl)
  6858. .props(TopK_props_impl)
  6859. .make_name(TopK_make_name_impl);
  6860. MGB_DYN_TYPE_OBJ_FINAL_IMPL(TypeCvt);
  6861. namespace {
  6862. size_t TypeCvt_hash_impl(const OpDef& def_) {
  6863. auto&& op_ = def_.cast_final_safe<TypeCvt>();
  6864. static_cast<void>(op_);
  6865. size_t val = mgb::hash(op_.dyn_typeinfo());
  6866. val = mgb::hash_pair_combine(val, mgb::hash(op_.dtype.handle()));
  6867. return val;
  6868. }
  6869. bool TypeCvt_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6870. auto &&a_ = lhs_.cast_final_safe<TypeCvt>(),
  6871. &&b_ = rhs_.cast_final_safe<TypeCvt>();
  6872. static_cast<void>(a_);
  6873. static_cast<void>(b_);
  6874. if (a_.dtype != b_.dtype) return false;
  6875. return true;
  6876. }
  6877. std::vector<std::pair<const char*, std::string>> TypeCvt_props_impl(const OpDef& def_) {
  6878. auto&& op_ = def_.cast_final_safe<TypeCvt>();
  6879. static_cast<void>(op_);
  6880. std::vector<std::pair<const char*, std::string>> props_;
  6881. props_.emplace_back("dtype", op_.dtype.name());
  6882. return props_;
  6883. }
  6884. std::string TypeCvt_make_name_impl(const OpDef& def_) {
  6885. auto&& op_ = def_.cast_final_safe<TypeCvt>();
  6886. static_cast<void>(op_);
  6887. return "TypeCvt";
  6888. }
  6889. } // anonymous namespace
  6890. OP_TRAIT_REG(TypeCvt, TypeCvt)
  6891. .hash(TypeCvt_hash_impl)
  6892. .is_same_st(TypeCvt_is_same_st_impl)
  6893. .props(TypeCvt_props_impl)
  6894. .make_name(TypeCvt_make_name_impl);
  6895. MGB_DYN_TYPE_OBJ_FINAL_IMPL(UniformRNG);
  6896. namespace {
  6897. size_t UniformRNG_hash_impl(const OpDef& def_) {
  6898. auto&& op_ = def_.cast_final_safe<UniformRNG>();
  6899. static_cast<void>(op_);
  6900. return mgb::hash_pair_combine(
  6901. mgb::hash(op_.dyn_typeinfo()),
  6902. mgb::hash_pair_combine(
  6903. mgb::hash(op_.handle),
  6904. mgb::hash(op_.dtype.enumv())
  6905. )
  6906. );
  6907. }
  6908. bool UniformRNG_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6909. auto &&a_ = lhs_.cast_final_safe<UniformRNG>(),
  6910. &&b_ = rhs_.cast_final_safe<UniformRNG>();
  6911. static_cast<void>(a_);
  6912. static_cast<void>(b_);
  6913. return a_.handle == b_.handle && a_.dtype == b_.dtype;}
  6914. std::vector<std::pair<const char*, std::string>> UniformRNG_props_impl(const OpDef& def_) {
  6915. auto&& op_ = def_.cast_final_safe<UniformRNG>();
  6916. static_cast<void>(op_);
  6917. std::vector<std::pair<const char*, std::string>> props_;
  6918. props_.emplace_back("seed", std::to_string(op_.seed));
  6919. props_.emplace_back("dtype", op_.dtype.name());
  6920. props_.emplace_back("handle", std::to_string(op_.handle));
  6921. return props_;
  6922. }
  6923. std::string UniformRNG_make_name_impl(const OpDef& def_) {
  6924. auto&& op_ = def_.cast_final_safe<UniformRNG>();
  6925. static_cast<void>(op_);
  6926. return "UniformRNG";
  6927. }
  6928. } // anonymous namespace
  6929. OP_TRAIT_REG(UniformRNG, UniformRNG)
  6930. .hash(UniformRNG_hash_impl)
  6931. .is_same_st(UniformRNG_is_same_st_impl)
  6932. .props(UniformRNG_props_impl)
  6933. .make_name(UniformRNG_make_name_impl);
  6934. MGB_DYN_TYPE_OBJ_FINAL_IMPL(WarpAffine);
  6935. namespace {
  6936. size_t WarpAffine_hash_impl(const OpDef& def_) {
  6937. auto&& op_ = def_.cast_final_safe<WarpAffine>();
  6938. static_cast<void>(op_);
  6939. size_t val = mgb::hash(op_.dyn_typeinfo());
  6940. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
  6941. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.border_mode));
  6942. val = mgb::hash_pair_combine(val, mgb::hash(op_.border_val));
  6943. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  6944. return val;
  6945. }
  6946. bool WarpAffine_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  6947. auto &&a_ = lhs_.cast_final_safe<WarpAffine>(),
  6948. &&b_ = rhs_.cast_final_safe<WarpAffine>();
  6949. static_cast<void>(a_);
  6950. static_cast<void>(b_);
  6951. if (a_.imode != b_.imode) return false;
  6952. if (a_.border_mode != b_.border_mode) return false;
  6953. if (a_.border_val != b_.border_val) return false;
  6954. if (a_.format != b_.format) return false;
  6955. return true;
  6956. }
  6957. std::vector<std::pair<const char*, std::string>> WarpAffine_props_impl(const OpDef& def_) {
  6958. auto&& op_ = def_.cast_final_safe<WarpAffine>();
  6959. static_cast<void>(op_);
  6960. std::vector<std::pair<const char*, std::string>> props_;
  6961. switch (op_.imode){
  6962. case WarpAffine::InterpolationMode::NEAREST:
  6963. props_.emplace_back("imode", "NEAREST");
  6964. break;
  6965. case WarpAffine::InterpolationMode::LINEAR:
  6966. props_.emplace_back("imode", "LINEAR");
  6967. break;
  6968. case WarpAffine::InterpolationMode::AREA:
  6969. props_.emplace_back("imode", "AREA");
  6970. break;
  6971. case WarpAffine::InterpolationMode::CUBIC:
  6972. props_.emplace_back("imode", "CUBIC");
  6973. break;
  6974. case WarpAffine::InterpolationMode::LANCZOS4:
  6975. props_.emplace_back("imode", "LANCZOS4");
  6976. break;
  6977. default:
  6978. props_.emplace_back("imode", "INVALID");
  6979. break;
  6980. }
  6981. switch (op_.border_mode){
  6982. case WarpAffine::BorderMode::REPLICATE:
  6983. props_.emplace_back("border_mode", "REPLICATE");
  6984. break;
  6985. case WarpAffine::BorderMode::REFLECT:
  6986. props_.emplace_back("border_mode", "REFLECT");
  6987. break;
  6988. case WarpAffine::BorderMode::REFLECT_101:
  6989. props_.emplace_back("border_mode", "REFLECT_101");
  6990. break;
  6991. case WarpAffine::BorderMode::WRAP:
  6992. props_.emplace_back("border_mode", "WRAP");
  6993. break;
  6994. case WarpAffine::BorderMode::CONSTANT:
  6995. props_.emplace_back("border_mode", "CONSTANT");
  6996. break;
  6997. case WarpAffine::BorderMode::TRANSPARENT:
  6998. props_.emplace_back("border_mode", "TRANSPARENT");
  6999. break;
  7000. case WarpAffine::BorderMode::ISOLATED:
  7001. props_.emplace_back("border_mode", "ISOLATED");
  7002. break;
  7003. default:
  7004. props_.emplace_back("border_mode", "INVALID");
  7005. break;
  7006. }
  7007. props_.emplace_back("border_val", std::to_string(op_.border_val));
  7008. switch (op_.format){
  7009. case WarpAffine::Format::NCHW:
  7010. props_.emplace_back("format", "NCHW");
  7011. break;
  7012. case WarpAffine::Format::NHWC:
  7013. props_.emplace_back("format", "NHWC");
  7014. break;
  7015. case WarpAffine::Format::NHWCD4:
  7016. props_.emplace_back("format", "NHWCD4");
  7017. break;
  7018. case WarpAffine::Format::NCHW4:
  7019. props_.emplace_back("format", "NCHW4");
  7020. break;
  7021. case WarpAffine::Format::NCHW8:
  7022. props_.emplace_back("format", "NCHW8");
  7023. break;
  7024. case WarpAffine::Format::NCHW32:
  7025. props_.emplace_back("format", "NCHW32");
  7026. break;
  7027. case WarpAffine::Format::NCHW88:
  7028. props_.emplace_back("format", "NCHW88");
  7029. break;
  7030. case WarpAffine::Format::NCHW44:
  7031. props_.emplace_back("format", "NCHW44");
  7032. break;
  7033. case WarpAffine::Format::NCHW44_DOT:
  7034. props_.emplace_back("format", "NCHW44_DOT");
  7035. break;
  7036. case WarpAffine::Format::NCHW4_NCHW32:
  7037. props_.emplace_back("format", "NCHW4_NCHW32");
  7038. break;
  7039. case WarpAffine::Format::NCHW32_NCHW4:
  7040. props_.emplace_back("format", "NCHW32_NCHW4");
  7041. break;
  7042. case WarpAffine::Format::NCHW4_NCHW:
  7043. props_.emplace_back("format", "NCHW4_NCHW");
  7044. break;
  7045. case WarpAffine::Format::NHWC_NCHW:
  7046. props_.emplace_back("format", "NHWC_NCHW");
  7047. break;
  7048. case WarpAffine::Format::NHWC_NCHW4_IC_SMALL:
  7049. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  7050. break;
  7051. case WarpAffine::Format::NCHW_NCHW4_IC_SMALL:
  7052. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  7053. break;
  7054. case WarpAffine::Format::CHWN4:
  7055. props_.emplace_back("format", "CHWN4");
  7056. break;
  7057. case WarpAffine::Format::NCHW64:
  7058. props_.emplace_back("format", "NCHW64");
  7059. break;
  7060. case WarpAffine::Format::NCHW4_NHWC:
  7061. props_.emplace_back("format", "NCHW4_NHWC");
  7062. break;
  7063. default:
  7064. props_.emplace_back("format", "INVALID");
  7065. break;
  7066. }
  7067. return props_;
  7068. }
  7069. std::string WarpAffine_make_name_impl(const OpDef& def_) {
  7070. auto&& op_ = def_.cast_final_safe<WarpAffine>();
  7071. static_cast<void>(op_);
  7072. return "WarpAffine";
  7073. }
  7074. } // anonymous namespace
  7075. OP_TRAIT_REG(WarpAffine, WarpAffine)
  7076. .hash(WarpAffine_hash_impl)
  7077. .is_same_st(WarpAffine_is_same_st_impl)
  7078. .props(WarpAffine_props_impl)
  7079. .make_name(WarpAffine_make_name_impl);
  7080. MGB_DYN_TYPE_OBJ_FINAL_IMPL(WarpPerspective);
  7081. namespace {
  7082. size_t WarpPerspective_hash_impl(const OpDef& def_) {
  7083. auto&& op_ = def_.cast_final_safe<WarpPerspective>();
  7084. static_cast<void>(op_);
  7085. size_t val = mgb::hash(op_.dyn_typeinfo());
  7086. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
  7087. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.bmode));
  7088. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  7089. val = mgb::hash_pair_combine(val, mgb::hash(op_.border_val));
  7090. return val;
  7091. }
  7092. bool WarpPerspective_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  7093. auto &&a_ = lhs_.cast_final_safe<WarpPerspective>(),
  7094. &&b_ = rhs_.cast_final_safe<WarpPerspective>();
  7095. static_cast<void>(a_);
  7096. static_cast<void>(b_);
  7097. if (a_.imode != b_.imode) return false;
  7098. if (a_.bmode != b_.bmode) return false;
  7099. if (a_.format != b_.format) return false;
  7100. if (a_.border_val != b_.border_val) return false;
  7101. return true;
  7102. }
  7103. std::vector<std::pair<const char*, std::string>> WarpPerspective_props_impl(const OpDef& def_) {
  7104. auto&& op_ = def_.cast_final_safe<WarpPerspective>();
  7105. static_cast<void>(op_);
  7106. std::vector<std::pair<const char*, std::string>> props_;
  7107. switch (op_.imode){
  7108. case WarpPerspective::InterpolationMode::NEAREST:
  7109. props_.emplace_back("imode", "NEAREST");
  7110. break;
  7111. case WarpPerspective::InterpolationMode::LINEAR:
  7112. props_.emplace_back("imode", "LINEAR");
  7113. break;
  7114. case WarpPerspective::InterpolationMode::AREA:
  7115. props_.emplace_back("imode", "AREA");
  7116. break;
  7117. case WarpPerspective::InterpolationMode::CUBIC:
  7118. props_.emplace_back("imode", "CUBIC");
  7119. break;
  7120. case WarpPerspective::InterpolationMode::LANCZOS4:
  7121. props_.emplace_back("imode", "LANCZOS4");
  7122. break;
  7123. default:
  7124. props_.emplace_back("imode", "INVALID");
  7125. break;
  7126. }
  7127. switch (op_.bmode){
  7128. case WarpPerspective::BorderMode::REPLICATE:
  7129. props_.emplace_back("bmode", "REPLICATE");
  7130. break;
  7131. case WarpPerspective::BorderMode::REFLECT:
  7132. props_.emplace_back("bmode", "REFLECT");
  7133. break;
  7134. case WarpPerspective::BorderMode::REFLECT_101:
  7135. props_.emplace_back("bmode", "REFLECT_101");
  7136. break;
  7137. case WarpPerspective::BorderMode::WRAP:
  7138. props_.emplace_back("bmode", "WRAP");
  7139. break;
  7140. case WarpPerspective::BorderMode::CONSTANT:
  7141. props_.emplace_back("bmode", "CONSTANT");
  7142. break;
  7143. case WarpPerspective::BorderMode::TRANSPARENT:
  7144. props_.emplace_back("bmode", "TRANSPARENT");
  7145. break;
  7146. case WarpPerspective::BorderMode::ISOLATED:
  7147. props_.emplace_back("bmode", "ISOLATED");
  7148. break;
  7149. default:
  7150. props_.emplace_back("bmode", "INVALID");
  7151. break;
  7152. }
  7153. switch (op_.format){
  7154. case WarpPerspective::Format::NCHW:
  7155. props_.emplace_back("format", "NCHW");
  7156. break;
  7157. case WarpPerspective::Format::NHWC:
  7158. props_.emplace_back("format", "NHWC");
  7159. break;
  7160. case WarpPerspective::Format::NHWCD4:
  7161. props_.emplace_back("format", "NHWCD4");
  7162. break;
  7163. case WarpPerspective::Format::NCHW4:
  7164. props_.emplace_back("format", "NCHW4");
  7165. break;
  7166. case WarpPerspective::Format::NCHW8:
  7167. props_.emplace_back("format", "NCHW8");
  7168. break;
  7169. case WarpPerspective::Format::NCHW32:
  7170. props_.emplace_back("format", "NCHW32");
  7171. break;
  7172. case WarpPerspective::Format::NCHW88:
  7173. props_.emplace_back("format", "NCHW88");
  7174. break;
  7175. case WarpPerspective::Format::NCHW44:
  7176. props_.emplace_back("format", "NCHW44");
  7177. break;
  7178. case WarpPerspective::Format::NCHW44_DOT:
  7179. props_.emplace_back("format", "NCHW44_DOT");
  7180. break;
  7181. case WarpPerspective::Format::NCHW4_NCHW32:
  7182. props_.emplace_back("format", "NCHW4_NCHW32");
  7183. break;
  7184. case WarpPerspective::Format::NCHW32_NCHW4:
  7185. props_.emplace_back("format", "NCHW32_NCHW4");
  7186. break;
  7187. case WarpPerspective::Format::NCHW4_NCHW:
  7188. props_.emplace_back("format", "NCHW4_NCHW");
  7189. break;
  7190. case WarpPerspective::Format::NHWC_NCHW:
  7191. props_.emplace_back("format", "NHWC_NCHW");
  7192. break;
  7193. case WarpPerspective::Format::NHWC_NCHW4_IC_SMALL:
  7194. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  7195. break;
  7196. case WarpPerspective::Format::NCHW_NCHW4_IC_SMALL:
  7197. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  7198. break;
  7199. case WarpPerspective::Format::CHWN4:
  7200. props_.emplace_back("format", "CHWN4");
  7201. break;
  7202. case WarpPerspective::Format::NCHW64:
  7203. props_.emplace_back("format", "NCHW64");
  7204. break;
  7205. case WarpPerspective::Format::NCHW4_NHWC:
  7206. props_.emplace_back("format", "NCHW4_NHWC");
  7207. break;
  7208. default:
  7209. props_.emplace_back("format", "INVALID");
  7210. break;
  7211. }
  7212. props_.emplace_back("border_val", std::to_string(op_.border_val));
  7213. return props_;
  7214. }
  7215. std::string WarpPerspective_make_name_impl(const OpDef& def_) {
  7216. auto&& op_ = def_.cast_final_safe<WarpPerspective>();
  7217. static_cast<void>(op_);
  7218. return "WarpPerspective";
  7219. }
  7220. } // anonymous namespace
  7221. OP_TRAIT_REG(WarpPerspective, WarpPerspective)
  7222. .hash(WarpPerspective_hash_impl)
  7223. .is_same_st(WarpPerspective_is_same_st_impl)
  7224. .props(WarpPerspective_props_impl)
  7225. .make_name(WarpPerspective_make_name_impl);
  7226. MGB_DYN_TYPE_OBJ_FINAL_IMPL(WarpPerspectiveBackwardData);
  7227. namespace {
  7228. size_t WarpPerspectiveBackwardData_hash_impl(const OpDef& def_) {
  7229. auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardData>();
  7230. static_cast<void>(op_);
  7231. size_t val = mgb::hash(op_.dyn_typeinfo());
  7232. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
  7233. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.bmode));
  7234. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  7235. val = mgb::hash_pair_combine(val, mgb::hash(op_.border_val));
  7236. return val;
  7237. }
  7238. bool WarpPerspectiveBackwardData_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  7239. auto &&a_ = lhs_.cast_final_safe<WarpPerspectiveBackwardData>(),
  7240. &&b_ = rhs_.cast_final_safe<WarpPerspectiveBackwardData>();
  7241. static_cast<void>(a_);
  7242. static_cast<void>(b_);
  7243. if (a_.imode != b_.imode) return false;
  7244. if (a_.bmode != b_.bmode) return false;
  7245. if (a_.format != b_.format) return false;
  7246. if (a_.border_val != b_.border_val) return false;
  7247. return true;
  7248. }
  7249. std::vector<std::pair<const char*, std::string>> WarpPerspectiveBackwardData_props_impl(const OpDef& def_) {
  7250. auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardData>();
  7251. static_cast<void>(op_);
  7252. std::vector<std::pair<const char*, std::string>> props_;
  7253. switch (op_.imode){
  7254. case WarpPerspectiveBackwardData::InterpolationMode::NEAREST:
  7255. props_.emplace_back("imode", "NEAREST");
  7256. break;
  7257. case WarpPerspectiveBackwardData::InterpolationMode::LINEAR:
  7258. props_.emplace_back("imode", "LINEAR");
  7259. break;
  7260. case WarpPerspectiveBackwardData::InterpolationMode::AREA:
  7261. props_.emplace_back("imode", "AREA");
  7262. break;
  7263. case WarpPerspectiveBackwardData::InterpolationMode::CUBIC:
  7264. props_.emplace_back("imode", "CUBIC");
  7265. break;
  7266. case WarpPerspectiveBackwardData::InterpolationMode::LANCZOS4:
  7267. props_.emplace_back("imode", "LANCZOS4");
  7268. break;
  7269. default:
  7270. props_.emplace_back("imode", "INVALID");
  7271. break;
  7272. }
  7273. switch (op_.bmode){
  7274. case WarpPerspectiveBackwardData::BorderMode::REPLICATE:
  7275. props_.emplace_back("bmode", "REPLICATE");
  7276. break;
  7277. case WarpPerspectiveBackwardData::BorderMode::REFLECT:
  7278. props_.emplace_back("bmode", "REFLECT");
  7279. break;
  7280. case WarpPerspectiveBackwardData::BorderMode::REFLECT_101:
  7281. props_.emplace_back("bmode", "REFLECT_101");
  7282. break;
  7283. case WarpPerspectiveBackwardData::BorderMode::WRAP:
  7284. props_.emplace_back("bmode", "WRAP");
  7285. break;
  7286. case WarpPerspectiveBackwardData::BorderMode::CONSTANT:
  7287. props_.emplace_back("bmode", "CONSTANT");
  7288. break;
  7289. case WarpPerspectiveBackwardData::BorderMode::TRANSPARENT:
  7290. props_.emplace_back("bmode", "TRANSPARENT");
  7291. break;
  7292. case WarpPerspectiveBackwardData::BorderMode::ISOLATED:
  7293. props_.emplace_back("bmode", "ISOLATED");
  7294. break;
  7295. default:
  7296. props_.emplace_back("bmode", "INVALID");
  7297. break;
  7298. }
  7299. switch (op_.format){
  7300. case WarpPerspectiveBackwardData::Format::NCHW:
  7301. props_.emplace_back("format", "NCHW");
  7302. break;
  7303. case WarpPerspectiveBackwardData::Format::NHWC:
  7304. props_.emplace_back("format", "NHWC");
  7305. break;
  7306. case WarpPerspectiveBackwardData::Format::NHWCD4:
  7307. props_.emplace_back("format", "NHWCD4");
  7308. break;
  7309. case WarpPerspectiveBackwardData::Format::NCHW4:
  7310. props_.emplace_back("format", "NCHW4");
  7311. break;
  7312. case WarpPerspectiveBackwardData::Format::NCHW8:
  7313. props_.emplace_back("format", "NCHW8");
  7314. break;
  7315. case WarpPerspectiveBackwardData::Format::NCHW32:
  7316. props_.emplace_back("format", "NCHW32");
  7317. break;
  7318. case WarpPerspectiveBackwardData::Format::NCHW88:
  7319. props_.emplace_back("format", "NCHW88");
  7320. break;
  7321. case WarpPerspectiveBackwardData::Format::NCHW44:
  7322. props_.emplace_back("format", "NCHW44");
  7323. break;
  7324. case WarpPerspectiveBackwardData::Format::NCHW44_DOT:
  7325. props_.emplace_back("format", "NCHW44_DOT");
  7326. break;
  7327. case WarpPerspectiveBackwardData::Format::NCHW4_NCHW32:
  7328. props_.emplace_back("format", "NCHW4_NCHW32");
  7329. break;
  7330. case WarpPerspectiveBackwardData::Format::NCHW32_NCHW4:
  7331. props_.emplace_back("format", "NCHW32_NCHW4");
  7332. break;
  7333. case WarpPerspectiveBackwardData::Format::NCHW4_NCHW:
  7334. props_.emplace_back("format", "NCHW4_NCHW");
  7335. break;
  7336. case WarpPerspectiveBackwardData::Format::NHWC_NCHW:
  7337. props_.emplace_back("format", "NHWC_NCHW");
  7338. break;
  7339. case WarpPerspectiveBackwardData::Format::NHWC_NCHW4_IC_SMALL:
  7340. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  7341. break;
  7342. case WarpPerspectiveBackwardData::Format::NCHW_NCHW4_IC_SMALL:
  7343. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  7344. break;
  7345. case WarpPerspectiveBackwardData::Format::CHWN4:
  7346. props_.emplace_back("format", "CHWN4");
  7347. break;
  7348. case WarpPerspectiveBackwardData::Format::NCHW64:
  7349. props_.emplace_back("format", "NCHW64");
  7350. break;
  7351. case WarpPerspectiveBackwardData::Format::NCHW4_NHWC:
  7352. props_.emplace_back("format", "NCHW4_NHWC");
  7353. break;
  7354. default:
  7355. props_.emplace_back("format", "INVALID");
  7356. break;
  7357. }
  7358. props_.emplace_back("border_val", std::to_string(op_.border_val));
  7359. return props_;
  7360. }
  7361. std::string WarpPerspectiveBackwardData_make_name_impl(const OpDef& def_) {
  7362. auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardData>();
  7363. static_cast<void>(op_);
  7364. return "WarpPerspectiveBackwardData";
  7365. }
  7366. } // anonymous namespace
  7367. OP_TRAIT_REG(WarpPerspectiveBackwardData, WarpPerspectiveBackwardData)
  7368. .hash(WarpPerspectiveBackwardData_hash_impl)
  7369. .is_same_st(WarpPerspectiveBackwardData_is_same_st_impl)
  7370. .props(WarpPerspectiveBackwardData_props_impl)
  7371. .make_name(WarpPerspectiveBackwardData_make_name_impl);
  7372. MGB_DYN_TYPE_OBJ_FINAL_IMPL(WarpPerspectiveBackwardMat);
  7373. namespace {
  7374. size_t WarpPerspectiveBackwardMat_hash_impl(const OpDef& def_) {
  7375. auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardMat>();
  7376. static_cast<void>(op_);
  7377. size_t val = mgb::hash(op_.dyn_typeinfo());
  7378. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.imode));
  7379. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.bmode));
  7380. val = mgb::hash_pair_combine(val, mgb::enumhash()(op_.format));
  7381. val = mgb::hash_pair_combine(val, mgb::hash(op_.border_val));
  7382. return val;
  7383. }
  7384. bool WarpPerspectiveBackwardMat_is_same_st_impl(const OpDef& lhs_, const OpDef& rhs_) {
  7385. auto &&a_ = lhs_.cast_final_safe<WarpPerspectiveBackwardMat>(),
  7386. &&b_ = rhs_.cast_final_safe<WarpPerspectiveBackwardMat>();
  7387. static_cast<void>(a_);
  7388. static_cast<void>(b_);
  7389. if (a_.imode != b_.imode) return false;
  7390. if (a_.bmode != b_.bmode) return false;
  7391. if (a_.format != b_.format) return false;
  7392. if (a_.border_val != b_.border_val) return false;
  7393. return true;
  7394. }
  7395. std::vector<std::pair<const char*, std::string>> WarpPerspectiveBackwardMat_props_impl(const OpDef& def_) {
  7396. auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardMat>();
  7397. static_cast<void>(op_);
  7398. std::vector<std::pair<const char*, std::string>> props_;
  7399. switch (op_.imode){
  7400. case WarpPerspectiveBackwardMat::InterpolationMode::NEAREST:
  7401. props_.emplace_back("imode", "NEAREST");
  7402. break;
  7403. case WarpPerspectiveBackwardMat::InterpolationMode::LINEAR:
  7404. props_.emplace_back("imode", "LINEAR");
  7405. break;
  7406. case WarpPerspectiveBackwardMat::InterpolationMode::AREA:
  7407. props_.emplace_back("imode", "AREA");
  7408. break;
  7409. case WarpPerspectiveBackwardMat::InterpolationMode::CUBIC:
  7410. props_.emplace_back("imode", "CUBIC");
  7411. break;
  7412. case WarpPerspectiveBackwardMat::InterpolationMode::LANCZOS4:
  7413. props_.emplace_back("imode", "LANCZOS4");
  7414. break;
  7415. default:
  7416. props_.emplace_back("imode", "INVALID");
  7417. break;
  7418. }
  7419. switch (op_.bmode){
  7420. case WarpPerspectiveBackwardMat::BorderMode::REPLICATE:
  7421. props_.emplace_back("bmode", "REPLICATE");
  7422. break;
  7423. case WarpPerspectiveBackwardMat::BorderMode::REFLECT:
  7424. props_.emplace_back("bmode", "REFLECT");
  7425. break;
  7426. case WarpPerspectiveBackwardMat::BorderMode::REFLECT_101:
  7427. props_.emplace_back("bmode", "REFLECT_101");
  7428. break;
  7429. case WarpPerspectiveBackwardMat::BorderMode::WRAP:
  7430. props_.emplace_back("bmode", "WRAP");
  7431. break;
  7432. case WarpPerspectiveBackwardMat::BorderMode::CONSTANT:
  7433. props_.emplace_back("bmode", "CONSTANT");
  7434. break;
  7435. case WarpPerspectiveBackwardMat::BorderMode::TRANSPARENT:
  7436. props_.emplace_back("bmode", "TRANSPARENT");
  7437. break;
  7438. case WarpPerspectiveBackwardMat::BorderMode::ISOLATED:
  7439. props_.emplace_back("bmode", "ISOLATED");
  7440. break;
  7441. default:
  7442. props_.emplace_back("bmode", "INVALID");
  7443. break;
  7444. }
  7445. switch (op_.format){
  7446. case WarpPerspectiveBackwardMat::Format::NCHW:
  7447. props_.emplace_back("format", "NCHW");
  7448. break;
  7449. case WarpPerspectiveBackwardMat::Format::NHWC:
  7450. props_.emplace_back("format", "NHWC");
  7451. break;
  7452. case WarpPerspectiveBackwardMat::Format::NHWCD4:
  7453. props_.emplace_back("format", "NHWCD4");
  7454. break;
  7455. case WarpPerspectiveBackwardMat::Format::NCHW4:
  7456. props_.emplace_back("format", "NCHW4");
  7457. break;
  7458. case WarpPerspectiveBackwardMat::Format::NCHW8:
  7459. props_.emplace_back("format", "NCHW8");
  7460. break;
  7461. case WarpPerspectiveBackwardMat::Format::NCHW32:
  7462. props_.emplace_back("format", "NCHW32");
  7463. break;
  7464. case WarpPerspectiveBackwardMat::Format::NCHW88:
  7465. props_.emplace_back("format", "NCHW88");
  7466. break;
  7467. case WarpPerspectiveBackwardMat::Format::NCHW44:
  7468. props_.emplace_back("format", "NCHW44");
  7469. break;
  7470. case WarpPerspectiveBackwardMat::Format::NCHW44_DOT:
  7471. props_.emplace_back("format", "NCHW44_DOT");
  7472. break;
  7473. case WarpPerspectiveBackwardMat::Format::NCHW4_NCHW32:
  7474. props_.emplace_back("format", "NCHW4_NCHW32");
  7475. break;
  7476. case WarpPerspectiveBackwardMat::Format::NCHW32_NCHW4:
  7477. props_.emplace_back("format", "NCHW32_NCHW4");
  7478. break;
  7479. case WarpPerspectiveBackwardMat::Format::NCHW4_NCHW:
  7480. props_.emplace_back("format", "NCHW4_NCHW");
  7481. break;
  7482. case WarpPerspectiveBackwardMat::Format::NHWC_NCHW:
  7483. props_.emplace_back("format", "NHWC_NCHW");
  7484. break;
  7485. case WarpPerspectiveBackwardMat::Format::NHWC_NCHW4_IC_SMALL:
  7486. props_.emplace_back("format", "NHWC_NCHW4_IC_SMALL");
  7487. break;
  7488. case WarpPerspectiveBackwardMat::Format::NCHW_NCHW4_IC_SMALL:
  7489. props_.emplace_back("format", "NCHW_NCHW4_IC_SMALL");
  7490. break;
  7491. case WarpPerspectiveBackwardMat::Format::CHWN4:
  7492. props_.emplace_back("format", "CHWN4");
  7493. break;
  7494. case WarpPerspectiveBackwardMat::Format::NCHW64:
  7495. props_.emplace_back("format", "NCHW64");
  7496. break;
  7497. case WarpPerspectiveBackwardMat::Format::NCHW4_NHWC:
  7498. props_.emplace_back("format", "NCHW4_NHWC");
  7499. break;
  7500. default:
  7501. props_.emplace_back("format", "INVALID");
  7502. break;
  7503. }
  7504. props_.emplace_back("border_val", std::to_string(op_.border_val));
  7505. return props_;
  7506. }
  7507. std::string WarpPerspectiveBackwardMat_make_name_impl(const OpDef& def_) {
  7508. auto&& op_ = def_.cast_final_safe<WarpPerspectiveBackwardMat>();
  7509. static_cast<void>(op_);
  7510. return "WarpPerspectiveBackwardMat";
  7511. }
  7512. } // anonymous namespace
  7513. OP_TRAIT_REG(WarpPerspectiveBackwardMat, WarpPerspectiveBackwardMat)
  7514. .hash(WarpPerspectiveBackwardMat_hash_impl)
  7515. .is_same_st(WarpPerspectiveBackwardMat_is_same_st_impl)
  7516. .props(WarpPerspectiveBackwardMat_props_impl)
  7517. .make_name(WarpPerspectiveBackwardMat_make_name_impl);
  7518. // clang-format on