|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249 |
- // clang-format off
-
- template<> struct EnumTrait<AdaptivePooling::Mode> {
- static constexpr const char *name = "AdaptivePooling.Mode";
- static constexpr std::underlying_type_t<AdaptivePooling::Mode> max = 3 - 1;
- };
- template<> PyTypeObject* EnumWrapper<AdaptivePooling::Mode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<AdaptivePooling::Mode>::members[] = {"MAX", "AVERAGE", "AVERAGE_COUNT_EXCLUDE_PADDING"};
-
- template<> std::unordered_map<std::string, AdaptivePooling::Mode>
- EnumWrapper<AdaptivePooling::Mode>::mem2value = {{normalize_enum("MAX"), AdaptivePooling::Mode::MAX}, {normalize_enum("AVERAGE"), AdaptivePooling::Mode::AVERAGE}, {normalize_enum("AVERAGE_COUNT_EXCLUDE_PADDING"), AdaptivePooling::Mode::AVERAGE_COUNT_EXCLUDE_PADDING}};
- template<> PyObject* EnumWrapper<AdaptivePooling::Mode>::pyobj_insts[3] = {nullptr};
-
- void _init_py_AdaptivePooling_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<AdaptivePooling::Mode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<AdaptivePooling::Mode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<AdaptivePooling::Mode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<AdaptivePooling::Mode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.AdaptivePooling.Mode",
- // basicsize
- sizeof(EnumWrapper<AdaptivePooling::Mode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Mode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("AdaptivePooling.Mode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Mode>*>(inst)->value = AdaptivePooling::Mode::MAX;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "MAX", inst) >= 0);
- EnumWrapper<AdaptivePooling::Mode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Mode>*>(inst)->value = AdaptivePooling::Mode::AVERAGE;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "AVERAGE", inst) >= 0);
- EnumWrapper<AdaptivePooling::Mode>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Mode>*>(inst)->value = AdaptivePooling::Mode::AVERAGE_COUNT_EXCLUDE_PADDING;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "AVERAGE_COUNT_EXCLUDE_PADDING", inst) >= 0);
- EnumWrapper<AdaptivePooling::Mode>::pyobj_insts[2] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- template<> struct EnumTrait<AdaptivePooling::Format> {
- static constexpr const char *name = "AdaptivePooling.Format";
- static constexpr std::underlying_type_t<AdaptivePooling::Format> max = 18 - 1;
- };
- template<> PyTypeObject* EnumWrapper<AdaptivePooling::Format>::type = nullptr;
-
- template<> const char*
- EnumWrapper<AdaptivePooling::Format>::members[] = {"NCHW", "NHWC", "NHWCD4", "NCHW4", "NCHW8", "NCHW32", "NCHW88", "NCHW44", "NCHW44_DOT", "NCHW4_NCHW32", "NCHW32_NCHW4", "NCHW4_NCHW", "NHWC_NCHW", "NHWC_NCHW4_IC_SMALL", "NCHW_NCHW4_IC_SMALL", "CHWN4", "NCHW64", "NCHW4_NHWC"};
-
- template<> std::unordered_map<std::string, AdaptivePooling::Format>
- EnumWrapper<AdaptivePooling::Format>::mem2value = {{normalize_enum("NCHW"), AdaptivePooling::Format::NCHW}, {normalize_enum("NHWC"), AdaptivePooling::Format::NHWC}, {normalize_enum("NHWCD4"), AdaptivePooling::Format::NHWCD4}, {normalize_enum("NCHW4"), AdaptivePooling::Format::NCHW4}, {normalize_enum("NCHW8"), AdaptivePooling::Format::NCHW8}, {normalize_enum("NCHW32"), AdaptivePooling::Format::NCHW32}, {normalize_enum("NCHW88"), AdaptivePooling::Format::NCHW88}, {normalize_enum("NCHW44"), AdaptivePooling::Format::NCHW44}, {normalize_enum("NCHW44_DOT"), AdaptivePooling::Format::NCHW44_DOT}, {normalize_enum("NCHW4_NCHW32"), AdaptivePooling::Format::NCHW4_NCHW32}, {normalize_enum("NCHW32_NCHW4"), AdaptivePooling::Format::NCHW32_NCHW4}, {normalize_enum("NCHW4_NCHW"), AdaptivePooling::Format::NCHW4_NCHW}, {normalize_enum("NHWC_NCHW"), AdaptivePooling::Format::NHWC_NCHW}, {normalize_enum("NHWC_NCHW4_IC_SMALL"), AdaptivePooling::Format::NHWC_NCHW4_IC_SMALL}, {normalize_enum("NCHW_NCHW4_IC_SMALL"), AdaptivePooling::Format::NCHW_NCHW4_IC_SMALL}, {normalize_enum("CHWN4"), AdaptivePooling::Format::CHWN4}, {normalize_enum("NCHW64"), AdaptivePooling::Format::NCHW64}, {normalize_enum("NCHW4_NHWC"), AdaptivePooling::Format::NCHW4_NHWC}};
- template<> PyObject* EnumWrapper<AdaptivePooling::Format>::pyobj_insts[18] = {nullptr};
-
- void _init_py_AdaptivePooling_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<AdaptivePooling::Format>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<AdaptivePooling::Format>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<AdaptivePooling::Format>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<AdaptivePooling::Format>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.AdaptivePooling.Format",
- // basicsize
- sizeof(EnumWrapper<AdaptivePooling::Format>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Format").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("AdaptivePooling.Format").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NCHW;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NHWC;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NHWC", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NHWCD4;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NHWCD4", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[2] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NCHW4;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW4", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[3] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NCHW8;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW8", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[4] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NCHW32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW32", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[5] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NCHW88;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW88", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[6] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NCHW44;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW44", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[7] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NCHW44_DOT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW44_DOT", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[8] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NCHW4_NCHW32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW4_NCHW32", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[9] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NCHW32_NCHW4;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW32_NCHW4", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[10] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NCHW4_NCHW;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW4_NCHW", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[11] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NHWC_NCHW;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NHWC_NCHW", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[12] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NHWC_NCHW4_IC_SMALL;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NHWC_NCHW4_IC_SMALL", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[13] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NCHW_NCHW4_IC_SMALL;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW_NCHW4_IC_SMALL", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[14] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::CHWN4;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "CHWN4", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[15] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NCHW64;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW64", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[16] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<AdaptivePooling::Format>*>(inst)->value = AdaptivePooling::Format::NCHW4_NHWC;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW4_NHWC", inst) >= 0);
- EnumWrapper<AdaptivePooling::Format>::pyobj_insts[17] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(AdaptivePooling) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(AdaptivePooling)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"shape", serialization<decltype(opdef.shape)>::dump(opdef.shape)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(AdaptivePooling)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("shape");
- if (iter != state.end()) {
- opdef.shape = serialization<decltype(opdef.shape)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(AdaptivePooling)
-
- int PyOp(AdaptivePooling)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "format", "shape", "scope", NULL};
- PyObject *mode = NULL, *format = NULL, *shape = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", const_cast<char**>(kwlist), &mode, &format, &shape, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(AdaptivePooling)*>(self)->inst().mode =
- py::cast<decltype(AdaptivePooling::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(AdaptivePooling)*>(self)->inst().format =
- py::cast<decltype(AdaptivePooling::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (shape) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(AdaptivePooling)*>(self)->inst().shape =
- py::cast<decltype(AdaptivePooling::shape)>(py::handle(shape));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(AdaptivePooling)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(AdaptivePooling, mode), py_set_generic(AdaptivePooling, mode), const_cast<char*>("mode"), NULL},
- {const_cast<char*>("format"), py_get_generic(AdaptivePooling, format), py_set_generic(AdaptivePooling, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("shape"), py_get_generic(AdaptivePooling, shape), py_set_generic(AdaptivePooling, shape), const_cast<char*>("shape"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(AdaptivePooling)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(AdaptivePooling)::getstate, METH_NOARGS, "AdaptivePooling getstate"},
- {const_cast<char*>("__setstate__"), PyOp(AdaptivePooling)::setstate, METH_VARARGS, "AdaptivePooling setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_AdaptivePooling(py::module m) {
- using py_op = PyOp(AdaptivePooling);
- auto& py_type = PyOpType(AdaptivePooling);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.AdaptivePooling";
- py_type.tp_basicsize = sizeof(PyOp(AdaptivePooling));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "AdaptivePooling";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_AdaptivePooling_Mode(py_type);
- _init_py_AdaptivePooling_Format(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("AdaptivePooling", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(AdaptivePooling::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(AddAxis) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(AddAxis)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"axis", serialization<decltype(opdef.axis)>::dump(opdef.axis)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(AddAxis)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("axis");
- if (iter != state.end()) {
- opdef.axis = serialization<decltype(opdef.axis)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(AddAxis)
-
- int PyOp(AddAxis)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"axis", "scope", NULL};
- PyObject *axis = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &axis, &scope))
- return -1;
-
- if (axis) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(AddAxis)*>(self)->inst().axis =
- py::cast<decltype(AddAxis::axis)>(py::handle(axis));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(AddAxis)::py_getsetters[] = {
- {const_cast<char*>("axis"), py_get_generic(AddAxis, axis), py_set_generic(AddAxis, axis), const_cast<char*>("axis"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(AddAxis)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(AddAxis)::getstate, METH_NOARGS, "AddAxis getstate"},
- {const_cast<char*>("__setstate__"), PyOp(AddAxis)::setstate, METH_VARARGS, "AddAxis setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_AddAxis(py::module m) {
- using py_op = PyOp(AddAxis);
- auto& py_type = PyOpType(AddAxis);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.AddAxis";
- py_type.tp_basicsize = sizeof(PyOp(AddAxis));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "AddAxis";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("AddAxis", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(AddAxis::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Argmax) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Argmax)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"axis", serialization<decltype(opdef.axis)>::dump(opdef.axis)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Argmax)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("axis");
- if (iter != state.end()) {
- opdef.axis = serialization<decltype(opdef.axis)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Argmax)
-
- int PyOp(Argmax)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"axis", "scope", NULL};
- PyObject *axis = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &axis, &scope))
- return -1;
-
- if (axis) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Argmax)*>(self)->inst().axis =
- py::cast<decltype(Argmax::axis)>(py::handle(axis));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Argmax)::py_getsetters[] = {
- {const_cast<char*>("axis"), py_get_generic(Argmax, axis), py_set_generic(Argmax, axis), const_cast<char*>("axis"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Argmax)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Argmax)::getstate, METH_NOARGS, "Argmax getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Argmax)::setstate, METH_VARARGS, "Argmax setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Argmax(py::module m) {
- using py_op = PyOp(Argmax);
- auto& py_type = PyOpType(Argmax);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Argmax";
- py_type.tp_basicsize = sizeof(PyOp(Argmax));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Argmax";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Argmax", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Argmax::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Argmin) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Argmin)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"axis", serialization<decltype(opdef.axis)>::dump(opdef.axis)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Argmin)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("axis");
- if (iter != state.end()) {
- opdef.axis = serialization<decltype(opdef.axis)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Argmin)
-
- int PyOp(Argmin)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"axis", "scope", NULL};
- PyObject *axis = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &axis, &scope))
- return -1;
-
- if (axis) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Argmin)*>(self)->inst().axis =
- py::cast<decltype(Argmin::axis)>(py::handle(axis));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Argmin)::py_getsetters[] = {
- {const_cast<char*>("axis"), py_get_generic(Argmin, axis), py_set_generic(Argmin, axis), const_cast<char*>("axis"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Argmin)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Argmin)::getstate, METH_NOARGS, "Argmin getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Argmin)::setstate, METH_VARARGS, "Argmin setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Argmin(py::module m) {
- using py_op = PyOp(Argmin);
- auto& py_type = PyOpType(Argmin);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Argmin";
- py_type.tp_basicsize = sizeof(PyOp(Argmin));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Argmin";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Argmin", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Argmin::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<Argsort::Order> {
- static constexpr const char *name = "Argsort.Order";
- static constexpr std::underlying_type_t<Argsort::Order> max = 2 - 1;
- };
- template<> PyTypeObject* EnumWrapper<Argsort::Order>::type = nullptr;
-
- template<> const char*
- EnumWrapper<Argsort::Order>::members[] = {"ASCENDING", "DESCENDING"};
-
- template<> std::unordered_map<std::string, Argsort::Order>
- EnumWrapper<Argsort::Order>::mem2value = {{normalize_enum("ASCENDING"), Argsort::Order::ASCENDING}, {normalize_enum("DESCENDING"), Argsort::Order::DESCENDING}};
- template<> PyObject* EnumWrapper<Argsort::Order>::pyobj_insts[2] = {nullptr};
-
- void _init_py_Argsort_Order(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Argsort::Order>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<Argsort::Order>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<Argsort::Order>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<Argsort::Order>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.Argsort.Order",
- // basicsize
- sizeof(EnumWrapper<Argsort::Order>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Order").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("Argsort.Order").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Argsort::Order>*>(inst)->value = Argsort::Order::ASCENDING;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ASCENDING", inst) >= 0);
- EnumWrapper<Argsort::Order>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Argsort::Order>*>(inst)->value = Argsort::Order::DESCENDING;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "DESCENDING", inst) >= 0);
- EnumWrapper<Argsort::Order>::pyobj_insts[1] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Order", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(Argsort) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Argsort)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"order", serialization<decltype(opdef.order)>::dump(opdef.order)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Argsort)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("order");
- if (iter != state.end()) {
- opdef.order = serialization<decltype(opdef.order)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Argsort)
-
- int PyOp(Argsort)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"order", "scope", NULL};
- PyObject *order = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &order, &scope))
- return -1;
-
- if (order) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Argsort)*>(self)->inst().order =
- py::cast<decltype(Argsort::order)>(py::handle(order));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Argsort)::py_getsetters[] = {
- {const_cast<char*>("order"), py_get_generic(Argsort, order), py_set_generic(Argsort, order), const_cast<char*>("order"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Argsort)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Argsort)::getstate, METH_NOARGS, "Argsort getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Argsort)::setstate, METH_VARARGS, "Argsort setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Argsort(py::module m) {
- using py_op = PyOp(Argsort);
- auto& py_type = PyOpType(Argsort);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Argsort";
- py_type.tp_basicsize = sizeof(PyOp(Argsort));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Argsort";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_Argsort_Order(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("Argsort", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Argsort::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(AssertEqual) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(AssertEqual)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"maxerr", serialization<decltype(opdef.maxerr)>::dump(opdef.maxerr)},
- {"verbose", serialization<decltype(opdef.verbose)>::dump(opdef.verbose)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(AssertEqual)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("maxerr");
- if (iter != state.end()) {
- opdef.maxerr = serialization<decltype(opdef.maxerr)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("verbose");
- if (iter != state.end()) {
- opdef.verbose = serialization<decltype(opdef.verbose)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(AssertEqual)
-
- int PyOp(AssertEqual)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"maxerr", "verbose", "scope", NULL};
- PyObject *maxerr = NULL, *verbose = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &maxerr, &verbose, &scope))
- return -1;
-
- if (maxerr) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(AssertEqual)*>(self)->inst().maxerr =
- py::cast<decltype(AssertEqual::maxerr)>(py::handle(maxerr));
- } CATCH_ALL(-1)
- }
-
- if (verbose) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(AssertEqual)*>(self)->inst().verbose =
- py::cast<decltype(AssertEqual::verbose)>(py::handle(verbose));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(AssertEqual)::py_getsetters[] = {
- {const_cast<char*>("maxerr"), py_get_generic(AssertEqual, maxerr), py_set_generic(AssertEqual, maxerr), const_cast<char*>("maxerr"), NULL},
- {const_cast<char*>("verbose"), py_get_generic(AssertEqual, verbose), py_set_generic(AssertEqual, verbose), const_cast<char*>("verbose"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(AssertEqual)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(AssertEqual)::getstate, METH_NOARGS, "AssertEqual getstate"},
- {const_cast<char*>("__setstate__"), PyOp(AssertEqual)::setstate, METH_VARARGS, "AssertEqual setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_AssertEqual(py::module m) {
- using py_op = PyOp(AssertEqual);
- auto& py_type = PyOpType(AssertEqual);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.AssertEqual";
- py_type.tp_basicsize = sizeof(PyOp(AssertEqual));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "AssertEqual";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("AssertEqual", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(AssertEqual::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(AtlasRuntime) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(AtlasRuntime)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"buf", serialization<decltype(opdef.buf)>::dump(opdef.buf)},
- {"buf_size", serialization<decltype(opdef.buf_size)>::dump(opdef.buf_size)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(AtlasRuntime)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("buf");
- if (iter != state.end()) {
- opdef.buf = serialization<decltype(opdef.buf)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("buf_size");
- if (iter != state.end()) {
- opdef.buf_size = serialization<decltype(opdef.buf_size)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(AtlasRuntime)
-
- int PyOp(AtlasRuntime)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"buf", "buf_size", "scope", NULL};
- PyObject *buf = NULL, *buf_size = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &buf, &buf_size, &scope))
- return -1;
-
- if (buf) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(AtlasRuntime)*>(self)->inst().buf =
- py::cast<decltype(AtlasRuntime::buf)>(py::handle(buf));
- } CATCH_ALL(-1)
- }
-
- if (buf_size) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(AtlasRuntime)*>(self)->inst().buf_size =
- py::cast<decltype(AtlasRuntime::buf_size)>(py::handle(buf_size));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(AtlasRuntime)::py_getsetters[] = {
- {const_cast<char*>("buf"), py_get_generic(AtlasRuntime, buf), py_set_generic(AtlasRuntime, buf), const_cast<char*>("buf"), NULL},
- {const_cast<char*>("buf_size"), py_get_generic(AtlasRuntime, buf_size), py_set_generic(AtlasRuntime, buf_size), const_cast<char*>("buf_size"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(AtlasRuntime)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(AtlasRuntime)::getstate, METH_NOARGS, "AtlasRuntime getstate"},
- {const_cast<char*>("__setstate__"), PyOp(AtlasRuntime)::setstate, METH_VARARGS, "AtlasRuntime setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_AtlasRuntime(py::module m) {
- using py_op = PyOp(AtlasRuntime);
- auto& py_type = PyOpType(AtlasRuntime);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.AtlasRuntime";
- py_type.tp_basicsize = sizeof(PyOp(AtlasRuntime));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "AtlasRuntime";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("AtlasRuntime", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(AtlasRuntime::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Barrier) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Barrier)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"comp_node", serialization<decltype(opdef.comp_node)>::dump(opdef.comp_node)},
- {"nr_outputs", serialization<decltype(opdef.nr_outputs)>::dump(opdef.nr_outputs)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Barrier)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("comp_node");
- if (iter != state.end()) {
- opdef.comp_node = serialization<decltype(opdef.comp_node)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("nr_outputs");
- if (iter != state.end()) {
- opdef.nr_outputs = serialization<decltype(opdef.nr_outputs)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Barrier)
-
- int PyOp(Barrier)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"comp_node", "nr_outputs", "scope", NULL};
- PyObject *comp_node = NULL, *nr_outputs = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &comp_node, &nr_outputs, &scope))
- return -1;
-
- if (comp_node) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Barrier)*>(self)->inst().comp_node =
- py::cast<decltype(Barrier::comp_node)>(py::handle(comp_node));
- } CATCH_ALL(-1)
- }
-
- if (nr_outputs) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Barrier)*>(self)->inst().nr_outputs =
- py::cast<decltype(Barrier::nr_outputs)>(py::handle(nr_outputs));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Barrier)::py_getsetters[] = {
- {const_cast<char*>("comp_node"), py_get_generic(Barrier, comp_node), py_set_generic(Barrier, comp_node), const_cast<char*>("comp_node"), NULL},
- {const_cast<char*>("nr_outputs"), py_get_generic(Barrier, nr_outputs), py_set_generic(Barrier, nr_outputs), const_cast<char*>("nr_outputs"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Barrier)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Barrier)::getstate, METH_NOARGS, "Barrier getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Barrier)::setstate, METH_VARARGS, "Barrier setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Barrier(py::module m) {
- using py_op = PyOp(Barrier);
- auto& py_type = PyOpType(Barrier);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Barrier";
- py_type.tp_basicsize = sizeof(PyOp(Barrier));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Barrier";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Barrier", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Barrier::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<BatchConvBias::NonlineMode> {
- static constexpr const char *name = "BatchConvBias.NonlineMode";
- static constexpr std::underlying_type_t<BatchConvBias::NonlineMode> max = 4 - 1;
- };
- template<> PyTypeObject* EnumWrapper<BatchConvBias::NonlineMode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<BatchConvBias::NonlineMode>::members[] = {"IDENTITY", "RELU", "SIGMOID", "H_SWISH"};
-
- template<> std::unordered_map<std::string, BatchConvBias::NonlineMode>
- EnumWrapper<BatchConvBias::NonlineMode>::mem2value = {{normalize_enum("IDENTITY"), BatchConvBias::NonlineMode::IDENTITY}, {normalize_enum("RELU"), BatchConvBias::NonlineMode::RELU}, {normalize_enum("SIGMOID"), BatchConvBias::NonlineMode::SIGMOID}, {normalize_enum("H_SWISH"), BatchConvBias::NonlineMode::H_SWISH}};
- template<> PyObject* EnumWrapper<BatchConvBias::NonlineMode>::pyobj_insts[4] = {nullptr};
-
- void _init_py_BatchConvBias_NonlineMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<BatchConvBias::NonlineMode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<BatchConvBias::NonlineMode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<BatchConvBias::NonlineMode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<BatchConvBias::NonlineMode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.BatchConvBias.NonlineMode",
- // basicsize
- sizeof(EnumWrapper<BatchConvBias::NonlineMode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("NonlineMode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("BatchConvBias.NonlineMode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchConvBias::NonlineMode>*>(inst)->value = BatchConvBias::NonlineMode::IDENTITY;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "IDENTITY", inst) >= 0);
- EnumWrapper<BatchConvBias::NonlineMode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchConvBias::NonlineMode>*>(inst)->value = BatchConvBias::NonlineMode::RELU;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "RELU", inst) >= 0);
- EnumWrapper<BatchConvBias::NonlineMode>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchConvBias::NonlineMode>*>(inst)->value = BatchConvBias::NonlineMode::SIGMOID;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "SIGMOID", inst) >= 0);
- EnumWrapper<BatchConvBias::NonlineMode>::pyobj_insts[2] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchConvBias::NonlineMode>*>(inst)->value = BatchConvBias::NonlineMode::H_SWISH;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "H_SWISH", inst) >= 0);
- EnumWrapper<BatchConvBias::NonlineMode>::pyobj_insts[3] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "NonlineMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- template<> struct EnumTrait<BatchConvBias::Mode> {
- static constexpr const char *name = "BatchConvBias.Mode";
- static constexpr std::underlying_type_t<BatchConvBias::Mode> max = 2 - 1;
- };
- template<> PyTypeObject* EnumWrapper<BatchConvBias::Mode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<BatchConvBias::Mode>::members[] = {"CROSS_CORRELATION", "CONVOLUTION"};
-
- template<> std::unordered_map<std::string, BatchConvBias::Mode>
- EnumWrapper<BatchConvBias::Mode>::mem2value = {{normalize_enum("CROSS_CORRELATION"), BatchConvBias::Mode::CROSS_CORRELATION}, {normalize_enum("CONVOLUTION"), BatchConvBias::Mode::CONVOLUTION}};
- template<> PyObject* EnumWrapper<BatchConvBias::Mode>::pyobj_insts[2] = {nullptr};
-
- void _init_py_BatchConvBias_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<BatchConvBias::Mode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<BatchConvBias::Mode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<BatchConvBias::Mode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<BatchConvBias::Mode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.BatchConvBias.Mode",
- // basicsize
- sizeof(EnumWrapper<BatchConvBias::Mode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Mode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("BatchConvBias.Mode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchConvBias::Mode>*>(inst)->value = BatchConvBias::Mode::CROSS_CORRELATION;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "CROSS_CORRELATION", inst) >= 0);
- EnumWrapper<BatchConvBias::Mode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchConvBias::Mode>*>(inst)->value = BatchConvBias::Mode::CONVOLUTION;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "CONVOLUTION", inst) >= 0);
- EnumWrapper<BatchConvBias::Mode>::pyobj_insts[1] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- template<> struct EnumTrait<BatchConvBias::Sparse> {
- static constexpr const char *name = "BatchConvBias.Sparse";
- static constexpr std::underlying_type_t<BatchConvBias::Sparse> max = 2 - 1;
- };
- template<> PyTypeObject* EnumWrapper<BatchConvBias::Sparse>::type = nullptr;
-
- template<> const char*
- EnumWrapper<BatchConvBias::Sparse>::members[] = {"DENSE", "GROUP"};
-
- template<> std::unordered_map<std::string, BatchConvBias::Sparse>
- EnumWrapper<BatchConvBias::Sparse>::mem2value = {{normalize_enum("DENSE"), BatchConvBias::Sparse::DENSE}, {normalize_enum("GROUP"), BatchConvBias::Sparse::GROUP}};
- template<> PyObject* EnumWrapper<BatchConvBias::Sparse>::pyobj_insts[2] = {nullptr};
-
- void _init_py_BatchConvBias_Sparse(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<BatchConvBias::Sparse>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<BatchConvBias::Sparse>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<BatchConvBias::Sparse>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<BatchConvBias::Sparse>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.BatchConvBias.Sparse",
- // basicsize
- sizeof(EnumWrapper<BatchConvBias::Sparse>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Sparse").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("BatchConvBias.Sparse").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchConvBias::Sparse>*>(inst)->value = BatchConvBias::Sparse::DENSE;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "DENSE", inst) >= 0);
- EnumWrapper<BatchConvBias::Sparse>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchConvBias::Sparse>*>(inst)->value = BatchConvBias::Sparse::GROUP;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "GROUP", inst) >= 0);
- EnumWrapper<BatchConvBias::Sparse>::pyobj_insts[1] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Sparse", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_BatchConvBias_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<BatchConvBias::Format>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- template<> struct EnumTrait<BatchConvBias::ComputeMode> {
- static constexpr const char *name = "BatchConvBias.ComputeMode";
- static constexpr std::underlying_type_t<BatchConvBias::ComputeMode> max = 2 - 1;
- };
- template<> PyTypeObject* EnumWrapper<BatchConvBias::ComputeMode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<BatchConvBias::ComputeMode>::members[] = {"DEFAULT", "FLOAT32"};
-
- template<> std::unordered_map<std::string, BatchConvBias::ComputeMode>
- EnumWrapper<BatchConvBias::ComputeMode>::mem2value = {{normalize_enum("DEFAULT"), BatchConvBias::ComputeMode::DEFAULT}, {normalize_enum("FLOAT32"), BatchConvBias::ComputeMode::FLOAT32}};
- template<> PyObject* EnumWrapper<BatchConvBias::ComputeMode>::pyobj_insts[2] = {nullptr};
-
- void _init_py_BatchConvBias_ComputeMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<BatchConvBias::ComputeMode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<BatchConvBias::ComputeMode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<BatchConvBias::ComputeMode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<BatchConvBias::ComputeMode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.BatchConvBias.ComputeMode",
- // basicsize
- sizeof(EnumWrapper<BatchConvBias::ComputeMode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("ComputeMode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("BatchConvBias.ComputeMode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchConvBias::ComputeMode>*>(inst)->value = BatchConvBias::ComputeMode::DEFAULT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "DEFAULT", inst) >= 0);
- EnumWrapper<BatchConvBias::ComputeMode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchConvBias::ComputeMode>*>(inst)->value = BatchConvBias::ComputeMode::FLOAT32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FLOAT32", inst) >= 0);
- EnumWrapper<BatchConvBias::ComputeMode>::pyobj_insts[1] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "ComputeMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- template<> struct EnumTrait<BatchConvBias::Strategy> {
- static constexpr const char *name = "BatchConvBias.Strategy";
- static constexpr std::underlying_type_t<BatchConvBias::Strategy> max = (1llu << 4) - 1;
- };
- template<> PyTypeObject* BitCombinedEnumWrapper<BatchConvBias::Strategy>::type = nullptr;
-
- template<> const char*
- BitCombinedEnumWrapper<BatchConvBias::Strategy>::members[] = {"HEURISTIC", "PROFILE", "REPRODUCIBLE", "OPTIMIZED"};
-
- template<> std::unordered_map<std::string, BatchConvBias::Strategy>
- BitCombinedEnumWrapper<BatchConvBias::Strategy>::mem2value = {{normalize_enum("HEURISTIC"), BatchConvBias::Strategy::HEURISTIC}, {normalize_enum("PROFILE"), BatchConvBias::Strategy::PROFILE}, {normalize_enum("REPRODUCIBLE"), BatchConvBias::Strategy::REPRODUCIBLE}, {normalize_enum("OPTIMIZED"), BatchConvBias::Strategy::OPTIMIZED}};
- template<> PyObject* BitCombinedEnumWrapper<BatchConvBias::Strategy>::pyobj_insts[4] = {nullptr};
-
- void _init_py_BatchConvBias_Strategy(PyTypeObject& py_type) {
- auto& e_type = BitCombinedEnumWrapper<BatchConvBias::Strategy>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)BitCombinedEnumWrapper<BatchConvBias::Strategy>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)BitCombinedEnumWrapper<BatchConvBias::Strategy>::py_repr},
- {Py_tp_richcompare, (void*)BitCombinedEnumWrapper<BatchConvBias::Strategy>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {Py_tp_new, (void*)BitCombinedEnumWrapper<BatchConvBias::Strategy>::py_new_combined_enum},
- {Py_nb_or, (void*)BitCombinedEnumWrapper<BatchConvBias::Strategy>::py_or},
- {Py_nb_and, (void*)BitCombinedEnumWrapper<BatchConvBias::Strategy>::py_and},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.BatchConvBias.Strategy",
- // basicsize
- sizeof(BitCombinedEnumWrapper<BatchConvBias::Strategy>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Strategy").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("BatchConvBias.Strategy").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<BitCombinedEnumWrapper<BatchConvBias::Strategy>*>(inst)->value = BatchConvBias::Strategy::HEURISTIC;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "HEURISTIC", inst) >= 0);
- BitCombinedEnumWrapper<BatchConvBias::Strategy>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<BitCombinedEnumWrapper<BatchConvBias::Strategy>*>(inst)->value = BatchConvBias::Strategy::PROFILE;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "PROFILE", inst) >= 0);
- BitCombinedEnumWrapper<BatchConvBias::Strategy>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<BitCombinedEnumWrapper<BatchConvBias::Strategy>*>(inst)->value = BatchConvBias::Strategy::REPRODUCIBLE;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "REPRODUCIBLE", inst) >= 0);
- BitCombinedEnumWrapper<BatchConvBias::Strategy>::pyobj_insts[2] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<BitCombinedEnumWrapper<BatchConvBias::Strategy>*>(inst)->value = BatchConvBias::Strategy::OPTIMIZED;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "OPTIMIZED", inst) >= 0);
- BitCombinedEnumWrapper<BatchConvBias::Strategy>::pyobj_insts[3] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Strategy", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(BatchConvBias) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"nonlineMode", serialization<decltype(opdef.nonlineMode)>::dump(opdef.nonlineMode)},
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)},
- {"pad_h", serialization<decltype(opdef.pad_h)>::dump(opdef.pad_h)},
- {"pad_w", serialization<decltype(opdef.pad_w)>::dump(opdef.pad_w)},
- {"stride_h", serialization<decltype(opdef.stride_h)>::dump(opdef.stride_h)},
- {"stride_w", serialization<decltype(opdef.stride_w)>::dump(opdef.stride_w)},
- {"dilate_h", serialization<decltype(opdef.dilate_h)>::dump(opdef.dilate_h)},
- {"dilate_w", serialization<decltype(opdef.dilate_w)>::dump(opdef.dilate_w)},
- {"sparse", serialization<decltype(opdef.sparse)>::dump(opdef.sparse)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"compute_mode", serialization<decltype(opdef.compute_mode)>::dump(opdef.compute_mode)},
- {"strategy", serialization<decltype(opdef.strategy)>::dump(opdef.strategy)},
- {"workspace_limit", serialization<decltype(opdef.workspace_limit)>::dump(opdef.workspace_limit)},
- {"dtype", serialization<decltype(opdef.dtype)>::dump(opdef.dtype)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("nonlineMode");
- if (iter != state.end()) {
- opdef.nonlineMode = serialization<decltype(opdef.nonlineMode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_h");
- if (iter != state.end()) {
- opdef.pad_h = serialization<decltype(opdef.pad_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_w");
- if (iter != state.end()) {
- opdef.pad_w = serialization<decltype(opdef.pad_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_h");
- if (iter != state.end()) {
- opdef.stride_h = serialization<decltype(opdef.stride_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_w");
- if (iter != state.end()) {
- opdef.stride_w = serialization<decltype(opdef.stride_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_h");
- if (iter != state.end()) {
- opdef.dilate_h = serialization<decltype(opdef.dilate_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_w");
- if (iter != state.end()) {
- opdef.dilate_w = serialization<decltype(opdef.dilate_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("sparse");
- if (iter != state.end()) {
- opdef.sparse = serialization<decltype(opdef.sparse)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("compute_mode");
- if (iter != state.end()) {
- opdef.compute_mode = serialization<decltype(opdef.compute_mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("strategy");
- if (iter != state.end()) {
- opdef.strategy = serialization<decltype(opdef.strategy)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("workspace_limit");
- if (iter != state.end()) {
- opdef.workspace_limit = serialization<decltype(opdef.workspace_limit)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dtype");
- if (iter != state.end()) {
- opdef.dtype = serialization<decltype(opdef.dtype)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(BatchConvBias)
-
- int PyOp(BatchConvBias)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"nonlineMode", "mode", "pad_h", "pad_w", "stride_h", "stride_w", "dilate_h", "dilate_w", "sparse", "format", "compute_mode", "strategy", "workspace_limit", "dtype", "scope", NULL};
- PyObject *nonlineMode = NULL, *mode = NULL, *pad_h = NULL, *pad_w = NULL, *stride_h = NULL, *stride_w = NULL, *dilate_h = NULL, *dilate_w = NULL, *sparse = NULL, *format = NULL, *compute_mode = NULL, *strategy = NULL, *workspace_limit = NULL, *dtype = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOOOOOOOO", const_cast<char**>(kwlist), &nonlineMode, &mode, &pad_h, &pad_w, &stride_h, &stride_w, &dilate_h, &dilate_w, &sparse, &format, &compute_mode, &strategy, &workspace_limit, &dtype, &scope))
- return -1;
-
- if (nonlineMode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst().nonlineMode =
- py::cast<decltype(BatchConvBias::nonlineMode)>(py::handle(nonlineMode));
- } CATCH_ALL(-1)
- }
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst().mode =
- py::cast<decltype(BatchConvBias::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (pad_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst().pad_h =
- py::cast<decltype(BatchConvBias::pad_h)>(py::handle(pad_h));
- } CATCH_ALL(-1)
- }
-
- if (pad_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst().pad_w =
- py::cast<decltype(BatchConvBias::pad_w)>(py::handle(pad_w));
- } CATCH_ALL(-1)
- }
-
- if (stride_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst().stride_h =
- py::cast<decltype(BatchConvBias::stride_h)>(py::handle(stride_h));
- } CATCH_ALL(-1)
- }
-
- if (stride_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst().stride_w =
- py::cast<decltype(BatchConvBias::stride_w)>(py::handle(stride_w));
- } CATCH_ALL(-1)
- }
-
- if (dilate_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst().dilate_h =
- py::cast<decltype(BatchConvBias::dilate_h)>(py::handle(dilate_h));
- } CATCH_ALL(-1)
- }
-
- if (dilate_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst().dilate_w =
- py::cast<decltype(BatchConvBias::dilate_w)>(py::handle(dilate_w));
- } CATCH_ALL(-1)
- }
-
- if (sparse) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst().sparse =
- py::cast<decltype(BatchConvBias::sparse)>(py::handle(sparse));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst().format =
- py::cast<decltype(BatchConvBias::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (compute_mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst().compute_mode =
- py::cast<decltype(BatchConvBias::compute_mode)>(py::handle(compute_mode));
- } CATCH_ALL(-1)
- }
-
- if (strategy) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst().strategy =
- py::cast<decltype(BatchConvBias::strategy)>(py::handle(strategy));
- } CATCH_ALL(-1)
- }
-
- if (workspace_limit) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst().workspace_limit =
- py::cast<decltype(BatchConvBias::workspace_limit)>(py::handle(workspace_limit));
- } CATCH_ALL(-1)
- }
-
- if (dtype) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchConvBias)*>(self)->inst().dtype =
- py::cast<decltype(BatchConvBias::dtype)>(py::handle(dtype));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(BatchConvBias)::py_getsetters[] = {
- {const_cast<char*>("nonlineMode"), py_get_generic(BatchConvBias, nonlineMode), py_set_generic(BatchConvBias, nonlineMode), const_cast<char*>("nonlineMode"), NULL},
- {const_cast<char*>("mode"), py_get_generic(BatchConvBias, mode), py_set_generic(BatchConvBias, mode), const_cast<char*>("mode"), NULL},
- {const_cast<char*>("pad_h"), py_get_generic(BatchConvBias, pad_h), py_set_generic(BatchConvBias, pad_h), const_cast<char*>("pad_h"), NULL},
- {const_cast<char*>("pad_w"), py_get_generic(BatchConvBias, pad_w), py_set_generic(BatchConvBias, pad_w), const_cast<char*>("pad_w"), NULL},
- {const_cast<char*>("stride_h"), py_get_generic(BatchConvBias, stride_h), py_set_generic(BatchConvBias, stride_h), const_cast<char*>("stride_h"), NULL},
- {const_cast<char*>("stride_w"), py_get_generic(BatchConvBias, stride_w), py_set_generic(BatchConvBias, stride_w), const_cast<char*>("stride_w"), NULL},
- {const_cast<char*>("dilate_h"), py_get_generic(BatchConvBias, dilate_h), py_set_generic(BatchConvBias, dilate_h), const_cast<char*>("dilate_h"), NULL},
- {const_cast<char*>("dilate_w"), py_get_generic(BatchConvBias, dilate_w), py_set_generic(BatchConvBias, dilate_w), const_cast<char*>("dilate_w"), NULL},
- {const_cast<char*>("sparse"), py_get_generic(BatchConvBias, sparse), py_set_generic(BatchConvBias, sparse), const_cast<char*>("sparse"), NULL},
- {const_cast<char*>("format"), py_get_generic(BatchConvBias, format), py_set_generic(BatchConvBias, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("compute_mode"), py_get_generic(BatchConvBias, compute_mode), py_set_generic(BatchConvBias, compute_mode), const_cast<char*>("compute_mode"), NULL},
- {const_cast<char*>("strategy"), py_get_generic(BatchConvBias, strategy), py_set_generic(BatchConvBias, strategy), const_cast<char*>("strategy"), NULL},
- {const_cast<char*>("workspace_limit"), py_get_generic(BatchConvBias, workspace_limit), py_set_generic(BatchConvBias, workspace_limit), const_cast<char*>("workspace_limit"), NULL},
- {const_cast<char*>("dtype"), py_get_generic(BatchConvBias, dtype), py_set_generic(BatchConvBias, dtype), const_cast<char*>("dtype"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(BatchConvBias)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(BatchConvBias)::getstate, METH_NOARGS, "BatchConvBias getstate"},
- {const_cast<char*>("__setstate__"), PyOp(BatchConvBias)::setstate, METH_VARARGS, "BatchConvBias setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_BatchConvBias(py::module m) {
- using py_op = PyOp(BatchConvBias);
- auto& py_type = PyOpType(BatchConvBias);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.BatchConvBias";
- py_type.tp_basicsize = sizeof(PyOp(BatchConvBias));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "BatchConvBias";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_BatchConvBias_NonlineMode(py_type);
- _init_py_BatchConvBias_Mode(py_type);
- _init_py_BatchConvBias_Sparse(py_type);
- _init_py_BatchConvBias_Format(py_type);
- _init_py_BatchConvBias_ComputeMode(py_type);
- _init_py_BatchConvBias_Strategy(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("BatchConvBias", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(BatchConvBias::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<BatchNorm::ParamDim> {
- static constexpr const char *name = "BatchNorm.ParamDim";
- static constexpr std::underlying_type_t<BatchNorm::ParamDim> max = 4 - 1;
- };
- template<> PyTypeObject* EnumWrapper<BatchNorm::ParamDim>::type = nullptr;
-
- template<> const char*
- EnumWrapper<BatchNorm::ParamDim>::members[] = {"DIM_11HW", "DIM_1CHW", "DIM_1C11", "DIM_111C"};
-
- template<> std::unordered_map<std::string, BatchNorm::ParamDim>
- EnumWrapper<BatchNorm::ParamDim>::mem2value = {{normalize_enum("DIM_11HW"), BatchNorm::ParamDim::DIM_11HW}, {normalize_enum("DIM_1CHW"), BatchNorm::ParamDim::DIM_1CHW}, {normalize_enum("DIM_1C11"), BatchNorm::ParamDim::DIM_1C11}, {normalize_enum("DIM_111C"), BatchNorm::ParamDim::DIM_111C}};
- template<> PyObject* EnumWrapper<BatchNorm::ParamDim>::pyobj_insts[4] = {nullptr};
-
- void _init_py_BatchNorm_ParamDim(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<BatchNorm::ParamDim>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<BatchNorm::ParamDim>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<BatchNorm::ParamDim>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<BatchNorm::ParamDim>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.BatchNorm.ParamDim",
- // basicsize
- sizeof(EnumWrapper<BatchNorm::ParamDim>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("ParamDim").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("BatchNorm.ParamDim").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchNorm::ParamDim>*>(inst)->value = BatchNorm::ParamDim::DIM_11HW;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "DIM_11HW", inst) >= 0);
- EnumWrapper<BatchNorm::ParamDim>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchNorm::ParamDim>*>(inst)->value = BatchNorm::ParamDim::DIM_1CHW;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "DIM_1CHW", inst) >= 0);
- EnumWrapper<BatchNorm::ParamDim>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchNorm::ParamDim>*>(inst)->value = BatchNorm::ParamDim::DIM_1C11;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "DIM_1C11", inst) >= 0);
- EnumWrapper<BatchNorm::ParamDim>::pyobj_insts[2] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchNorm::ParamDim>*>(inst)->value = BatchNorm::ParamDim::DIM_111C;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "DIM_111C", inst) >= 0);
- EnumWrapper<BatchNorm::ParamDim>::pyobj_insts[3] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "ParamDim", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- template<> struct EnumTrait<BatchNorm::FwdMode> {
- static constexpr const char *name = "BatchNorm.FwdMode";
- static constexpr std::underlying_type_t<BatchNorm::FwdMode> max = 2 - 1;
- };
- template<> PyTypeObject* EnumWrapper<BatchNorm::FwdMode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<BatchNorm::FwdMode>::members[] = {"TRAINING", "INFERENCE"};
-
- template<> std::unordered_map<std::string, BatchNorm::FwdMode>
- EnumWrapper<BatchNorm::FwdMode>::mem2value = {{normalize_enum("TRAINING"), BatchNorm::FwdMode::TRAINING}, {normalize_enum("INFERENCE"), BatchNorm::FwdMode::INFERENCE}};
- template<> PyObject* EnumWrapper<BatchNorm::FwdMode>::pyobj_insts[2] = {nullptr};
-
- void _init_py_BatchNorm_FwdMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<BatchNorm::FwdMode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<BatchNorm::FwdMode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<BatchNorm::FwdMode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<BatchNorm::FwdMode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.BatchNorm.FwdMode",
- // basicsize
- sizeof(EnumWrapper<BatchNorm::FwdMode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("FwdMode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("BatchNorm.FwdMode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchNorm::FwdMode>*>(inst)->value = BatchNorm::FwdMode::TRAINING;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "TRAINING", inst) >= 0);
- EnumWrapper<BatchNorm::FwdMode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchNorm::FwdMode>*>(inst)->value = BatchNorm::FwdMode::INFERENCE;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "INFERENCE", inst) >= 0);
- EnumWrapper<BatchNorm::FwdMode>::pyobj_insts[1] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "FwdMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(BatchNorm) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(BatchNorm)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"param_dim", serialization<decltype(opdef.param_dim)>::dump(opdef.param_dim)},
- {"fwd_mode", serialization<decltype(opdef.fwd_mode)>::dump(opdef.fwd_mode)},
- {"epsilon", serialization<decltype(opdef.epsilon)>::dump(opdef.epsilon)},
- {"avg_factor", serialization<decltype(opdef.avg_factor)>::dump(opdef.avg_factor)},
- {"scale", serialization<decltype(opdef.scale)>::dump(opdef.scale)},
- {"bias", serialization<decltype(opdef.bias)>::dump(opdef.bias)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(BatchNorm)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("param_dim");
- if (iter != state.end()) {
- opdef.param_dim = serialization<decltype(opdef.param_dim)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("fwd_mode");
- if (iter != state.end()) {
- opdef.fwd_mode = serialization<decltype(opdef.fwd_mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("epsilon");
- if (iter != state.end()) {
- opdef.epsilon = serialization<decltype(opdef.epsilon)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("avg_factor");
- if (iter != state.end()) {
- opdef.avg_factor = serialization<decltype(opdef.avg_factor)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("scale");
- if (iter != state.end()) {
- opdef.scale = serialization<decltype(opdef.scale)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("bias");
- if (iter != state.end()) {
- opdef.bias = serialization<decltype(opdef.bias)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(BatchNorm)
-
- int PyOp(BatchNorm)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"param_dim", "fwd_mode", "epsilon", "avg_factor", "scale", "bias", "scope", NULL};
- PyObject *param_dim = NULL, *fwd_mode = NULL, *epsilon = NULL, *avg_factor = NULL, *scale = NULL, *bias = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOO", const_cast<char**>(kwlist), ¶m_dim, &fwd_mode, &epsilon, &avg_factor, &scale, &bias, &scope))
- return -1;
-
- if (param_dim) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchNorm)*>(self)->inst().param_dim =
- py::cast<decltype(BatchNorm::param_dim)>(py::handle(param_dim));
- } CATCH_ALL(-1)
- }
-
- if (fwd_mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchNorm)*>(self)->inst().fwd_mode =
- py::cast<decltype(BatchNorm::fwd_mode)>(py::handle(fwd_mode));
- } CATCH_ALL(-1)
- }
-
- if (epsilon) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchNorm)*>(self)->inst().epsilon =
- py::cast<decltype(BatchNorm::epsilon)>(py::handle(epsilon));
- } CATCH_ALL(-1)
- }
-
- if (avg_factor) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchNorm)*>(self)->inst().avg_factor =
- py::cast<decltype(BatchNorm::avg_factor)>(py::handle(avg_factor));
- } CATCH_ALL(-1)
- }
-
- if (scale) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchNorm)*>(self)->inst().scale =
- py::cast<decltype(BatchNorm::scale)>(py::handle(scale));
- } CATCH_ALL(-1)
- }
-
- if (bias) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchNorm)*>(self)->inst().bias =
- py::cast<decltype(BatchNorm::bias)>(py::handle(bias));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(BatchNorm)::py_getsetters[] = {
- {const_cast<char*>("param_dim"), py_get_generic(BatchNorm, param_dim), py_set_generic(BatchNorm, param_dim), const_cast<char*>("param_dim"), NULL},
- {const_cast<char*>("fwd_mode"), py_get_generic(BatchNorm, fwd_mode), py_set_generic(BatchNorm, fwd_mode), const_cast<char*>("fwd_mode"), NULL},
- {const_cast<char*>("epsilon"), py_get_generic(BatchNorm, epsilon), py_set_generic(BatchNorm, epsilon), const_cast<char*>("epsilon"), NULL},
- {const_cast<char*>("avg_factor"), py_get_generic(BatchNorm, avg_factor), py_set_generic(BatchNorm, avg_factor), const_cast<char*>("avg_factor"), NULL},
- {const_cast<char*>("scale"), py_get_generic(BatchNorm, scale), py_set_generic(BatchNorm, scale), const_cast<char*>("scale"), NULL},
- {const_cast<char*>("bias"), py_get_generic(BatchNorm, bias), py_set_generic(BatchNorm, bias), const_cast<char*>("bias"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(BatchNorm)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(BatchNorm)::getstate, METH_NOARGS, "BatchNorm getstate"},
- {const_cast<char*>("__setstate__"), PyOp(BatchNorm)::setstate, METH_VARARGS, "BatchNorm setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_BatchNorm(py::module m) {
- using py_op = PyOp(BatchNorm);
- auto& py_type = PyOpType(BatchNorm);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.BatchNorm";
- py_type.tp_basicsize = sizeof(PyOp(BatchNorm));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "BatchNorm";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_BatchNorm_ParamDim(py_type);
- _init_py_BatchNorm_FwdMode(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("BatchNorm", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(BatchNorm::typeinfo(), &py_type).second);
- }
-
- void _init_py_BatchNormBackward_ParamDim(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<BatchNormBackward::ParamDim>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "ParamDim", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_BatchNormBackward_FwdMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<BatchNormBackward::FwdMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "FwdMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(BatchNormBackward) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(BatchNormBackward)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"param_dim", serialization<decltype(opdef.param_dim)>::dump(opdef.param_dim)},
- {"fwd_mode", serialization<decltype(opdef.fwd_mode)>::dump(opdef.fwd_mode)},
- {"epsilon", serialization<decltype(opdef.epsilon)>::dump(opdef.epsilon)},
- {"avg_factor", serialization<decltype(opdef.avg_factor)>::dump(opdef.avg_factor)},
- {"scale", serialization<decltype(opdef.scale)>::dump(opdef.scale)},
- {"bias", serialization<decltype(opdef.bias)>::dump(opdef.bias)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(BatchNormBackward)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("param_dim");
- if (iter != state.end()) {
- opdef.param_dim = serialization<decltype(opdef.param_dim)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("fwd_mode");
- if (iter != state.end()) {
- opdef.fwd_mode = serialization<decltype(opdef.fwd_mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("epsilon");
- if (iter != state.end()) {
- opdef.epsilon = serialization<decltype(opdef.epsilon)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("avg_factor");
- if (iter != state.end()) {
- opdef.avg_factor = serialization<decltype(opdef.avg_factor)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("scale");
- if (iter != state.end()) {
- opdef.scale = serialization<decltype(opdef.scale)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("bias");
- if (iter != state.end()) {
- opdef.bias = serialization<decltype(opdef.bias)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(BatchNormBackward)
-
- int PyOp(BatchNormBackward)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"param_dim", "fwd_mode", "epsilon", "avg_factor", "scale", "bias", "scope", NULL};
- PyObject *param_dim = NULL, *fwd_mode = NULL, *epsilon = NULL, *avg_factor = NULL, *scale = NULL, *bias = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOO", const_cast<char**>(kwlist), ¶m_dim, &fwd_mode, &epsilon, &avg_factor, &scale, &bias, &scope))
- return -1;
-
- if (param_dim) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchNormBackward)*>(self)->inst().param_dim =
- py::cast<decltype(BatchNormBackward::param_dim)>(py::handle(param_dim));
- } CATCH_ALL(-1)
- }
-
- if (fwd_mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchNormBackward)*>(self)->inst().fwd_mode =
- py::cast<decltype(BatchNormBackward::fwd_mode)>(py::handle(fwd_mode));
- } CATCH_ALL(-1)
- }
-
- if (epsilon) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchNormBackward)*>(self)->inst().epsilon =
- py::cast<decltype(BatchNormBackward::epsilon)>(py::handle(epsilon));
- } CATCH_ALL(-1)
- }
-
- if (avg_factor) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchNormBackward)*>(self)->inst().avg_factor =
- py::cast<decltype(BatchNormBackward::avg_factor)>(py::handle(avg_factor));
- } CATCH_ALL(-1)
- }
-
- if (scale) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchNormBackward)*>(self)->inst().scale =
- py::cast<decltype(BatchNormBackward::scale)>(py::handle(scale));
- } CATCH_ALL(-1)
- }
-
- if (bias) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchNormBackward)*>(self)->inst().bias =
- py::cast<decltype(BatchNormBackward::bias)>(py::handle(bias));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(BatchNormBackward)::py_getsetters[] = {
- {const_cast<char*>("param_dim"), py_get_generic(BatchNormBackward, param_dim), py_set_generic(BatchNormBackward, param_dim), const_cast<char*>("param_dim"), NULL},
- {const_cast<char*>("fwd_mode"), py_get_generic(BatchNormBackward, fwd_mode), py_set_generic(BatchNormBackward, fwd_mode), const_cast<char*>("fwd_mode"), NULL},
- {const_cast<char*>("epsilon"), py_get_generic(BatchNormBackward, epsilon), py_set_generic(BatchNormBackward, epsilon), const_cast<char*>("epsilon"), NULL},
- {const_cast<char*>("avg_factor"), py_get_generic(BatchNormBackward, avg_factor), py_set_generic(BatchNormBackward, avg_factor), const_cast<char*>("avg_factor"), NULL},
- {const_cast<char*>("scale"), py_get_generic(BatchNormBackward, scale), py_set_generic(BatchNormBackward, scale), const_cast<char*>("scale"), NULL},
- {const_cast<char*>("bias"), py_get_generic(BatchNormBackward, bias), py_set_generic(BatchNormBackward, bias), const_cast<char*>("bias"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(BatchNormBackward)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(BatchNormBackward)::getstate, METH_NOARGS, "BatchNormBackward getstate"},
- {const_cast<char*>("__setstate__"), PyOp(BatchNormBackward)::setstate, METH_VARARGS, "BatchNormBackward setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_BatchNormBackward(py::module m) {
- using py_op = PyOp(BatchNormBackward);
- auto& py_type = PyOpType(BatchNormBackward);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.BatchNormBackward";
- py_type.tp_basicsize = sizeof(PyOp(BatchNormBackward));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "BatchNormBackward";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_BatchNormBackward_ParamDim(py_type);
- _init_py_BatchNormBackward_FwdMode(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("BatchNormBackward", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(BatchNormBackward::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(BatchedIncrMeshIndexing) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(BatchedIncrMeshIndexing)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"items", serialization<decltype(opdef.items)>::dump(opdef.items)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(BatchedIncrMeshIndexing)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("items");
- if (iter != state.end()) {
- opdef.items = serialization<decltype(opdef.items)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(BatchedIncrMeshIndexing)
-
- int PyOp(BatchedIncrMeshIndexing)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"items", "scope", NULL};
- PyObject *items = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &items, &scope))
- return -1;
-
- if (items) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchedIncrMeshIndexing)*>(self)->inst().items =
- py::cast<decltype(BatchedIncrMeshIndexing::items)>(py::handle(items));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(BatchedIncrMeshIndexing)::py_getsetters[] = {
- {const_cast<char*>("items"), py_get_generic(BatchedIncrMeshIndexing, items), py_set_generic(BatchedIncrMeshIndexing, items), const_cast<char*>("items"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(BatchedIncrMeshIndexing)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(BatchedIncrMeshIndexing)::getstate, METH_NOARGS, "BatchedIncrMeshIndexing getstate"},
- {const_cast<char*>("__setstate__"), PyOp(BatchedIncrMeshIndexing)::setstate, METH_VARARGS, "BatchedIncrMeshIndexing setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_BatchedIncrMeshIndexing(py::module m) {
- using py_op = PyOp(BatchedIncrMeshIndexing);
- auto& py_type = PyOpType(BatchedIncrMeshIndexing);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.BatchedIncrMeshIndexing";
- py_type.tp_basicsize = sizeof(PyOp(BatchedIncrMeshIndexing));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "BatchedIncrMeshIndexing";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("BatchedIncrMeshIndexing", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(BatchedIncrMeshIndexing::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<BatchedMatrixMul::ComputeMode> {
- static constexpr const char *name = "BatchedMatrixMul.ComputeMode";
- static constexpr std::underlying_type_t<BatchedMatrixMul::ComputeMode> max = 2 - 1;
- };
- template<> PyTypeObject* EnumWrapper<BatchedMatrixMul::ComputeMode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<BatchedMatrixMul::ComputeMode>::members[] = {"DEFAULT", "FLOAT32"};
-
- template<> std::unordered_map<std::string, BatchedMatrixMul::ComputeMode>
- EnumWrapper<BatchedMatrixMul::ComputeMode>::mem2value = {{normalize_enum("DEFAULT"), BatchedMatrixMul::ComputeMode::DEFAULT}, {normalize_enum("FLOAT32"), BatchedMatrixMul::ComputeMode::FLOAT32}};
- template<> PyObject* EnumWrapper<BatchedMatrixMul::ComputeMode>::pyobj_insts[2] = {nullptr};
-
- void _init_py_BatchedMatrixMul_ComputeMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<BatchedMatrixMul::ComputeMode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<BatchedMatrixMul::ComputeMode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<BatchedMatrixMul::ComputeMode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<BatchedMatrixMul::ComputeMode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.BatchedMatrixMul.ComputeMode",
- // basicsize
- sizeof(EnumWrapper<BatchedMatrixMul::ComputeMode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("ComputeMode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("BatchedMatrixMul.ComputeMode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchedMatrixMul::ComputeMode>*>(inst)->value = BatchedMatrixMul::ComputeMode::DEFAULT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "DEFAULT", inst) >= 0);
- EnumWrapper<BatchedMatrixMul::ComputeMode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchedMatrixMul::ComputeMode>*>(inst)->value = BatchedMatrixMul::ComputeMode::FLOAT32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FLOAT32", inst) >= 0);
- EnumWrapper<BatchedMatrixMul::ComputeMode>::pyobj_insts[1] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "ComputeMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- template<> struct EnumTrait<BatchedMatrixMul::Format> {
- static constexpr const char *name = "BatchedMatrixMul.Format";
- static constexpr std::underlying_type_t<BatchedMatrixMul::Format> max = 5 - 1;
- };
- template<> PyTypeObject* EnumWrapper<BatchedMatrixMul::Format>::type = nullptr;
-
- template<> const char*
- EnumWrapper<BatchedMatrixMul::Format>::members[] = {"DEFAULT", "MK4", "MK8", "MK4_DOT", "N32K4_DOT"};
-
- template<> std::unordered_map<std::string, BatchedMatrixMul::Format>
- EnumWrapper<BatchedMatrixMul::Format>::mem2value = {{normalize_enum("DEFAULT"), BatchedMatrixMul::Format::DEFAULT}, {normalize_enum("MK4"), BatchedMatrixMul::Format::MK4}, {normalize_enum("MK8"), BatchedMatrixMul::Format::MK8}, {normalize_enum("MK4_DOT"), BatchedMatrixMul::Format::MK4_DOT}, {normalize_enum("N32K4_DOT"), BatchedMatrixMul::Format::N32K4_DOT}};
- template<> PyObject* EnumWrapper<BatchedMatrixMul::Format>::pyobj_insts[5] = {nullptr};
-
- void _init_py_BatchedMatrixMul_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<BatchedMatrixMul::Format>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<BatchedMatrixMul::Format>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<BatchedMatrixMul::Format>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<BatchedMatrixMul::Format>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.BatchedMatrixMul.Format",
- // basicsize
- sizeof(EnumWrapper<BatchedMatrixMul::Format>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Format").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("BatchedMatrixMul.Format").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchedMatrixMul::Format>*>(inst)->value = BatchedMatrixMul::Format::DEFAULT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "DEFAULT", inst) >= 0);
- EnumWrapper<BatchedMatrixMul::Format>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchedMatrixMul::Format>*>(inst)->value = BatchedMatrixMul::Format::MK4;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "MK4", inst) >= 0);
- EnumWrapper<BatchedMatrixMul::Format>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchedMatrixMul::Format>*>(inst)->value = BatchedMatrixMul::Format::MK8;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "MK8", inst) >= 0);
- EnumWrapper<BatchedMatrixMul::Format>::pyobj_insts[2] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchedMatrixMul::Format>*>(inst)->value = BatchedMatrixMul::Format::MK4_DOT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "MK4_DOT", inst) >= 0);
- EnumWrapper<BatchedMatrixMul::Format>::pyobj_insts[3] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<BatchedMatrixMul::Format>*>(inst)->value = BatchedMatrixMul::Format::N32K4_DOT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "N32K4_DOT", inst) >= 0);
- EnumWrapper<BatchedMatrixMul::Format>::pyobj_insts[4] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_BatchedMatrixMul_Strategy(PyTypeObject& py_type) {
- auto& e_type = BitCombinedEnumWrapper<BatchedMatrixMul::Strategy>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Strategy", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(BatchedMatrixMul) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(BatchedMatrixMul)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"transposeA", serialization<decltype(opdef.transposeA)>::dump(opdef.transposeA)},
- {"transposeB", serialization<decltype(opdef.transposeB)>::dump(opdef.transposeB)},
- {"compute_mode", serialization<decltype(opdef.compute_mode)>::dump(opdef.compute_mode)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"strategy", serialization<decltype(opdef.strategy)>::dump(opdef.strategy)},
- {"workspace_limit", serialization<decltype(opdef.workspace_limit)>::dump(opdef.workspace_limit)},
- {"dimA", serialization<decltype(opdef.dimA)>::dump(opdef.dimA)},
- {"dimB", serialization<decltype(opdef.dimB)>::dump(opdef.dimB)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(BatchedMatrixMul)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("transposeA");
- if (iter != state.end()) {
- opdef.transposeA = serialization<decltype(opdef.transposeA)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("transposeB");
- if (iter != state.end()) {
- opdef.transposeB = serialization<decltype(opdef.transposeB)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("compute_mode");
- if (iter != state.end()) {
- opdef.compute_mode = serialization<decltype(opdef.compute_mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("strategy");
- if (iter != state.end()) {
- opdef.strategy = serialization<decltype(opdef.strategy)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("workspace_limit");
- if (iter != state.end()) {
- opdef.workspace_limit = serialization<decltype(opdef.workspace_limit)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dimA");
- if (iter != state.end()) {
- opdef.dimA = serialization<decltype(opdef.dimA)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dimB");
- if (iter != state.end()) {
- opdef.dimB = serialization<decltype(opdef.dimB)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(BatchedMatrixMul)
-
- int PyOp(BatchedMatrixMul)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"transposeA", "transposeB", "compute_mode", "format", "strategy", "workspace_limit", "dimA", "dimB", "scope", NULL};
- PyObject *transposeA = NULL, *transposeB = NULL, *compute_mode = NULL, *format = NULL, *strategy = NULL, *workspace_limit = NULL, *dimA = NULL, *dimB = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOO", const_cast<char**>(kwlist), &transposeA, &transposeB, &compute_mode, &format, &strategy, &workspace_limit, &dimA, &dimB, &scope))
- return -1;
-
- if (transposeA) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchedMatrixMul)*>(self)->inst().transposeA =
- py::cast<decltype(BatchedMatrixMul::transposeA)>(py::handle(transposeA));
- } CATCH_ALL(-1)
- }
-
- if (transposeB) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchedMatrixMul)*>(self)->inst().transposeB =
- py::cast<decltype(BatchedMatrixMul::transposeB)>(py::handle(transposeB));
- } CATCH_ALL(-1)
- }
-
- if (compute_mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchedMatrixMul)*>(self)->inst().compute_mode =
- py::cast<decltype(BatchedMatrixMul::compute_mode)>(py::handle(compute_mode));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchedMatrixMul)*>(self)->inst().format =
- py::cast<decltype(BatchedMatrixMul::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (strategy) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchedMatrixMul)*>(self)->inst().strategy =
- py::cast<decltype(BatchedMatrixMul::strategy)>(py::handle(strategy));
- } CATCH_ALL(-1)
- }
-
- if (workspace_limit) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchedMatrixMul)*>(self)->inst().workspace_limit =
- py::cast<decltype(BatchedMatrixMul::workspace_limit)>(py::handle(workspace_limit));
- } CATCH_ALL(-1)
- }
-
- if (dimA) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchedMatrixMul)*>(self)->inst().dimA =
- py::cast<decltype(BatchedMatrixMul::dimA)>(py::handle(dimA));
- } CATCH_ALL(-1)
- }
-
- if (dimB) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchedMatrixMul)*>(self)->inst().dimB =
- py::cast<decltype(BatchedMatrixMul::dimB)>(py::handle(dimB));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(BatchedMatrixMul)::py_getsetters[] = {
- {const_cast<char*>("transposeA"), py_get_generic(BatchedMatrixMul, transposeA), py_set_generic(BatchedMatrixMul, transposeA), const_cast<char*>("transposeA"), NULL},
- {const_cast<char*>("transposeB"), py_get_generic(BatchedMatrixMul, transposeB), py_set_generic(BatchedMatrixMul, transposeB), const_cast<char*>("transposeB"), NULL},
- {const_cast<char*>("compute_mode"), py_get_generic(BatchedMatrixMul, compute_mode), py_set_generic(BatchedMatrixMul, compute_mode), const_cast<char*>("compute_mode"), NULL},
- {const_cast<char*>("format"), py_get_generic(BatchedMatrixMul, format), py_set_generic(BatchedMatrixMul, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("strategy"), py_get_generic(BatchedMatrixMul, strategy), py_set_generic(BatchedMatrixMul, strategy), const_cast<char*>("strategy"), NULL},
- {const_cast<char*>("workspace_limit"), py_get_generic(BatchedMatrixMul, workspace_limit), py_set_generic(BatchedMatrixMul, workspace_limit), const_cast<char*>("workspace_limit"), NULL},
- {const_cast<char*>("dimA"), py_get_generic(BatchedMatrixMul, dimA), py_set_generic(BatchedMatrixMul, dimA), const_cast<char*>("dimA"), NULL},
- {const_cast<char*>("dimB"), py_get_generic(BatchedMatrixMul, dimB), py_set_generic(BatchedMatrixMul, dimB), const_cast<char*>("dimB"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(BatchedMatrixMul)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(BatchedMatrixMul)::getstate, METH_NOARGS, "BatchedMatrixMul getstate"},
- {const_cast<char*>("__setstate__"), PyOp(BatchedMatrixMul)::setstate, METH_VARARGS, "BatchedMatrixMul setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_BatchedMatrixMul(py::module m) {
- using py_op = PyOp(BatchedMatrixMul);
- auto& py_type = PyOpType(BatchedMatrixMul);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.BatchedMatrixMul";
- py_type.tp_basicsize = sizeof(PyOp(BatchedMatrixMul));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "BatchedMatrixMul";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_BatchedMatrixMul_ComputeMode(py_type);
- _init_py_BatchedMatrixMul_Format(py_type);
- _init_py_BatchedMatrixMul_Strategy(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("BatchedMatrixMul", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(BatchedMatrixMul::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(BatchedMeshIndexing) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(BatchedMeshIndexing)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"items", serialization<decltype(opdef.items)>::dump(opdef.items)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(BatchedMeshIndexing)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("items");
- if (iter != state.end()) {
- opdef.items = serialization<decltype(opdef.items)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(BatchedMeshIndexing)
-
- int PyOp(BatchedMeshIndexing)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"items", "scope", NULL};
- PyObject *items = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &items, &scope))
- return -1;
-
- if (items) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchedMeshIndexing)*>(self)->inst().items =
- py::cast<decltype(BatchedMeshIndexing::items)>(py::handle(items));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(BatchedMeshIndexing)::py_getsetters[] = {
- {const_cast<char*>("items"), py_get_generic(BatchedMeshIndexing, items), py_set_generic(BatchedMeshIndexing, items), const_cast<char*>("items"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(BatchedMeshIndexing)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(BatchedMeshIndexing)::getstate, METH_NOARGS, "BatchedMeshIndexing getstate"},
- {const_cast<char*>("__setstate__"), PyOp(BatchedMeshIndexing)::setstate, METH_VARARGS, "BatchedMeshIndexing setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_BatchedMeshIndexing(py::module m) {
- using py_op = PyOp(BatchedMeshIndexing);
- auto& py_type = PyOpType(BatchedMeshIndexing);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.BatchedMeshIndexing";
- py_type.tp_basicsize = sizeof(PyOp(BatchedMeshIndexing));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "BatchedMeshIndexing";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("BatchedMeshIndexing", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(BatchedMeshIndexing::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(BatchedSetMeshIndexing) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(BatchedSetMeshIndexing)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"items", serialization<decltype(opdef.items)>::dump(opdef.items)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(BatchedSetMeshIndexing)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("items");
- if (iter != state.end()) {
- opdef.items = serialization<decltype(opdef.items)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(BatchedSetMeshIndexing)
-
- int PyOp(BatchedSetMeshIndexing)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"items", "scope", NULL};
- PyObject *items = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &items, &scope))
- return -1;
-
- if (items) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BatchedSetMeshIndexing)*>(self)->inst().items =
- py::cast<decltype(BatchedSetMeshIndexing::items)>(py::handle(items));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(BatchedSetMeshIndexing)::py_getsetters[] = {
- {const_cast<char*>("items"), py_get_generic(BatchedSetMeshIndexing, items), py_set_generic(BatchedSetMeshIndexing, items), const_cast<char*>("items"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(BatchedSetMeshIndexing)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(BatchedSetMeshIndexing)::getstate, METH_NOARGS, "BatchedSetMeshIndexing getstate"},
- {const_cast<char*>("__setstate__"), PyOp(BatchedSetMeshIndexing)::setstate, METH_VARARGS, "BatchedSetMeshIndexing setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_BatchedSetMeshIndexing(py::module m) {
- using py_op = PyOp(BatchedSetMeshIndexing);
- auto& py_type = PyOpType(BatchedSetMeshIndexing);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.BatchedSetMeshIndexing";
- py_type.tp_basicsize = sizeof(PyOp(BatchedSetMeshIndexing));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "BatchedSetMeshIndexing";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("BatchedSetMeshIndexing", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(BatchedSetMeshIndexing::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(BetaRNG) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(BetaRNG)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"seed", serialization<decltype(opdef.seed)>::dump(opdef.seed)},
- {"handle", serialization<decltype(opdef.handle)>::dump(opdef.handle)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(BetaRNG)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("seed");
- if (iter != state.end()) {
- opdef.seed = serialization<decltype(opdef.seed)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("handle");
- if (iter != state.end()) {
- opdef.handle = serialization<decltype(opdef.handle)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(BetaRNG)
-
- int PyOp(BetaRNG)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"seed", "handle", "scope", NULL};
- PyObject *seed = NULL, *handle = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &seed, &handle, &scope))
- return -1;
-
- if (seed) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BetaRNG)*>(self)->inst().seed =
- py::cast<decltype(BetaRNG::seed)>(py::handle(seed));
- } CATCH_ALL(-1)
- }
-
- if (handle) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(BetaRNG)*>(self)->inst().handle =
- py::cast<decltype(BetaRNG::handle)>(py::handle(handle));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(BetaRNG)::py_getsetters[] = {
- {const_cast<char*>("seed"), py_get_generic(BetaRNG, seed), py_set_generic(BetaRNG, seed), const_cast<char*>("seed"), NULL},
- {const_cast<char*>("handle"), py_get_generic(BetaRNG, handle), py_set_generic(BetaRNG, handle), const_cast<char*>("handle"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(BetaRNG)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(BetaRNG)::getstate, METH_NOARGS, "BetaRNG getstate"},
- {const_cast<char*>("__setstate__"), PyOp(BetaRNG)::setstate, METH_VARARGS, "BetaRNG setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_BetaRNG(py::module m) {
- using py_op = PyOp(BetaRNG);
- auto& py_type = PyOpType(BetaRNG);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.BetaRNG";
- py_type.tp_basicsize = sizeof(PyOp(BetaRNG));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "BetaRNG";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("BetaRNG", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(BetaRNG::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Borrow) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Borrow)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"comp_node", serialization<decltype(opdef.comp_node)>::dump(opdef.comp_node)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Borrow)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("comp_node");
- if (iter != state.end()) {
- opdef.comp_node = serialization<decltype(opdef.comp_node)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Borrow)
-
- int PyOp(Borrow)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"comp_node", "scope", NULL};
- PyObject *comp_node = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &comp_node, &scope))
- return -1;
-
- if (comp_node) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Borrow)*>(self)->inst().comp_node =
- py::cast<decltype(Borrow::comp_node)>(py::handle(comp_node));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Borrow)::py_getsetters[] = {
- {const_cast<char*>("comp_node"), py_get_generic(Borrow, comp_node), py_set_generic(Borrow, comp_node), const_cast<char*>("comp_node"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Borrow)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Borrow)::getstate, METH_NOARGS, "Borrow getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Borrow)::setstate, METH_VARARGS, "Borrow setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Borrow(py::module m) {
- using py_op = PyOp(Borrow);
- auto& py_type = PyOpType(Borrow);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Borrow";
- py_type.tp_basicsize = sizeof(PyOp(Borrow));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Borrow";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Borrow", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Borrow::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Broadcast) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Broadcast)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"shape", serialization<decltype(opdef.shape)>::dump(opdef.shape)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Broadcast)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("shape");
- if (iter != state.end()) {
- opdef.shape = serialization<decltype(opdef.shape)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Broadcast)
-
- int PyOp(Broadcast)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"shape", "scope", NULL};
- PyObject *shape = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &shape, &scope))
- return -1;
-
- if (shape) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Broadcast)*>(self)->inst().shape =
- py::cast<decltype(Broadcast::shape)>(py::handle(shape));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Broadcast)::py_getsetters[] = {
- {const_cast<char*>("shape"), py_get_generic(Broadcast, shape), py_set_generic(Broadcast, shape), const_cast<char*>("shape"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Broadcast)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Broadcast)::getstate, METH_NOARGS, "Broadcast getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Broadcast)::setstate, METH_VARARGS, "Broadcast setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Broadcast(py::module m) {
- using py_op = PyOp(Broadcast);
- auto& py_type = PyOpType(Broadcast);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Broadcast";
- py_type.tp_basicsize = sizeof(PyOp(Broadcast));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Broadcast";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Broadcast", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Broadcast::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(CambriconRuntime) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(CambriconRuntime)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"buf", serialization<decltype(opdef.buf)>::dump(opdef.buf)},
- {"buf_size", serialization<decltype(opdef.buf_size)>::dump(opdef.buf_size)},
- {"symbol", serialization<decltype(opdef.symbol)>::dump(opdef.symbol)},
- {"tensor_dim_mutable", serialization<decltype(opdef.tensor_dim_mutable)>::dump(opdef.tensor_dim_mutable)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(CambriconRuntime)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("buf");
- if (iter != state.end()) {
- opdef.buf = serialization<decltype(opdef.buf)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("buf_size");
- if (iter != state.end()) {
- opdef.buf_size = serialization<decltype(opdef.buf_size)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("symbol");
- if (iter != state.end()) {
- opdef.symbol = serialization<decltype(opdef.symbol)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("tensor_dim_mutable");
- if (iter != state.end()) {
- opdef.tensor_dim_mutable = serialization<decltype(opdef.tensor_dim_mutable)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(CambriconRuntime)
-
- int PyOp(CambriconRuntime)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"buf", "buf_size", "symbol", "tensor_dim_mutable", "scope", NULL};
- PyObject *buf = NULL, *buf_size = NULL, *symbol = NULL, *tensor_dim_mutable = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOO", const_cast<char**>(kwlist), &buf, &buf_size, &symbol, &tensor_dim_mutable, &scope))
- return -1;
-
- if (buf) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CambriconRuntime)*>(self)->inst().buf =
- py::cast<decltype(CambriconRuntime::buf)>(py::handle(buf));
- } CATCH_ALL(-1)
- }
-
- if (buf_size) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CambriconRuntime)*>(self)->inst().buf_size =
- py::cast<decltype(CambriconRuntime::buf_size)>(py::handle(buf_size));
- } CATCH_ALL(-1)
- }
-
- if (symbol) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CambriconRuntime)*>(self)->inst().symbol =
- py::cast<decltype(CambriconRuntime::symbol)>(py::handle(symbol));
- } CATCH_ALL(-1)
- }
-
- if (tensor_dim_mutable) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CambriconRuntime)*>(self)->inst().tensor_dim_mutable =
- py::cast<decltype(CambriconRuntime::tensor_dim_mutable)>(py::handle(tensor_dim_mutable));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(CambriconRuntime)::py_getsetters[] = {
- {const_cast<char*>("buf"), py_get_generic(CambriconRuntime, buf), py_set_generic(CambriconRuntime, buf), const_cast<char*>("buf"), NULL},
- {const_cast<char*>("buf_size"), py_get_generic(CambriconRuntime, buf_size), py_set_generic(CambriconRuntime, buf_size), const_cast<char*>("buf_size"), NULL},
- {const_cast<char*>("symbol"), py_get_generic(CambriconRuntime, symbol), py_set_generic(CambriconRuntime, symbol), const_cast<char*>("symbol"), NULL},
- {const_cast<char*>("tensor_dim_mutable"), py_get_generic(CambriconRuntime, tensor_dim_mutable), py_set_generic(CambriconRuntime, tensor_dim_mutable), const_cast<char*>("tensor_dim_mutable"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(CambriconRuntime)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(CambriconRuntime)::getstate, METH_NOARGS, "CambriconRuntime getstate"},
- {const_cast<char*>("__setstate__"), PyOp(CambriconRuntime)::setstate, METH_VARARGS, "CambriconRuntime setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_CambriconRuntime(py::module m) {
- using py_op = PyOp(CambriconRuntime);
- auto& py_type = PyOpType(CambriconRuntime);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.CambriconRuntime";
- py_type.tp_basicsize = sizeof(PyOp(CambriconRuntime));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "CambriconRuntime";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("CambriconRuntime", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(CambriconRuntime::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(CheckNonFinite) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(CheckNonFinite)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"scale", serialization<decltype(opdef.scale)>::dump(opdef.scale)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(CheckNonFinite)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("scale");
- if (iter != state.end()) {
- opdef.scale = serialization<decltype(opdef.scale)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(CheckNonFinite)
-
- int PyOp(CheckNonFinite)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"scale", "scope", NULL};
- PyObject *scale = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &scale, &scope))
- return -1;
-
- if (scale) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CheckNonFinite)*>(self)->inst().scale =
- py::cast<decltype(CheckNonFinite::scale)>(py::handle(scale));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(CheckNonFinite)::py_getsetters[] = {
- {const_cast<char*>("scale"), py_get_generic(CheckNonFinite, scale), py_set_generic(CheckNonFinite, scale), const_cast<char*>("scale"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(CheckNonFinite)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(CheckNonFinite)::getstate, METH_NOARGS, "CheckNonFinite getstate"},
- {const_cast<char*>("__setstate__"), PyOp(CheckNonFinite)::setstate, METH_VARARGS, "CheckNonFinite setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_CheckNonFinite(py::module m) {
- using py_op = PyOp(CheckNonFinite);
- auto& py_type = PyOpType(CheckNonFinite);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.CheckNonFinite";
- py_type.tp_basicsize = sizeof(PyOp(CheckNonFinite));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "CheckNonFinite";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("CheckNonFinite", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(CheckNonFinite::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<CollectiveComm::Mode> {
- static constexpr const char *name = "CollectiveComm.Mode";
- static constexpr std::underlying_type_t<CollectiveComm::Mode> max = 11 - 1;
- };
- template<> PyTypeObject* EnumWrapper<CollectiveComm::Mode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<CollectiveComm::Mode>::members[] = {"REDUCE_SUM", "BROADCAST", "ALL_GATHER", "REDUCE_SCATTER_SUM", "ALL_REDUCE_SUM", "ALL_REDUCE_MAX", "ALL_REDUCE_MIN", "ALL_REDUCE_PROD", "GATHER", "SCATTER", "ALL_TO_ALL"};
-
- template<> std::unordered_map<std::string, CollectiveComm::Mode>
- EnumWrapper<CollectiveComm::Mode>::mem2value = {{normalize_enum("REDUCE_SUM"), CollectiveComm::Mode::REDUCE_SUM}, {normalize_enum("BROADCAST"), CollectiveComm::Mode::BROADCAST}, {normalize_enum("ALL_GATHER"), CollectiveComm::Mode::ALL_GATHER}, {normalize_enum("REDUCE_SCATTER_SUM"), CollectiveComm::Mode::REDUCE_SCATTER_SUM}, {normalize_enum("ALL_REDUCE_SUM"), CollectiveComm::Mode::ALL_REDUCE_SUM}, {normalize_enum("ALL_REDUCE_MAX"), CollectiveComm::Mode::ALL_REDUCE_MAX}, {normalize_enum("ALL_REDUCE_MIN"), CollectiveComm::Mode::ALL_REDUCE_MIN}, {normalize_enum("ALL_REDUCE_PROD"), CollectiveComm::Mode::ALL_REDUCE_PROD}, {normalize_enum("GATHER"), CollectiveComm::Mode::GATHER}, {normalize_enum("SCATTER"), CollectiveComm::Mode::SCATTER}, {normalize_enum("ALL_TO_ALL"), CollectiveComm::Mode::ALL_TO_ALL}};
- template<> PyObject* EnumWrapper<CollectiveComm::Mode>::pyobj_insts[11] = {nullptr};
-
- void _init_py_CollectiveComm_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<CollectiveComm::Mode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<CollectiveComm::Mode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<CollectiveComm::Mode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<CollectiveComm::Mode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.CollectiveComm.Mode",
- // basicsize
- sizeof(EnumWrapper<CollectiveComm::Mode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Mode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("CollectiveComm.Mode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CollectiveComm::Mode>*>(inst)->value = CollectiveComm::Mode::REDUCE_SUM;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "REDUCE_SUM", inst) >= 0);
- EnumWrapper<CollectiveComm::Mode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CollectiveComm::Mode>*>(inst)->value = CollectiveComm::Mode::BROADCAST;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "BROADCAST", inst) >= 0);
- EnumWrapper<CollectiveComm::Mode>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CollectiveComm::Mode>*>(inst)->value = CollectiveComm::Mode::ALL_GATHER;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ALL_GATHER", inst) >= 0);
- EnumWrapper<CollectiveComm::Mode>::pyobj_insts[2] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CollectiveComm::Mode>*>(inst)->value = CollectiveComm::Mode::REDUCE_SCATTER_SUM;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "REDUCE_SCATTER_SUM", inst) >= 0);
- EnumWrapper<CollectiveComm::Mode>::pyobj_insts[3] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CollectiveComm::Mode>*>(inst)->value = CollectiveComm::Mode::ALL_REDUCE_SUM;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ALL_REDUCE_SUM", inst) >= 0);
- EnumWrapper<CollectiveComm::Mode>::pyobj_insts[4] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CollectiveComm::Mode>*>(inst)->value = CollectiveComm::Mode::ALL_REDUCE_MAX;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ALL_REDUCE_MAX", inst) >= 0);
- EnumWrapper<CollectiveComm::Mode>::pyobj_insts[5] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CollectiveComm::Mode>*>(inst)->value = CollectiveComm::Mode::ALL_REDUCE_MIN;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ALL_REDUCE_MIN", inst) >= 0);
- EnumWrapper<CollectiveComm::Mode>::pyobj_insts[6] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CollectiveComm::Mode>*>(inst)->value = CollectiveComm::Mode::ALL_REDUCE_PROD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ALL_REDUCE_PROD", inst) >= 0);
- EnumWrapper<CollectiveComm::Mode>::pyobj_insts[7] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CollectiveComm::Mode>*>(inst)->value = CollectiveComm::Mode::GATHER;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "GATHER", inst) >= 0);
- EnumWrapper<CollectiveComm::Mode>::pyobj_insts[8] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CollectiveComm::Mode>*>(inst)->value = CollectiveComm::Mode::SCATTER;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "SCATTER", inst) >= 0);
- EnumWrapper<CollectiveComm::Mode>::pyobj_insts[9] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CollectiveComm::Mode>*>(inst)->value = CollectiveComm::Mode::ALL_TO_ALL;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ALL_TO_ALL", inst) >= 0);
- EnumWrapper<CollectiveComm::Mode>::pyobj_insts[10] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(CollectiveComm) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(CollectiveComm)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)},
- {"key", serialization<decltype(opdef.key)>::dump(opdef.key)},
- {"nr_devices", serialization<decltype(opdef.nr_devices)>::dump(opdef.nr_devices)},
- {"rank", serialization<decltype(opdef.rank)>::dump(opdef.rank)},
- {"is_root", serialization<decltype(opdef.is_root)>::dump(opdef.is_root)},
- {"local_grad", serialization<decltype(opdef.local_grad)>::dump(opdef.local_grad)},
- {"addr", serialization<decltype(opdef.addr)>::dump(opdef.addr)},
- {"port", serialization<decltype(opdef.port)>::dump(opdef.port)},
- {"dtype", serialization<decltype(opdef.dtype)>::dump(opdef.dtype)},
- {"backend", serialization<decltype(opdef.backend)>::dump(opdef.backend)},
- {"comp_node", serialization<decltype(opdef.comp_node)>::dump(opdef.comp_node)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(CollectiveComm)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("key");
- if (iter != state.end()) {
- opdef.key = serialization<decltype(opdef.key)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("nr_devices");
- if (iter != state.end()) {
- opdef.nr_devices = serialization<decltype(opdef.nr_devices)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("rank");
- if (iter != state.end()) {
- opdef.rank = serialization<decltype(opdef.rank)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("is_root");
- if (iter != state.end()) {
- opdef.is_root = serialization<decltype(opdef.is_root)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("local_grad");
- if (iter != state.end()) {
- opdef.local_grad = serialization<decltype(opdef.local_grad)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("addr");
- if (iter != state.end()) {
- opdef.addr = serialization<decltype(opdef.addr)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("port");
- if (iter != state.end()) {
- opdef.port = serialization<decltype(opdef.port)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dtype");
- if (iter != state.end()) {
- opdef.dtype = serialization<decltype(opdef.dtype)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("backend");
- if (iter != state.end()) {
- opdef.backend = serialization<decltype(opdef.backend)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("comp_node");
- if (iter != state.end()) {
- opdef.comp_node = serialization<decltype(opdef.comp_node)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(CollectiveComm)
-
- int PyOp(CollectiveComm)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "key", "nr_devices", "rank", "is_root", "local_grad", "addr", "port", "dtype", "backend", "comp_node", "scope", NULL};
- PyObject *mode = NULL, *key = NULL, *nr_devices = NULL, *rank = NULL, *is_root = NULL, *local_grad = NULL, *addr = NULL, *port = NULL, *dtype = NULL, *backend = NULL, *comp_node = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOOOOO", const_cast<char**>(kwlist), &mode, &key, &nr_devices, &rank, &is_root, &local_grad, &addr, &port, &dtype, &backend, &comp_node, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CollectiveComm)*>(self)->inst().mode =
- py::cast<decltype(CollectiveComm::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (key) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CollectiveComm)*>(self)->inst().key =
- py::cast<decltype(CollectiveComm::key)>(py::handle(key));
- } CATCH_ALL(-1)
- }
-
- if (nr_devices) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CollectiveComm)*>(self)->inst().nr_devices =
- py::cast<decltype(CollectiveComm::nr_devices)>(py::handle(nr_devices));
- } CATCH_ALL(-1)
- }
-
- if (rank) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CollectiveComm)*>(self)->inst().rank =
- py::cast<decltype(CollectiveComm::rank)>(py::handle(rank));
- } CATCH_ALL(-1)
- }
-
- if (is_root) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CollectiveComm)*>(self)->inst().is_root =
- py::cast<decltype(CollectiveComm::is_root)>(py::handle(is_root));
- } CATCH_ALL(-1)
- }
-
- if (local_grad) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CollectiveComm)*>(self)->inst().local_grad =
- py::cast<decltype(CollectiveComm::local_grad)>(py::handle(local_grad));
- } CATCH_ALL(-1)
- }
-
- if (addr) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CollectiveComm)*>(self)->inst().addr =
- py::cast<decltype(CollectiveComm::addr)>(py::handle(addr));
- } CATCH_ALL(-1)
- }
-
- if (port) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CollectiveComm)*>(self)->inst().port =
- py::cast<decltype(CollectiveComm::port)>(py::handle(port));
- } CATCH_ALL(-1)
- }
-
- if (dtype) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CollectiveComm)*>(self)->inst().dtype =
- py::cast<decltype(CollectiveComm::dtype)>(py::handle(dtype));
- } CATCH_ALL(-1)
- }
-
- if (backend) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CollectiveComm)*>(self)->inst().backend =
- py::cast<decltype(CollectiveComm::backend)>(py::handle(backend));
- } CATCH_ALL(-1)
- }
-
- if (comp_node) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CollectiveComm)*>(self)->inst().comp_node =
- py::cast<decltype(CollectiveComm::comp_node)>(py::handle(comp_node));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(CollectiveComm)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(CollectiveComm, mode), py_set_generic(CollectiveComm, mode), const_cast<char*>("mode"), NULL},
- {const_cast<char*>("key"), py_get_generic(CollectiveComm, key), py_set_generic(CollectiveComm, key), const_cast<char*>("key"), NULL},
- {const_cast<char*>("nr_devices"), py_get_generic(CollectiveComm, nr_devices), py_set_generic(CollectiveComm, nr_devices), const_cast<char*>("nr_devices"), NULL},
- {const_cast<char*>("rank"), py_get_generic(CollectiveComm, rank), py_set_generic(CollectiveComm, rank), const_cast<char*>("rank"), NULL},
- {const_cast<char*>("is_root"), py_get_generic(CollectiveComm, is_root), py_set_generic(CollectiveComm, is_root), const_cast<char*>("is_root"), NULL},
- {const_cast<char*>("local_grad"), py_get_generic(CollectiveComm, local_grad), py_set_generic(CollectiveComm, local_grad), const_cast<char*>("local_grad"), NULL},
- {const_cast<char*>("addr"), py_get_generic(CollectiveComm, addr), py_set_generic(CollectiveComm, addr), const_cast<char*>("addr"), NULL},
- {const_cast<char*>("port"), py_get_generic(CollectiveComm, port), py_set_generic(CollectiveComm, port), const_cast<char*>("port"), NULL},
- {const_cast<char*>("dtype"), py_get_generic(CollectiveComm, dtype), py_set_generic(CollectiveComm, dtype), const_cast<char*>("dtype"), NULL},
- {const_cast<char*>("backend"), py_get_generic(CollectiveComm, backend), py_set_generic(CollectiveComm, backend), const_cast<char*>("backend"), NULL},
- {const_cast<char*>("comp_node"), py_get_generic(CollectiveComm, comp_node), py_set_generic(CollectiveComm, comp_node), const_cast<char*>("comp_node"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(CollectiveComm)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(CollectiveComm)::getstate, METH_NOARGS, "CollectiveComm getstate"},
- {const_cast<char*>("__setstate__"), PyOp(CollectiveComm)::setstate, METH_VARARGS, "CollectiveComm setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_CollectiveComm(py::module m) {
- using py_op = PyOp(CollectiveComm);
- auto& py_type = PyOpType(CollectiveComm);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.CollectiveComm";
- py_type.tp_basicsize = sizeof(PyOp(CollectiveComm));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "CollectiveComm";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_CollectiveComm_Mode(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("CollectiveComm", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(CollectiveComm::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Concat) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Concat)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"axis", serialization<decltype(opdef.axis)>::dump(opdef.axis)},
- {"comp_node", serialization<decltype(opdef.comp_node)>::dump(opdef.comp_node)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Concat)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("axis");
- if (iter != state.end()) {
- opdef.axis = serialization<decltype(opdef.axis)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("comp_node");
- if (iter != state.end()) {
- opdef.comp_node = serialization<decltype(opdef.comp_node)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Concat)
-
- int PyOp(Concat)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"axis", "comp_node", "scope", NULL};
- PyObject *axis = NULL, *comp_node = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &axis, &comp_node, &scope))
- return -1;
-
- if (axis) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Concat)*>(self)->inst().axis =
- py::cast<decltype(Concat::axis)>(py::handle(axis));
- } CATCH_ALL(-1)
- }
-
- if (comp_node) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Concat)*>(self)->inst().comp_node =
- py::cast<decltype(Concat::comp_node)>(py::handle(comp_node));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Concat)::py_getsetters[] = {
- {const_cast<char*>("axis"), py_get_generic(Concat, axis), py_set_generic(Concat, axis), const_cast<char*>("axis"), NULL},
- {const_cast<char*>("comp_node"), py_get_generic(Concat, comp_node), py_set_generic(Concat, comp_node), const_cast<char*>("comp_node"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Concat)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Concat)::getstate, METH_NOARGS, "Concat getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Concat)::setstate, METH_VARARGS, "Concat setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Concat(py::module m) {
- using py_op = PyOp(Concat);
- auto& py_type = PyOpType(Concat);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Concat";
- py_type.tp_basicsize = sizeof(PyOp(Concat));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Concat";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Concat", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Concat::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(CondTake) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(CondTake)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(CondTake)*>(self)->inst();
- static_cast<void>(opdef);
-
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(CondTake)
-
- int PyOp(CondTake)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
-
- return 0;
- }
-
- PyGetSetDef PyOp(CondTake)::py_getsetters[] = {
-
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(CondTake)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(CondTake)::getstate, METH_NOARGS, "CondTake getstate"},
- {const_cast<char*>("__setstate__"), PyOp(CondTake)::setstate, METH_VARARGS, "CondTake setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_CondTake(py::module m) {
- using py_op = PyOp(CondTake);
- auto& py_type = PyOpType(CondTake);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.CondTake";
- py_type.tp_basicsize = sizeof(PyOp(CondTake));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "CondTake";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("CondTake", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(CondTake::typeinfo(), &py_type).second);
- }
-
- void _init_py_ConvBias_NonlineMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<ConvBias::NonlineMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "NonlineMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_ConvBias_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<ConvBias::Mode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_ConvBias_Sparse(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<ConvBias::Sparse>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Sparse", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_ConvBias_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<ConvBias::Format>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_ConvBias_ComputeMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<ConvBias::ComputeMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "ComputeMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_ConvBias_Strategy(PyTypeObject& py_type) {
- auto& e_type = BitCombinedEnumWrapper<ConvBias::Strategy>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Strategy", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(ConvBias) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(ConvBias)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"nonlineMode", serialization<decltype(opdef.nonlineMode)>::dump(opdef.nonlineMode)},
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)},
- {"sparse", serialization<decltype(opdef.sparse)>::dump(opdef.sparse)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"pad_h", serialization<decltype(opdef.pad_h)>::dump(opdef.pad_h)},
- {"pad_w", serialization<decltype(opdef.pad_w)>::dump(opdef.pad_w)},
- {"stride_h", serialization<decltype(opdef.stride_h)>::dump(opdef.stride_h)},
- {"stride_w", serialization<decltype(opdef.stride_w)>::dump(opdef.stride_w)},
- {"dilate_h", serialization<decltype(opdef.dilate_h)>::dump(opdef.dilate_h)},
- {"dilate_w", serialization<decltype(opdef.dilate_w)>::dump(opdef.dilate_w)},
- {"compute_mode", serialization<decltype(opdef.compute_mode)>::dump(opdef.compute_mode)},
- {"strategy", serialization<decltype(opdef.strategy)>::dump(opdef.strategy)},
- {"workspace_limit", serialization<decltype(opdef.workspace_limit)>::dump(opdef.workspace_limit)},
- {"dtype", serialization<decltype(opdef.dtype)>::dump(opdef.dtype)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(ConvBias)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("nonlineMode");
- if (iter != state.end()) {
- opdef.nonlineMode = serialization<decltype(opdef.nonlineMode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("sparse");
- if (iter != state.end()) {
- opdef.sparse = serialization<decltype(opdef.sparse)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_h");
- if (iter != state.end()) {
- opdef.pad_h = serialization<decltype(opdef.pad_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_w");
- if (iter != state.end()) {
- opdef.pad_w = serialization<decltype(opdef.pad_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_h");
- if (iter != state.end()) {
- opdef.stride_h = serialization<decltype(opdef.stride_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_w");
- if (iter != state.end()) {
- opdef.stride_w = serialization<decltype(opdef.stride_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_h");
- if (iter != state.end()) {
- opdef.dilate_h = serialization<decltype(opdef.dilate_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_w");
- if (iter != state.end()) {
- opdef.dilate_w = serialization<decltype(opdef.dilate_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("compute_mode");
- if (iter != state.end()) {
- opdef.compute_mode = serialization<decltype(opdef.compute_mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("strategy");
- if (iter != state.end()) {
- opdef.strategy = serialization<decltype(opdef.strategy)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("workspace_limit");
- if (iter != state.end()) {
- opdef.workspace_limit = serialization<decltype(opdef.workspace_limit)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dtype");
- if (iter != state.end()) {
- opdef.dtype = serialization<decltype(opdef.dtype)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(ConvBias)
-
- int PyOp(ConvBias)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"nonlineMode", "mode", "sparse", "format", "pad_h", "pad_w", "stride_h", "stride_w", "dilate_h", "dilate_w", "compute_mode", "strategy", "workspace_limit", "dtype", "scope", NULL};
- PyObject *nonlineMode = NULL, *mode = NULL, *sparse = NULL, *format = NULL, *pad_h = NULL, *pad_w = NULL, *stride_h = NULL, *stride_w = NULL, *dilate_h = NULL, *dilate_w = NULL, *compute_mode = NULL, *strategy = NULL, *workspace_limit = NULL, *dtype = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOOOOOOOO", const_cast<char**>(kwlist), &nonlineMode, &mode, &sparse, &format, &pad_h, &pad_w, &stride_h, &stride_w, &dilate_h, &dilate_w, &compute_mode, &strategy, &workspace_limit, &dtype, &scope))
- return -1;
-
- if (nonlineMode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvBias)*>(self)->inst().nonlineMode =
- py::cast<decltype(ConvBias::nonlineMode)>(py::handle(nonlineMode));
- } CATCH_ALL(-1)
- }
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvBias)*>(self)->inst().mode =
- py::cast<decltype(ConvBias::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (sparse) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvBias)*>(self)->inst().sparse =
- py::cast<decltype(ConvBias::sparse)>(py::handle(sparse));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvBias)*>(self)->inst().format =
- py::cast<decltype(ConvBias::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (pad_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvBias)*>(self)->inst().pad_h =
- py::cast<decltype(ConvBias::pad_h)>(py::handle(pad_h));
- } CATCH_ALL(-1)
- }
-
- if (pad_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvBias)*>(self)->inst().pad_w =
- py::cast<decltype(ConvBias::pad_w)>(py::handle(pad_w));
- } CATCH_ALL(-1)
- }
-
- if (stride_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvBias)*>(self)->inst().stride_h =
- py::cast<decltype(ConvBias::stride_h)>(py::handle(stride_h));
- } CATCH_ALL(-1)
- }
-
- if (stride_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvBias)*>(self)->inst().stride_w =
- py::cast<decltype(ConvBias::stride_w)>(py::handle(stride_w));
- } CATCH_ALL(-1)
- }
-
- if (dilate_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvBias)*>(self)->inst().dilate_h =
- py::cast<decltype(ConvBias::dilate_h)>(py::handle(dilate_h));
- } CATCH_ALL(-1)
- }
-
- if (dilate_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvBias)*>(self)->inst().dilate_w =
- py::cast<decltype(ConvBias::dilate_w)>(py::handle(dilate_w));
- } CATCH_ALL(-1)
- }
-
- if (compute_mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvBias)*>(self)->inst().compute_mode =
- py::cast<decltype(ConvBias::compute_mode)>(py::handle(compute_mode));
- } CATCH_ALL(-1)
- }
-
- if (strategy) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvBias)*>(self)->inst().strategy =
- py::cast<decltype(ConvBias::strategy)>(py::handle(strategy));
- } CATCH_ALL(-1)
- }
-
- if (workspace_limit) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvBias)*>(self)->inst().workspace_limit =
- py::cast<decltype(ConvBias::workspace_limit)>(py::handle(workspace_limit));
- } CATCH_ALL(-1)
- }
-
- if (dtype) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvBias)*>(self)->inst().dtype =
- py::cast<decltype(ConvBias::dtype)>(py::handle(dtype));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(ConvBias)::py_getsetters[] = {
- {const_cast<char*>("nonlineMode"), py_get_generic(ConvBias, nonlineMode), py_set_generic(ConvBias, nonlineMode), const_cast<char*>("nonlineMode"), NULL},
- {const_cast<char*>("mode"), py_get_generic(ConvBias, mode), py_set_generic(ConvBias, mode), const_cast<char*>("mode"), NULL},
- {const_cast<char*>("sparse"), py_get_generic(ConvBias, sparse), py_set_generic(ConvBias, sparse), const_cast<char*>("sparse"), NULL},
- {const_cast<char*>("format"), py_get_generic(ConvBias, format), py_set_generic(ConvBias, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("pad_h"), py_get_generic(ConvBias, pad_h), py_set_generic(ConvBias, pad_h), const_cast<char*>("pad_h"), NULL},
- {const_cast<char*>("pad_w"), py_get_generic(ConvBias, pad_w), py_set_generic(ConvBias, pad_w), const_cast<char*>("pad_w"), NULL},
- {const_cast<char*>("stride_h"), py_get_generic(ConvBias, stride_h), py_set_generic(ConvBias, stride_h), const_cast<char*>("stride_h"), NULL},
- {const_cast<char*>("stride_w"), py_get_generic(ConvBias, stride_w), py_set_generic(ConvBias, stride_w), const_cast<char*>("stride_w"), NULL},
- {const_cast<char*>("dilate_h"), py_get_generic(ConvBias, dilate_h), py_set_generic(ConvBias, dilate_h), const_cast<char*>("dilate_h"), NULL},
- {const_cast<char*>("dilate_w"), py_get_generic(ConvBias, dilate_w), py_set_generic(ConvBias, dilate_w), const_cast<char*>("dilate_w"), NULL},
- {const_cast<char*>("compute_mode"), py_get_generic(ConvBias, compute_mode), py_set_generic(ConvBias, compute_mode), const_cast<char*>("compute_mode"), NULL},
- {const_cast<char*>("strategy"), py_get_generic(ConvBias, strategy), py_set_generic(ConvBias, strategy), const_cast<char*>("strategy"), NULL},
- {const_cast<char*>("workspace_limit"), py_get_generic(ConvBias, workspace_limit), py_set_generic(ConvBias, workspace_limit), const_cast<char*>("workspace_limit"), NULL},
- {const_cast<char*>("dtype"), py_get_generic(ConvBias, dtype), py_set_generic(ConvBias, dtype), const_cast<char*>("dtype"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(ConvBias)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(ConvBias)::getstate, METH_NOARGS, "ConvBias getstate"},
- {const_cast<char*>("__setstate__"), PyOp(ConvBias)::setstate, METH_VARARGS, "ConvBias setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_ConvBias(py::module m) {
- using py_op = PyOp(ConvBias);
- auto& py_type = PyOpType(ConvBias);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.ConvBias";
- py_type.tp_basicsize = sizeof(PyOp(ConvBias));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "ConvBias";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_ConvBias_NonlineMode(py_type);
- _init_py_ConvBias_Mode(py_type);
- _init_py_ConvBias_Sparse(py_type);
- _init_py_ConvBias_Format(py_type);
- _init_py_ConvBias_ComputeMode(py_type);
- _init_py_ConvBias_Strategy(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("ConvBias", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(ConvBias::typeinfo(), &py_type).second);
- }
-
- void _init_py_Convolution_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Convolution::Mode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_Convolution_Sparse(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Convolution::Sparse>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Sparse", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_Convolution_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Convolution::Format>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_Convolution_ComputeMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Convolution::ComputeMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "ComputeMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_Convolution_Strategy(PyTypeObject& py_type) {
- auto& e_type = BitCombinedEnumWrapper<Convolution::Strategy>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Strategy", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(Convolution) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Convolution)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)},
- {"pad_h", serialization<decltype(opdef.pad_h)>::dump(opdef.pad_h)},
- {"pad_w", serialization<decltype(opdef.pad_w)>::dump(opdef.pad_w)},
- {"stride_h", serialization<decltype(opdef.stride_h)>::dump(opdef.stride_h)},
- {"stride_w", serialization<decltype(opdef.stride_w)>::dump(opdef.stride_w)},
- {"dilate_h", serialization<decltype(opdef.dilate_h)>::dump(opdef.dilate_h)},
- {"dilate_w", serialization<decltype(opdef.dilate_w)>::dump(opdef.dilate_w)},
- {"sparse", serialization<decltype(opdef.sparse)>::dump(opdef.sparse)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"compute_mode", serialization<decltype(opdef.compute_mode)>::dump(opdef.compute_mode)},
- {"strategy", serialization<decltype(opdef.strategy)>::dump(opdef.strategy)},
- {"workspace_limit", serialization<decltype(opdef.workspace_limit)>::dump(opdef.workspace_limit)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Convolution)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_h");
- if (iter != state.end()) {
- opdef.pad_h = serialization<decltype(opdef.pad_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_w");
- if (iter != state.end()) {
- opdef.pad_w = serialization<decltype(opdef.pad_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_h");
- if (iter != state.end()) {
- opdef.stride_h = serialization<decltype(opdef.stride_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_w");
- if (iter != state.end()) {
- opdef.stride_w = serialization<decltype(opdef.stride_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_h");
- if (iter != state.end()) {
- opdef.dilate_h = serialization<decltype(opdef.dilate_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_w");
- if (iter != state.end()) {
- opdef.dilate_w = serialization<decltype(opdef.dilate_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("sparse");
- if (iter != state.end()) {
- opdef.sparse = serialization<decltype(opdef.sparse)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("compute_mode");
- if (iter != state.end()) {
- opdef.compute_mode = serialization<decltype(opdef.compute_mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("strategy");
- if (iter != state.end()) {
- opdef.strategy = serialization<decltype(opdef.strategy)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("workspace_limit");
- if (iter != state.end()) {
- opdef.workspace_limit = serialization<decltype(opdef.workspace_limit)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Convolution)
-
- int PyOp(Convolution)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "pad_h", "pad_w", "stride_h", "stride_w", "dilate_h", "dilate_w", "sparse", "format", "compute_mode", "strategy", "workspace_limit", "scope", NULL};
- PyObject *mode = NULL, *pad_h = NULL, *pad_w = NULL, *stride_h = NULL, *stride_w = NULL, *dilate_h = NULL, *dilate_w = NULL, *sparse = NULL, *format = NULL, *compute_mode = NULL, *strategy = NULL, *workspace_limit = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOOOOOO", const_cast<char**>(kwlist), &mode, &pad_h, &pad_w, &stride_h, &stride_w, &dilate_h, &dilate_w, &sparse, &format, &compute_mode, &strategy, &workspace_limit, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution)*>(self)->inst().mode =
- py::cast<decltype(Convolution::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (pad_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution)*>(self)->inst().pad_h =
- py::cast<decltype(Convolution::pad_h)>(py::handle(pad_h));
- } CATCH_ALL(-1)
- }
-
- if (pad_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution)*>(self)->inst().pad_w =
- py::cast<decltype(Convolution::pad_w)>(py::handle(pad_w));
- } CATCH_ALL(-1)
- }
-
- if (stride_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution)*>(self)->inst().stride_h =
- py::cast<decltype(Convolution::stride_h)>(py::handle(stride_h));
- } CATCH_ALL(-1)
- }
-
- if (stride_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution)*>(self)->inst().stride_w =
- py::cast<decltype(Convolution::stride_w)>(py::handle(stride_w));
- } CATCH_ALL(-1)
- }
-
- if (dilate_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution)*>(self)->inst().dilate_h =
- py::cast<decltype(Convolution::dilate_h)>(py::handle(dilate_h));
- } CATCH_ALL(-1)
- }
-
- if (dilate_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution)*>(self)->inst().dilate_w =
- py::cast<decltype(Convolution::dilate_w)>(py::handle(dilate_w));
- } CATCH_ALL(-1)
- }
-
- if (sparse) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution)*>(self)->inst().sparse =
- py::cast<decltype(Convolution::sparse)>(py::handle(sparse));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution)*>(self)->inst().format =
- py::cast<decltype(Convolution::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (compute_mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution)*>(self)->inst().compute_mode =
- py::cast<decltype(Convolution::compute_mode)>(py::handle(compute_mode));
- } CATCH_ALL(-1)
- }
-
- if (strategy) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution)*>(self)->inst().strategy =
- py::cast<decltype(Convolution::strategy)>(py::handle(strategy));
- } CATCH_ALL(-1)
- }
-
- if (workspace_limit) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution)*>(self)->inst().workspace_limit =
- py::cast<decltype(Convolution::workspace_limit)>(py::handle(workspace_limit));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Convolution)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(Convolution, mode), py_set_generic(Convolution, mode), const_cast<char*>("mode"), NULL},
- {const_cast<char*>("pad_h"), py_get_generic(Convolution, pad_h), py_set_generic(Convolution, pad_h), const_cast<char*>("pad_h"), NULL},
- {const_cast<char*>("pad_w"), py_get_generic(Convolution, pad_w), py_set_generic(Convolution, pad_w), const_cast<char*>("pad_w"), NULL},
- {const_cast<char*>("stride_h"), py_get_generic(Convolution, stride_h), py_set_generic(Convolution, stride_h), const_cast<char*>("stride_h"), NULL},
- {const_cast<char*>("stride_w"), py_get_generic(Convolution, stride_w), py_set_generic(Convolution, stride_w), const_cast<char*>("stride_w"), NULL},
- {const_cast<char*>("dilate_h"), py_get_generic(Convolution, dilate_h), py_set_generic(Convolution, dilate_h), const_cast<char*>("dilate_h"), NULL},
- {const_cast<char*>("dilate_w"), py_get_generic(Convolution, dilate_w), py_set_generic(Convolution, dilate_w), const_cast<char*>("dilate_w"), NULL},
- {const_cast<char*>("sparse"), py_get_generic(Convolution, sparse), py_set_generic(Convolution, sparse), const_cast<char*>("sparse"), NULL},
- {const_cast<char*>("format"), py_get_generic(Convolution, format), py_set_generic(Convolution, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("compute_mode"), py_get_generic(Convolution, compute_mode), py_set_generic(Convolution, compute_mode), const_cast<char*>("compute_mode"), NULL},
- {const_cast<char*>("strategy"), py_get_generic(Convolution, strategy), py_set_generic(Convolution, strategy), const_cast<char*>("strategy"), NULL},
- {const_cast<char*>("workspace_limit"), py_get_generic(Convolution, workspace_limit), py_set_generic(Convolution, workspace_limit), const_cast<char*>("workspace_limit"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Convolution)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Convolution)::getstate, METH_NOARGS, "Convolution getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Convolution)::setstate, METH_VARARGS, "Convolution setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Convolution(py::module m) {
- using py_op = PyOp(Convolution);
- auto& py_type = PyOpType(Convolution);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Convolution";
- py_type.tp_basicsize = sizeof(PyOp(Convolution));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Convolution";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_Convolution_Mode(py_type);
- _init_py_Convolution_Sparse(py_type);
- _init_py_Convolution_Format(py_type);
- _init_py_Convolution_ComputeMode(py_type);
- _init_py_Convolution_Strategy(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("Convolution", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Convolution::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<Convolution3D::Mode> {
- static constexpr const char *name = "Convolution3D.Mode";
- static constexpr std::underlying_type_t<Convolution3D::Mode> max = 2 - 1;
- };
- template<> PyTypeObject* EnumWrapper<Convolution3D::Mode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<Convolution3D::Mode>::members[] = {"CROSS_CORRELATION", "CONVOLUTION"};
-
- template<> std::unordered_map<std::string, Convolution3D::Mode>
- EnumWrapper<Convolution3D::Mode>::mem2value = {{normalize_enum("CROSS_CORRELATION"), Convolution3D::Mode::CROSS_CORRELATION}, {normalize_enum("CONVOLUTION"), Convolution3D::Mode::CONVOLUTION}};
- template<> PyObject* EnumWrapper<Convolution3D::Mode>::pyobj_insts[2] = {nullptr};
-
- void _init_py_Convolution3D_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Convolution3D::Mode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<Convolution3D::Mode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<Convolution3D::Mode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<Convolution3D::Mode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.Convolution3D.Mode",
- // basicsize
- sizeof(EnumWrapper<Convolution3D::Mode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Mode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("Convolution3D.Mode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Convolution3D::Mode>*>(inst)->value = Convolution3D::Mode::CROSS_CORRELATION;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "CROSS_CORRELATION", inst) >= 0);
- EnumWrapper<Convolution3D::Mode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Convolution3D::Mode>*>(inst)->value = Convolution3D::Mode::CONVOLUTION;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "CONVOLUTION", inst) >= 0);
- EnumWrapper<Convolution3D::Mode>::pyobj_insts[1] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- template<> struct EnumTrait<Convolution3D::Sparse> {
- static constexpr const char *name = "Convolution3D.Sparse";
- static constexpr std::underlying_type_t<Convolution3D::Sparse> max = 2 - 1;
- };
- template<> PyTypeObject* EnumWrapper<Convolution3D::Sparse>::type = nullptr;
-
- template<> const char*
- EnumWrapper<Convolution3D::Sparse>::members[] = {"DENSE", "GROUP"};
-
- template<> std::unordered_map<std::string, Convolution3D::Sparse>
- EnumWrapper<Convolution3D::Sparse>::mem2value = {{normalize_enum("DENSE"), Convolution3D::Sparse::DENSE}, {normalize_enum("GROUP"), Convolution3D::Sparse::GROUP}};
- template<> PyObject* EnumWrapper<Convolution3D::Sparse>::pyobj_insts[2] = {nullptr};
-
- void _init_py_Convolution3D_Sparse(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Convolution3D::Sparse>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<Convolution3D::Sparse>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<Convolution3D::Sparse>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<Convolution3D::Sparse>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.Convolution3D.Sparse",
- // basicsize
- sizeof(EnumWrapper<Convolution3D::Sparse>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Sparse").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("Convolution3D.Sparse").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Convolution3D::Sparse>*>(inst)->value = Convolution3D::Sparse::DENSE;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "DENSE", inst) >= 0);
- EnumWrapper<Convolution3D::Sparse>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Convolution3D::Sparse>*>(inst)->value = Convolution3D::Sparse::GROUP;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "GROUP", inst) >= 0);
- EnumWrapper<Convolution3D::Sparse>::pyobj_insts[1] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Sparse", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- template<> struct EnumTrait<Convolution3D::DataType> {
- static constexpr const char *name = "Convolution3D.DataType";
- static constexpr std::underlying_type_t<Convolution3D::DataType> max = 2 - 1;
- };
- template<> PyTypeObject* EnumWrapper<Convolution3D::DataType>::type = nullptr;
-
- template<> const char*
- EnumWrapper<Convolution3D::DataType>::members[] = {"FLOAT", "FLOAT_IO16xC32"};
-
- template<> std::unordered_map<std::string, Convolution3D::DataType>
- EnumWrapper<Convolution3D::DataType>::mem2value = {{normalize_enum("FLOAT"), Convolution3D::DataType::FLOAT}, {normalize_enum("FLOAT_IO16xC32"), Convolution3D::DataType::FLOAT_IO16xC32}};
- template<> PyObject* EnumWrapper<Convolution3D::DataType>::pyobj_insts[2] = {nullptr};
-
- void _init_py_Convolution3D_DataType(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Convolution3D::DataType>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<Convolution3D::DataType>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<Convolution3D::DataType>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<Convolution3D::DataType>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.Convolution3D.DataType",
- // basicsize
- sizeof(EnumWrapper<Convolution3D::DataType>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("DataType").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("Convolution3D.DataType").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Convolution3D::DataType>*>(inst)->value = Convolution3D::DataType::FLOAT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FLOAT", inst) >= 0);
- EnumWrapper<Convolution3D::DataType>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Convolution3D::DataType>*>(inst)->value = Convolution3D::DataType::FLOAT_IO16xC32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FLOAT_IO16xC32", inst) >= 0);
- EnumWrapper<Convolution3D::DataType>::pyobj_insts[1] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "DataType", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- template<> struct EnumTrait<Convolution3D::Format> {
- static constexpr const char *name = "Convolution3D.Format";
- static constexpr std::underlying_type_t<Convolution3D::Format> max = 2 - 1;
- };
- template<> PyTypeObject* EnumWrapper<Convolution3D::Format>::type = nullptr;
-
- template<> const char*
- EnumWrapper<Convolution3D::Format>::members[] = {"NCDHW", "NDHWC"};
-
- template<> std::unordered_map<std::string, Convolution3D::Format>
- EnumWrapper<Convolution3D::Format>::mem2value = {{normalize_enum("NCDHW"), Convolution3D::Format::NCDHW}, {normalize_enum("NDHWC"), Convolution3D::Format::NDHWC}};
- template<> PyObject* EnumWrapper<Convolution3D::Format>::pyobj_insts[2] = {nullptr};
-
- void _init_py_Convolution3D_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Convolution3D::Format>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<Convolution3D::Format>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<Convolution3D::Format>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<Convolution3D::Format>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.Convolution3D.Format",
- // basicsize
- sizeof(EnumWrapper<Convolution3D::Format>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Format").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("Convolution3D.Format").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Convolution3D::Format>*>(inst)->value = Convolution3D::Format::NCDHW;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCDHW", inst) >= 0);
- EnumWrapper<Convolution3D::Format>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Convolution3D::Format>*>(inst)->value = Convolution3D::Format::NDHWC;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NDHWC", inst) >= 0);
- EnumWrapper<Convolution3D::Format>::pyobj_insts[1] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_Convolution3D_Strategy(PyTypeObject& py_type) {
- auto& e_type = BitCombinedEnumWrapper<Convolution3D::Strategy>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Strategy", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(Convolution3D) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Convolution3D)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)},
- {"pad_d", serialization<decltype(opdef.pad_d)>::dump(opdef.pad_d)},
- {"pad_h", serialization<decltype(opdef.pad_h)>::dump(opdef.pad_h)},
- {"pad_w", serialization<decltype(opdef.pad_w)>::dump(opdef.pad_w)},
- {"stride_d", serialization<decltype(opdef.stride_d)>::dump(opdef.stride_d)},
- {"stride_h", serialization<decltype(opdef.stride_h)>::dump(opdef.stride_h)},
- {"stride_w", serialization<decltype(opdef.stride_w)>::dump(opdef.stride_w)},
- {"dilate_d", serialization<decltype(opdef.dilate_d)>::dump(opdef.dilate_d)},
- {"dilate_h", serialization<decltype(opdef.dilate_h)>::dump(opdef.dilate_h)},
- {"dilate_w", serialization<decltype(opdef.dilate_w)>::dump(opdef.dilate_w)},
- {"sparse", serialization<decltype(opdef.sparse)>::dump(opdef.sparse)},
- {"data_type", serialization<decltype(opdef.data_type)>::dump(opdef.data_type)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"strategy", serialization<decltype(opdef.strategy)>::dump(opdef.strategy)},
- {"workspace_limit", serialization<decltype(opdef.workspace_limit)>::dump(opdef.workspace_limit)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Convolution3D)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_d");
- if (iter != state.end()) {
- opdef.pad_d = serialization<decltype(opdef.pad_d)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_h");
- if (iter != state.end()) {
- opdef.pad_h = serialization<decltype(opdef.pad_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_w");
- if (iter != state.end()) {
- opdef.pad_w = serialization<decltype(opdef.pad_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_d");
- if (iter != state.end()) {
- opdef.stride_d = serialization<decltype(opdef.stride_d)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_h");
- if (iter != state.end()) {
- opdef.stride_h = serialization<decltype(opdef.stride_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_w");
- if (iter != state.end()) {
- opdef.stride_w = serialization<decltype(opdef.stride_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_d");
- if (iter != state.end()) {
- opdef.dilate_d = serialization<decltype(opdef.dilate_d)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_h");
- if (iter != state.end()) {
- opdef.dilate_h = serialization<decltype(opdef.dilate_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_w");
- if (iter != state.end()) {
- opdef.dilate_w = serialization<decltype(opdef.dilate_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("sparse");
- if (iter != state.end()) {
- opdef.sparse = serialization<decltype(opdef.sparse)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("data_type");
- if (iter != state.end()) {
- opdef.data_type = serialization<decltype(opdef.data_type)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("strategy");
- if (iter != state.end()) {
- opdef.strategy = serialization<decltype(opdef.strategy)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("workspace_limit");
- if (iter != state.end()) {
- opdef.workspace_limit = serialization<decltype(opdef.workspace_limit)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Convolution3D)
-
- int PyOp(Convolution3D)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "pad_d", "pad_h", "pad_w", "stride_d", "stride_h", "stride_w", "dilate_d", "dilate_h", "dilate_w", "sparse", "data_type", "format", "strategy", "workspace_limit", "scope", NULL};
- PyObject *mode = NULL, *pad_d = NULL, *pad_h = NULL, *pad_w = NULL, *stride_d = NULL, *stride_h = NULL, *stride_w = NULL, *dilate_d = NULL, *dilate_h = NULL, *dilate_w = NULL, *sparse = NULL, *data_type = NULL, *format = NULL, *strategy = NULL, *workspace_limit = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOOOOOOOOO", const_cast<char**>(kwlist), &mode, &pad_d, &pad_h, &pad_w, &stride_d, &stride_h, &stride_w, &dilate_d, &dilate_h, &dilate_w, &sparse, &data_type, &format, &strategy, &workspace_limit, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3D)*>(self)->inst().mode =
- py::cast<decltype(Convolution3D::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (pad_d) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3D)*>(self)->inst().pad_d =
- py::cast<decltype(Convolution3D::pad_d)>(py::handle(pad_d));
- } CATCH_ALL(-1)
- }
-
- if (pad_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3D)*>(self)->inst().pad_h =
- py::cast<decltype(Convolution3D::pad_h)>(py::handle(pad_h));
- } CATCH_ALL(-1)
- }
-
- if (pad_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3D)*>(self)->inst().pad_w =
- py::cast<decltype(Convolution3D::pad_w)>(py::handle(pad_w));
- } CATCH_ALL(-1)
- }
-
- if (stride_d) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3D)*>(self)->inst().stride_d =
- py::cast<decltype(Convolution3D::stride_d)>(py::handle(stride_d));
- } CATCH_ALL(-1)
- }
-
- if (stride_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3D)*>(self)->inst().stride_h =
- py::cast<decltype(Convolution3D::stride_h)>(py::handle(stride_h));
- } CATCH_ALL(-1)
- }
-
- if (stride_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3D)*>(self)->inst().stride_w =
- py::cast<decltype(Convolution3D::stride_w)>(py::handle(stride_w));
- } CATCH_ALL(-1)
- }
-
- if (dilate_d) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3D)*>(self)->inst().dilate_d =
- py::cast<decltype(Convolution3D::dilate_d)>(py::handle(dilate_d));
- } CATCH_ALL(-1)
- }
-
- if (dilate_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3D)*>(self)->inst().dilate_h =
- py::cast<decltype(Convolution3D::dilate_h)>(py::handle(dilate_h));
- } CATCH_ALL(-1)
- }
-
- if (dilate_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3D)*>(self)->inst().dilate_w =
- py::cast<decltype(Convolution3D::dilate_w)>(py::handle(dilate_w));
- } CATCH_ALL(-1)
- }
-
- if (sparse) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3D)*>(self)->inst().sparse =
- py::cast<decltype(Convolution3D::sparse)>(py::handle(sparse));
- } CATCH_ALL(-1)
- }
-
- if (data_type) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3D)*>(self)->inst().data_type =
- py::cast<decltype(Convolution3D::data_type)>(py::handle(data_type));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3D)*>(self)->inst().format =
- py::cast<decltype(Convolution3D::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (strategy) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3D)*>(self)->inst().strategy =
- py::cast<decltype(Convolution3D::strategy)>(py::handle(strategy));
- } CATCH_ALL(-1)
- }
-
- if (workspace_limit) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3D)*>(self)->inst().workspace_limit =
- py::cast<decltype(Convolution3D::workspace_limit)>(py::handle(workspace_limit));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Convolution3D)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(Convolution3D, mode), py_set_generic(Convolution3D, mode), const_cast<char*>("mode"), NULL},
- {const_cast<char*>("pad_d"), py_get_generic(Convolution3D, pad_d), py_set_generic(Convolution3D, pad_d), const_cast<char*>("pad_d"), NULL},
- {const_cast<char*>("pad_h"), py_get_generic(Convolution3D, pad_h), py_set_generic(Convolution3D, pad_h), const_cast<char*>("pad_h"), NULL},
- {const_cast<char*>("pad_w"), py_get_generic(Convolution3D, pad_w), py_set_generic(Convolution3D, pad_w), const_cast<char*>("pad_w"), NULL},
- {const_cast<char*>("stride_d"), py_get_generic(Convolution3D, stride_d), py_set_generic(Convolution3D, stride_d), const_cast<char*>("stride_d"), NULL},
- {const_cast<char*>("stride_h"), py_get_generic(Convolution3D, stride_h), py_set_generic(Convolution3D, stride_h), const_cast<char*>("stride_h"), NULL},
- {const_cast<char*>("stride_w"), py_get_generic(Convolution3D, stride_w), py_set_generic(Convolution3D, stride_w), const_cast<char*>("stride_w"), NULL},
- {const_cast<char*>("dilate_d"), py_get_generic(Convolution3D, dilate_d), py_set_generic(Convolution3D, dilate_d), const_cast<char*>("dilate_d"), NULL},
- {const_cast<char*>("dilate_h"), py_get_generic(Convolution3D, dilate_h), py_set_generic(Convolution3D, dilate_h), const_cast<char*>("dilate_h"), NULL},
- {const_cast<char*>("dilate_w"), py_get_generic(Convolution3D, dilate_w), py_set_generic(Convolution3D, dilate_w), const_cast<char*>("dilate_w"), NULL},
- {const_cast<char*>("sparse"), py_get_generic(Convolution3D, sparse), py_set_generic(Convolution3D, sparse), const_cast<char*>("sparse"), NULL},
- {const_cast<char*>("data_type"), py_get_generic(Convolution3D, data_type), py_set_generic(Convolution3D, data_type), const_cast<char*>("data_type"), NULL},
- {const_cast<char*>("format"), py_get_generic(Convolution3D, format), py_set_generic(Convolution3D, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("strategy"), py_get_generic(Convolution3D, strategy), py_set_generic(Convolution3D, strategy), const_cast<char*>("strategy"), NULL},
- {const_cast<char*>("workspace_limit"), py_get_generic(Convolution3D, workspace_limit), py_set_generic(Convolution3D, workspace_limit), const_cast<char*>("workspace_limit"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Convolution3D)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Convolution3D)::getstate, METH_NOARGS, "Convolution3D getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Convolution3D)::setstate, METH_VARARGS, "Convolution3D setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Convolution3D(py::module m) {
- using py_op = PyOp(Convolution3D);
- auto& py_type = PyOpType(Convolution3D);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Convolution3D";
- py_type.tp_basicsize = sizeof(PyOp(Convolution3D));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Convolution3D";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_Convolution3D_Mode(py_type);
- _init_py_Convolution3D_Sparse(py_type);
- _init_py_Convolution3D_DataType(py_type);
- _init_py_Convolution3D_Format(py_type);
- _init_py_Convolution3D_Strategy(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("Convolution3D", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Convolution3D::typeinfo(), &py_type).second);
- }
-
- void _init_py_Convolution3DBackwardData_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Convolution3DBackwardData::Mode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_Convolution3DBackwardData_Sparse(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Convolution3DBackwardData::Sparse>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Sparse", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_Convolution3DBackwardData_DataType(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Convolution3DBackwardData::DataType>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "DataType", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_Convolution3DBackwardData_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Convolution3DBackwardData::Format>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_Convolution3DBackwardData_Strategy(PyTypeObject& py_type) {
- auto& e_type = BitCombinedEnumWrapper<Convolution3DBackwardData::Strategy>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Strategy", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(Convolution3DBackwardData) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)},
- {"pad_d", serialization<decltype(opdef.pad_d)>::dump(opdef.pad_d)},
- {"pad_h", serialization<decltype(opdef.pad_h)>::dump(opdef.pad_h)},
- {"pad_w", serialization<decltype(opdef.pad_w)>::dump(opdef.pad_w)},
- {"stride_d", serialization<decltype(opdef.stride_d)>::dump(opdef.stride_d)},
- {"stride_h", serialization<decltype(opdef.stride_h)>::dump(opdef.stride_h)},
- {"stride_w", serialization<decltype(opdef.stride_w)>::dump(opdef.stride_w)},
- {"dilate_d", serialization<decltype(opdef.dilate_d)>::dump(opdef.dilate_d)},
- {"dilate_h", serialization<decltype(opdef.dilate_h)>::dump(opdef.dilate_h)},
- {"dilate_w", serialization<decltype(opdef.dilate_w)>::dump(opdef.dilate_w)},
- {"sparse", serialization<decltype(opdef.sparse)>::dump(opdef.sparse)},
- {"data_type", serialization<decltype(opdef.data_type)>::dump(opdef.data_type)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"strategy", serialization<decltype(opdef.strategy)>::dump(opdef.strategy)},
- {"workspace_limit", serialization<decltype(opdef.workspace_limit)>::dump(opdef.workspace_limit)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_d");
- if (iter != state.end()) {
- opdef.pad_d = serialization<decltype(opdef.pad_d)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_h");
- if (iter != state.end()) {
- opdef.pad_h = serialization<decltype(opdef.pad_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_w");
- if (iter != state.end()) {
- opdef.pad_w = serialization<decltype(opdef.pad_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_d");
- if (iter != state.end()) {
- opdef.stride_d = serialization<decltype(opdef.stride_d)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_h");
- if (iter != state.end()) {
- opdef.stride_h = serialization<decltype(opdef.stride_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_w");
- if (iter != state.end()) {
- opdef.stride_w = serialization<decltype(opdef.stride_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_d");
- if (iter != state.end()) {
- opdef.dilate_d = serialization<decltype(opdef.dilate_d)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_h");
- if (iter != state.end()) {
- opdef.dilate_h = serialization<decltype(opdef.dilate_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_w");
- if (iter != state.end()) {
- opdef.dilate_w = serialization<decltype(opdef.dilate_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("sparse");
- if (iter != state.end()) {
- opdef.sparse = serialization<decltype(opdef.sparse)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("data_type");
- if (iter != state.end()) {
- opdef.data_type = serialization<decltype(opdef.data_type)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("strategy");
- if (iter != state.end()) {
- opdef.strategy = serialization<decltype(opdef.strategy)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("workspace_limit");
- if (iter != state.end()) {
- opdef.workspace_limit = serialization<decltype(opdef.workspace_limit)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Convolution3DBackwardData)
-
- int PyOp(Convolution3DBackwardData)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "pad_d", "pad_h", "pad_w", "stride_d", "stride_h", "stride_w", "dilate_d", "dilate_h", "dilate_w", "sparse", "data_type", "format", "strategy", "workspace_limit", "scope", NULL};
- PyObject *mode = NULL, *pad_d = NULL, *pad_h = NULL, *pad_w = NULL, *stride_d = NULL, *stride_h = NULL, *stride_w = NULL, *dilate_d = NULL, *dilate_h = NULL, *dilate_w = NULL, *sparse = NULL, *data_type = NULL, *format = NULL, *strategy = NULL, *workspace_limit = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOOOOOOOOO", const_cast<char**>(kwlist), &mode, &pad_d, &pad_h, &pad_w, &stride_d, &stride_h, &stride_w, &dilate_d, &dilate_h, &dilate_w, &sparse, &data_type, &format, &strategy, &workspace_limit, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst().mode =
- py::cast<decltype(Convolution3DBackwardData::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (pad_d) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst().pad_d =
- py::cast<decltype(Convolution3DBackwardData::pad_d)>(py::handle(pad_d));
- } CATCH_ALL(-1)
- }
-
- if (pad_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst().pad_h =
- py::cast<decltype(Convolution3DBackwardData::pad_h)>(py::handle(pad_h));
- } CATCH_ALL(-1)
- }
-
- if (pad_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst().pad_w =
- py::cast<decltype(Convolution3DBackwardData::pad_w)>(py::handle(pad_w));
- } CATCH_ALL(-1)
- }
-
- if (stride_d) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst().stride_d =
- py::cast<decltype(Convolution3DBackwardData::stride_d)>(py::handle(stride_d));
- } CATCH_ALL(-1)
- }
-
- if (stride_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst().stride_h =
- py::cast<decltype(Convolution3DBackwardData::stride_h)>(py::handle(stride_h));
- } CATCH_ALL(-1)
- }
-
- if (stride_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst().stride_w =
- py::cast<decltype(Convolution3DBackwardData::stride_w)>(py::handle(stride_w));
- } CATCH_ALL(-1)
- }
-
- if (dilate_d) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst().dilate_d =
- py::cast<decltype(Convolution3DBackwardData::dilate_d)>(py::handle(dilate_d));
- } CATCH_ALL(-1)
- }
-
- if (dilate_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst().dilate_h =
- py::cast<decltype(Convolution3DBackwardData::dilate_h)>(py::handle(dilate_h));
- } CATCH_ALL(-1)
- }
-
- if (dilate_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst().dilate_w =
- py::cast<decltype(Convolution3DBackwardData::dilate_w)>(py::handle(dilate_w));
- } CATCH_ALL(-1)
- }
-
- if (sparse) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst().sparse =
- py::cast<decltype(Convolution3DBackwardData::sparse)>(py::handle(sparse));
- } CATCH_ALL(-1)
- }
-
- if (data_type) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst().data_type =
- py::cast<decltype(Convolution3DBackwardData::data_type)>(py::handle(data_type));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst().format =
- py::cast<decltype(Convolution3DBackwardData::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (strategy) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst().strategy =
- py::cast<decltype(Convolution3DBackwardData::strategy)>(py::handle(strategy));
- } CATCH_ALL(-1)
- }
-
- if (workspace_limit) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Convolution3DBackwardData)*>(self)->inst().workspace_limit =
- py::cast<decltype(Convolution3DBackwardData::workspace_limit)>(py::handle(workspace_limit));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Convolution3DBackwardData)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(Convolution3DBackwardData, mode), py_set_generic(Convolution3DBackwardData, mode), const_cast<char*>("mode"), NULL},
- {const_cast<char*>("pad_d"), py_get_generic(Convolution3DBackwardData, pad_d), py_set_generic(Convolution3DBackwardData, pad_d), const_cast<char*>("pad_d"), NULL},
- {const_cast<char*>("pad_h"), py_get_generic(Convolution3DBackwardData, pad_h), py_set_generic(Convolution3DBackwardData, pad_h), const_cast<char*>("pad_h"), NULL},
- {const_cast<char*>("pad_w"), py_get_generic(Convolution3DBackwardData, pad_w), py_set_generic(Convolution3DBackwardData, pad_w), const_cast<char*>("pad_w"), NULL},
- {const_cast<char*>("stride_d"), py_get_generic(Convolution3DBackwardData, stride_d), py_set_generic(Convolution3DBackwardData, stride_d), const_cast<char*>("stride_d"), NULL},
- {const_cast<char*>("stride_h"), py_get_generic(Convolution3DBackwardData, stride_h), py_set_generic(Convolution3DBackwardData, stride_h), const_cast<char*>("stride_h"), NULL},
- {const_cast<char*>("stride_w"), py_get_generic(Convolution3DBackwardData, stride_w), py_set_generic(Convolution3DBackwardData, stride_w), const_cast<char*>("stride_w"), NULL},
- {const_cast<char*>("dilate_d"), py_get_generic(Convolution3DBackwardData, dilate_d), py_set_generic(Convolution3DBackwardData, dilate_d), const_cast<char*>("dilate_d"), NULL},
- {const_cast<char*>("dilate_h"), py_get_generic(Convolution3DBackwardData, dilate_h), py_set_generic(Convolution3DBackwardData, dilate_h), const_cast<char*>("dilate_h"), NULL},
- {const_cast<char*>("dilate_w"), py_get_generic(Convolution3DBackwardData, dilate_w), py_set_generic(Convolution3DBackwardData, dilate_w), const_cast<char*>("dilate_w"), NULL},
- {const_cast<char*>("sparse"), py_get_generic(Convolution3DBackwardData, sparse), py_set_generic(Convolution3DBackwardData, sparse), const_cast<char*>("sparse"), NULL},
- {const_cast<char*>("data_type"), py_get_generic(Convolution3DBackwardData, data_type), py_set_generic(Convolution3DBackwardData, data_type), const_cast<char*>("data_type"), NULL},
- {const_cast<char*>("format"), py_get_generic(Convolution3DBackwardData, format), py_set_generic(Convolution3DBackwardData, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("strategy"), py_get_generic(Convolution3DBackwardData, strategy), py_set_generic(Convolution3DBackwardData, strategy), const_cast<char*>("strategy"), NULL},
- {const_cast<char*>("workspace_limit"), py_get_generic(Convolution3DBackwardData, workspace_limit), py_set_generic(Convolution3DBackwardData, workspace_limit), const_cast<char*>("workspace_limit"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Convolution3DBackwardData)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Convolution3DBackwardData)::getstate, METH_NOARGS, "Convolution3DBackwardData getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Convolution3DBackwardData)::setstate, METH_VARARGS, "Convolution3DBackwardData setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Convolution3DBackwardData(py::module m) {
- using py_op = PyOp(Convolution3DBackwardData);
- auto& py_type = PyOpType(Convolution3DBackwardData);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Convolution3DBackwardData";
- py_type.tp_basicsize = sizeof(PyOp(Convolution3DBackwardData));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Convolution3DBackwardData";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_Convolution3DBackwardData_Mode(py_type);
- _init_py_Convolution3DBackwardData_Sparse(py_type);
- _init_py_Convolution3DBackwardData_DataType(py_type);
- _init_py_Convolution3DBackwardData_Format(py_type);
- _init_py_Convolution3DBackwardData_Strategy(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("Convolution3DBackwardData", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Convolution3DBackwardData::typeinfo(), &py_type).second);
- }
-
- void _init_py_ConvolutionBackwardData_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<ConvolutionBackwardData::Mode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_ConvolutionBackwardData_Sparse(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<ConvolutionBackwardData::Sparse>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Sparse", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_ConvolutionBackwardData_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<ConvolutionBackwardData::Format>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_ConvolutionBackwardData_ComputeMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<ConvolutionBackwardData::ComputeMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "ComputeMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_ConvolutionBackwardData_Strategy(PyTypeObject& py_type) {
- auto& e_type = BitCombinedEnumWrapper<ConvolutionBackwardData::Strategy>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Strategy", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(ConvolutionBackwardData) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(ConvolutionBackwardData)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)},
- {"pad_h", serialization<decltype(opdef.pad_h)>::dump(opdef.pad_h)},
- {"pad_w", serialization<decltype(opdef.pad_w)>::dump(opdef.pad_w)},
- {"stride_h", serialization<decltype(opdef.stride_h)>::dump(opdef.stride_h)},
- {"stride_w", serialization<decltype(opdef.stride_w)>::dump(opdef.stride_w)},
- {"dilate_h", serialization<decltype(opdef.dilate_h)>::dump(opdef.dilate_h)},
- {"dilate_w", serialization<decltype(opdef.dilate_w)>::dump(opdef.dilate_w)},
- {"sparse", serialization<decltype(opdef.sparse)>::dump(opdef.sparse)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"compute_mode", serialization<decltype(opdef.compute_mode)>::dump(opdef.compute_mode)},
- {"strategy", serialization<decltype(opdef.strategy)>::dump(opdef.strategy)},
- {"workspace_limit", serialization<decltype(opdef.workspace_limit)>::dump(opdef.workspace_limit)},
- {"dtype", serialization<decltype(opdef.dtype)>::dump(opdef.dtype)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(ConvolutionBackwardData)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_h");
- if (iter != state.end()) {
- opdef.pad_h = serialization<decltype(opdef.pad_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_w");
- if (iter != state.end()) {
- opdef.pad_w = serialization<decltype(opdef.pad_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_h");
- if (iter != state.end()) {
- opdef.stride_h = serialization<decltype(opdef.stride_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_w");
- if (iter != state.end()) {
- opdef.stride_w = serialization<decltype(opdef.stride_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_h");
- if (iter != state.end()) {
- opdef.dilate_h = serialization<decltype(opdef.dilate_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_w");
- if (iter != state.end()) {
- opdef.dilate_w = serialization<decltype(opdef.dilate_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("sparse");
- if (iter != state.end()) {
- opdef.sparse = serialization<decltype(opdef.sparse)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("compute_mode");
- if (iter != state.end()) {
- opdef.compute_mode = serialization<decltype(opdef.compute_mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("strategy");
- if (iter != state.end()) {
- opdef.strategy = serialization<decltype(opdef.strategy)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("workspace_limit");
- if (iter != state.end()) {
- opdef.workspace_limit = serialization<decltype(opdef.workspace_limit)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dtype");
- if (iter != state.end()) {
- opdef.dtype = serialization<decltype(opdef.dtype)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(ConvolutionBackwardData)
-
- int PyOp(ConvolutionBackwardData)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "pad_h", "pad_w", "stride_h", "stride_w", "dilate_h", "dilate_w", "sparse", "format", "compute_mode", "strategy", "workspace_limit", "dtype", "scope", NULL};
- PyObject *mode = NULL, *pad_h = NULL, *pad_w = NULL, *stride_h = NULL, *stride_w = NULL, *dilate_h = NULL, *dilate_w = NULL, *sparse = NULL, *format = NULL, *compute_mode = NULL, *strategy = NULL, *workspace_limit = NULL, *dtype = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOOOOOOO", const_cast<char**>(kwlist), &mode, &pad_h, &pad_w, &stride_h, &stride_w, &dilate_h, &dilate_w, &sparse, &format, &compute_mode, &strategy, &workspace_limit, &dtype, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvolutionBackwardData)*>(self)->inst().mode =
- py::cast<decltype(ConvolutionBackwardData::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (pad_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvolutionBackwardData)*>(self)->inst().pad_h =
- py::cast<decltype(ConvolutionBackwardData::pad_h)>(py::handle(pad_h));
- } CATCH_ALL(-1)
- }
-
- if (pad_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvolutionBackwardData)*>(self)->inst().pad_w =
- py::cast<decltype(ConvolutionBackwardData::pad_w)>(py::handle(pad_w));
- } CATCH_ALL(-1)
- }
-
- if (stride_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvolutionBackwardData)*>(self)->inst().stride_h =
- py::cast<decltype(ConvolutionBackwardData::stride_h)>(py::handle(stride_h));
- } CATCH_ALL(-1)
- }
-
- if (stride_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvolutionBackwardData)*>(self)->inst().stride_w =
- py::cast<decltype(ConvolutionBackwardData::stride_w)>(py::handle(stride_w));
- } CATCH_ALL(-1)
- }
-
- if (dilate_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvolutionBackwardData)*>(self)->inst().dilate_h =
- py::cast<decltype(ConvolutionBackwardData::dilate_h)>(py::handle(dilate_h));
- } CATCH_ALL(-1)
- }
-
- if (dilate_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvolutionBackwardData)*>(self)->inst().dilate_w =
- py::cast<decltype(ConvolutionBackwardData::dilate_w)>(py::handle(dilate_w));
- } CATCH_ALL(-1)
- }
-
- if (sparse) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvolutionBackwardData)*>(self)->inst().sparse =
- py::cast<decltype(ConvolutionBackwardData::sparse)>(py::handle(sparse));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvolutionBackwardData)*>(self)->inst().format =
- py::cast<decltype(ConvolutionBackwardData::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (compute_mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvolutionBackwardData)*>(self)->inst().compute_mode =
- py::cast<decltype(ConvolutionBackwardData::compute_mode)>(py::handle(compute_mode));
- } CATCH_ALL(-1)
- }
-
- if (strategy) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvolutionBackwardData)*>(self)->inst().strategy =
- py::cast<decltype(ConvolutionBackwardData::strategy)>(py::handle(strategy));
- } CATCH_ALL(-1)
- }
-
- if (workspace_limit) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvolutionBackwardData)*>(self)->inst().workspace_limit =
- py::cast<decltype(ConvolutionBackwardData::workspace_limit)>(py::handle(workspace_limit));
- } CATCH_ALL(-1)
- }
-
- if (dtype) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ConvolutionBackwardData)*>(self)->inst().dtype =
- py::cast<decltype(ConvolutionBackwardData::dtype)>(py::handle(dtype));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(ConvolutionBackwardData)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(ConvolutionBackwardData, mode), py_set_generic(ConvolutionBackwardData, mode), const_cast<char*>("mode"), NULL},
- {const_cast<char*>("pad_h"), py_get_generic(ConvolutionBackwardData, pad_h), py_set_generic(ConvolutionBackwardData, pad_h), const_cast<char*>("pad_h"), NULL},
- {const_cast<char*>("pad_w"), py_get_generic(ConvolutionBackwardData, pad_w), py_set_generic(ConvolutionBackwardData, pad_w), const_cast<char*>("pad_w"), NULL},
- {const_cast<char*>("stride_h"), py_get_generic(ConvolutionBackwardData, stride_h), py_set_generic(ConvolutionBackwardData, stride_h), const_cast<char*>("stride_h"), NULL},
- {const_cast<char*>("stride_w"), py_get_generic(ConvolutionBackwardData, stride_w), py_set_generic(ConvolutionBackwardData, stride_w), const_cast<char*>("stride_w"), NULL},
- {const_cast<char*>("dilate_h"), py_get_generic(ConvolutionBackwardData, dilate_h), py_set_generic(ConvolutionBackwardData, dilate_h), const_cast<char*>("dilate_h"), NULL},
- {const_cast<char*>("dilate_w"), py_get_generic(ConvolutionBackwardData, dilate_w), py_set_generic(ConvolutionBackwardData, dilate_w), const_cast<char*>("dilate_w"), NULL},
- {const_cast<char*>("sparse"), py_get_generic(ConvolutionBackwardData, sparse), py_set_generic(ConvolutionBackwardData, sparse), const_cast<char*>("sparse"), NULL},
- {const_cast<char*>("format"), py_get_generic(ConvolutionBackwardData, format), py_set_generic(ConvolutionBackwardData, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("compute_mode"), py_get_generic(ConvolutionBackwardData, compute_mode), py_set_generic(ConvolutionBackwardData, compute_mode), const_cast<char*>("compute_mode"), NULL},
- {const_cast<char*>("strategy"), py_get_generic(ConvolutionBackwardData, strategy), py_set_generic(ConvolutionBackwardData, strategy), const_cast<char*>("strategy"), NULL},
- {const_cast<char*>("workspace_limit"), py_get_generic(ConvolutionBackwardData, workspace_limit), py_set_generic(ConvolutionBackwardData, workspace_limit), const_cast<char*>("workspace_limit"), NULL},
- {const_cast<char*>("dtype"), py_get_generic(ConvolutionBackwardData, dtype), py_set_generic(ConvolutionBackwardData, dtype), const_cast<char*>("dtype"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(ConvolutionBackwardData)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(ConvolutionBackwardData)::getstate, METH_NOARGS, "ConvolutionBackwardData getstate"},
- {const_cast<char*>("__setstate__"), PyOp(ConvolutionBackwardData)::setstate, METH_VARARGS, "ConvolutionBackwardData setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_ConvolutionBackwardData(py::module m) {
- using py_op = PyOp(ConvolutionBackwardData);
- auto& py_type = PyOpType(ConvolutionBackwardData);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.ConvolutionBackwardData";
- py_type.tp_basicsize = sizeof(PyOp(ConvolutionBackwardData));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "ConvolutionBackwardData";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_ConvolutionBackwardData_Mode(py_type);
- _init_py_ConvolutionBackwardData_Sparse(py_type);
- _init_py_ConvolutionBackwardData_Format(py_type);
- _init_py_ConvolutionBackwardData_ComputeMode(py_type);
- _init_py_ConvolutionBackwardData_Strategy(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("ConvolutionBackwardData", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(ConvolutionBackwardData::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Copy) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Copy)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"comp_node", serialization<decltype(opdef.comp_node)>::dump(opdef.comp_node)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Copy)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("comp_node");
- if (iter != state.end()) {
- opdef.comp_node = serialization<decltype(opdef.comp_node)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Copy)
-
- int PyOp(Copy)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"comp_node", "scope", NULL};
- PyObject *comp_node = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &comp_node, &scope))
- return -1;
-
- if (comp_node) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Copy)*>(self)->inst().comp_node =
- py::cast<decltype(Copy::comp_node)>(py::handle(comp_node));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Copy)::py_getsetters[] = {
- {const_cast<char*>("comp_node"), py_get_generic(Copy, comp_node), py_set_generic(Copy, comp_node), const_cast<char*>("comp_node"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Copy)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Copy)::getstate, METH_NOARGS, "Copy getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Copy)::setstate, METH_VARARGS, "Copy setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Copy(py::module m) {
- using py_op = PyOp(Copy);
- auto& py_type = PyOpType(Copy);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Copy";
- py_type.tp_basicsize = sizeof(PyOp(Copy));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Copy";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Copy", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Copy::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<Correlation::Format> {
- static constexpr const char *name = "Correlation.Format";
- static constexpr std::underlying_type_t<Correlation::Format> max = 20 - 1;
- };
- template<> PyTypeObject* EnumWrapper<Correlation::Format>::type = nullptr;
-
- template<> const char*
- EnumWrapper<Correlation::Format>::members[] = {"NCHW", "NHWC", "NHWCD4", "NCHW4", "NCHW8", "NCHW32", "NCHW88", "NCHW44", "NCHW44_DOT", "NCHW_WINOGRAD", "NCHW88_WINOGRAD", "NCHW44_WINOGRAD", "NCHW4_NCHW32", "NCHW32_NCHW4", "NCHW4_NCHW", "NHWC_NCHW", "NHWC_NCHW4_IC_SMALL", "NCHW_NCHW4_IC_SMALL", "CHWN4", "NCHW4_NHWC"};
-
- template<> std::unordered_map<std::string, Correlation::Format>
- EnumWrapper<Correlation::Format>::mem2value = {{normalize_enum("NCHW"), Correlation::Format::NCHW}, {normalize_enum("NHWC"), Correlation::Format::NHWC}, {normalize_enum("NHWCD4"), Correlation::Format::NHWCD4}, {normalize_enum("NCHW4"), Correlation::Format::NCHW4}, {normalize_enum("NCHW8"), Correlation::Format::NCHW8}, {normalize_enum("NCHW32"), Correlation::Format::NCHW32}, {normalize_enum("NCHW88"), Correlation::Format::NCHW88}, {normalize_enum("NCHW44"), Correlation::Format::NCHW44}, {normalize_enum("NCHW44_DOT"), Correlation::Format::NCHW44_DOT}, {normalize_enum("NCHW_WINOGRAD"), Correlation::Format::NCHW_WINOGRAD}, {normalize_enum("NCHW88_WINOGRAD"), Correlation::Format::NCHW88_WINOGRAD}, {normalize_enum("NCHW44_WINOGRAD"), Correlation::Format::NCHW44_WINOGRAD}, {normalize_enum("NCHW4_NCHW32"), Correlation::Format::NCHW4_NCHW32}, {normalize_enum("NCHW32_NCHW4"), Correlation::Format::NCHW32_NCHW4}, {normalize_enum("NCHW4_NCHW"), Correlation::Format::NCHW4_NCHW}, {normalize_enum("NHWC_NCHW"), Correlation::Format::NHWC_NCHW}, {normalize_enum("NHWC_NCHW4_IC_SMALL"), Correlation::Format::NHWC_NCHW4_IC_SMALL}, {normalize_enum("NCHW_NCHW4_IC_SMALL"), Correlation::Format::NCHW_NCHW4_IC_SMALL}, {normalize_enum("CHWN4"), Correlation::Format::CHWN4}, {normalize_enum("NCHW4_NHWC"), Correlation::Format::NCHW4_NHWC}};
- template<> PyObject* EnumWrapper<Correlation::Format>::pyobj_insts[20] = {nullptr};
-
- void _init_py_Correlation_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Correlation::Format>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<Correlation::Format>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<Correlation::Format>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<Correlation::Format>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.Correlation.Format",
- // basicsize
- sizeof(EnumWrapper<Correlation::Format>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Format").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("Correlation.Format").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NCHW;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NHWC;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NHWC", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NHWCD4;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NHWCD4", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[2] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NCHW4;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW4", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[3] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NCHW8;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW8", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[4] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NCHW32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW32", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[5] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NCHW88;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW88", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[6] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NCHW44;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW44", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[7] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NCHW44_DOT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW44_DOT", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[8] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NCHW_WINOGRAD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW_WINOGRAD", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[9] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NCHW88_WINOGRAD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW88_WINOGRAD", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[10] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NCHW44_WINOGRAD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW44_WINOGRAD", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[11] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NCHW4_NCHW32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW4_NCHW32", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[12] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NCHW32_NCHW4;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW32_NCHW4", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[13] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NCHW4_NCHW;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW4_NCHW", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[14] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NHWC_NCHW;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NHWC_NCHW", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[15] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NHWC_NCHW4_IC_SMALL;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NHWC_NCHW4_IC_SMALL", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[16] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NCHW_NCHW4_IC_SMALL;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW_NCHW4_IC_SMALL", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[17] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::CHWN4;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "CHWN4", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[18] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Correlation::Format>*>(inst)->value = Correlation::Format::NCHW4_NHWC;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NCHW4_NHWC", inst) >= 0);
- EnumWrapper<Correlation::Format>::pyobj_insts[19] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(Correlation) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Correlation)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"kernel_size", serialization<decltype(opdef.kernel_size)>::dump(opdef.kernel_size)},
- {"max_displacement", serialization<decltype(opdef.max_displacement)>::dump(opdef.max_displacement)},
- {"stride1", serialization<decltype(opdef.stride1)>::dump(opdef.stride1)},
- {"stride2", serialization<decltype(opdef.stride2)>::dump(opdef.stride2)},
- {"pad_size", serialization<decltype(opdef.pad_size)>::dump(opdef.pad_size)},
- {"is_multiply", serialization<decltype(opdef.is_multiply)>::dump(opdef.is_multiply)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Correlation)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("kernel_size");
- if (iter != state.end()) {
- opdef.kernel_size = serialization<decltype(opdef.kernel_size)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("max_displacement");
- if (iter != state.end()) {
- opdef.max_displacement = serialization<decltype(opdef.max_displacement)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride1");
- if (iter != state.end()) {
- opdef.stride1 = serialization<decltype(opdef.stride1)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride2");
- if (iter != state.end()) {
- opdef.stride2 = serialization<decltype(opdef.stride2)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_size");
- if (iter != state.end()) {
- opdef.pad_size = serialization<decltype(opdef.pad_size)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("is_multiply");
- if (iter != state.end()) {
- opdef.is_multiply = serialization<decltype(opdef.is_multiply)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Correlation)
-
- int PyOp(Correlation)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"format", "kernel_size", "max_displacement", "stride1", "stride2", "pad_size", "is_multiply", "scope", NULL};
- PyObject *format = NULL, *kernel_size = NULL, *max_displacement = NULL, *stride1 = NULL, *stride2 = NULL, *pad_size = NULL, *is_multiply = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOO", const_cast<char**>(kwlist), &format, &kernel_size, &max_displacement, &stride1, &stride2, &pad_size, &is_multiply, &scope))
- return -1;
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Correlation)*>(self)->inst().format =
- py::cast<decltype(Correlation::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (kernel_size) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Correlation)*>(self)->inst().kernel_size =
- py::cast<decltype(Correlation::kernel_size)>(py::handle(kernel_size));
- } CATCH_ALL(-1)
- }
-
- if (max_displacement) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Correlation)*>(self)->inst().max_displacement =
- py::cast<decltype(Correlation::max_displacement)>(py::handle(max_displacement));
- } CATCH_ALL(-1)
- }
-
- if (stride1) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Correlation)*>(self)->inst().stride1 =
- py::cast<decltype(Correlation::stride1)>(py::handle(stride1));
- } CATCH_ALL(-1)
- }
-
- if (stride2) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Correlation)*>(self)->inst().stride2 =
- py::cast<decltype(Correlation::stride2)>(py::handle(stride2));
- } CATCH_ALL(-1)
- }
-
- if (pad_size) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Correlation)*>(self)->inst().pad_size =
- py::cast<decltype(Correlation::pad_size)>(py::handle(pad_size));
- } CATCH_ALL(-1)
- }
-
- if (is_multiply) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Correlation)*>(self)->inst().is_multiply =
- py::cast<decltype(Correlation::is_multiply)>(py::handle(is_multiply));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Correlation)::py_getsetters[] = {
- {const_cast<char*>("format"), py_get_generic(Correlation, format), py_set_generic(Correlation, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("kernel_size"), py_get_generic(Correlation, kernel_size), py_set_generic(Correlation, kernel_size), const_cast<char*>("kernel_size"), NULL},
- {const_cast<char*>("max_displacement"), py_get_generic(Correlation, max_displacement), py_set_generic(Correlation, max_displacement), const_cast<char*>("max_displacement"), NULL},
- {const_cast<char*>("stride1"), py_get_generic(Correlation, stride1), py_set_generic(Correlation, stride1), const_cast<char*>("stride1"), NULL},
- {const_cast<char*>("stride2"), py_get_generic(Correlation, stride2), py_set_generic(Correlation, stride2), const_cast<char*>("stride2"), NULL},
- {const_cast<char*>("pad_size"), py_get_generic(Correlation, pad_size), py_set_generic(Correlation, pad_size), const_cast<char*>("pad_size"), NULL},
- {const_cast<char*>("is_multiply"), py_get_generic(Correlation, is_multiply), py_set_generic(Correlation, is_multiply), const_cast<char*>("is_multiply"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Correlation)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Correlation)::getstate, METH_NOARGS, "Correlation getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Correlation)::setstate, METH_VARARGS, "Correlation setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Correlation(py::module m) {
- using py_op = PyOp(Correlation);
- auto& py_type = PyOpType(Correlation);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Correlation";
- py_type.tp_basicsize = sizeof(PyOp(Correlation));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Correlation";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_Correlation_Format(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("Correlation", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Correlation::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Cumsum) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Cumsum)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"axis", serialization<decltype(opdef.axis)>::dump(opdef.axis)},
- {"exclusive", serialization<decltype(opdef.exclusive)>::dump(opdef.exclusive)},
- {"reverse", serialization<decltype(opdef.reverse)>::dump(opdef.reverse)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Cumsum)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("axis");
- if (iter != state.end()) {
- opdef.axis = serialization<decltype(opdef.axis)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("exclusive");
- if (iter != state.end()) {
- opdef.exclusive = serialization<decltype(opdef.exclusive)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("reverse");
- if (iter != state.end()) {
- opdef.reverse = serialization<decltype(opdef.reverse)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Cumsum)
-
- int PyOp(Cumsum)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"axis", "exclusive", "reverse", "scope", NULL};
- PyObject *axis = NULL, *exclusive = NULL, *reverse = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", const_cast<char**>(kwlist), &axis, &exclusive, &reverse, &scope))
- return -1;
-
- if (axis) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Cumsum)*>(self)->inst().axis =
- py::cast<decltype(Cumsum::axis)>(py::handle(axis));
- } CATCH_ALL(-1)
- }
-
- if (exclusive) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Cumsum)*>(self)->inst().exclusive =
- py::cast<decltype(Cumsum::exclusive)>(py::handle(exclusive));
- } CATCH_ALL(-1)
- }
-
- if (reverse) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Cumsum)*>(self)->inst().reverse =
- py::cast<decltype(Cumsum::reverse)>(py::handle(reverse));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Cumsum)::py_getsetters[] = {
- {const_cast<char*>("axis"), py_get_generic(Cumsum, axis), py_set_generic(Cumsum, axis), const_cast<char*>("axis"), NULL},
- {const_cast<char*>("exclusive"), py_get_generic(Cumsum, exclusive), py_set_generic(Cumsum, exclusive), const_cast<char*>("exclusive"), NULL},
- {const_cast<char*>("reverse"), py_get_generic(Cumsum, reverse), py_set_generic(Cumsum, reverse), const_cast<char*>("reverse"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Cumsum)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Cumsum)::getstate, METH_NOARGS, "Cumsum getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Cumsum)::setstate, METH_VARARGS, "Cumsum setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Cumsum(py::module m) {
- using py_op = PyOp(Cumsum);
- auto& py_type = PyOpType(Cumsum);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Cumsum";
- py_type.tp_basicsize = sizeof(PyOp(Cumsum));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Cumsum";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Cumsum", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Cumsum::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<CvtColor::Mode> {
- static constexpr const char *name = "CvtColor.Mode";
- static constexpr std::underlying_type_t<CvtColor::Mode> max = 32 - 1;
- };
- template<> PyTypeObject* EnumWrapper<CvtColor::Mode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<CvtColor::Mode>::members[] = {"RGB2GRAY", "RGB2YUV", "YUV2RGB", "GRAY2RGB", "RGBA2RGB", "RGBA2BGR", "RGBA2GRAY", "RGB2BGR", "BGR2GRAY", "BGR2RGB", "YUV2GRAY_NV21", "YUV2RGB_NV21", "YUV2BGR_NV21", "YUV2GRAY_NV12", "YUV2RGB_NV12", "YUV2BGR_NV12", "YUV2GRAY_YV12", "YUV2RGB_YV12", "YUV2BGR_YV12", "YUV2GRAY_YU12", "YUV2RGB_YU12", "YUV2BGR_YU12", "YCrCb2RGB", "YCrCb2BGR", "BT601_YUV2RGB_NV21", "BT601_YUV2BGR_NV21", "BT601_YUV2RGB_NV12", "BT601_YUV2BGR_NV12", "BT601_YUV2RGB_YV12", "BT601_YUV2BGR_YV12", "BT601_YUV2RGB_YU12", "BT601_YUV2BGR_YU12"};
-
- template<> std::unordered_map<std::string, CvtColor::Mode>
- EnumWrapper<CvtColor::Mode>::mem2value = {{normalize_enum("RGB2GRAY"), CvtColor::Mode::RGB2GRAY}, {normalize_enum("RGB2YUV"), CvtColor::Mode::RGB2YUV}, {normalize_enum("YUV2RGB"), CvtColor::Mode::YUV2RGB}, {normalize_enum("GRAY2RGB"), CvtColor::Mode::GRAY2RGB}, {normalize_enum("RGBA2RGB"), CvtColor::Mode::RGBA2RGB}, {normalize_enum("RGBA2BGR"), CvtColor::Mode::RGBA2BGR}, {normalize_enum("RGBA2GRAY"), CvtColor::Mode::RGBA2GRAY}, {normalize_enum("RGB2BGR"), CvtColor::Mode::RGB2BGR}, {normalize_enum("BGR2GRAY"), CvtColor::Mode::BGR2GRAY}, {normalize_enum("BGR2RGB"), CvtColor::Mode::BGR2RGB}, {normalize_enum("YUV2GRAY_NV21"), CvtColor::Mode::YUV2GRAY_NV21}, {normalize_enum("YUV2RGB_NV21"), CvtColor::Mode::YUV2RGB_NV21}, {normalize_enum("YUV2BGR_NV21"), CvtColor::Mode::YUV2BGR_NV21}, {normalize_enum("YUV2GRAY_NV12"), CvtColor::Mode::YUV2GRAY_NV12}, {normalize_enum("YUV2RGB_NV12"), CvtColor::Mode::YUV2RGB_NV12}, {normalize_enum("YUV2BGR_NV12"), CvtColor::Mode::YUV2BGR_NV12}, {normalize_enum("YUV2GRAY_YV12"), CvtColor::Mode::YUV2GRAY_YV12}, {normalize_enum("YUV2RGB_YV12"), CvtColor::Mode::YUV2RGB_YV12}, {normalize_enum("YUV2BGR_YV12"), CvtColor::Mode::YUV2BGR_YV12}, {normalize_enum("YUV2GRAY_YU12"), CvtColor::Mode::YUV2GRAY_YU12}, {normalize_enum("YUV2RGB_YU12"), CvtColor::Mode::YUV2RGB_YU12}, {normalize_enum("YUV2BGR_YU12"), CvtColor::Mode::YUV2BGR_YU12}, {normalize_enum("YCrCb2RGB"), CvtColor::Mode::YCrCb2RGB}, {normalize_enum("YCrCb2BGR"), CvtColor::Mode::YCrCb2BGR}, {normalize_enum("BT601_YUV2RGB_NV21"), CvtColor::Mode::BT601_YUV2RGB_NV21}, {normalize_enum("BT601_YUV2BGR_NV21"), CvtColor::Mode::BT601_YUV2BGR_NV21}, {normalize_enum("BT601_YUV2RGB_NV12"), CvtColor::Mode::BT601_YUV2RGB_NV12}, {normalize_enum("BT601_YUV2BGR_NV12"), CvtColor::Mode::BT601_YUV2BGR_NV12}, {normalize_enum("BT601_YUV2RGB_YV12"), CvtColor::Mode::BT601_YUV2RGB_YV12}, {normalize_enum("BT601_YUV2BGR_YV12"), CvtColor::Mode::BT601_YUV2BGR_YV12}, {normalize_enum("BT601_YUV2RGB_YU12"), CvtColor::Mode::BT601_YUV2RGB_YU12}, {normalize_enum("BT601_YUV2BGR_YU12"), CvtColor::Mode::BT601_YUV2BGR_YU12}};
- template<> PyObject* EnumWrapper<CvtColor::Mode>::pyobj_insts[32] = {nullptr};
-
- void _init_py_CvtColor_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<CvtColor::Mode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<CvtColor::Mode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<CvtColor::Mode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<CvtColor::Mode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.CvtColor.Mode",
- // basicsize
- sizeof(EnumWrapper<CvtColor::Mode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Mode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("CvtColor.Mode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::RGB2GRAY;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "RGB2GRAY", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::RGB2YUV;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "RGB2YUV", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::YUV2RGB;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "YUV2RGB", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[2] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::GRAY2RGB;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "GRAY2RGB", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[3] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::RGBA2RGB;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "RGBA2RGB", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[4] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::RGBA2BGR;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "RGBA2BGR", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[5] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::RGBA2GRAY;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "RGBA2GRAY", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[6] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::RGB2BGR;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "RGB2BGR", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[7] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::BGR2GRAY;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "BGR2GRAY", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[8] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::BGR2RGB;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "BGR2RGB", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[9] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::YUV2GRAY_NV21;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "YUV2GRAY_NV21", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[10] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::YUV2RGB_NV21;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "YUV2RGB_NV21", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[11] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::YUV2BGR_NV21;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "YUV2BGR_NV21", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[12] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::YUV2GRAY_NV12;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "YUV2GRAY_NV12", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[13] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::YUV2RGB_NV12;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "YUV2RGB_NV12", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[14] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::YUV2BGR_NV12;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "YUV2BGR_NV12", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[15] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::YUV2GRAY_YV12;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "YUV2GRAY_YV12", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[16] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::YUV2RGB_YV12;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "YUV2RGB_YV12", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[17] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::YUV2BGR_YV12;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "YUV2BGR_YV12", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[18] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::YUV2GRAY_YU12;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "YUV2GRAY_YU12", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[19] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::YUV2RGB_YU12;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "YUV2RGB_YU12", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[20] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::YUV2BGR_YU12;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "YUV2BGR_YU12", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[21] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::YCrCb2RGB;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "YCrCb2RGB", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[22] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::YCrCb2BGR;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "YCrCb2BGR", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[23] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::BT601_YUV2RGB_NV21;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "BT601_YUV2RGB_NV21", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[24] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::BT601_YUV2BGR_NV21;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "BT601_YUV2BGR_NV21", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[25] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::BT601_YUV2RGB_NV12;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "BT601_YUV2RGB_NV12", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[26] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::BT601_YUV2BGR_NV12;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "BT601_YUV2BGR_NV12", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[27] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::BT601_YUV2RGB_YV12;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "BT601_YUV2RGB_YV12", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[28] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::BT601_YUV2BGR_YV12;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "BT601_YUV2BGR_YV12", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[29] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::BT601_YUV2RGB_YU12;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "BT601_YUV2RGB_YU12", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[30] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<CvtColor::Mode>*>(inst)->value = CvtColor::Mode::BT601_YUV2BGR_YU12;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "BT601_YUV2BGR_YU12", inst) >= 0);
- EnumWrapper<CvtColor::Mode>::pyobj_insts[31] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(CvtColor) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(CvtColor)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(CvtColor)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(CvtColor)
-
- int PyOp(CvtColor)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "scope", NULL};
- PyObject *mode = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &mode, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(CvtColor)*>(self)->inst().mode =
- py::cast<decltype(CvtColor::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(CvtColor)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(CvtColor, mode), py_set_generic(CvtColor, mode), const_cast<char*>("mode"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(CvtColor)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(CvtColor)::getstate, METH_NOARGS, "CvtColor getstate"},
- {const_cast<char*>("__setstate__"), PyOp(CvtColor)::setstate, METH_VARARGS, "CvtColor setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_CvtColor(py::module m) {
- using py_op = PyOp(CvtColor);
- auto& py_type = PyOpType(CvtColor);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.CvtColor";
- py_type.tp_basicsize = sizeof(PyOp(CvtColor));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "CvtColor";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_CvtColor_Mode(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("CvtColor", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(CvtColor::typeinfo(), &py_type).second);
- }
-
- void _init_py_DeformableConv_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<DeformableConv::Mode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_DeformableConv_Sparse(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<DeformableConv::Sparse>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Sparse", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_DeformableConv_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<DeformableConv::Format>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_DeformableConv_ComputeMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<DeformableConv::ComputeMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "ComputeMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_DeformableConv_Strategy(PyTypeObject& py_type) {
- auto& e_type = BitCombinedEnumWrapper<DeformableConv::Strategy>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Strategy", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(DeformableConv) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(DeformableConv)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)},
- {"pad_h", serialization<decltype(opdef.pad_h)>::dump(opdef.pad_h)},
- {"pad_w", serialization<decltype(opdef.pad_w)>::dump(opdef.pad_w)},
- {"stride_h", serialization<decltype(opdef.stride_h)>::dump(opdef.stride_h)},
- {"stride_w", serialization<decltype(opdef.stride_w)>::dump(opdef.stride_w)},
- {"dilate_h", serialization<decltype(opdef.dilate_h)>::dump(opdef.dilate_h)},
- {"dilate_w", serialization<decltype(opdef.dilate_w)>::dump(opdef.dilate_w)},
- {"sparse", serialization<decltype(opdef.sparse)>::dump(opdef.sparse)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"compute_mode", serialization<decltype(opdef.compute_mode)>::dump(opdef.compute_mode)},
- {"strategy", serialization<decltype(opdef.strategy)>::dump(opdef.strategy)},
- {"workspace_limit", serialization<decltype(opdef.workspace_limit)>::dump(opdef.workspace_limit)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(DeformableConv)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_h");
- if (iter != state.end()) {
- opdef.pad_h = serialization<decltype(opdef.pad_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_w");
- if (iter != state.end()) {
- opdef.pad_w = serialization<decltype(opdef.pad_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_h");
- if (iter != state.end()) {
- opdef.stride_h = serialization<decltype(opdef.stride_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_w");
- if (iter != state.end()) {
- opdef.stride_w = serialization<decltype(opdef.stride_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_h");
- if (iter != state.end()) {
- opdef.dilate_h = serialization<decltype(opdef.dilate_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_w");
- if (iter != state.end()) {
- opdef.dilate_w = serialization<decltype(opdef.dilate_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("sparse");
- if (iter != state.end()) {
- opdef.sparse = serialization<decltype(opdef.sparse)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("compute_mode");
- if (iter != state.end()) {
- opdef.compute_mode = serialization<decltype(opdef.compute_mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("strategy");
- if (iter != state.end()) {
- opdef.strategy = serialization<decltype(opdef.strategy)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("workspace_limit");
- if (iter != state.end()) {
- opdef.workspace_limit = serialization<decltype(opdef.workspace_limit)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(DeformableConv)
-
- int PyOp(DeformableConv)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "pad_h", "pad_w", "stride_h", "stride_w", "dilate_h", "dilate_w", "sparse", "format", "compute_mode", "strategy", "workspace_limit", "scope", NULL};
- PyObject *mode = NULL, *pad_h = NULL, *pad_w = NULL, *stride_h = NULL, *stride_w = NULL, *dilate_h = NULL, *dilate_w = NULL, *sparse = NULL, *format = NULL, *compute_mode = NULL, *strategy = NULL, *workspace_limit = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOOOOOO", const_cast<char**>(kwlist), &mode, &pad_h, &pad_w, &stride_h, &stride_w, &dilate_h, &dilate_w, &sparse, &format, &compute_mode, &strategy, &workspace_limit, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformableConv)*>(self)->inst().mode =
- py::cast<decltype(DeformableConv::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (pad_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformableConv)*>(self)->inst().pad_h =
- py::cast<decltype(DeformableConv::pad_h)>(py::handle(pad_h));
- } CATCH_ALL(-1)
- }
-
- if (pad_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformableConv)*>(self)->inst().pad_w =
- py::cast<decltype(DeformableConv::pad_w)>(py::handle(pad_w));
- } CATCH_ALL(-1)
- }
-
- if (stride_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformableConv)*>(self)->inst().stride_h =
- py::cast<decltype(DeformableConv::stride_h)>(py::handle(stride_h));
- } CATCH_ALL(-1)
- }
-
- if (stride_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformableConv)*>(self)->inst().stride_w =
- py::cast<decltype(DeformableConv::stride_w)>(py::handle(stride_w));
- } CATCH_ALL(-1)
- }
-
- if (dilate_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformableConv)*>(self)->inst().dilate_h =
- py::cast<decltype(DeformableConv::dilate_h)>(py::handle(dilate_h));
- } CATCH_ALL(-1)
- }
-
- if (dilate_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformableConv)*>(self)->inst().dilate_w =
- py::cast<decltype(DeformableConv::dilate_w)>(py::handle(dilate_w));
- } CATCH_ALL(-1)
- }
-
- if (sparse) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformableConv)*>(self)->inst().sparse =
- py::cast<decltype(DeformableConv::sparse)>(py::handle(sparse));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformableConv)*>(self)->inst().format =
- py::cast<decltype(DeformableConv::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (compute_mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformableConv)*>(self)->inst().compute_mode =
- py::cast<decltype(DeformableConv::compute_mode)>(py::handle(compute_mode));
- } CATCH_ALL(-1)
- }
-
- if (strategy) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformableConv)*>(self)->inst().strategy =
- py::cast<decltype(DeformableConv::strategy)>(py::handle(strategy));
- } CATCH_ALL(-1)
- }
-
- if (workspace_limit) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformableConv)*>(self)->inst().workspace_limit =
- py::cast<decltype(DeformableConv::workspace_limit)>(py::handle(workspace_limit));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(DeformableConv)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(DeformableConv, mode), py_set_generic(DeformableConv, mode), const_cast<char*>("mode"), NULL},
- {const_cast<char*>("pad_h"), py_get_generic(DeformableConv, pad_h), py_set_generic(DeformableConv, pad_h), const_cast<char*>("pad_h"), NULL},
- {const_cast<char*>("pad_w"), py_get_generic(DeformableConv, pad_w), py_set_generic(DeformableConv, pad_w), const_cast<char*>("pad_w"), NULL},
- {const_cast<char*>("stride_h"), py_get_generic(DeformableConv, stride_h), py_set_generic(DeformableConv, stride_h), const_cast<char*>("stride_h"), NULL},
- {const_cast<char*>("stride_w"), py_get_generic(DeformableConv, stride_w), py_set_generic(DeformableConv, stride_w), const_cast<char*>("stride_w"), NULL},
- {const_cast<char*>("dilate_h"), py_get_generic(DeformableConv, dilate_h), py_set_generic(DeformableConv, dilate_h), const_cast<char*>("dilate_h"), NULL},
- {const_cast<char*>("dilate_w"), py_get_generic(DeformableConv, dilate_w), py_set_generic(DeformableConv, dilate_w), const_cast<char*>("dilate_w"), NULL},
- {const_cast<char*>("sparse"), py_get_generic(DeformableConv, sparse), py_set_generic(DeformableConv, sparse), const_cast<char*>("sparse"), NULL},
- {const_cast<char*>("format"), py_get_generic(DeformableConv, format), py_set_generic(DeformableConv, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("compute_mode"), py_get_generic(DeformableConv, compute_mode), py_set_generic(DeformableConv, compute_mode), const_cast<char*>("compute_mode"), NULL},
- {const_cast<char*>("strategy"), py_get_generic(DeformableConv, strategy), py_set_generic(DeformableConv, strategy), const_cast<char*>("strategy"), NULL},
- {const_cast<char*>("workspace_limit"), py_get_generic(DeformableConv, workspace_limit), py_set_generic(DeformableConv, workspace_limit), const_cast<char*>("workspace_limit"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(DeformableConv)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(DeformableConv)::getstate, METH_NOARGS, "DeformableConv getstate"},
- {const_cast<char*>("__setstate__"), PyOp(DeformableConv)::setstate, METH_VARARGS, "DeformableConv setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_DeformableConv(py::module m) {
- using py_op = PyOp(DeformableConv);
- auto& py_type = PyOpType(DeformableConv);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.DeformableConv";
- py_type.tp_basicsize = sizeof(PyOp(DeformableConv));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "DeformableConv";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_DeformableConv_Mode(py_type);
- _init_py_DeformableConv_Sparse(py_type);
- _init_py_DeformableConv_Format(py_type);
- _init_py_DeformableConv_ComputeMode(py_type);
- _init_py_DeformableConv_Strategy(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("DeformableConv", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(DeformableConv::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(DeformablePSROIPooling) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(DeformablePSROIPooling)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"no_trans", serialization<decltype(opdef.no_trans)>::dump(opdef.no_trans)},
- {"spatial_scale", serialization<decltype(opdef.spatial_scale)>::dump(opdef.spatial_scale)},
- {"trans_std", serialization<decltype(opdef.trans_std)>::dump(opdef.trans_std)},
- {"pooled_h", serialization<decltype(opdef.pooled_h)>::dump(opdef.pooled_h)},
- {"pooled_w", serialization<decltype(opdef.pooled_w)>::dump(opdef.pooled_w)},
- {"part_size", serialization<decltype(opdef.part_size)>::dump(opdef.part_size)},
- {"sample_per_part", serialization<decltype(opdef.sample_per_part)>::dump(opdef.sample_per_part)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(DeformablePSROIPooling)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("no_trans");
- if (iter != state.end()) {
- opdef.no_trans = serialization<decltype(opdef.no_trans)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("spatial_scale");
- if (iter != state.end()) {
- opdef.spatial_scale = serialization<decltype(opdef.spatial_scale)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("trans_std");
- if (iter != state.end()) {
- opdef.trans_std = serialization<decltype(opdef.trans_std)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pooled_h");
- if (iter != state.end()) {
- opdef.pooled_h = serialization<decltype(opdef.pooled_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pooled_w");
- if (iter != state.end()) {
- opdef.pooled_w = serialization<decltype(opdef.pooled_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("part_size");
- if (iter != state.end()) {
- opdef.part_size = serialization<decltype(opdef.part_size)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("sample_per_part");
- if (iter != state.end()) {
- opdef.sample_per_part = serialization<decltype(opdef.sample_per_part)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(DeformablePSROIPooling)
-
- int PyOp(DeformablePSROIPooling)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"no_trans", "spatial_scale", "trans_std", "pooled_h", "pooled_w", "part_size", "sample_per_part", "scope", NULL};
- PyObject *no_trans = NULL, *spatial_scale = NULL, *trans_std = NULL, *pooled_h = NULL, *pooled_w = NULL, *part_size = NULL, *sample_per_part = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOO", const_cast<char**>(kwlist), &no_trans, &spatial_scale, &trans_std, &pooled_h, &pooled_w, &part_size, &sample_per_part, &scope))
- return -1;
-
- if (no_trans) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformablePSROIPooling)*>(self)->inst().no_trans =
- py::cast<decltype(DeformablePSROIPooling::no_trans)>(py::handle(no_trans));
- } CATCH_ALL(-1)
- }
-
- if (spatial_scale) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformablePSROIPooling)*>(self)->inst().spatial_scale =
- py::cast<decltype(DeformablePSROIPooling::spatial_scale)>(py::handle(spatial_scale));
- } CATCH_ALL(-1)
- }
-
- if (trans_std) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformablePSROIPooling)*>(self)->inst().trans_std =
- py::cast<decltype(DeformablePSROIPooling::trans_std)>(py::handle(trans_std));
- } CATCH_ALL(-1)
- }
-
- if (pooled_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformablePSROIPooling)*>(self)->inst().pooled_h =
- py::cast<decltype(DeformablePSROIPooling::pooled_h)>(py::handle(pooled_h));
- } CATCH_ALL(-1)
- }
-
- if (pooled_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformablePSROIPooling)*>(self)->inst().pooled_w =
- py::cast<decltype(DeformablePSROIPooling::pooled_w)>(py::handle(pooled_w));
- } CATCH_ALL(-1)
- }
-
- if (part_size) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformablePSROIPooling)*>(self)->inst().part_size =
- py::cast<decltype(DeformablePSROIPooling::part_size)>(py::handle(part_size));
- } CATCH_ALL(-1)
- }
-
- if (sample_per_part) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(DeformablePSROIPooling)*>(self)->inst().sample_per_part =
- py::cast<decltype(DeformablePSROIPooling::sample_per_part)>(py::handle(sample_per_part));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(DeformablePSROIPooling)::py_getsetters[] = {
- {const_cast<char*>("no_trans"), py_get_generic(DeformablePSROIPooling, no_trans), py_set_generic(DeformablePSROIPooling, no_trans), const_cast<char*>("no_trans"), NULL},
- {const_cast<char*>("spatial_scale"), py_get_generic(DeformablePSROIPooling, spatial_scale), py_set_generic(DeformablePSROIPooling, spatial_scale), const_cast<char*>("spatial_scale"), NULL},
- {const_cast<char*>("trans_std"), py_get_generic(DeformablePSROIPooling, trans_std), py_set_generic(DeformablePSROIPooling, trans_std), const_cast<char*>("trans_std"), NULL},
- {const_cast<char*>("pooled_h"), py_get_generic(DeformablePSROIPooling, pooled_h), py_set_generic(DeformablePSROIPooling, pooled_h), const_cast<char*>("pooled_h"), NULL},
- {const_cast<char*>("pooled_w"), py_get_generic(DeformablePSROIPooling, pooled_w), py_set_generic(DeformablePSROIPooling, pooled_w), const_cast<char*>("pooled_w"), NULL},
- {const_cast<char*>("part_size"), py_get_generic(DeformablePSROIPooling, part_size), py_set_generic(DeformablePSROIPooling, part_size), const_cast<char*>("part_size"), NULL},
- {const_cast<char*>("sample_per_part"), py_get_generic(DeformablePSROIPooling, sample_per_part), py_set_generic(DeformablePSROIPooling, sample_per_part), const_cast<char*>("sample_per_part"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(DeformablePSROIPooling)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(DeformablePSROIPooling)::getstate, METH_NOARGS, "DeformablePSROIPooling getstate"},
- {const_cast<char*>("__setstate__"), PyOp(DeformablePSROIPooling)::setstate, METH_VARARGS, "DeformablePSROIPooling setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_DeformablePSROIPooling(py::module m) {
- using py_op = PyOp(DeformablePSROIPooling);
- auto& py_type = PyOpType(DeformablePSROIPooling);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.DeformablePSROIPooling";
- py_type.tp_basicsize = sizeof(PyOp(DeformablePSROIPooling));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "DeformablePSROIPooling";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("DeformablePSROIPooling", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(DeformablePSROIPooling::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Diag) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Diag)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"k", serialization<decltype(opdef.k)>::dump(opdef.k)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Diag)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("k");
- if (iter != state.end()) {
- opdef.k = serialization<decltype(opdef.k)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Diag)
-
- int PyOp(Diag)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"k", "scope", NULL};
- PyObject *k = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &k, &scope))
- return -1;
-
- if (k) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Diag)*>(self)->inst().k =
- py::cast<decltype(Diag::k)>(py::handle(k));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Diag)::py_getsetters[] = {
- {const_cast<char*>("k"), py_get_generic(Diag, k), py_set_generic(Diag, k), const_cast<char*>("k"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Diag)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Diag)::getstate, METH_NOARGS, "Diag getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Diag)::setstate, METH_VARARGS, "Diag setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Diag(py::module m) {
- using py_op = PyOp(Diag);
- auto& py_type = PyOpType(Diag);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Diag";
- py_type.tp_basicsize = sizeof(PyOp(Diag));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Diag";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Diag", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Diag::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Dimshuffle) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Dimshuffle)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"pattern", serialization<decltype(opdef.pattern)>::dump(opdef.pattern)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Dimshuffle)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("pattern");
- if (iter != state.end()) {
- opdef.pattern = serialization<decltype(opdef.pattern)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Dimshuffle)
-
- int PyOp(Dimshuffle)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"pattern", "scope", NULL};
- PyObject *pattern = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &pattern, &scope))
- return -1;
-
- if (pattern) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Dimshuffle)*>(self)->inst().pattern =
- py::cast<decltype(Dimshuffle::pattern)>(py::handle(pattern));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Dimshuffle)::py_getsetters[] = {
- {const_cast<char*>("pattern"), py_get_generic(Dimshuffle, pattern), py_set_generic(Dimshuffle, pattern), const_cast<char*>("pattern"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Dimshuffle)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Dimshuffle)::getstate, METH_NOARGS, "Dimshuffle getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Dimshuffle)::setstate, METH_VARARGS, "Dimshuffle setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Dimshuffle(py::module m) {
- using py_op = PyOp(Dimshuffle);
- auto& py_type = PyOpType(Dimshuffle);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Dimshuffle";
- py_type.tp_basicsize = sizeof(PyOp(Dimshuffle));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Dimshuffle";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Dimshuffle", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Dimshuffle::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Dot) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Dot)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Dot)*>(self)->inst();
- static_cast<void>(opdef);
-
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Dot)
-
- int PyOp(Dot)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
-
- return 0;
- }
-
- PyGetSetDef PyOp(Dot)::py_getsetters[] = {
-
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Dot)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Dot)::getstate, METH_NOARGS, "Dot getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Dot)::setstate, METH_VARARGS, "Dot setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Dot(py::module m) {
- using py_op = PyOp(Dot);
- auto& py_type = PyOpType(Dot);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Dot";
- py_type.tp_basicsize = sizeof(PyOp(Dot));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Dot";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Dot", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Dot::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Dropout) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Dropout)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"drop_prob", serialization<decltype(opdef.drop_prob)>::dump(opdef.drop_prob)},
- {"seed", serialization<decltype(opdef.seed)>::dump(opdef.seed)},
- {"handle", serialization<decltype(opdef.handle)>::dump(opdef.handle)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Dropout)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("drop_prob");
- if (iter != state.end()) {
- opdef.drop_prob = serialization<decltype(opdef.drop_prob)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("seed");
- if (iter != state.end()) {
- opdef.seed = serialization<decltype(opdef.seed)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("handle");
- if (iter != state.end()) {
- opdef.handle = serialization<decltype(opdef.handle)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Dropout)
-
- int PyOp(Dropout)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"drop_prob", "seed", "handle", "scope", NULL};
- PyObject *drop_prob = NULL, *seed = NULL, *handle = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", const_cast<char**>(kwlist), &drop_prob, &seed, &handle, &scope))
- return -1;
-
- if (drop_prob) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Dropout)*>(self)->inst().drop_prob =
- py::cast<decltype(Dropout::drop_prob)>(py::handle(drop_prob));
- } CATCH_ALL(-1)
- }
-
- if (seed) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Dropout)*>(self)->inst().seed =
- py::cast<decltype(Dropout::seed)>(py::handle(seed));
- } CATCH_ALL(-1)
- }
-
- if (handle) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Dropout)*>(self)->inst().handle =
- py::cast<decltype(Dropout::handle)>(py::handle(handle));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Dropout)::py_getsetters[] = {
- {const_cast<char*>("drop_prob"), py_get_generic(Dropout, drop_prob), py_set_generic(Dropout, drop_prob), const_cast<char*>("drop_prob"), NULL},
- {const_cast<char*>("seed"), py_get_generic(Dropout, seed), py_set_generic(Dropout, seed), const_cast<char*>("seed"), NULL},
- {const_cast<char*>("handle"), py_get_generic(Dropout, handle), py_set_generic(Dropout, handle), const_cast<char*>("handle"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Dropout)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Dropout)::getstate, METH_NOARGS, "Dropout getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Dropout)::setstate, METH_VARARGS, "Dropout setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Dropout(py::module m) {
- using py_op = PyOp(Dropout);
- auto& py_type = PyOpType(Dropout);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Dropout";
- py_type.tp_basicsize = sizeof(PyOp(Dropout));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Dropout";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Dropout", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Dropout::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<Elemwise::Mode> {
- static constexpr const char *name = "Elemwise.Mode";
- static constexpr std::underlying_type_t<Elemwise::Mode> max = 61 - 1;
- };
- template<> PyTypeObject* EnumWrapper<Elemwise::Mode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<Elemwise::Mode>::members[] = {"RELU", "ABS", "ACOS", "ASIN", "CEIL", "COS", "EXP", "EXPM1", "FLOOR", "LOG", "LOG1P", "NEGATE", "SIGMOID", "SIN", "TANH", "ABS_GRAD", "ADD", "FLOOR_DIV", "MAX", "MIN", "MOD", "MUL", "POW", "SIGMOID_GRAD", "SUB", "SWITCH_GT0", "TANH_GRAD", "TRUE_DIV", "LOG_SUM_EXP", "LT", "LEQ", "EQ", "SHL", "SHR", "COND_LEQ_MOV", "FUSE_MUL_ADD3", "FUSE_MUL_ADD4", "FUSE_ADD_RELU", "FUSE_ADD_SIGMOID", "FUSE_ADD_TANH", "FAST_TANH", "FAST_TANH_GRAD", "ROUND", "RMULH", "ATAN2", "ERF", "ERFINV", "ERFC", "ERFCINV", "H_SWISH", "H_SWISH_GRAD", "FUSE_ADD_H_SWISH", "NOT", "AND", "OR", "XOR", "SILU", "SILU_GRAD", "GELU", "GELU_GRAD", "COND_LT_MOV"};
-
- template<> std::unordered_map<std::string, Elemwise::Mode>
- EnumWrapper<Elemwise::Mode>::mem2value = {{normalize_enum("RELU"), Elemwise::Mode::RELU}, {normalize_enum("ABS"), Elemwise::Mode::ABS}, {normalize_enum("ACOS"), Elemwise::Mode::ACOS}, {normalize_enum("ASIN"), Elemwise::Mode::ASIN}, {normalize_enum("CEIL"), Elemwise::Mode::CEIL}, {normalize_enum("COS"), Elemwise::Mode::COS}, {normalize_enum("EXP"), Elemwise::Mode::EXP}, {normalize_enum("EXPM1"), Elemwise::Mode::EXPM1}, {normalize_enum("FLOOR"), Elemwise::Mode::FLOOR}, {normalize_enum("LOG"), Elemwise::Mode::LOG}, {normalize_enum("LOG1P"), Elemwise::Mode::LOG1P}, {normalize_enum("NEGATE"), Elemwise::Mode::NEGATE}, {normalize_enum("SIGMOID"), Elemwise::Mode::SIGMOID}, {normalize_enum("SIN"), Elemwise::Mode::SIN}, {normalize_enum("TANH"), Elemwise::Mode::TANH}, {normalize_enum("ABS_GRAD"), Elemwise::Mode::ABS_GRAD}, {normalize_enum("ADD"), Elemwise::Mode::ADD}, {normalize_enum("FLOOR_DIV"), Elemwise::Mode::FLOOR_DIV}, {normalize_enum("MAX"), Elemwise::Mode::MAX}, {normalize_enum("MIN"), Elemwise::Mode::MIN}, {normalize_enum("MOD"), Elemwise::Mode::MOD}, {normalize_enum("MUL"), Elemwise::Mode::MUL}, {normalize_enum("POW"), Elemwise::Mode::POW}, {normalize_enum("SIGMOID_GRAD"), Elemwise::Mode::SIGMOID_GRAD}, {normalize_enum("SUB"), Elemwise::Mode::SUB}, {normalize_enum("SWITCH_GT0"), Elemwise::Mode::SWITCH_GT0}, {normalize_enum("TANH_GRAD"), Elemwise::Mode::TANH_GRAD}, {normalize_enum("TRUE_DIV"), Elemwise::Mode::TRUE_DIV}, {normalize_enum("LOG_SUM_EXP"), Elemwise::Mode::LOG_SUM_EXP}, {normalize_enum("LT"), Elemwise::Mode::LT}, {normalize_enum("LEQ"), Elemwise::Mode::LEQ}, {normalize_enum("EQ"), Elemwise::Mode::EQ}, {normalize_enum("SHL"), Elemwise::Mode::SHL}, {normalize_enum("SHR"), Elemwise::Mode::SHR}, {normalize_enum("COND_LEQ_MOV"), Elemwise::Mode::COND_LEQ_MOV}, {normalize_enum("FUSE_MUL_ADD3"), Elemwise::Mode::FUSE_MUL_ADD3}, {normalize_enum("FUSE_MUL_ADD4"), Elemwise::Mode::FUSE_MUL_ADD4}, {normalize_enum("FUSE_ADD_RELU"), Elemwise::Mode::FUSE_ADD_RELU}, {normalize_enum("FUSE_ADD_SIGMOID"), Elemwise::Mode::FUSE_ADD_SIGMOID}, {normalize_enum("FUSE_ADD_TANH"), Elemwise::Mode::FUSE_ADD_TANH}, {normalize_enum("FAST_TANH"), Elemwise::Mode::FAST_TANH}, {normalize_enum("FAST_TANH_GRAD"), Elemwise::Mode::FAST_TANH_GRAD}, {normalize_enum("ROUND"), Elemwise::Mode::ROUND}, {normalize_enum("RMULH"), Elemwise::Mode::RMULH}, {normalize_enum("ATAN2"), Elemwise::Mode::ATAN2}, {normalize_enum("ERF"), Elemwise::Mode::ERF}, {normalize_enum("ERFINV"), Elemwise::Mode::ERFINV}, {normalize_enum("ERFC"), Elemwise::Mode::ERFC}, {normalize_enum("ERFCINV"), Elemwise::Mode::ERFCINV}, {normalize_enum("H_SWISH"), Elemwise::Mode::H_SWISH}, {normalize_enum("H_SWISH_GRAD"), Elemwise::Mode::H_SWISH_GRAD}, {normalize_enum("FUSE_ADD_H_SWISH"), Elemwise::Mode::FUSE_ADD_H_SWISH}, {normalize_enum("NOT"), Elemwise::Mode::NOT}, {normalize_enum("AND"), Elemwise::Mode::AND}, {normalize_enum("OR"), Elemwise::Mode::OR}, {normalize_enum("XOR"), Elemwise::Mode::XOR}, {normalize_enum("SILU"), Elemwise::Mode::SILU}, {normalize_enum("SILU_GRAD"), Elemwise::Mode::SILU_GRAD}, {normalize_enum("GELU"), Elemwise::Mode::GELU}, {normalize_enum("GELU_GRAD"), Elemwise::Mode::GELU_GRAD}, {normalize_enum("COND_LT_MOV"), Elemwise::Mode::COND_LT_MOV}};
- template<> PyObject* EnumWrapper<Elemwise::Mode>::pyobj_insts[61] = {nullptr};
-
- void _init_py_Elemwise_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Elemwise::Mode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<Elemwise::Mode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<Elemwise::Mode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<Elemwise::Mode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.Elemwise.Mode",
- // basicsize
- sizeof(EnumWrapper<Elemwise::Mode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Mode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("Elemwise.Mode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::RELU;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "RELU", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::ABS;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ABS", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::ACOS;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ACOS", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[2] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::ASIN;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ASIN", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[3] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::CEIL;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "CEIL", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[4] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::COS;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "COS", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[5] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::EXP;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "EXP", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[6] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::EXPM1;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "EXPM1", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[7] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::FLOOR;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FLOOR", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[8] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::LOG;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "LOG", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[9] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::LOG1P;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "LOG1P", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[10] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::NEGATE;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NEGATE", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[11] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::SIGMOID;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "SIGMOID", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[12] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::SIN;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "SIN", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[13] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::TANH;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "TANH", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[14] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::ABS_GRAD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ABS_GRAD", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[15] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::ADD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ADD", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[16] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::FLOOR_DIV;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FLOOR_DIV", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[17] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::MAX;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "MAX", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[18] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::MIN;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "MIN", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[19] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::MOD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "MOD", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[20] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::MUL;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "MUL", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[21] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::POW;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "POW", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[22] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::SIGMOID_GRAD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "SIGMOID_GRAD", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[23] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::SUB;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "SUB", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[24] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::SWITCH_GT0;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "SWITCH_GT0", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[25] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::TANH_GRAD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "TANH_GRAD", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[26] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::TRUE_DIV;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "TRUE_DIV", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[27] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::LOG_SUM_EXP;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "LOG_SUM_EXP", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[28] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::LT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "LT", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[29] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::LEQ;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "LEQ", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[30] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::EQ;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "EQ", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[31] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::SHL;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "SHL", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[32] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::SHR;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "SHR", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[33] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::COND_LEQ_MOV;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "COND_LEQ_MOV", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[34] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::FUSE_MUL_ADD3;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FUSE_MUL_ADD3", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[35] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::FUSE_MUL_ADD4;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FUSE_MUL_ADD4", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[36] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::FUSE_ADD_RELU;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FUSE_ADD_RELU", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[37] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::FUSE_ADD_SIGMOID;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FUSE_ADD_SIGMOID", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[38] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::FUSE_ADD_TANH;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FUSE_ADD_TANH", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[39] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::FAST_TANH;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FAST_TANH", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[40] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::FAST_TANH_GRAD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FAST_TANH_GRAD", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[41] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::ROUND;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ROUND", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[42] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::RMULH;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "RMULH", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[43] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::ATAN2;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ATAN2", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[44] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::ERF;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ERF", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[45] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::ERFINV;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ERFINV", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[46] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::ERFC;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ERFC", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[47] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::ERFCINV;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ERFCINV", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[48] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::H_SWISH;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "H_SWISH", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[49] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::H_SWISH_GRAD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "H_SWISH_GRAD", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[50] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::FUSE_ADD_H_SWISH;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FUSE_ADD_H_SWISH", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[51] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::NOT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NOT", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[52] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::AND;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "AND", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[53] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::OR;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "OR", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[54] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::XOR;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "XOR", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[55] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::SILU;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "SILU", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[56] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::SILU_GRAD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "SILU_GRAD", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[57] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::GELU;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "GELU", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[58] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::GELU_GRAD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "GELU_GRAD", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[59] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Elemwise::Mode>*>(inst)->value = Elemwise::Mode::COND_LT_MOV;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "COND_LT_MOV", inst) >= 0);
- EnumWrapper<Elemwise::Mode>::pyobj_insts[60] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(Elemwise) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Elemwise)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Elemwise)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Elemwise)
-
- int PyOp(Elemwise)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "scope", NULL};
- PyObject *mode = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &mode, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Elemwise)*>(self)->inst().mode =
- py::cast<decltype(Elemwise::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Elemwise)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(Elemwise, mode), py_set_generic(Elemwise, mode), const_cast<char*>("mode"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Elemwise)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Elemwise)::getstate, METH_NOARGS, "Elemwise getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Elemwise)::setstate, METH_VARARGS, "Elemwise setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Elemwise(py::module m) {
- using py_op = PyOp(Elemwise);
- auto& py_type = PyOpType(Elemwise);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Elemwise";
- py_type.tp_basicsize = sizeof(PyOp(Elemwise));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Elemwise";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_Elemwise_Mode(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("Elemwise", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Elemwise::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<ElemwiseMultiType::Mode> {
- static constexpr const char *name = "ElemwiseMultiType.Mode";
- static constexpr std::underlying_type_t<ElemwiseMultiType::Mode> max = 58 - 1;
- };
- template<> PyTypeObject* EnumWrapper<ElemwiseMultiType::Mode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<ElemwiseMultiType::Mode>::members[] = {"FUSE_MUL_ADD3_INT16x32x32x32", "FUSE_MUL_ADD3_IXxF32xF32xI8", "ROUND_SHR_SATURATE_IXxI8xI8", "FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT16x16x16x8", "FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT32x32x32x8", "ROUND_SHR_SATURATE_IXxI8xI16", "QADD", "QFUSE_ADD_RELU", "QMUL", "QMIN", "QMAX", "QSUB", "QTRUE_DIV", "QFUSE_ADD_SIGMOID", "QFUSE_ADD_TANH", "QRELU", "QABS", "QSIGMOID", "QEXP", "QTANH", "QFUSE_MUL_ADD3", "QFAST_TANH", "QNEGATE", "QACOS", "QASIN", "QCEIL", "QCOS", "QEXPM1", "QFLOOR", "QLOG", "QLOG1P", "QSIN", "QROUND", "QERF", "QERFINV", "QERFC", "QERFCINV", "QABS_GRAD", "QFLOOR_DIV", "QMOD", "QSIGMOID_GRAD", "QSWITCH_GT0", "QTANH_GRAD", "QLT", "QLEQ", "QEQ", "QPOW", "QLOG_SUM_EXP", "QFAST_TANH_GRAD", "QATAN2", "QCOND_LEQ_MOV", "QH_SWISH", "QFUSE_ADD_H_SWISH", "QH_SWISH_GRAD", "FUSE_MUL_ADD3_INT16xF32xF32xF32", "MUL_INT16xF32xF32", "FUSE_MUL_ADD3_UINT8xF32xF32xF32", "QCOND_LT_MOV"};
-
- template<> std::unordered_map<std::string, ElemwiseMultiType::Mode>
- EnumWrapper<ElemwiseMultiType::Mode>::mem2value = {{normalize_enum("FUSE_MUL_ADD3_INT16x32x32x32"), ElemwiseMultiType::Mode::FUSE_MUL_ADD3_INT16x32x32x32}, {normalize_enum("FUSE_MUL_ADD3_IXxF32xF32xI8"), ElemwiseMultiType::Mode::FUSE_MUL_ADD3_IXxF32xF32xI8}, {normalize_enum("ROUND_SHR_SATURATE_IXxI8xI8"), ElemwiseMultiType::Mode::ROUND_SHR_SATURATE_IXxI8xI8}, {normalize_enum("FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT16x16x16x8"), ElemwiseMultiType::Mode::FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT16x16x16x8}, {normalize_enum("FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT32x32x32x8"), ElemwiseMultiType::Mode::FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT32x32x32x8}, {normalize_enum("ROUND_SHR_SATURATE_IXxI8xI16"), ElemwiseMultiType::Mode::ROUND_SHR_SATURATE_IXxI8xI16}, {normalize_enum("QADD"), ElemwiseMultiType::Mode::QADD}, {normalize_enum("QFUSE_ADD_RELU"), ElemwiseMultiType::Mode::QFUSE_ADD_RELU}, {normalize_enum("QMUL"), ElemwiseMultiType::Mode::QMUL}, {normalize_enum("QMIN"), ElemwiseMultiType::Mode::QMIN}, {normalize_enum("QMAX"), ElemwiseMultiType::Mode::QMAX}, {normalize_enum("QSUB"), ElemwiseMultiType::Mode::QSUB}, {normalize_enum("QTRUE_DIV"), ElemwiseMultiType::Mode::QTRUE_DIV}, {normalize_enum("QFUSE_ADD_SIGMOID"), ElemwiseMultiType::Mode::QFUSE_ADD_SIGMOID}, {normalize_enum("QFUSE_ADD_TANH"), ElemwiseMultiType::Mode::QFUSE_ADD_TANH}, {normalize_enum("QRELU"), ElemwiseMultiType::Mode::QRELU}, {normalize_enum("QABS"), ElemwiseMultiType::Mode::QABS}, {normalize_enum("QSIGMOID"), ElemwiseMultiType::Mode::QSIGMOID}, {normalize_enum("QEXP"), ElemwiseMultiType::Mode::QEXP}, {normalize_enum("QTANH"), ElemwiseMultiType::Mode::QTANH}, {normalize_enum("QFUSE_MUL_ADD3"), ElemwiseMultiType::Mode::QFUSE_MUL_ADD3}, {normalize_enum("QFAST_TANH"), ElemwiseMultiType::Mode::QFAST_TANH}, {normalize_enum("QNEGATE"), ElemwiseMultiType::Mode::QNEGATE}, {normalize_enum("QACOS"), ElemwiseMultiType::Mode::QACOS}, {normalize_enum("QASIN"), ElemwiseMultiType::Mode::QASIN}, {normalize_enum("QCEIL"), ElemwiseMultiType::Mode::QCEIL}, {normalize_enum("QCOS"), ElemwiseMultiType::Mode::QCOS}, {normalize_enum("QEXPM1"), ElemwiseMultiType::Mode::QEXPM1}, {normalize_enum("QFLOOR"), ElemwiseMultiType::Mode::QFLOOR}, {normalize_enum("QLOG"), ElemwiseMultiType::Mode::QLOG}, {normalize_enum("QLOG1P"), ElemwiseMultiType::Mode::QLOG1P}, {normalize_enum("QSIN"), ElemwiseMultiType::Mode::QSIN}, {normalize_enum("QROUND"), ElemwiseMultiType::Mode::QROUND}, {normalize_enum("QERF"), ElemwiseMultiType::Mode::QERF}, {normalize_enum("QERFINV"), ElemwiseMultiType::Mode::QERFINV}, {normalize_enum("QERFC"), ElemwiseMultiType::Mode::QERFC}, {normalize_enum("QERFCINV"), ElemwiseMultiType::Mode::QERFCINV}, {normalize_enum("QABS_GRAD"), ElemwiseMultiType::Mode::QABS_GRAD}, {normalize_enum("QFLOOR_DIV"), ElemwiseMultiType::Mode::QFLOOR_DIV}, {normalize_enum("QMOD"), ElemwiseMultiType::Mode::QMOD}, {normalize_enum("QSIGMOID_GRAD"), ElemwiseMultiType::Mode::QSIGMOID_GRAD}, {normalize_enum("QSWITCH_GT0"), ElemwiseMultiType::Mode::QSWITCH_GT0}, {normalize_enum("QTANH_GRAD"), ElemwiseMultiType::Mode::QTANH_GRAD}, {normalize_enum("QLT"), ElemwiseMultiType::Mode::QLT}, {normalize_enum("QLEQ"), ElemwiseMultiType::Mode::QLEQ}, {normalize_enum("QEQ"), ElemwiseMultiType::Mode::QEQ}, {normalize_enum("QPOW"), ElemwiseMultiType::Mode::QPOW}, {normalize_enum("QLOG_SUM_EXP"), ElemwiseMultiType::Mode::QLOG_SUM_EXP}, {normalize_enum("QFAST_TANH_GRAD"), ElemwiseMultiType::Mode::QFAST_TANH_GRAD}, {normalize_enum("QATAN2"), ElemwiseMultiType::Mode::QATAN2}, {normalize_enum("QCOND_LEQ_MOV"), ElemwiseMultiType::Mode::QCOND_LEQ_MOV}, {normalize_enum("QH_SWISH"), ElemwiseMultiType::Mode::QH_SWISH}, {normalize_enum("QFUSE_ADD_H_SWISH"), ElemwiseMultiType::Mode::QFUSE_ADD_H_SWISH}, {normalize_enum("QH_SWISH_GRAD"), ElemwiseMultiType::Mode::QH_SWISH_GRAD}, {normalize_enum("FUSE_MUL_ADD3_INT16xF32xF32xF32"), ElemwiseMultiType::Mode::FUSE_MUL_ADD3_INT16xF32xF32xF32}, {normalize_enum("MUL_INT16xF32xF32"), ElemwiseMultiType::Mode::MUL_INT16xF32xF32}, {normalize_enum("FUSE_MUL_ADD3_UINT8xF32xF32xF32"), ElemwiseMultiType::Mode::FUSE_MUL_ADD3_UINT8xF32xF32xF32}, {normalize_enum("QCOND_LT_MOV"), ElemwiseMultiType::Mode::QCOND_LT_MOV}};
- template<> PyObject* EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[58] = {nullptr};
-
- void _init_py_ElemwiseMultiType_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<ElemwiseMultiType::Mode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<ElemwiseMultiType::Mode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<ElemwiseMultiType::Mode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<ElemwiseMultiType::Mode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.ElemwiseMultiType.Mode",
- // basicsize
- sizeof(EnumWrapper<ElemwiseMultiType::Mode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Mode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("ElemwiseMultiType.Mode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::FUSE_MUL_ADD3_INT16x32x32x32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FUSE_MUL_ADD3_INT16x32x32x32", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::FUSE_MUL_ADD3_IXxF32xF32xI8;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FUSE_MUL_ADD3_IXxF32xF32xI8", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::ROUND_SHR_SATURATE_IXxI8xI8;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ROUND_SHR_SATURATE_IXxI8xI8", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[2] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT16x16x16x8;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT16x16x16x8", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[3] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT32x32x32x8;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FUSE_ADD_RMULH_ROUND_SHR_SATURATE_INT32x32x32x8", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[4] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::ROUND_SHR_SATURATE_IXxI8xI16;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ROUND_SHR_SATURATE_IXxI8xI16", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[5] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QADD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QADD", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[6] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QFUSE_ADD_RELU;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QFUSE_ADD_RELU", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[7] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QMUL;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QMUL", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[8] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QMIN;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QMIN", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[9] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QMAX;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QMAX", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[10] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QSUB;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QSUB", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[11] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QTRUE_DIV;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QTRUE_DIV", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[12] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QFUSE_ADD_SIGMOID;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QFUSE_ADD_SIGMOID", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[13] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QFUSE_ADD_TANH;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QFUSE_ADD_TANH", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[14] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QRELU;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QRELU", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[15] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QABS;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QABS", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[16] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QSIGMOID;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QSIGMOID", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[17] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QEXP;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QEXP", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[18] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QTANH;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QTANH", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[19] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QFUSE_MUL_ADD3;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QFUSE_MUL_ADD3", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[20] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QFAST_TANH;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QFAST_TANH", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[21] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QNEGATE;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QNEGATE", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[22] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QACOS;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QACOS", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[23] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QASIN;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QASIN", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[24] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QCEIL;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QCEIL", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[25] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QCOS;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QCOS", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[26] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QEXPM1;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QEXPM1", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[27] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QFLOOR;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QFLOOR", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[28] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QLOG;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QLOG", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[29] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QLOG1P;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QLOG1P", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[30] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QSIN;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QSIN", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[31] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QROUND;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QROUND", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[32] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QERF;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QERF", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[33] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QERFINV;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QERFINV", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[34] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QERFC;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QERFC", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[35] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QERFCINV;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QERFCINV", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[36] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QABS_GRAD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QABS_GRAD", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[37] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QFLOOR_DIV;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QFLOOR_DIV", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[38] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QMOD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QMOD", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[39] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QSIGMOID_GRAD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QSIGMOID_GRAD", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[40] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QSWITCH_GT0;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QSWITCH_GT0", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[41] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QTANH_GRAD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QTANH_GRAD", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[42] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QLT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QLT", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[43] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QLEQ;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QLEQ", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[44] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QEQ;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QEQ", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[45] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QPOW;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QPOW", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[46] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QLOG_SUM_EXP;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QLOG_SUM_EXP", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[47] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QFAST_TANH_GRAD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QFAST_TANH_GRAD", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[48] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QATAN2;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QATAN2", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[49] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QCOND_LEQ_MOV;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QCOND_LEQ_MOV", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[50] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QH_SWISH;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QH_SWISH", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[51] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QFUSE_ADD_H_SWISH;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QFUSE_ADD_H_SWISH", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[52] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QH_SWISH_GRAD;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QH_SWISH_GRAD", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[53] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::FUSE_MUL_ADD3_INT16xF32xF32xF32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FUSE_MUL_ADD3_INT16xF32xF32xF32", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[54] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::MUL_INT16xF32xF32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "MUL_INT16xF32xF32", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[55] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::FUSE_MUL_ADD3_UINT8xF32xF32xF32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FUSE_MUL_ADD3_UINT8xF32xF32xF32", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[56] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ElemwiseMultiType::Mode>*>(inst)->value = ElemwiseMultiType::Mode::QCOND_LT_MOV;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QCOND_LT_MOV", inst) >= 0);
- EnumWrapper<ElemwiseMultiType::Mode>::pyobj_insts[57] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(ElemwiseMultiType) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(ElemwiseMultiType)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)},
- {"dtype", serialization<decltype(opdef.dtype)>::dump(opdef.dtype)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(ElemwiseMultiType)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dtype");
- if (iter != state.end()) {
- opdef.dtype = serialization<decltype(opdef.dtype)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(ElemwiseMultiType)
-
- int PyOp(ElemwiseMultiType)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "dtype", "scope", NULL};
- PyObject *mode = NULL, *dtype = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &mode, &dtype, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ElemwiseMultiType)*>(self)->inst().mode =
- py::cast<decltype(ElemwiseMultiType::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (dtype) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ElemwiseMultiType)*>(self)->inst().dtype =
- py::cast<decltype(ElemwiseMultiType::dtype)>(py::handle(dtype));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(ElemwiseMultiType)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(ElemwiseMultiType, mode), py_set_generic(ElemwiseMultiType, mode), const_cast<char*>("mode"), NULL},
- {const_cast<char*>("dtype"), py_get_generic(ElemwiseMultiType, dtype), py_set_generic(ElemwiseMultiType, dtype), const_cast<char*>("dtype"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(ElemwiseMultiType)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(ElemwiseMultiType)::getstate, METH_NOARGS, "ElemwiseMultiType getstate"},
- {const_cast<char*>("__setstate__"), PyOp(ElemwiseMultiType)::setstate, METH_VARARGS, "ElemwiseMultiType setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_ElemwiseMultiType(py::module m) {
- using py_op = PyOp(ElemwiseMultiType);
- auto& py_type = PyOpType(ElemwiseMultiType);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.ElemwiseMultiType";
- py_type.tp_basicsize = sizeof(PyOp(ElemwiseMultiType));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "ElemwiseMultiType";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_ElemwiseMultiType_Mode(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("ElemwiseMultiType", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(ElemwiseMultiType::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(ExternOpr) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(ExternOpr)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"output_shapes", serialization<decltype(opdef.output_shapes)>::dump(opdef.output_shapes)},
- {"name", serialization<decltype(opdef.name)>::dump(opdef.name)},
- {"data", serialization<decltype(opdef.data)>::dump(opdef.data)},
- {"data_len", serialization<decltype(opdef.data_len)>::dump(opdef.data_len)},
- {"output_dtypes", serialization<decltype(opdef.output_dtypes)>::dump(opdef.output_dtypes)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(ExternOpr)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("output_shapes");
- if (iter != state.end()) {
- opdef.output_shapes = serialization<decltype(opdef.output_shapes)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("name");
- if (iter != state.end()) {
- opdef.name = serialization<decltype(opdef.name)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("data");
- if (iter != state.end()) {
- opdef.data = serialization<decltype(opdef.data)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("data_len");
- if (iter != state.end()) {
- opdef.data_len = serialization<decltype(opdef.data_len)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("output_dtypes");
- if (iter != state.end()) {
- opdef.output_dtypes = serialization<decltype(opdef.output_dtypes)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(ExternOpr)
-
- int PyOp(ExternOpr)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"output_shapes", "name", "data", "data_len", "output_dtypes", "scope", NULL};
- PyObject *output_shapes = NULL, *name = NULL, *data = NULL, *data_len = NULL, *output_dtypes = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOO", const_cast<char**>(kwlist), &output_shapes, &name, &data, &data_len, &output_dtypes, &scope))
- return -1;
-
- if (output_shapes) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ExternOpr)*>(self)->inst().output_shapes =
- py::cast<decltype(ExternOpr::output_shapes)>(py::handle(output_shapes));
- } CATCH_ALL(-1)
- }
-
- if (name) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ExternOpr)*>(self)->inst().name =
- py::cast<decltype(ExternOpr::name)>(py::handle(name));
- } CATCH_ALL(-1)
- }
-
- if (data) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ExternOpr)*>(self)->inst().data =
- py::cast<decltype(ExternOpr::data)>(py::handle(data));
- } CATCH_ALL(-1)
- }
-
- if (data_len) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ExternOpr)*>(self)->inst().data_len =
- py::cast<decltype(ExternOpr::data_len)>(py::handle(data_len));
- } CATCH_ALL(-1)
- }
-
- if (output_dtypes) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ExternOpr)*>(self)->inst().output_dtypes =
- py::cast<decltype(ExternOpr::output_dtypes)>(py::handle(output_dtypes));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(ExternOpr)::py_getsetters[] = {
- {const_cast<char*>("output_shapes"), py_get_generic(ExternOpr, output_shapes), py_set_generic(ExternOpr, output_shapes), const_cast<char*>("output_shapes"), NULL},
- {const_cast<char*>("name"), py_get_generic(ExternOpr, name), py_set_generic(ExternOpr, name), const_cast<char*>("name"), NULL},
- {const_cast<char*>("data"), py_get_generic(ExternOpr, data), py_set_generic(ExternOpr, data), const_cast<char*>("data"), NULL},
- {const_cast<char*>("data_len"), py_get_generic(ExternOpr, data_len), py_set_generic(ExternOpr, data_len), const_cast<char*>("data_len"), NULL},
- {const_cast<char*>("output_dtypes"), py_get_generic(ExternOpr, output_dtypes), py_set_generic(ExternOpr, output_dtypes), const_cast<char*>("output_dtypes"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(ExternOpr)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(ExternOpr)::getstate, METH_NOARGS, "ExternOpr getstate"},
- {const_cast<char*>("__setstate__"), PyOp(ExternOpr)::setstate, METH_VARARGS, "ExternOpr setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_ExternOpr(py::module m) {
- using py_op = PyOp(ExternOpr);
- auto& py_type = PyOpType(ExternOpr);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.ExternOpr";
- py_type.tp_basicsize = sizeof(PyOp(ExternOpr));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "ExternOpr";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("ExternOpr", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(ExternOpr::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Eye) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Eye)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"k", serialization<decltype(opdef.k)>::dump(opdef.k)},
- {"dtype", serialization<decltype(opdef.dtype)>::dump(opdef.dtype)},
- {"comp_node", serialization<decltype(opdef.comp_node)>::dump(opdef.comp_node)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Eye)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("k");
- if (iter != state.end()) {
- opdef.k = serialization<decltype(opdef.k)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dtype");
- if (iter != state.end()) {
- opdef.dtype = serialization<decltype(opdef.dtype)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("comp_node");
- if (iter != state.end()) {
- opdef.comp_node = serialization<decltype(opdef.comp_node)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Eye)
-
- int PyOp(Eye)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"k", "dtype", "comp_node", "scope", NULL};
- PyObject *k = NULL, *dtype = NULL, *comp_node = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", const_cast<char**>(kwlist), &k, &dtype, &comp_node, &scope))
- return -1;
-
- if (k) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Eye)*>(self)->inst().k =
- py::cast<decltype(Eye::k)>(py::handle(k));
- } CATCH_ALL(-1)
- }
-
- if (dtype) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Eye)*>(self)->inst().dtype =
- py::cast<decltype(Eye::dtype)>(py::handle(dtype));
- } CATCH_ALL(-1)
- }
-
- if (comp_node) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Eye)*>(self)->inst().comp_node =
- py::cast<decltype(Eye::comp_node)>(py::handle(comp_node));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Eye)::py_getsetters[] = {
- {const_cast<char*>("k"), py_get_generic(Eye, k), py_set_generic(Eye, k), const_cast<char*>("k"), NULL},
- {const_cast<char*>("dtype"), py_get_generic(Eye, dtype), py_set_generic(Eye, dtype), const_cast<char*>("dtype"), NULL},
- {const_cast<char*>("comp_node"), py_get_generic(Eye, comp_node), py_set_generic(Eye, comp_node), const_cast<char*>("comp_node"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Eye)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Eye)::getstate, METH_NOARGS, "Eye getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Eye)::setstate, METH_VARARGS, "Eye setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Eye(py::module m) {
- using py_op = PyOp(Eye);
- auto& py_type = PyOpType(Eye);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Eye";
- py_type.tp_basicsize = sizeof(PyOp(Eye));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Eye";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Eye", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Eye::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(FakeQuant) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(FakeQuant)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"qmin", serialization<decltype(opdef.qmin)>::dump(opdef.qmin)},
- {"qmax", serialization<decltype(opdef.qmax)>::dump(opdef.qmax)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(FakeQuant)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("qmin");
- if (iter != state.end()) {
- opdef.qmin = serialization<decltype(opdef.qmin)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("qmax");
- if (iter != state.end()) {
- opdef.qmax = serialization<decltype(opdef.qmax)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(FakeQuant)
-
- int PyOp(FakeQuant)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"qmin", "qmax", "scope", NULL};
- PyObject *qmin = NULL, *qmax = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &qmin, &qmax, &scope))
- return -1;
-
- if (qmin) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(FakeQuant)*>(self)->inst().qmin =
- py::cast<decltype(FakeQuant::qmin)>(py::handle(qmin));
- } CATCH_ALL(-1)
- }
-
- if (qmax) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(FakeQuant)*>(self)->inst().qmax =
- py::cast<decltype(FakeQuant::qmax)>(py::handle(qmax));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(FakeQuant)::py_getsetters[] = {
- {const_cast<char*>("qmin"), py_get_generic(FakeQuant, qmin), py_set_generic(FakeQuant, qmin), const_cast<char*>("qmin"), NULL},
- {const_cast<char*>("qmax"), py_get_generic(FakeQuant, qmax), py_set_generic(FakeQuant, qmax), const_cast<char*>("qmax"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(FakeQuant)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(FakeQuant)::getstate, METH_NOARGS, "FakeQuant getstate"},
- {const_cast<char*>("__setstate__"), PyOp(FakeQuant)::setstate, METH_VARARGS, "FakeQuant setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_FakeQuant(py::module m) {
- using py_op = PyOp(FakeQuant);
- auto& py_type = PyOpType(FakeQuant);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.FakeQuant";
- py_type.tp_basicsize = sizeof(PyOp(FakeQuant));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "FakeQuant";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("FakeQuant", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(FakeQuant::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(FastpathCopy) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(FastpathCopy)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(FastpathCopy)*>(self)->inst();
- static_cast<void>(opdef);
-
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(FastpathCopy)
-
- int PyOp(FastpathCopy)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
-
- return 0;
- }
-
- PyGetSetDef PyOp(FastpathCopy)::py_getsetters[] = {
-
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(FastpathCopy)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(FastpathCopy)::getstate, METH_NOARGS, "FastpathCopy getstate"},
- {const_cast<char*>("__setstate__"), PyOp(FastpathCopy)::setstate, METH_VARARGS, "FastpathCopy setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_FastpathCopy(py::module m) {
- using py_op = PyOp(FastpathCopy);
- auto& py_type = PyOpType(FastpathCopy);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.FastpathCopy";
- py_type.tp_basicsize = sizeof(PyOp(FastpathCopy));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "FastpathCopy";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("FastpathCopy", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(FastpathCopy::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(GammaRNG) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(GammaRNG)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"seed", serialization<decltype(opdef.seed)>::dump(opdef.seed)},
- {"handle", serialization<decltype(opdef.handle)>::dump(opdef.handle)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(GammaRNG)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("seed");
- if (iter != state.end()) {
- opdef.seed = serialization<decltype(opdef.seed)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("handle");
- if (iter != state.end()) {
- opdef.handle = serialization<decltype(opdef.handle)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(GammaRNG)
-
- int PyOp(GammaRNG)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"seed", "handle", "scope", NULL};
- PyObject *seed = NULL, *handle = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &seed, &handle, &scope))
- return -1;
-
- if (seed) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GammaRNG)*>(self)->inst().seed =
- py::cast<decltype(GammaRNG::seed)>(py::handle(seed));
- } CATCH_ALL(-1)
- }
-
- if (handle) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GammaRNG)*>(self)->inst().handle =
- py::cast<decltype(GammaRNG::handle)>(py::handle(handle));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(GammaRNG)::py_getsetters[] = {
- {const_cast<char*>("seed"), py_get_generic(GammaRNG, seed), py_set_generic(GammaRNG, seed), const_cast<char*>("seed"), NULL},
- {const_cast<char*>("handle"), py_get_generic(GammaRNG, handle), py_set_generic(GammaRNG, handle), const_cast<char*>("handle"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(GammaRNG)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(GammaRNG)::getstate, METH_NOARGS, "GammaRNG getstate"},
- {const_cast<char*>("__setstate__"), PyOp(GammaRNG)::setstate, METH_VARARGS, "GammaRNG setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_GammaRNG(py::module m) {
- using py_op = PyOp(GammaRNG);
- auto& py_type = PyOpType(GammaRNG);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.GammaRNG";
- py_type.tp_basicsize = sizeof(PyOp(GammaRNG));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "GammaRNG";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("GammaRNG", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(GammaRNG::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(GaussianRNG) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(GaussianRNG)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"seed", serialization<decltype(opdef.seed)>::dump(opdef.seed)},
- {"mean", serialization<decltype(opdef.mean)>::dump(opdef.mean)},
- {"std", serialization<decltype(opdef.std)>::dump(opdef.std)},
- {"dtype", serialization<decltype(opdef.dtype)>::dump(opdef.dtype)},
- {"handle", serialization<decltype(opdef.handle)>::dump(opdef.handle)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(GaussianRNG)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("seed");
- if (iter != state.end()) {
- opdef.seed = serialization<decltype(opdef.seed)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("mean");
- if (iter != state.end()) {
- opdef.mean = serialization<decltype(opdef.mean)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("std");
- if (iter != state.end()) {
- opdef.std = serialization<decltype(opdef.std)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dtype");
- if (iter != state.end()) {
- opdef.dtype = serialization<decltype(opdef.dtype)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("handle");
- if (iter != state.end()) {
- opdef.handle = serialization<decltype(opdef.handle)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(GaussianRNG)
-
- int PyOp(GaussianRNG)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"seed", "mean", "std", "dtype", "handle", "scope", NULL};
- PyObject *seed = NULL, *mean = NULL, *std = NULL, *dtype = NULL, *handle = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOO", const_cast<char**>(kwlist), &seed, &mean, &std, &dtype, &handle, &scope))
- return -1;
-
- if (seed) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GaussianRNG)*>(self)->inst().seed =
- py::cast<decltype(GaussianRNG::seed)>(py::handle(seed));
- } CATCH_ALL(-1)
- }
-
- if (mean) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GaussianRNG)*>(self)->inst().mean =
- py::cast<decltype(GaussianRNG::mean)>(py::handle(mean));
- } CATCH_ALL(-1)
- }
-
- if (std) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GaussianRNG)*>(self)->inst().std =
- py::cast<decltype(GaussianRNG::std)>(py::handle(std));
- } CATCH_ALL(-1)
- }
-
- if (dtype) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GaussianRNG)*>(self)->inst().dtype =
- py::cast<decltype(GaussianRNG::dtype)>(py::handle(dtype));
- } CATCH_ALL(-1)
- }
-
- if (handle) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GaussianRNG)*>(self)->inst().handle =
- py::cast<decltype(GaussianRNG::handle)>(py::handle(handle));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(GaussianRNG)::py_getsetters[] = {
- {const_cast<char*>("seed"), py_get_generic(GaussianRNG, seed), py_set_generic(GaussianRNG, seed), const_cast<char*>("seed"), NULL},
- {const_cast<char*>("mean"), py_get_generic(GaussianRNG, mean), py_set_generic(GaussianRNG, mean), const_cast<char*>("mean"), NULL},
- {const_cast<char*>("std"), py_get_generic(GaussianRNG, std), py_set_generic(GaussianRNG, std), const_cast<char*>("std"), NULL},
- {const_cast<char*>("dtype"), py_get_generic(GaussianRNG, dtype), py_set_generic(GaussianRNG, dtype), const_cast<char*>("dtype"), NULL},
- {const_cast<char*>("handle"), py_get_generic(GaussianRNG, handle), py_set_generic(GaussianRNG, handle), const_cast<char*>("handle"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(GaussianRNG)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(GaussianRNG)::getstate, METH_NOARGS, "GaussianRNG getstate"},
- {const_cast<char*>("__setstate__"), PyOp(GaussianRNG)::setstate, METH_VARARGS, "GaussianRNG setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_GaussianRNG(py::module m) {
- using py_op = PyOp(GaussianRNG);
- auto& py_type = PyOpType(GaussianRNG);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.GaussianRNG";
- py_type.tp_basicsize = sizeof(PyOp(GaussianRNG));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "GaussianRNG";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("GaussianRNG", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(GaussianRNG::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(GetVarShape) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(GetVarShape)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"axis", serialization<decltype(opdef.axis)>::dump(opdef.axis)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(GetVarShape)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("axis");
- if (iter != state.end()) {
- opdef.axis = serialization<decltype(opdef.axis)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(GetVarShape)
-
- int PyOp(GetVarShape)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"axis", "scope", NULL};
- PyObject *axis = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &axis, &scope))
- return -1;
-
- if (axis) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GetVarShape)*>(self)->inst().axis =
- py::cast<decltype(GetVarShape::axis)>(py::handle(axis));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(GetVarShape)::py_getsetters[] = {
- {const_cast<char*>("axis"), py_get_generic(GetVarShape, axis), py_set_generic(GetVarShape, axis), const_cast<char*>("axis"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(GetVarShape)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(GetVarShape)::getstate, METH_NOARGS, "GetVarShape getstate"},
- {const_cast<char*>("__setstate__"), PyOp(GetVarShape)::setstate, METH_VARARGS, "GetVarShape setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_GetVarShape(py::module m) {
- using py_op = PyOp(GetVarShape);
- auto& py_type = PyOpType(GetVarShape);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.GetVarShape";
- py_type.tp_basicsize = sizeof(PyOp(GetVarShape));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "GetVarShape";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("GetVarShape", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(GetVarShape::typeinfo(), &py_type).second);
- }
-
- void _init_py_GroupLocal_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<GroupLocal::Mode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_GroupLocal_Sparse(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<GroupLocal::Sparse>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Sparse", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_GroupLocal_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<GroupLocal::Format>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_GroupLocal_ComputeMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<GroupLocal::ComputeMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "ComputeMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(GroupLocal) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(GroupLocal)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)},
- {"pad_h", serialization<decltype(opdef.pad_h)>::dump(opdef.pad_h)},
- {"pad_w", serialization<decltype(opdef.pad_w)>::dump(opdef.pad_w)},
- {"stride_h", serialization<decltype(opdef.stride_h)>::dump(opdef.stride_h)},
- {"stride_w", serialization<decltype(opdef.stride_w)>::dump(opdef.stride_w)},
- {"dilate_h", serialization<decltype(opdef.dilate_h)>::dump(opdef.dilate_h)},
- {"dilate_w", serialization<decltype(opdef.dilate_w)>::dump(opdef.dilate_w)},
- {"sparse", serialization<decltype(opdef.sparse)>::dump(opdef.sparse)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"compute_mode", serialization<decltype(opdef.compute_mode)>::dump(opdef.compute_mode)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(GroupLocal)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_h");
- if (iter != state.end()) {
- opdef.pad_h = serialization<decltype(opdef.pad_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_w");
- if (iter != state.end()) {
- opdef.pad_w = serialization<decltype(opdef.pad_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_h");
- if (iter != state.end()) {
- opdef.stride_h = serialization<decltype(opdef.stride_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_w");
- if (iter != state.end()) {
- opdef.stride_w = serialization<decltype(opdef.stride_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_h");
- if (iter != state.end()) {
- opdef.dilate_h = serialization<decltype(opdef.dilate_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_w");
- if (iter != state.end()) {
- opdef.dilate_w = serialization<decltype(opdef.dilate_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("sparse");
- if (iter != state.end()) {
- opdef.sparse = serialization<decltype(opdef.sparse)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("compute_mode");
- if (iter != state.end()) {
- opdef.compute_mode = serialization<decltype(opdef.compute_mode)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(GroupLocal)
-
- int PyOp(GroupLocal)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "pad_h", "pad_w", "stride_h", "stride_w", "dilate_h", "dilate_w", "sparse", "format", "compute_mode", "scope", NULL};
- PyObject *mode = NULL, *pad_h = NULL, *pad_w = NULL, *stride_h = NULL, *stride_w = NULL, *dilate_h = NULL, *dilate_w = NULL, *sparse = NULL, *format = NULL, *compute_mode = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOOOO", const_cast<char**>(kwlist), &mode, &pad_h, &pad_w, &stride_h, &stride_w, &dilate_h, &dilate_w, &sparse, &format, &compute_mode, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GroupLocal)*>(self)->inst().mode =
- py::cast<decltype(GroupLocal::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (pad_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GroupLocal)*>(self)->inst().pad_h =
- py::cast<decltype(GroupLocal::pad_h)>(py::handle(pad_h));
- } CATCH_ALL(-1)
- }
-
- if (pad_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GroupLocal)*>(self)->inst().pad_w =
- py::cast<decltype(GroupLocal::pad_w)>(py::handle(pad_w));
- } CATCH_ALL(-1)
- }
-
- if (stride_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GroupLocal)*>(self)->inst().stride_h =
- py::cast<decltype(GroupLocal::stride_h)>(py::handle(stride_h));
- } CATCH_ALL(-1)
- }
-
- if (stride_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GroupLocal)*>(self)->inst().stride_w =
- py::cast<decltype(GroupLocal::stride_w)>(py::handle(stride_w));
- } CATCH_ALL(-1)
- }
-
- if (dilate_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GroupLocal)*>(self)->inst().dilate_h =
- py::cast<decltype(GroupLocal::dilate_h)>(py::handle(dilate_h));
- } CATCH_ALL(-1)
- }
-
- if (dilate_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GroupLocal)*>(self)->inst().dilate_w =
- py::cast<decltype(GroupLocal::dilate_w)>(py::handle(dilate_w));
- } CATCH_ALL(-1)
- }
-
- if (sparse) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GroupLocal)*>(self)->inst().sparse =
- py::cast<decltype(GroupLocal::sparse)>(py::handle(sparse));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GroupLocal)*>(self)->inst().format =
- py::cast<decltype(GroupLocal::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (compute_mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(GroupLocal)*>(self)->inst().compute_mode =
- py::cast<decltype(GroupLocal::compute_mode)>(py::handle(compute_mode));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(GroupLocal)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(GroupLocal, mode), py_set_generic(GroupLocal, mode), const_cast<char*>("mode"), NULL},
- {const_cast<char*>("pad_h"), py_get_generic(GroupLocal, pad_h), py_set_generic(GroupLocal, pad_h), const_cast<char*>("pad_h"), NULL},
- {const_cast<char*>("pad_w"), py_get_generic(GroupLocal, pad_w), py_set_generic(GroupLocal, pad_w), const_cast<char*>("pad_w"), NULL},
- {const_cast<char*>("stride_h"), py_get_generic(GroupLocal, stride_h), py_set_generic(GroupLocal, stride_h), const_cast<char*>("stride_h"), NULL},
- {const_cast<char*>("stride_w"), py_get_generic(GroupLocal, stride_w), py_set_generic(GroupLocal, stride_w), const_cast<char*>("stride_w"), NULL},
- {const_cast<char*>("dilate_h"), py_get_generic(GroupLocal, dilate_h), py_set_generic(GroupLocal, dilate_h), const_cast<char*>("dilate_h"), NULL},
- {const_cast<char*>("dilate_w"), py_get_generic(GroupLocal, dilate_w), py_set_generic(GroupLocal, dilate_w), const_cast<char*>("dilate_w"), NULL},
- {const_cast<char*>("sparse"), py_get_generic(GroupLocal, sparse), py_set_generic(GroupLocal, sparse), const_cast<char*>("sparse"), NULL},
- {const_cast<char*>("format"), py_get_generic(GroupLocal, format), py_set_generic(GroupLocal, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("compute_mode"), py_get_generic(GroupLocal, compute_mode), py_set_generic(GroupLocal, compute_mode), const_cast<char*>("compute_mode"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(GroupLocal)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(GroupLocal)::getstate, METH_NOARGS, "GroupLocal getstate"},
- {const_cast<char*>("__setstate__"), PyOp(GroupLocal)::setstate, METH_VARARGS, "GroupLocal setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_GroupLocal(py::module m) {
- using py_op = PyOp(GroupLocal);
- auto& py_type = PyOpType(GroupLocal);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.GroupLocal";
- py_type.tp_basicsize = sizeof(PyOp(GroupLocal));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "GroupLocal";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_GroupLocal_Mode(py_type);
- _init_py_GroupLocal_Sparse(py_type);
- _init_py_GroupLocal_Format(py_type);
- _init_py_GroupLocal_ComputeMode(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("GroupLocal", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(GroupLocal::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Identity) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Identity)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Identity)*>(self)->inst();
- static_cast<void>(opdef);
-
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Identity)
-
- int PyOp(Identity)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
-
- return 0;
- }
-
- PyGetSetDef PyOp(Identity)::py_getsetters[] = {
-
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Identity)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Identity)::getstate, METH_NOARGS, "Identity getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Identity)::setstate, METH_VARARGS, "Identity setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Identity(py::module m) {
- using py_op = PyOp(Identity);
- auto& py_type = PyOpType(Identity);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Identity";
- py_type.tp_basicsize = sizeof(PyOp(Identity));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Identity";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Identity", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Identity::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Images2Neibs) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Images2Neibs)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"pad_h", serialization<decltype(opdef.pad_h)>::dump(opdef.pad_h)},
- {"pad_w", serialization<decltype(opdef.pad_w)>::dump(opdef.pad_w)},
- {"stride_h", serialization<decltype(opdef.stride_h)>::dump(opdef.stride_h)},
- {"stride_w", serialization<decltype(opdef.stride_w)>::dump(opdef.stride_w)},
- {"dilate_h", serialization<decltype(opdef.dilate_h)>::dump(opdef.dilate_h)},
- {"dilate_w", serialization<decltype(opdef.dilate_w)>::dump(opdef.dilate_w)},
- {"window_h", serialization<decltype(opdef.window_h)>::dump(opdef.window_h)},
- {"window_w", serialization<decltype(opdef.window_w)>::dump(opdef.window_w)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Images2Neibs)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("pad_h");
- if (iter != state.end()) {
- opdef.pad_h = serialization<decltype(opdef.pad_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_w");
- if (iter != state.end()) {
- opdef.pad_w = serialization<decltype(opdef.pad_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_h");
- if (iter != state.end()) {
- opdef.stride_h = serialization<decltype(opdef.stride_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_w");
- if (iter != state.end()) {
- opdef.stride_w = serialization<decltype(opdef.stride_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_h");
- if (iter != state.end()) {
- opdef.dilate_h = serialization<decltype(opdef.dilate_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_w");
- if (iter != state.end()) {
- opdef.dilate_w = serialization<decltype(opdef.dilate_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("window_h");
- if (iter != state.end()) {
- opdef.window_h = serialization<decltype(opdef.window_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("window_w");
- if (iter != state.end()) {
- opdef.window_w = serialization<decltype(opdef.window_w)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Images2Neibs)
-
- int PyOp(Images2Neibs)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"pad_h", "pad_w", "stride_h", "stride_w", "dilate_h", "dilate_w", "window_h", "window_w", "scope", NULL};
- PyObject *pad_h = NULL, *pad_w = NULL, *stride_h = NULL, *stride_w = NULL, *dilate_h = NULL, *dilate_w = NULL, *window_h = NULL, *window_w = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOO", const_cast<char**>(kwlist), &pad_h, &pad_w, &stride_h, &stride_w, &dilate_h, &dilate_w, &window_h, &window_w, &scope))
- return -1;
-
- if (pad_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Images2Neibs)*>(self)->inst().pad_h =
- py::cast<decltype(Images2Neibs::pad_h)>(py::handle(pad_h));
- } CATCH_ALL(-1)
- }
-
- if (pad_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Images2Neibs)*>(self)->inst().pad_w =
- py::cast<decltype(Images2Neibs::pad_w)>(py::handle(pad_w));
- } CATCH_ALL(-1)
- }
-
- if (stride_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Images2Neibs)*>(self)->inst().stride_h =
- py::cast<decltype(Images2Neibs::stride_h)>(py::handle(stride_h));
- } CATCH_ALL(-1)
- }
-
- if (stride_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Images2Neibs)*>(self)->inst().stride_w =
- py::cast<decltype(Images2Neibs::stride_w)>(py::handle(stride_w));
- } CATCH_ALL(-1)
- }
-
- if (dilate_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Images2Neibs)*>(self)->inst().dilate_h =
- py::cast<decltype(Images2Neibs::dilate_h)>(py::handle(dilate_h));
- } CATCH_ALL(-1)
- }
-
- if (dilate_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Images2Neibs)*>(self)->inst().dilate_w =
- py::cast<decltype(Images2Neibs::dilate_w)>(py::handle(dilate_w));
- } CATCH_ALL(-1)
- }
-
- if (window_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Images2Neibs)*>(self)->inst().window_h =
- py::cast<decltype(Images2Neibs::window_h)>(py::handle(window_h));
- } CATCH_ALL(-1)
- }
-
- if (window_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Images2Neibs)*>(self)->inst().window_w =
- py::cast<decltype(Images2Neibs::window_w)>(py::handle(window_w));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Images2Neibs)::py_getsetters[] = {
- {const_cast<char*>("pad_h"), py_get_generic(Images2Neibs, pad_h), py_set_generic(Images2Neibs, pad_h), const_cast<char*>("pad_h"), NULL},
- {const_cast<char*>("pad_w"), py_get_generic(Images2Neibs, pad_w), py_set_generic(Images2Neibs, pad_w), const_cast<char*>("pad_w"), NULL},
- {const_cast<char*>("stride_h"), py_get_generic(Images2Neibs, stride_h), py_set_generic(Images2Neibs, stride_h), const_cast<char*>("stride_h"), NULL},
- {const_cast<char*>("stride_w"), py_get_generic(Images2Neibs, stride_w), py_set_generic(Images2Neibs, stride_w), const_cast<char*>("stride_w"), NULL},
- {const_cast<char*>("dilate_h"), py_get_generic(Images2Neibs, dilate_h), py_set_generic(Images2Neibs, dilate_h), const_cast<char*>("dilate_h"), NULL},
- {const_cast<char*>("dilate_w"), py_get_generic(Images2Neibs, dilate_w), py_set_generic(Images2Neibs, dilate_w), const_cast<char*>("dilate_w"), NULL},
- {const_cast<char*>("window_h"), py_get_generic(Images2Neibs, window_h), py_set_generic(Images2Neibs, window_h), const_cast<char*>("window_h"), NULL},
- {const_cast<char*>("window_w"), py_get_generic(Images2Neibs, window_w), py_set_generic(Images2Neibs, window_w), const_cast<char*>("window_w"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Images2Neibs)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Images2Neibs)::getstate, METH_NOARGS, "Images2Neibs getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Images2Neibs)::setstate, METH_VARARGS, "Images2Neibs setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Images2Neibs(py::module m) {
- using py_op = PyOp(Images2Neibs);
- auto& py_type = PyOpType(Images2Neibs);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Images2Neibs";
- py_type.tp_basicsize = sizeof(PyOp(Images2Neibs));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Images2Neibs";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Images2Neibs", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Images2Neibs::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(IncrMeshIndexing) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(IncrMeshIndexing)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"items", serialization<decltype(opdef.items)>::dump(opdef.items)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(IncrMeshIndexing)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("items");
- if (iter != state.end()) {
- opdef.items = serialization<decltype(opdef.items)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(IncrMeshIndexing)
-
- int PyOp(IncrMeshIndexing)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"items", "scope", NULL};
- PyObject *items = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &items, &scope))
- return -1;
-
- if (items) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(IncrMeshIndexing)*>(self)->inst().items =
- py::cast<decltype(IncrMeshIndexing::items)>(py::handle(items));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(IncrMeshIndexing)::py_getsetters[] = {
- {const_cast<char*>("items"), py_get_generic(IncrMeshIndexing, items), py_set_generic(IncrMeshIndexing, items), const_cast<char*>("items"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(IncrMeshIndexing)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(IncrMeshIndexing)::getstate, METH_NOARGS, "IncrMeshIndexing getstate"},
- {const_cast<char*>("__setstate__"), PyOp(IncrMeshIndexing)::setstate, METH_VARARGS, "IncrMeshIndexing setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_IncrMeshIndexing(py::module m) {
- using py_op = PyOp(IncrMeshIndexing);
- auto& py_type = PyOpType(IncrMeshIndexing);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.IncrMeshIndexing";
- py_type.tp_basicsize = sizeof(PyOp(IncrMeshIndexing));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "IncrMeshIndexing";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("IncrMeshIndexing", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(IncrMeshIndexing::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(IncrSubtensor) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(IncrSubtensor)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"items", serialization<decltype(opdef.items)>::dump(opdef.items)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(IncrSubtensor)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("items");
- if (iter != state.end()) {
- opdef.items = serialization<decltype(opdef.items)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(IncrSubtensor)
-
- int PyOp(IncrSubtensor)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"items", "scope", NULL};
- PyObject *items = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &items, &scope))
- return -1;
-
- if (items) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(IncrSubtensor)*>(self)->inst().items =
- py::cast<decltype(IncrSubtensor::items)>(py::handle(items));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(IncrSubtensor)::py_getsetters[] = {
- {const_cast<char*>("items"), py_get_generic(IncrSubtensor, items), py_set_generic(IncrSubtensor, items), const_cast<char*>("items"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(IncrSubtensor)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(IncrSubtensor)::getstate, METH_NOARGS, "IncrSubtensor getstate"},
- {const_cast<char*>("__setstate__"), PyOp(IncrSubtensor)::setstate, METH_VARARGS, "IncrSubtensor setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_IncrSubtensor(py::module m) {
- using py_op = PyOp(IncrSubtensor);
- auto& py_type = PyOpType(IncrSubtensor);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.IncrSubtensor";
- py_type.tp_basicsize = sizeof(PyOp(IncrSubtensor));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "IncrSubtensor";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("IncrSubtensor", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(IncrSubtensor::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(IndexingIncrMultiAxisVec) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(IndexingIncrMultiAxisVec)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"items", serialization<decltype(opdef.items)>::dump(opdef.items)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(IndexingIncrMultiAxisVec)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("items");
- if (iter != state.end()) {
- opdef.items = serialization<decltype(opdef.items)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(IndexingIncrMultiAxisVec)
-
- int PyOp(IndexingIncrMultiAxisVec)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"items", "scope", NULL};
- PyObject *items = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &items, &scope))
- return -1;
-
- if (items) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(IndexingIncrMultiAxisVec)*>(self)->inst().items =
- py::cast<decltype(IndexingIncrMultiAxisVec::items)>(py::handle(items));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(IndexingIncrMultiAxisVec)::py_getsetters[] = {
- {const_cast<char*>("items"), py_get_generic(IndexingIncrMultiAxisVec, items), py_set_generic(IndexingIncrMultiAxisVec, items), const_cast<char*>("items"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(IndexingIncrMultiAxisVec)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(IndexingIncrMultiAxisVec)::getstate, METH_NOARGS, "IndexingIncrMultiAxisVec getstate"},
- {const_cast<char*>("__setstate__"), PyOp(IndexingIncrMultiAxisVec)::setstate, METH_VARARGS, "IndexingIncrMultiAxisVec setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_IndexingIncrMultiAxisVec(py::module m) {
- using py_op = PyOp(IndexingIncrMultiAxisVec);
- auto& py_type = PyOpType(IndexingIncrMultiAxisVec);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.IndexingIncrMultiAxisVec";
- py_type.tp_basicsize = sizeof(PyOp(IndexingIncrMultiAxisVec));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "IndexingIncrMultiAxisVec";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("IndexingIncrMultiAxisVec", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(IndexingIncrMultiAxisVec::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(IndexingMultiAxisVec) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(IndexingMultiAxisVec)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"items", serialization<decltype(opdef.items)>::dump(opdef.items)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(IndexingMultiAxisVec)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("items");
- if (iter != state.end()) {
- opdef.items = serialization<decltype(opdef.items)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(IndexingMultiAxisVec)
-
- int PyOp(IndexingMultiAxisVec)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"items", "scope", NULL};
- PyObject *items = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &items, &scope))
- return -1;
-
- if (items) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(IndexingMultiAxisVec)*>(self)->inst().items =
- py::cast<decltype(IndexingMultiAxisVec::items)>(py::handle(items));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(IndexingMultiAxisVec)::py_getsetters[] = {
- {const_cast<char*>("items"), py_get_generic(IndexingMultiAxisVec, items), py_set_generic(IndexingMultiAxisVec, items), const_cast<char*>("items"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(IndexingMultiAxisVec)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(IndexingMultiAxisVec)::getstate, METH_NOARGS, "IndexingMultiAxisVec getstate"},
- {const_cast<char*>("__setstate__"), PyOp(IndexingMultiAxisVec)::setstate, METH_VARARGS, "IndexingMultiAxisVec setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_IndexingMultiAxisVec(py::module m) {
- using py_op = PyOp(IndexingMultiAxisVec);
- auto& py_type = PyOpType(IndexingMultiAxisVec);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.IndexingMultiAxisVec";
- py_type.tp_basicsize = sizeof(PyOp(IndexingMultiAxisVec));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "IndexingMultiAxisVec";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("IndexingMultiAxisVec", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(IndexingMultiAxisVec::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(IndexingOneHot) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(IndexingOneHot)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"axis", serialization<decltype(opdef.axis)>::dump(opdef.axis)},
- {"ndim", serialization<decltype(opdef.ndim)>::dump(opdef.ndim)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(IndexingOneHot)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("axis");
- if (iter != state.end()) {
- opdef.axis = serialization<decltype(opdef.axis)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("ndim");
- if (iter != state.end()) {
- opdef.ndim = serialization<decltype(opdef.ndim)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(IndexingOneHot)
-
- int PyOp(IndexingOneHot)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"axis", "ndim", "scope", NULL};
- PyObject *axis = NULL, *ndim = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &axis, &ndim, &scope))
- return -1;
-
- if (axis) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(IndexingOneHot)*>(self)->inst().axis =
- py::cast<decltype(IndexingOneHot::axis)>(py::handle(axis));
- } CATCH_ALL(-1)
- }
-
- if (ndim) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(IndexingOneHot)*>(self)->inst().ndim =
- py::cast<decltype(IndexingOneHot::ndim)>(py::handle(ndim));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(IndexingOneHot)::py_getsetters[] = {
- {const_cast<char*>("axis"), py_get_generic(IndexingOneHot, axis), py_set_generic(IndexingOneHot, axis), const_cast<char*>("axis"), NULL},
- {const_cast<char*>("ndim"), py_get_generic(IndexingOneHot, ndim), py_set_generic(IndexingOneHot, ndim), const_cast<char*>("ndim"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(IndexingOneHot)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(IndexingOneHot)::getstate, METH_NOARGS, "IndexingOneHot getstate"},
- {const_cast<char*>("__setstate__"), PyOp(IndexingOneHot)::setstate, METH_VARARGS, "IndexingOneHot setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_IndexingOneHot(py::module m) {
- using py_op = PyOp(IndexingOneHot);
- auto& py_type = PyOpType(IndexingOneHot);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.IndexingOneHot";
- py_type.tp_basicsize = sizeof(PyOp(IndexingOneHot));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "IndexingOneHot";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("IndexingOneHot", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(IndexingOneHot::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(IndexingSetMultiAxisVec) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(IndexingSetMultiAxisVec)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"items", serialization<decltype(opdef.items)>::dump(opdef.items)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(IndexingSetMultiAxisVec)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("items");
- if (iter != state.end()) {
- opdef.items = serialization<decltype(opdef.items)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(IndexingSetMultiAxisVec)
-
- int PyOp(IndexingSetMultiAxisVec)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"items", "scope", NULL};
- PyObject *items = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &items, &scope))
- return -1;
-
- if (items) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(IndexingSetMultiAxisVec)*>(self)->inst().items =
- py::cast<decltype(IndexingSetMultiAxisVec::items)>(py::handle(items));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(IndexingSetMultiAxisVec)::py_getsetters[] = {
- {const_cast<char*>("items"), py_get_generic(IndexingSetMultiAxisVec, items), py_set_generic(IndexingSetMultiAxisVec, items), const_cast<char*>("items"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(IndexingSetMultiAxisVec)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(IndexingSetMultiAxisVec)::getstate, METH_NOARGS, "IndexingSetMultiAxisVec getstate"},
- {const_cast<char*>("__setstate__"), PyOp(IndexingSetMultiAxisVec)::setstate, METH_VARARGS, "IndexingSetMultiAxisVec setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_IndexingSetMultiAxisVec(py::module m) {
- using py_op = PyOp(IndexingSetMultiAxisVec);
- auto& py_type = PyOpType(IndexingSetMultiAxisVec);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.IndexingSetMultiAxisVec";
- py_type.tp_basicsize = sizeof(PyOp(IndexingSetMultiAxisVec));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "IndexingSetMultiAxisVec";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("IndexingSetMultiAxisVec", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(IndexingSetMultiAxisVec::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(IndexingSetOneHot) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(IndexingSetOneHot)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"axis", serialization<decltype(opdef.axis)>::dump(opdef.axis)},
- {"ndim", serialization<decltype(opdef.ndim)>::dump(opdef.ndim)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(IndexingSetOneHot)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("axis");
- if (iter != state.end()) {
- opdef.axis = serialization<decltype(opdef.axis)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("ndim");
- if (iter != state.end()) {
- opdef.ndim = serialization<decltype(opdef.ndim)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(IndexingSetOneHot)
-
- int PyOp(IndexingSetOneHot)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"axis", "ndim", "scope", NULL};
- PyObject *axis = NULL, *ndim = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &axis, &ndim, &scope))
- return -1;
-
- if (axis) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(IndexingSetOneHot)*>(self)->inst().axis =
- py::cast<decltype(IndexingSetOneHot::axis)>(py::handle(axis));
- } CATCH_ALL(-1)
- }
-
- if (ndim) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(IndexingSetOneHot)*>(self)->inst().ndim =
- py::cast<decltype(IndexingSetOneHot::ndim)>(py::handle(ndim));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(IndexingSetOneHot)::py_getsetters[] = {
- {const_cast<char*>("axis"), py_get_generic(IndexingSetOneHot, axis), py_set_generic(IndexingSetOneHot, axis), const_cast<char*>("axis"), NULL},
- {const_cast<char*>("ndim"), py_get_generic(IndexingSetOneHot, ndim), py_set_generic(IndexingSetOneHot, ndim), const_cast<char*>("ndim"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(IndexingSetOneHot)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(IndexingSetOneHot)::getstate, METH_NOARGS, "IndexingSetOneHot getstate"},
- {const_cast<char*>("__setstate__"), PyOp(IndexingSetOneHot)::setstate, METH_VARARGS, "IndexingSetOneHot setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_IndexingSetOneHot(py::module m) {
- using py_op = PyOp(IndexingSetOneHot);
- auto& py_type = PyOpType(IndexingSetOneHot);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.IndexingSetOneHot";
- py_type.tp_basicsize = sizeof(PyOp(IndexingSetOneHot));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "IndexingSetOneHot";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("IndexingSetOneHot", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(IndexingSetOneHot::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(InplaceAdd) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(InplaceAdd)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(InplaceAdd)*>(self)->inst();
- static_cast<void>(opdef);
-
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(InplaceAdd)
-
- int PyOp(InplaceAdd)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
-
- return 0;
- }
-
- PyGetSetDef PyOp(InplaceAdd)::py_getsetters[] = {
-
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(InplaceAdd)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(InplaceAdd)::getstate, METH_NOARGS, "InplaceAdd getstate"},
- {const_cast<char*>("__setstate__"), PyOp(InplaceAdd)::setstate, METH_VARARGS, "InplaceAdd setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_InplaceAdd(py::module m) {
- using py_op = PyOp(InplaceAdd);
- auto& py_type = PyOpType(InplaceAdd);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.InplaceAdd";
- py_type.tp_basicsize = sizeof(PyOp(InplaceAdd));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "InplaceAdd";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("InplaceAdd", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(InplaceAdd::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(LAMBUpdate) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(LAMBUpdate)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"beta_1", serialization<decltype(opdef.beta_1)>::dump(opdef.beta_1)},
- {"beta_2", serialization<decltype(opdef.beta_2)>::dump(opdef.beta_2)},
- {"step", serialization<decltype(opdef.step)>::dump(opdef.step)},
- {"lr", serialization<decltype(opdef.lr)>::dump(opdef.lr)},
- {"weight_decay", serialization<decltype(opdef.weight_decay)>::dump(opdef.weight_decay)},
- {"eps", serialization<decltype(opdef.eps)>::dump(opdef.eps)},
- {"bias_correction", serialization<decltype(opdef.bias_correction)>::dump(opdef.bias_correction)},
- {"always_adapt", serialization<decltype(opdef.always_adapt)>::dump(opdef.always_adapt)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(LAMBUpdate)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("beta_1");
- if (iter != state.end()) {
- opdef.beta_1 = serialization<decltype(opdef.beta_1)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("beta_2");
- if (iter != state.end()) {
- opdef.beta_2 = serialization<decltype(opdef.beta_2)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("step");
- if (iter != state.end()) {
- opdef.step = serialization<decltype(opdef.step)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("lr");
- if (iter != state.end()) {
- opdef.lr = serialization<decltype(opdef.lr)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("weight_decay");
- if (iter != state.end()) {
- opdef.weight_decay = serialization<decltype(opdef.weight_decay)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("eps");
- if (iter != state.end()) {
- opdef.eps = serialization<decltype(opdef.eps)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("bias_correction");
- if (iter != state.end()) {
- opdef.bias_correction = serialization<decltype(opdef.bias_correction)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("always_adapt");
- if (iter != state.end()) {
- opdef.always_adapt = serialization<decltype(opdef.always_adapt)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(LAMBUpdate)
-
- int PyOp(LAMBUpdate)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"beta_1", "beta_2", "step", "lr", "weight_decay", "eps", "bias_correction", "always_adapt", "scope", NULL};
- PyObject *beta_1 = NULL, *beta_2 = NULL, *step = NULL, *lr = NULL, *weight_decay = NULL, *eps = NULL, *bias_correction = NULL, *always_adapt = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOO", const_cast<char**>(kwlist), &beta_1, &beta_2, &step, &lr, &weight_decay, &eps, &bias_correction, &always_adapt, &scope))
- return -1;
-
- if (beta_1) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LAMBUpdate)*>(self)->inst().beta_1 =
- py::cast<decltype(LAMBUpdate::beta_1)>(py::handle(beta_1));
- } CATCH_ALL(-1)
- }
-
- if (beta_2) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LAMBUpdate)*>(self)->inst().beta_2 =
- py::cast<decltype(LAMBUpdate::beta_2)>(py::handle(beta_2));
- } CATCH_ALL(-1)
- }
-
- if (step) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LAMBUpdate)*>(self)->inst().step =
- py::cast<decltype(LAMBUpdate::step)>(py::handle(step));
- } CATCH_ALL(-1)
- }
-
- if (lr) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LAMBUpdate)*>(self)->inst().lr =
- py::cast<decltype(LAMBUpdate::lr)>(py::handle(lr));
- } CATCH_ALL(-1)
- }
-
- if (weight_decay) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LAMBUpdate)*>(self)->inst().weight_decay =
- py::cast<decltype(LAMBUpdate::weight_decay)>(py::handle(weight_decay));
- } CATCH_ALL(-1)
- }
-
- if (eps) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LAMBUpdate)*>(self)->inst().eps =
- py::cast<decltype(LAMBUpdate::eps)>(py::handle(eps));
- } CATCH_ALL(-1)
- }
-
- if (bias_correction) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LAMBUpdate)*>(self)->inst().bias_correction =
- py::cast<decltype(LAMBUpdate::bias_correction)>(py::handle(bias_correction));
- } CATCH_ALL(-1)
- }
-
- if (always_adapt) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LAMBUpdate)*>(self)->inst().always_adapt =
- py::cast<decltype(LAMBUpdate::always_adapt)>(py::handle(always_adapt));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(LAMBUpdate)::py_getsetters[] = {
- {const_cast<char*>("beta_1"), py_get_generic(LAMBUpdate, beta_1), py_set_generic(LAMBUpdate, beta_1), const_cast<char*>("beta_1"), NULL},
- {const_cast<char*>("beta_2"), py_get_generic(LAMBUpdate, beta_2), py_set_generic(LAMBUpdate, beta_2), const_cast<char*>("beta_2"), NULL},
- {const_cast<char*>("step"), py_get_generic(LAMBUpdate, step), py_set_generic(LAMBUpdate, step), const_cast<char*>("step"), NULL},
- {const_cast<char*>("lr"), py_get_generic(LAMBUpdate, lr), py_set_generic(LAMBUpdate, lr), const_cast<char*>("lr"), NULL},
- {const_cast<char*>("weight_decay"), py_get_generic(LAMBUpdate, weight_decay), py_set_generic(LAMBUpdate, weight_decay), const_cast<char*>("weight_decay"), NULL},
- {const_cast<char*>("eps"), py_get_generic(LAMBUpdate, eps), py_set_generic(LAMBUpdate, eps), const_cast<char*>("eps"), NULL},
- {const_cast<char*>("bias_correction"), py_get_generic(LAMBUpdate, bias_correction), py_set_generic(LAMBUpdate, bias_correction), const_cast<char*>("bias_correction"), NULL},
- {const_cast<char*>("always_adapt"), py_get_generic(LAMBUpdate, always_adapt), py_set_generic(LAMBUpdate, always_adapt), const_cast<char*>("always_adapt"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(LAMBUpdate)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(LAMBUpdate)::getstate, METH_NOARGS, "LAMBUpdate getstate"},
- {const_cast<char*>("__setstate__"), PyOp(LAMBUpdate)::setstate, METH_VARARGS, "LAMBUpdate setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_LAMBUpdate(py::module m) {
- using py_op = PyOp(LAMBUpdate);
- auto& py_type = PyOpType(LAMBUpdate);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.LAMBUpdate";
- py_type.tp_basicsize = sizeof(PyOp(LAMBUpdate));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "LAMBUpdate";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("LAMBUpdate", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(LAMBUpdate::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(LRN) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(LRN)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"n", serialization<decltype(opdef.n)>::dump(opdef.n)},
- {"k", serialization<decltype(opdef.k)>::dump(opdef.k)},
- {"alpha", serialization<decltype(opdef.alpha)>::dump(opdef.alpha)},
- {"beta", serialization<decltype(opdef.beta)>::dump(opdef.beta)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(LRN)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("n");
- if (iter != state.end()) {
- opdef.n = serialization<decltype(opdef.n)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("k");
- if (iter != state.end()) {
- opdef.k = serialization<decltype(opdef.k)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("alpha");
- if (iter != state.end()) {
- opdef.alpha = serialization<decltype(opdef.alpha)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("beta");
- if (iter != state.end()) {
- opdef.beta = serialization<decltype(opdef.beta)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(LRN)
-
- int PyOp(LRN)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"n", "k", "alpha", "beta", "scope", NULL};
- PyObject *n = NULL, *k = NULL, *alpha = NULL, *beta = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOO", const_cast<char**>(kwlist), &n, &k, &alpha, &beta, &scope))
- return -1;
-
- if (n) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LRN)*>(self)->inst().n =
- py::cast<decltype(LRN::n)>(py::handle(n));
- } CATCH_ALL(-1)
- }
-
- if (k) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LRN)*>(self)->inst().k =
- py::cast<decltype(LRN::k)>(py::handle(k));
- } CATCH_ALL(-1)
- }
-
- if (alpha) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LRN)*>(self)->inst().alpha =
- py::cast<decltype(LRN::alpha)>(py::handle(alpha));
- } CATCH_ALL(-1)
- }
-
- if (beta) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LRN)*>(self)->inst().beta =
- py::cast<decltype(LRN::beta)>(py::handle(beta));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(LRN)::py_getsetters[] = {
- {const_cast<char*>("n"), py_get_generic(LRN, n), py_set_generic(LRN, n), const_cast<char*>("n"), NULL},
- {const_cast<char*>("k"), py_get_generic(LRN, k), py_set_generic(LRN, k), const_cast<char*>("k"), NULL},
- {const_cast<char*>("alpha"), py_get_generic(LRN, alpha), py_set_generic(LRN, alpha), const_cast<char*>("alpha"), NULL},
- {const_cast<char*>("beta"), py_get_generic(LRN, beta), py_set_generic(LRN, beta), const_cast<char*>("beta"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(LRN)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(LRN)::getstate, METH_NOARGS, "LRN getstate"},
- {const_cast<char*>("__setstate__"), PyOp(LRN)::setstate, METH_VARARGS, "LRN setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_LRN(py::module m) {
- using py_op = PyOp(LRN);
- auto& py_type = PyOpType(LRN);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.LRN";
- py_type.tp_basicsize = sizeof(PyOp(LRN));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "LRN";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("LRN", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(LRN::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(LSQ) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(LSQ)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"qmin", serialization<decltype(opdef.qmin)>::dump(opdef.qmin)},
- {"qmax", serialization<decltype(opdef.qmax)>::dump(opdef.qmax)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(LSQ)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("qmin");
- if (iter != state.end()) {
- opdef.qmin = serialization<decltype(opdef.qmin)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("qmax");
- if (iter != state.end()) {
- opdef.qmax = serialization<decltype(opdef.qmax)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(LSQ)
-
- int PyOp(LSQ)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"qmin", "qmax", "scope", NULL};
- PyObject *qmin = NULL, *qmax = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &qmin, &qmax, &scope))
- return -1;
-
- if (qmin) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LSQ)*>(self)->inst().qmin =
- py::cast<decltype(LSQ::qmin)>(py::handle(qmin));
- } CATCH_ALL(-1)
- }
-
- if (qmax) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LSQ)*>(self)->inst().qmax =
- py::cast<decltype(LSQ::qmax)>(py::handle(qmax));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(LSQ)::py_getsetters[] = {
- {const_cast<char*>("qmin"), py_get_generic(LSQ, qmin), py_set_generic(LSQ, qmin), const_cast<char*>("qmin"), NULL},
- {const_cast<char*>("qmax"), py_get_generic(LSQ, qmax), py_set_generic(LSQ, qmax), const_cast<char*>("qmax"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(LSQ)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(LSQ)::getstate, METH_NOARGS, "LSQ getstate"},
- {const_cast<char*>("__setstate__"), PyOp(LSQ)::setstate, METH_VARARGS, "LSQ setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_LSQ(py::module m) {
- using py_op = PyOp(LSQ);
- auto& py_type = PyOpType(LSQ);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.LSQ";
- py_type.tp_basicsize = sizeof(PyOp(LSQ));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "LSQ";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("LSQ", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(LSQ::typeinfo(), &py_type).second);
- }
-
- void _init_py_LSTM_FwdMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<LSTM::FwdMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "FwdMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(LSTM) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(LSTM)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"num_layers", serialization<decltype(opdef.num_layers)>::dump(opdef.num_layers)},
- {"bidirectional", serialization<decltype(opdef.bidirectional)>::dump(opdef.bidirectional)},
- {"bias", serialization<decltype(opdef.bias)>::dump(opdef.bias)},
- {"hidden_size", serialization<decltype(opdef.hidden_size)>::dump(opdef.hidden_size)},
- {"proj_size", serialization<decltype(opdef.proj_size)>::dump(opdef.proj_size)},
- {"dropout", serialization<decltype(opdef.dropout)>::dump(opdef.dropout)},
- {"fwd_mode", serialization<decltype(opdef.fwd_mode)>::dump(opdef.fwd_mode)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(LSTM)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("num_layers");
- if (iter != state.end()) {
- opdef.num_layers = serialization<decltype(opdef.num_layers)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("bidirectional");
- if (iter != state.end()) {
- opdef.bidirectional = serialization<decltype(opdef.bidirectional)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("bias");
- if (iter != state.end()) {
- opdef.bias = serialization<decltype(opdef.bias)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("hidden_size");
- if (iter != state.end()) {
- opdef.hidden_size = serialization<decltype(opdef.hidden_size)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("proj_size");
- if (iter != state.end()) {
- opdef.proj_size = serialization<decltype(opdef.proj_size)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dropout");
- if (iter != state.end()) {
- opdef.dropout = serialization<decltype(opdef.dropout)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("fwd_mode");
- if (iter != state.end()) {
- opdef.fwd_mode = serialization<decltype(opdef.fwd_mode)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(LSTM)
-
- int PyOp(LSTM)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"num_layers", "bidirectional", "bias", "hidden_size", "proj_size", "dropout", "fwd_mode", "scope", NULL};
- PyObject *num_layers = NULL, *bidirectional = NULL, *bias = NULL, *hidden_size = NULL, *proj_size = NULL, *dropout = NULL, *fwd_mode = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOO", const_cast<char**>(kwlist), &num_layers, &bidirectional, &bias, &hidden_size, &proj_size, &dropout, &fwd_mode, &scope))
- return -1;
-
- if (num_layers) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LSTM)*>(self)->inst().num_layers =
- py::cast<decltype(LSTM::num_layers)>(py::handle(num_layers));
- } CATCH_ALL(-1)
- }
-
- if (bidirectional) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LSTM)*>(self)->inst().bidirectional =
- py::cast<decltype(LSTM::bidirectional)>(py::handle(bidirectional));
- } CATCH_ALL(-1)
- }
-
- if (bias) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LSTM)*>(self)->inst().bias =
- py::cast<decltype(LSTM::bias)>(py::handle(bias));
- } CATCH_ALL(-1)
- }
-
- if (hidden_size) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LSTM)*>(self)->inst().hidden_size =
- py::cast<decltype(LSTM::hidden_size)>(py::handle(hidden_size));
- } CATCH_ALL(-1)
- }
-
- if (proj_size) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LSTM)*>(self)->inst().proj_size =
- py::cast<decltype(LSTM::proj_size)>(py::handle(proj_size));
- } CATCH_ALL(-1)
- }
-
- if (dropout) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LSTM)*>(self)->inst().dropout =
- py::cast<decltype(LSTM::dropout)>(py::handle(dropout));
- } CATCH_ALL(-1)
- }
-
- if (fwd_mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LSTM)*>(self)->inst().fwd_mode =
- py::cast<decltype(LSTM::fwd_mode)>(py::handle(fwd_mode));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(LSTM)::py_getsetters[] = {
- {const_cast<char*>("num_layers"), py_get_generic(LSTM, num_layers), py_set_generic(LSTM, num_layers), const_cast<char*>("num_layers"), NULL},
- {const_cast<char*>("bidirectional"), py_get_generic(LSTM, bidirectional), py_set_generic(LSTM, bidirectional), const_cast<char*>("bidirectional"), NULL},
- {const_cast<char*>("bias"), py_get_generic(LSTM, bias), py_set_generic(LSTM, bias), const_cast<char*>("bias"), NULL},
- {const_cast<char*>("hidden_size"), py_get_generic(LSTM, hidden_size), py_set_generic(LSTM, hidden_size), const_cast<char*>("hidden_size"), NULL},
- {const_cast<char*>("proj_size"), py_get_generic(LSTM, proj_size), py_set_generic(LSTM, proj_size), const_cast<char*>("proj_size"), NULL},
- {const_cast<char*>("dropout"), py_get_generic(LSTM, dropout), py_set_generic(LSTM, dropout), const_cast<char*>("dropout"), NULL},
- {const_cast<char*>("fwd_mode"), py_get_generic(LSTM, fwd_mode), py_set_generic(LSTM, fwd_mode), const_cast<char*>("fwd_mode"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(LSTM)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(LSTM)::getstate, METH_NOARGS, "LSTM getstate"},
- {const_cast<char*>("__setstate__"), PyOp(LSTM)::setstate, METH_VARARGS, "LSTM setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_LSTM(py::module m) {
- using py_op = PyOp(LSTM);
- auto& py_type = PyOpType(LSTM);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.LSTM";
- py_type.tp_basicsize = sizeof(PyOp(LSTM));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "LSTM";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_LSTM_FwdMode(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("LSTM", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(LSTM::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(LSTMCell) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(LSTMCell)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(LSTMCell)*>(self)->inst();
- static_cast<void>(opdef);
-
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(LSTMCell)
-
- int PyOp(LSTMCell)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
-
- return 0;
- }
-
- PyGetSetDef PyOp(LSTMCell)::py_getsetters[] = {
-
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(LSTMCell)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(LSTMCell)::getstate, METH_NOARGS, "LSTMCell getstate"},
- {const_cast<char*>("__setstate__"), PyOp(LSTMCell)::setstate, METH_VARARGS, "LSTMCell setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_LSTMCell(py::module m) {
- using py_op = PyOp(LSTMCell);
- auto& py_type = PyOpType(LSTMCell);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.LSTMCell";
- py_type.tp_basicsize = sizeof(PyOp(LSTMCell));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "LSTMCell";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("LSTMCell", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(LSTMCell::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(LayerNorm) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(LayerNorm)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"affine", serialization<decltype(opdef.affine)>::dump(opdef.affine)},
- {"eps", serialization<decltype(opdef.eps)>::dump(opdef.eps)},
- {"normalized_dim", serialization<decltype(opdef.normalized_dim)>::dump(opdef.normalized_dim)},
- {"normalized_size", serialization<decltype(opdef.normalized_size)>::dump(opdef.normalized_size)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(LayerNorm)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("affine");
- if (iter != state.end()) {
- opdef.affine = serialization<decltype(opdef.affine)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("eps");
- if (iter != state.end()) {
- opdef.eps = serialization<decltype(opdef.eps)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("normalized_dim");
- if (iter != state.end()) {
- opdef.normalized_dim = serialization<decltype(opdef.normalized_dim)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("normalized_size");
- if (iter != state.end()) {
- opdef.normalized_size = serialization<decltype(opdef.normalized_size)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(LayerNorm)
-
- int PyOp(LayerNorm)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"affine", "eps", "normalized_dim", "normalized_size", "scope", NULL};
- PyObject *affine = NULL, *eps = NULL, *normalized_dim = NULL, *normalized_size = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOO", const_cast<char**>(kwlist), &affine, &eps, &normalized_dim, &normalized_size, &scope))
- return -1;
-
- if (affine) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LayerNorm)*>(self)->inst().affine =
- py::cast<decltype(LayerNorm::affine)>(py::handle(affine));
- } CATCH_ALL(-1)
- }
-
- if (eps) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LayerNorm)*>(self)->inst().eps =
- py::cast<decltype(LayerNorm::eps)>(py::handle(eps));
- } CATCH_ALL(-1)
- }
-
- if (normalized_dim) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LayerNorm)*>(self)->inst().normalized_dim =
- py::cast<decltype(LayerNorm::normalized_dim)>(py::handle(normalized_dim));
- } CATCH_ALL(-1)
- }
-
- if (normalized_size) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(LayerNorm)*>(self)->inst().normalized_size =
- py::cast<decltype(LayerNorm::normalized_size)>(py::handle(normalized_size));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(LayerNorm)::py_getsetters[] = {
- {const_cast<char*>("affine"), py_get_generic(LayerNorm, affine), py_set_generic(LayerNorm, affine), const_cast<char*>("affine"), NULL},
- {const_cast<char*>("eps"), py_get_generic(LayerNorm, eps), py_set_generic(LayerNorm, eps), const_cast<char*>("eps"), NULL},
- {const_cast<char*>("normalized_dim"), py_get_generic(LayerNorm, normalized_dim), py_set_generic(LayerNorm, normalized_dim), const_cast<char*>("normalized_dim"), NULL},
- {const_cast<char*>("normalized_size"), py_get_generic(LayerNorm, normalized_size), py_set_generic(LayerNorm, normalized_size), const_cast<char*>("normalized_size"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(LayerNorm)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(LayerNorm)::getstate, METH_NOARGS, "LayerNorm getstate"},
- {const_cast<char*>("__setstate__"), PyOp(LayerNorm)::setstate, METH_VARARGS, "LayerNorm setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_LayerNorm(py::module m) {
- using py_op = PyOp(LayerNorm);
- auto& py_type = PyOpType(LayerNorm);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.LayerNorm";
- py_type.tp_basicsize = sizeof(PyOp(LayerNorm));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "LayerNorm";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("LayerNorm", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(LayerNorm::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Linspace) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Linspace)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"endpoint", serialization<decltype(opdef.endpoint)>::dump(opdef.endpoint)},
- {"comp_node", serialization<decltype(opdef.comp_node)>::dump(opdef.comp_node)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Linspace)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("endpoint");
- if (iter != state.end()) {
- opdef.endpoint = serialization<decltype(opdef.endpoint)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("comp_node");
- if (iter != state.end()) {
- opdef.comp_node = serialization<decltype(opdef.comp_node)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Linspace)
-
- int PyOp(Linspace)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"endpoint", "comp_node", "scope", NULL};
- PyObject *endpoint = NULL, *comp_node = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &endpoint, &comp_node, &scope))
- return -1;
-
- if (endpoint) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Linspace)*>(self)->inst().endpoint =
- py::cast<decltype(Linspace::endpoint)>(py::handle(endpoint));
- } CATCH_ALL(-1)
- }
-
- if (comp_node) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Linspace)*>(self)->inst().comp_node =
- py::cast<decltype(Linspace::comp_node)>(py::handle(comp_node));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Linspace)::py_getsetters[] = {
- {const_cast<char*>("endpoint"), py_get_generic(Linspace, endpoint), py_set_generic(Linspace, endpoint), const_cast<char*>("endpoint"), NULL},
- {const_cast<char*>("comp_node"), py_get_generic(Linspace, comp_node), py_set_generic(Linspace, comp_node), const_cast<char*>("comp_node"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Linspace)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Linspace)::getstate, METH_NOARGS, "Linspace getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Linspace)::setstate, METH_VARARGS, "Linspace setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Linspace(py::module m) {
- using py_op = PyOp(Linspace);
- auto& py_type = PyOpType(Linspace);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Linspace";
- py_type.tp_basicsize = sizeof(PyOp(Linspace));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Linspace";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Linspace", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Linspace::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(MagicMindRuntime) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(MagicMindRuntime)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"buf", serialization<decltype(opdef.buf)>::dump(opdef.buf)},
- {"buf_size", serialization<decltype(opdef.buf_size)>::dump(opdef.buf_size)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(MagicMindRuntime)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("buf");
- if (iter != state.end()) {
- opdef.buf = serialization<decltype(opdef.buf)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("buf_size");
- if (iter != state.end()) {
- opdef.buf_size = serialization<decltype(opdef.buf_size)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(MagicMindRuntime)
-
- int PyOp(MagicMindRuntime)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"buf", "buf_size", "scope", NULL};
- PyObject *buf = NULL, *buf_size = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &buf, &buf_size, &scope))
- return -1;
-
- if (buf) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(MagicMindRuntime)*>(self)->inst().buf =
- py::cast<decltype(MagicMindRuntime::buf)>(py::handle(buf));
- } CATCH_ALL(-1)
- }
-
- if (buf_size) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(MagicMindRuntime)*>(self)->inst().buf_size =
- py::cast<decltype(MagicMindRuntime::buf_size)>(py::handle(buf_size));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(MagicMindRuntime)::py_getsetters[] = {
- {const_cast<char*>("buf"), py_get_generic(MagicMindRuntime, buf), py_set_generic(MagicMindRuntime, buf), const_cast<char*>("buf"), NULL},
- {const_cast<char*>("buf_size"), py_get_generic(MagicMindRuntime, buf_size), py_set_generic(MagicMindRuntime, buf_size), const_cast<char*>("buf_size"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(MagicMindRuntime)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(MagicMindRuntime)::getstate, METH_NOARGS, "MagicMindRuntime getstate"},
- {const_cast<char*>("__setstate__"), PyOp(MagicMindRuntime)::setstate, METH_VARARGS, "MagicMindRuntime setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_MagicMindRuntime(py::module m) {
- using py_op = PyOp(MagicMindRuntime);
- auto& py_type = PyOpType(MagicMindRuntime);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.MagicMindRuntime";
- py_type.tp_basicsize = sizeof(PyOp(MagicMindRuntime));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "MagicMindRuntime";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("MagicMindRuntime", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(MagicMindRuntime::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(MatrixInverse) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(MatrixInverse)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(MatrixInverse)*>(self)->inst();
- static_cast<void>(opdef);
-
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(MatrixInverse)
-
- int PyOp(MatrixInverse)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
-
- return 0;
- }
-
- PyGetSetDef PyOp(MatrixInverse)::py_getsetters[] = {
-
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(MatrixInverse)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(MatrixInverse)::getstate, METH_NOARGS, "MatrixInverse getstate"},
- {const_cast<char*>("__setstate__"), PyOp(MatrixInverse)::setstate, METH_VARARGS, "MatrixInverse setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_MatrixInverse(py::module m) {
- using py_op = PyOp(MatrixInverse);
- auto& py_type = PyOpType(MatrixInverse);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.MatrixInverse";
- py_type.tp_basicsize = sizeof(PyOp(MatrixInverse));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "MatrixInverse";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("MatrixInverse", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(MatrixInverse::typeinfo(), &py_type).second);
- }
-
- void _init_py_MatrixMul_ComputeMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<MatrixMul::ComputeMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "ComputeMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_MatrixMul_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<MatrixMul::Format>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_MatrixMul_Strategy(PyTypeObject& py_type) {
- auto& e_type = BitCombinedEnumWrapper<MatrixMul::Strategy>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Strategy", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(MatrixMul) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(MatrixMul)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"transposeA", serialization<decltype(opdef.transposeA)>::dump(opdef.transposeA)},
- {"transposeB", serialization<decltype(opdef.transposeB)>::dump(opdef.transposeB)},
- {"compute_mode", serialization<decltype(opdef.compute_mode)>::dump(opdef.compute_mode)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"strategy", serialization<decltype(opdef.strategy)>::dump(opdef.strategy)},
- {"workspace_limit", serialization<decltype(opdef.workspace_limit)>::dump(opdef.workspace_limit)},
- {"dimA", serialization<decltype(opdef.dimA)>::dump(opdef.dimA)},
- {"dimB", serialization<decltype(opdef.dimB)>::dump(opdef.dimB)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(MatrixMul)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("transposeA");
- if (iter != state.end()) {
- opdef.transposeA = serialization<decltype(opdef.transposeA)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("transposeB");
- if (iter != state.end()) {
- opdef.transposeB = serialization<decltype(opdef.transposeB)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("compute_mode");
- if (iter != state.end()) {
- opdef.compute_mode = serialization<decltype(opdef.compute_mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("strategy");
- if (iter != state.end()) {
- opdef.strategy = serialization<decltype(opdef.strategy)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("workspace_limit");
- if (iter != state.end()) {
- opdef.workspace_limit = serialization<decltype(opdef.workspace_limit)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dimA");
- if (iter != state.end()) {
- opdef.dimA = serialization<decltype(opdef.dimA)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dimB");
- if (iter != state.end()) {
- opdef.dimB = serialization<decltype(opdef.dimB)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(MatrixMul)
-
- int PyOp(MatrixMul)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"transposeA", "transposeB", "compute_mode", "format", "strategy", "workspace_limit", "dimA", "dimB", "scope", NULL};
- PyObject *transposeA = NULL, *transposeB = NULL, *compute_mode = NULL, *format = NULL, *strategy = NULL, *workspace_limit = NULL, *dimA = NULL, *dimB = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOO", const_cast<char**>(kwlist), &transposeA, &transposeB, &compute_mode, &format, &strategy, &workspace_limit, &dimA, &dimB, &scope))
- return -1;
-
- if (transposeA) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(MatrixMul)*>(self)->inst().transposeA =
- py::cast<decltype(MatrixMul::transposeA)>(py::handle(transposeA));
- } CATCH_ALL(-1)
- }
-
- if (transposeB) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(MatrixMul)*>(self)->inst().transposeB =
- py::cast<decltype(MatrixMul::transposeB)>(py::handle(transposeB));
- } CATCH_ALL(-1)
- }
-
- if (compute_mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(MatrixMul)*>(self)->inst().compute_mode =
- py::cast<decltype(MatrixMul::compute_mode)>(py::handle(compute_mode));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(MatrixMul)*>(self)->inst().format =
- py::cast<decltype(MatrixMul::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (strategy) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(MatrixMul)*>(self)->inst().strategy =
- py::cast<decltype(MatrixMul::strategy)>(py::handle(strategy));
- } CATCH_ALL(-1)
- }
-
- if (workspace_limit) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(MatrixMul)*>(self)->inst().workspace_limit =
- py::cast<decltype(MatrixMul::workspace_limit)>(py::handle(workspace_limit));
- } CATCH_ALL(-1)
- }
-
- if (dimA) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(MatrixMul)*>(self)->inst().dimA =
- py::cast<decltype(MatrixMul::dimA)>(py::handle(dimA));
- } CATCH_ALL(-1)
- }
-
- if (dimB) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(MatrixMul)*>(self)->inst().dimB =
- py::cast<decltype(MatrixMul::dimB)>(py::handle(dimB));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(MatrixMul)::py_getsetters[] = {
- {const_cast<char*>("transposeA"), py_get_generic(MatrixMul, transposeA), py_set_generic(MatrixMul, transposeA), const_cast<char*>("transposeA"), NULL},
- {const_cast<char*>("transposeB"), py_get_generic(MatrixMul, transposeB), py_set_generic(MatrixMul, transposeB), const_cast<char*>("transposeB"), NULL},
- {const_cast<char*>("compute_mode"), py_get_generic(MatrixMul, compute_mode), py_set_generic(MatrixMul, compute_mode), const_cast<char*>("compute_mode"), NULL},
- {const_cast<char*>("format"), py_get_generic(MatrixMul, format), py_set_generic(MatrixMul, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("strategy"), py_get_generic(MatrixMul, strategy), py_set_generic(MatrixMul, strategy), const_cast<char*>("strategy"), NULL},
- {const_cast<char*>("workspace_limit"), py_get_generic(MatrixMul, workspace_limit), py_set_generic(MatrixMul, workspace_limit), const_cast<char*>("workspace_limit"), NULL},
- {const_cast<char*>("dimA"), py_get_generic(MatrixMul, dimA), py_set_generic(MatrixMul, dimA), const_cast<char*>("dimA"), NULL},
- {const_cast<char*>("dimB"), py_get_generic(MatrixMul, dimB), py_set_generic(MatrixMul, dimB), const_cast<char*>("dimB"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(MatrixMul)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(MatrixMul)::getstate, METH_NOARGS, "MatrixMul getstate"},
- {const_cast<char*>("__setstate__"), PyOp(MatrixMul)::setstate, METH_VARARGS, "MatrixMul setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_MatrixMul(py::module m) {
- using py_op = PyOp(MatrixMul);
- auto& py_type = PyOpType(MatrixMul);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.MatrixMul";
- py_type.tp_basicsize = sizeof(PyOp(MatrixMul));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "MatrixMul";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_MatrixMul_ComputeMode(py_type);
- _init_py_MatrixMul_Format(py_type);
- _init_py_MatrixMul_Strategy(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("MatrixMul", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(MatrixMul::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(MeshIndexing) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(MeshIndexing)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"items", serialization<decltype(opdef.items)>::dump(opdef.items)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(MeshIndexing)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("items");
- if (iter != state.end()) {
- opdef.items = serialization<decltype(opdef.items)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(MeshIndexing)
-
- int PyOp(MeshIndexing)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"items", "scope", NULL};
- PyObject *items = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &items, &scope))
- return -1;
-
- if (items) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(MeshIndexing)*>(self)->inst().items =
- py::cast<decltype(MeshIndexing::items)>(py::handle(items));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(MeshIndexing)::py_getsetters[] = {
- {const_cast<char*>("items"), py_get_generic(MeshIndexing, items), py_set_generic(MeshIndexing, items), const_cast<char*>("items"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(MeshIndexing)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(MeshIndexing)::getstate, METH_NOARGS, "MeshIndexing getstate"},
- {const_cast<char*>("__setstate__"), PyOp(MeshIndexing)::setstate, METH_VARARGS, "MeshIndexing setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_MeshIndexing(py::module m) {
- using py_op = PyOp(MeshIndexing);
- auto& py_type = PyOpType(MeshIndexing);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.MeshIndexing";
- py_type.tp_basicsize = sizeof(PyOp(MeshIndexing));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "MeshIndexing";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("MeshIndexing", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(MeshIndexing::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(NMSKeep) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(NMSKeep)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"iou_thresh", serialization<decltype(opdef.iou_thresh)>::dump(opdef.iou_thresh)},
- {"max_output", serialization<decltype(opdef.max_output)>::dump(opdef.max_output)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(NMSKeep)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("iou_thresh");
- if (iter != state.end()) {
- opdef.iou_thresh = serialization<decltype(opdef.iou_thresh)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("max_output");
- if (iter != state.end()) {
- opdef.max_output = serialization<decltype(opdef.max_output)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(NMSKeep)
-
- int PyOp(NMSKeep)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"iou_thresh", "max_output", "scope", NULL};
- PyObject *iou_thresh = NULL, *max_output = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &iou_thresh, &max_output, &scope))
- return -1;
-
- if (iou_thresh) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(NMSKeep)*>(self)->inst().iou_thresh =
- py::cast<decltype(NMSKeep::iou_thresh)>(py::handle(iou_thresh));
- } CATCH_ALL(-1)
- }
-
- if (max_output) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(NMSKeep)*>(self)->inst().max_output =
- py::cast<decltype(NMSKeep::max_output)>(py::handle(max_output));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(NMSKeep)::py_getsetters[] = {
- {const_cast<char*>("iou_thresh"), py_get_generic(NMSKeep, iou_thresh), py_set_generic(NMSKeep, iou_thresh), const_cast<char*>("iou_thresh"), NULL},
- {const_cast<char*>("max_output"), py_get_generic(NMSKeep, max_output), py_set_generic(NMSKeep, max_output), const_cast<char*>("max_output"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(NMSKeep)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(NMSKeep)::getstate, METH_NOARGS, "NMSKeep getstate"},
- {const_cast<char*>("__setstate__"), PyOp(NMSKeep)::setstate, METH_VARARGS, "NMSKeep setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_NMSKeep(py::module m) {
- using py_op = PyOp(NMSKeep);
- auto& py_type = PyOpType(NMSKeep);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.NMSKeep";
- py_type.tp_basicsize = sizeof(PyOp(NMSKeep));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "NMSKeep";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("NMSKeep", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(NMSKeep::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(NvOf) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(NvOf)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"precision", serialization<decltype(opdef.precision)>::dump(opdef.precision)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(NvOf)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("precision");
- if (iter != state.end()) {
- opdef.precision = serialization<decltype(opdef.precision)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(NvOf)
-
- int PyOp(NvOf)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"precision", "scope", NULL};
- PyObject *precision = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &precision, &scope))
- return -1;
-
- if (precision) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(NvOf)*>(self)->inst().precision =
- py::cast<decltype(NvOf::precision)>(py::handle(precision));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(NvOf)::py_getsetters[] = {
- {const_cast<char*>("precision"), py_get_generic(NvOf, precision), py_set_generic(NvOf, precision), const_cast<char*>("precision"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(NvOf)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(NvOf)::getstate, METH_NOARGS, "NvOf getstate"},
- {const_cast<char*>("__setstate__"), PyOp(NvOf)::setstate, METH_VARARGS, "NvOf setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_NvOf(py::module m) {
- using py_op = PyOp(NvOf);
- auto& py_type = PyOpType(NvOf);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.NvOf";
- py_type.tp_basicsize = sizeof(PyOp(NvOf));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "NvOf";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("NvOf", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(NvOf::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<Padding::PaddingMode> {
- static constexpr const char *name = "Padding.PaddingMode";
- static constexpr std::underlying_type_t<Padding::PaddingMode> max = 3 - 1;
- };
- template<> PyTypeObject* EnumWrapper<Padding::PaddingMode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<Padding::PaddingMode>::members[] = {"REPLICATE", "REFLECT", "CONSTANT"};
-
- template<> std::unordered_map<std::string, Padding::PaddingMode>
- EnumWrapper<Padding::PaddingMode>::mem2value = {{normalize_enum("REPLICATE"), Padding::PaddingMode::REPLICATE}, {normalize_enum("REFLECT"), Padding::PaddingMode::REFLECT}, {normalize_enum("CONSTANT"), Padding::PaddingMode::CONSTANT}};
- template<> PyObject* EnumWrapper<Padding::PaddingMode>::pyobj_insts[3] = {nullptr};
-
- void _init_py_Padding_PaddingMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Padding::PaddingMode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<Padding::PaddingMode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<Padding::PaddingMode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<Padding::PaddingMode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.Padding.PaddingMode",
- // basicsize
- sizeof(EnumWrapper<Padding::PaddingMode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("PaddingMode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("Padding.PaddingMode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Padding::PaddingMode>*>(inst)->value = Padding::PaddingMode::REPLICATE;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "REPLICATE", inst) >= 0);
- EnumWrapper<Padding::PaddingMode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Padding::PaddingMode>*>(inst)->value = Padding::PaddingMode::REFLECT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "REFLECT", inst) >= 0);
- EnumWrapper<Padding::PaddingMode>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Padding::PaddingMode>*>(inst)->value = Padding::PaddingMode::CONSTANT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "CONSTANT", inst) >= 0);
- EnumWrapper<Padding::PaddingMode>::pyobj_insts[2] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "PaddingMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(Padding) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Padding)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"front_offset_dim0", serialization<decltype(opdef.front_offset_dim0)>::dump(opdef.front_offset_dim0)},
- {"front_offset_dim1", serialization<decltype(opdef.front_offset_dim1)>::dump(opdef.front_offset_dim1)},
- {"front_offset_dim2", serialization<decltype(opdef.front_offset_dim2)>::dump(opdef.front_offset_dim2)},
- {"front_offset_dim3", serialization<decltype(opdef.front_offset_dim3)>::dump(opdef.front_offset_dim3)},
- {"front_offset_dim4", serialization<decltype(opdef.front_offset_dim4)>::dump(opdef.front_offset_dim4)},
- {"front_offset_dim5", serialization<decltype(opdef.front_offset_dim5)>::dump(opdef.front_offset_dim5)},
- {"front_offset_dim6", serialization<decltype(opdef.front_offset_dim6)>::dump(opdef.front_offset_dim6)},
- {"back_offset_dim0", serialization<decltype(opdef.back_offset_dim0)>::dump(opdef.back_offset_dim0)},
- {"back_offset_dim1", serialization<decltype(opdef.back_offset_dim1)>::dump(opdef.back_offset_dim1)},
- {"back_offset_dim2", serialization<decltype(opdef.back_offset_dim2)>::dump(opdef.back_offset_dim2)},
- {"back_offset_dim3", serialization<decltype(opdef.back_offset_dim3)>::dump(opdef.back_offset_dim3)},
- {"back_offset_dim4", serialization<decltype(opdef.back_offset_dim4)>::dump(opdef.back_offset_dim4)},
- {"back_offset_dim5", serialization<decltype(opdef.back_offset_dim5)>::dump(opdef.back_offset_dim5)},
- {"back_offset_dim6", serialization<decltype(opdef.back_offset_dim6)>::dump(opdef.back_offset_dim6)},
- {"padding_val", serialization<decltype(opdef.padding_val)>::dump(opdef.padding_val)},
- {"padding_mode", serialization<decltype(opdef.padding_mode)>::dump(opdef.padding_mode)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Padding)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("front_offset_dim0");
- if (iter != state.end()) {
- opdef.front_offset_dim0 = serialization<decltype(opdef.front_offset_dim0)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("front_offset_dim1");
- if (iter != state.end()) {
- opdef.front_offset_dim1 = serialization<decltype(opdef.front_offset_dim1)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("front_offset_dim2");
- if (iter != state.end()) {
- opdef.front_offset_dim2 = serialization<decltype(opdef.front_offset_dim2)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("front_offset_dim3");
- if (iter != state.end()) {
- opdef.front_offset_dim3 = serialization<decltype(opdef.front_offset_dim3)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("front_offset_dim4");
- if (iter != state.end()) {
- opdef.front_offset_dim4 = serialization<decltype(opdef.front_offset_dim4)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("front_offset_dim5");
- if (iter != state.end()) {
- opdef.front_offset_dim5 = serialization<decltype(opdef.front_offset_dim5)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("front_offset_dim6");
- if (iter != state.end()) {
- opdef.front_offset_dim6 = serialization<decltype(opdef.front_offset_dim6)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("back_offset_dim0");
- if (iter != state.end()) {
- opdef.back_offset_dim0 = serialization<decltype(opdef.back_offset_dim0)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("back_offset_dim1");
- if (iter != state.end()) {
- opdef.back_offset_dim1 = serialization<decltype(opdef.back_offset_dim1)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("back_offset_dim2");
- if (iter != state.end()) {
- opdef.back_offset_dim2 = serialization<decltype(opdef.back_offset_dim2)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("back_offset_dim3");
- if (iter != state.end()) {
- opdef.back_offset_dim3 = serialization<decltype(opdef.back_offset_dim3)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("back_offset_dim4");
- if (iter != state.end()) {
- opdef.back_offset_dim4 = serialization<decltype(opdef.back_offset_dim4)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("back_offset_dim5");
- if (iter != state.end()) {
- opdef.back_offset_dim5 = serialization<decltype(opdef.back_offset_dim5)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("back_offset_dim6");
- if (iter != state.end()) {
- opdef.back_offset_dim6 = serialization<decltype(opdef.back_offset_dim6)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("padding_val");
- if (iter != state.end()) {
- opdef.padding_val = serialization<decltype(opdef.padding_val)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("padding_mode");
- if (iter != state.end()) {
- opdef.padding_mode = serialization<decltype(opdef.padding_mode)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Padding)
-
- int PyOp(Padding)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"front_offset_dim0", "front_offset_dim1", "front_offset_dim2", "front_offset_dim3", "front_offset_dim4", "front_offset_dim5", "front_offset_dim6", "back_offset_dim0", "back_offset_dim1", "back_offset_dim2", "back_offset_dim3", "back_offset_dim4", "back_offset_dim5", "back_offset_dim6", "padding_val", "padding_mode", "scope", NULL};
- PyObject *front_offset_dim0 = NULL, *front_offset_dim1 = NULL, *front_offset_dim2 = NULL, *front_offset_dim3 = NULL, *front_offset_dim4 = NULL, *front_offset_dim5 = NULL, *front_offset_dim6 = NULL, *back_offset_dim0 = NULL, *back_offset_dim1 = NULL, *back_offset_dim2 = NULL, *back_offset_dim3 = NULL, *back_offset_dim4 = NULL, *back_offset_dim5 = NULL, *back_offset_dim6 = NULL, *padding_val = NULL, *padding_mode = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOOOOOOOOOO", const_cast<char**>(kwlist), &front_offset_dim0, &front_offset_dim1, &front_offset_dim2, &front_offset_dim3, &front_offset_dim4, &front_offset_dim5, &front_offset_dim6, &back_offset_dim0, &back_offset_dim1, &back_offset_dim2, &back_offset_dim3, &back_offset_dim4, &back_offset_dim5, &back_offset_dim6, &padding_val, &padding_mode, &scope))
- return -1;
-
- if (front_offset_dim0) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().front_offset_dim0 =
- py::cast<decltype(Padding::front_offset_dim0)>(py::handle(front_offset_dim0));
- } CATCH_ALL(-1)
- }
-
- if (front_offset_dim1) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().front_offset_dim1 =
- py::cast<decltype(Padding::front_offset_dim1)>(py::handle(front_offset_dim1));
- } CATCH_ALL(-1)
- }
-
- if (front_offset_dim2) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().front_offset_dim2 =
- py::cast<decltype(Padding::front_offset_dim2)>(py::handle(front_offset_dim2));
- } CATCH_ALL(-1)
- }
-
- if (front_offset_dim3) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().front_offset_dim3 =
- py::cast<decltype(Padding::front_offset_dim3)>(py::handle(front_offset_dim3));
- } CATCH_ALL(-1)
- }
-
- if (front_offset_dim4) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().front_offset_dim4 =
- py::cast<decltype(Padding::front_offset_dim4)>(py::handle(front_offset_dim4));
- } CATCH_ALL(-1)
- }
-
- if (front_offset_dim5) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().front_offset_dim5 =
- py::cast<decltype(Padding::front_offset_dim5)>(py::handle(front_offset_dim5));
- } CATCH_ALL(-1)
- }
-
- if (front_offset_dim6) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().front_offset_dim6 =
- py::cast<decltype(Padding::front_offset_dim6)>(py::handle(front_offset_dim6));
- } CATCH_ALL(-1)
- }
-
- if (back_offset_dim0) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().back_offset_dim0 =
- py::cast<decltype(Padding::back_offset_dim0)>(py::handle(back_offset_dim0));
- } CATCH_ALL(-1)
- }
-
- if (back_offset_dim1) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().back_offset_dim1 =
- py::cast<decltype(Padding::back_offset_dim1)>(py::handle(back_offset_dim1));
- } CATCH_ALL(-1)
- }
-
- if (back_offset_dim2) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().back_offset_dim2 =
- py::cast<decltype(Padding::back_offset_dim2)>(py::handle(back_offset_dim2));
- } CATCH_ALL(-1)
- }
-
- if (back_offset_dim3) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().back_offset_dim3 =
- py::cast<decltype(Padding::back_offset_dim3)>(py::handle(back_offset_dim3));
- } CATCH_ALL(-1)
- }
-
- if (back_offset_dim4) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().back_offset_dim4 =
- py::cast<decltype(Padding::back_offset_dim4)>(py::handle(back_offset_dim4));
- } CATCH_ALL(-1)
- }
-
- if (back_offset_dim5) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().back_offset_dim5 =
- py::cast<decltype(Padding::back_offset_dim5)>(py::handle(back_offset_dim5));
- } CATCH_ALL(-1)
- }
-
- if (back_offset_dim6) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().back_offset_dim6 =
- py::cast<decltype(Padding::back_offset_dim6)>(py::handle(back_offset_dim6));
- } CATCH_ALL(-1)
- }
-
- if (padding_val) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().padding_val =
- py::cast<decltype(Padding::padding_val)>(py::handle(padding_val));
- } CATCH_ALL(-1)
- }
-
- if (padding_mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Padding)*>(self)->inst().padding_mode =
- py::cast<decltype(Padding::padding_mode)>(py::handle(padding_mode));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Padding)::py_getsetters[] = {
- {const_cast<char*>("front_offset_dim0"), py_get_generic(Padding, front_offset_dim0), py_set_generic(Padding, front_offset_dim0), const_cast<char*>("front_offset_dim0"), NULL},
- {const_cast<char*>("front_offset_dim1"), py_get_generic(Padding, front_offset_dim1), py_set_generic(Padding, front_offset_dim1), const_cast<char*>("front_offset_dim1"), NULL},
- {const_cast<char*>("front_offset_dim2"), py_get_generic(Padding, front_offset_dim2), py_set_generic(Padding, front_offset_dim2), const_cast<char*>("front_offset_dim2"), NULL},
- {const_cast<char*>("front_offset_dim3"), py_get_generic(Padding, front_offset_dim3), py_set_generic(Padding, front_offset_dim3), const_cast<char*>("front_offset_dim3"), NULL},
- {const_cast<char*>("front_offset_dim4"), py_get_generic(Padding, front_offset_dim4), py_set_generic(Padding, front_offset_dim4), const_cast<char*>("front_offset_dim4"), NULL},
- {const_cast<char*>("front_offset_dim5"), py_get_generic(Padding, front_offset_dim5), py_set_generic(Padding, front_offset_dim5), const_cast<char*>("front_offset_dim5"), NULL},
- {const_cast<char*>("front_offset_dim6"), py_get_generic(Padding, front_offset_dim6), py_set_generic(Padding, front_offset_dim6), const_cast<char*>("front_offset_dim6"), NULL},
- {const_cast<char*>("back_offset_dim0"), py_get_generic(Padding, back_offset_dim0), py_set_generic(Padding, back_offset_dim0), const_cast<char*>("back_offset_dim0"), NULL},
- {const_cast<char*>("back_offset_dim1"), py_get_generic(Padding, back_offset_dim1), py_set_generic(Padding, back_offset_dim1), const_cast<char*>("back_offset_dim1"), NULL},
- {const_cast<char*>("back_offset_dim2"), py_get_generic(Padding, back_offset_dim2), py_set_generic(Padding, back_offset_dim2), const_cast<char*>("back_offset_dim2"), NULL},
- {const_cast<char*>("back_offset_dim3"), py_get_generic(Padding, back_offset_dim3), py_set_generic(Padding, back_offset_dim3), const_cast<char*>("back_offset_dim3"), NULL},
- {const_cast<char*>("back_offset_dim4"), py_get_generic(Padding, back_offset_dim4), py_set_generic(Padding, back_offset_dim4), const_cast<char*>("back_offset_dim4"), NULL},
- {const_cast<char*>("back_offset_dim5"), py_get_generic(Padding, back_offset_dim5), py_set_generic(Padding, back_offset_dim5), const_cast<char*>("back_offset_dim5"), NULL},
- {const_cast<char*>("back_offset_dim6"), py_get_generic(Padding, back_offset_dim6), py_set_generic(Padding, back_offset_dim6), const_cast<char*>("back_offset_dim6"), NULL},
- {const_cast<char*>("padding_val"), py_get_generic(Padding, padding_val), py_set_generic(Padding, padding_val), const_cast<char*>("padding_val"), NULL},
- {const_cast<char*>("padding_mode"), py_get_generic(Padding, padding_mode), py_set_generic(Padding, padding_mode), const_cast<char*>("padding_mode"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Padding)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Padding)::getstate, METH_NOARGS, "Padding getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Padding)::setstate, METH_VARARGS, "Padding setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Padding(py::module m) {
- using py_op = PyOp(Padding);
- auto& py_type = PyOpType(Padding);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Padding";
- py_type.tp_basicsize = sizeof(PyOp(Padding));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Padding";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_Padding_PaddingMode(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("Padding", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Padding::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(ParamPackConcat) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(ParamPackConcat)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"offsets", serialization<decltype(opdef.offsets)>::dump(opdef.offsets)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(ParamPackConcat)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("offsets");
- if (iter != state.end()) {
- opdef.offsets = serialization<decltype(opdef.offsets)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(ParamPackConcat)
-
- int PyOp(ParamPackConcat)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"offsets", "scope", NULL};
- PyObject *offsets = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &offsets, &scope))
- return -1;
-
- if (offsets) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ParamPackConcat)*>(self)->inst().offsets =
- py::cast<decltype(ParamPackConcat::offsets)>(py::handle(offsets));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(ParamPackConcat)::py_getsetters[] = {
- {const_cast<char*>("offsets"), py_get_generic(ParamPackConcat, offsets), py_set_generic(ParamPackConcat, offsets), const_cast<char*>("offsets"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(ParamPackConcat)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(ParamPackConcat)::getstate, METH_NOARGS, "ParamPackConcat getstate"},
- {const_cast<char*>("__setstate__"), PyOp(ParamPackConcat)::setstate, METH_VARARGS, "ParamPackConcat setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_ParamPackConcat(py::module m) {
- using py_op = PyOp(ParamPackConcat);
- auto& py_type = PyOpType(ParamPackConcat);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.ParamPackConcat";
- py_type.tp_basicsize = sizeof(PyOp(ParamPackConcat));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "ParamPackConcat";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("ParamPackConcat", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(ParamPackConcat::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(ParamPackSplit) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(ParamPackSplit)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"offsets", serialization<decltype(opdef.offsets)>::dump(opdef.offsets)},
- {"shapes", serialization<decltype(opdef.shapes)>::dump(opdef.shapes)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(ParamPackSplit)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("offsets");
- if (iter != state.end()) {
- opdef.offsets = serialization<decltype(opdef.offsets)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("shapes");
- if (iter != state.end()) {
- opdef.shapes = serialization<decltype(opdef.shapes)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(ParamPackSplit)
-
- int PyOp(ParamPackSplit)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"offsets", "shapes", "scope", NULL};
- PyObject *offsets = NULL, *shapes = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &offsets, &shapes, &scope))
- return -1;
-
- if (offsets) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ParamPackSplit)*>(self)->inst().offsets =
- py::cast<decltype(ParamPackSplit::offsets)>(py::handle(offsets));
- } CATCH_ALL(-1)
- }
-
- if (shapes) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ParamPackSplit)*>(self)->inst().shapes =
- py::cast<decltype(ParamPackSplit::shapes)>(py::handle(shapes));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(ParamPackSplit)::py_getsetters[] = {
- {const_cast<char*>("offsets"), py_get_generic(ParamPackSplit, offsets), py_set_generic(ParamPackSplit, offsets), const_cast<char*>("offsets"), NULL},
- {const_cast<char*>("shapes"), py_get_generic(ParamPackSplit, shapes), py_set_generic(ParamPackSplit, shapes), const_cast<char*>("shapes"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(ParamPackSplit)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(ParamPackSplit)::getstate, METH_NOARGS, "ParamPackSplit getstate"},
- {const_cast<char*>("__setstate__"), PyOp(ParamPackSplit)::setstate, METH_VARARGS, "ParamPackSplit setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_ParamPackSplit(py::module m) {
- using py_op = PyOp(ParamPackSplit);
- auto& py_type = PyOpType(ParamPackSplit);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.ParamPackSplit";
- py_type.tp_basicsize = sizeof(PyOp(ParamPackSplit));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "ParamPackSplit";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("ParamPackSplit", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(ParamPackSplit::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(PermutationRNG) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(PermutationRNG)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"seed", serialization<decltype(opdef.seed)>::dump(opdef.seed)},
- {"dtype", serialization<decltype(opdef.dtype)>::dump(opdef.dtype)},
- {"handle", serialization<decltype(opdef.handle)>::dump(opdef.handle)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(PermutationRNG)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("seed");
- if (iter != state.end()) {
- opdef.seed = serialization<decltype(opdef.seed)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dtype");
- if (iter != state.end()) {
- opdef.dtype = serialization<decltype(opdef.dtype)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("handle");
- if (iter != state.end()) {
- opdef.handle = serialization<decltype(opdef.handle)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(PermutationRNG)
-
- int PyOp(PermutationRNG)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"seed", "dtype", "handle", "scope", NULL};
- PyObject *seed = NULL, *dtype = NULL, *handle = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", const_cast<char**>(kwlist), &seed, &dtype, &handle, &scope))
- return -1;
-
- if (seed) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(PermutationRNG)*>(self)->inst().seed =
- py::cast<decltype(PermutationRNG::seed)>(py::handle(seed));
- } CATCH_ALL(-1)
- }
-
- if (dtype) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(PermutationRNG)*>(self)->inst().dtype =
- py::cast<decltype(PermutationRNG::dtype)>(py::handle(dtype));
- } CATCH_ALL(-1)
- }
-
- if (handle) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(PermutationRNG)*>(self)->inst().handle =
- py::cast<decltype(PermutationRNG::handle)>(py::handle(handle));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(PermutationRNG)::py_getsetters[] = {
- {const_cast<char*>("seed"), py_get_generic(PermutationRNG, seed), py_set_generic(PermutationRNG, seed), const_cast<char*>("seed"), NULL},
- {const_cast<char*>("dtype"), py_get_generic(PermutationRNG, dtype), py_set_generic(PermutationRNG, dtype), const_cast<char*>("dtype"), NULL},
- {const_cast<char*>("handle"), py_get_generic(PermutationRNG, handle), py_set_generic(PermutationRNG, handle), const_cast<char*>("handle"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(PermutationRNG)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(PermutationRNG)::getstate, METH_NOARGS, "PermutationRNG getstate"},
- {const_cast<char*>("__setstate__"), PyOp(PermutationRNG)::setstate, METH_VARARGS, "PermutationRNG setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_PermutationRNG(py::module m) {
- using py_op = PyOp(PermutationRNG);
- auto& py_type = PyOpType(PermutationRNG);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.PermutationRNG";
- py_type.tp_basicsize = sizeof(PyOp(PermutationRNG));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "PermutationRNG";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("PermutationRNG", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(PermutationRNG::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(PixelShuffle) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(PixelShuffle)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"factor", serialization<decltype(opdef.factor)>::dump(opdef.factor)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(PixelShuffle)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("factor");
- if (iter != state.end()) {
- opdef.factor = serialization<decltype(opdef.factor)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(PixelShuffle)
-
- int PyOp(PixelShuffle)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"factor", "scope", NULL};
- PyObject *factor = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &factor, &scope))
- return -1;
-
- if (factor) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(PixelShuffle)*>(self)->inst().factor =
- py::cast<decltype(PixelShuffle::factor)>(py::handle(factor));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(PixelShuffle)::py_getsetters[] = {
- {const_cast<char*>("factor"), py_get_generic(PixelShuffle, factor), py_set_generic(PixelShuffle, factor), const_cast<char*>("factor"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(PixelShuffle)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(PixelShuffle)::getstate, METH_NOARGS, "PixelShuffle getstate"},
- {const_cast<char*>("__setstate__"), PyOp(PixelShuffle)::setstate, METH_VARARGS, "PixelShuffle setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_PixelShuffle(py::module m) {
- using py_op = PyOp(PixelShuffle);
- auto& py_type = PyOpType(PixelShuffle);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.PixelShuffle";
- py_type.tp_basicsize = sizeof(PyOp(PixelShuffle));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "PixelShuffle";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("PixelShuffle", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(PixelShuffle::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(PixelShuffleBackward) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(PixelShuffleBackward)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"factor", serialization<decltype(opdef.factor)>::dump(opdef.factor)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(PixelShuffleBackward)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("factor");
- if (iter != state.end()) {
- opdef.factor = serialization<decltype(opdef.factor)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(PixelShuffleBackward)
-
- int PyOp(PixelShuffleBackward)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"factor", "scope", NULL};
- PyObject *factor = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &factor, &scope))
- return -1;
-
- if (factor) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(PixelShuffleBackward)*>(self)->inst().factor =
- py::cast<decltype(PixelShuffleBackward::factor)>(py::handle(factor));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(PixelShuffleBackward)::py_getsetters[] = {
- {const_cast<char*>("factor"), py_get_generic(PixelShuffleBackward, factor), py_set_generic(PixelShuffleBackward, factor), const_cast<char*>("factor"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(PixelShuffleBackward)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(PixelShuffleBackward)::getstate, METH_NOARGS, "PixelShuffleBackward getstate"},
- {const_cast<char*>("__setstate__"), PyOp(PixelShuffleBackward)::setstate, METH_VARARGS, "PixelShuffleBackward setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_PixelShuffleBackward(py::module m) {
- using py_op = PyOp(PixelShuffleBackward);
- auto& py_type = PyOpType(PixelShuffleBackward);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.PixelShuffleBackward";
- py_type.tp_basicsize = sizeof(PyOp(PixelShuffleBackward));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "PixelShuffleBackward";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("PixelShuffleBackward", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(PixelShuffleBackward::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(PoissonRNG) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(PoissonRNG)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"seed", serialization<decltype(opdef.seed)>::dump(opdef.seed)},
- {"handle", serialization<decltype(opdef.handle)>::dump(opdef.handle)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(PoissonRNG)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("seed");
- if (iter != state.end()) {
- opdef.seed = serialization<decltype(opdef.seed)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("handle");
- if (iter != state.end()) {
- opdef.handle = serialization<decltype(opdef.handle)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(PoissonRNG)
-
- int PyOp(PoissonRNG)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"seed", "handle", "scope", NULL};
- PyObject *seed = NULL, *handle = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &seed, &handle, &scope))
- return -1;
-
- if (seed) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(PoissonRNG)*>(self)->inst().seed =
- py::cast<decltype(PoissonRNG::seed)>(py::handle(seed));
- } CATCH_ALL(-1)
- }
-
- if (handle) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(PoissonRNG)*>(self)->inst().handle =
- py::cast<decltype(PoissonRNG::handle)>(py::handle(handle));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(PoissonRNG)::py_getsetters[] = {
- {const_cast<char*>("seed"), py_get_generic(PoissonRNG, seed), py_set_generic(PoissonRNG, seed), const_cast<char*>("seed"), NULL},
- {const_cast<char*>("handle"), py_get_generic(PoissonRNG, handle), py_set_generic(PoissonRNG, handle), const_cast<char*>("handle"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(PoissonRNG)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(PoissonRNG)::getstate, METH_NOARGS, "PoissonRNG getstate"},
- {const_cast<char*>("__setstate__"), PyOp(PoissonRNG)::setstate, METH_VARARGS, "PoissonRNG setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_PoissonRNG(py::module m) {
- using py_op = PyOp(PoissonRNG);
- auto& py_type = PyOpType(PoissonRNG);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.PoissonRNG";
- py_type.tp_basicsize = sizeof(PyOp(PoissonRNG));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "PoissonRNG";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("PoissonRNG", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(PoissonRNG::typeinfo(), &py_type).second);
- }
-
- void _init_py_Pooling_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Pooling::Mode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_Pooling_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Pooling::Format>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_Pooling_Strategy(PyTypeObject& py_type) {
- auto& e_type = BitCombinedEnumWrapper<Pooling::Strategy>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Strategy", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(Pooling) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Pooling)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)},
- {"pad_h", serialization<decltype(opdef.pad_h)>::dump(opdef.pad_h)},
- {"pad_w", serialization<decltype(opdef.pad_w)>::dump(opdef.pad_w)},
- {"stride_h", serialization<decltype(opdef.stride_h)>::dump(opdef.stride_h)},
- {"stride_w", serialization<decltype(opdef.stride_w)>::dump(opdef.stride_w)},
- {"window_h", serialization<decltype(opdef.window_h)>::dump(opdef.window_h)},
- {"window_w", serialization<decltype(opdef.window_w)>::dump(opdef.window_w)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"strategy", serialization<decltype(opdef.strategy)>::dump(opdef.strategy)},
- {"workspace_limit", serialization<decltype(opdef.workspace_limit)>::dump(opdef.workspace_limit)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Pooling)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_h");
- if (iter != state.end()) {
- opdef.pad_h = serialization<decltype(opdef.pad_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_w");
- if (iter != state.end()) {
- opdef.pad_w = serialization<decltype(opdef.pad_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_h");
- if (iter != state.end()) {
- opdef.stride_h = serialization<decltype(opdef.stride_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_w");
- if (iter != state.end()) {
- opdef.stride_w = serialization<decltype(opdef.stride_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("window_h");
- if (iter != state.end()) {
- opdef.window_h = serialization<decltype(opdef.window_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("window_w");
- if (iter != state.end()) {
- opdef.window_w = serialization<decltype(opdef.window_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("strategy");
- if (iter != state.end()) {
- opdef.strategy = serialization<decltype(opdef.strategy)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("workspace_limit");
- if (iter != state.end()) {
- opdef.workspace_limit = serialization<decltype(opdef.workspace_limit)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Pooling)
-
- int PyOp(Pooling)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "pad_h", "pad_w", "stride_h", "stride_w", "window_h", "window_w", "format", "strategy", "workspace_limit", "scope", NULL};
- PyObject *mode = NULL, *pad_h = NULL, *pad_w = NULL, *stride_h = NULL, *stride_w = NULL, *window_h = NULL, *window_w = NULL, *format = NULL, *strategy = NULL, *workspace_limit = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOOOO", const_cast<char**>(kwlist), &mode, &pad_h, &pad_w, &stride_h, &stride_w, &window_h, &window_w, &format, &strategy, &workspace_limit, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Pooling)*>(self)->inst().mode =
- py::cast<decltype(Pooling::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (pad_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Pooling)*>(self)->inst().pad_h =
- py::cast<decltype(Pooling::pad_h)>(py::handle(pad_h));
- } CATCH_ALL(-1)
- }
-
- if (pad_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Pooling)*>(self)->inst().pad_w =
- py::cast<decltype(Pooling::pad_w)>(py::handle(pad_w));
- } CATCH_ALL(-1)
- }
-
- if (stride_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Pooling)*>(self)->inst().stride_h =
- py::cast<decltype(Pooling::stride_h)>(py::handle(stride_h));
- } CATCH_ALL(-1)
- }
-
- if (stride_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Pooling)*>(self)->inst().stride_w =
- py::cast<decltype(Pooling::stride_w)>(py::handle(stride_w));
- } CATCH_ALL(-1)
- }
-
- if (window_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Pooling)*>(self)->inst().window_h =
- py::cast<decltype(Pooling::window_h)>(py::handle(window_h));
- } CATCH_ALL(-1)
- }
-
- if (window_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Pooling)*>(self)->inst().window_w =
- py::cast<decltype(Pooling::window_w)>(py::handle(window_w));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Pooling)*>(self)->inst().format =
- py::cast<decltype(Pooling::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (strategy) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Pooling)*>(self)->inst().strategy =
- py::cast<decltype(Pooling::strategy)>(py::handle(strategy));
- } CATCH_ALL(-1)
- }
-
- if (workspace_limit) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Pooling)*>(self)->inst().workspace_limit =
- py::cast<decltype(Pooling::workspace_limit)>(py::handle(workspace_limit));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Pooling)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(Pooling, mode), py_set_generic(Pooling, mode), const_cast<char*>("mode"), NULL},
- {const_cast<char*>("pad_h"), py_get_generic(Pooling, pad_h), py_set_generic(Pooling, pad_h), const_cast<char*>("pad_h"), NULL},
- {const_cast<char*>("pad_w"), py_get_generic(Pooling, pad_w), py_set_generic(Pooling, pad_w), const_cast<char*>("pad_w"), NULL},
- {const_cast<char*>("stride_h"), py_get_generic(Pooling, stride_h), py_set_generic(Pooling, stride_h), const_cast<char*>("stride_h"), NULL},
- {const_cast<char*>("stride_w"), py_get_generic(Pooling, stride_w), py_set_generic(Pooling, stride_w), const_cast<char*>("stride_w"), NULL},
- {const_cast<char*>("window_h"), py_get_generic(Pooling, window_h), py_set_generic(Pooling, window_h), const_cast<char*>("window_h"), NULL},
- {const_cast<char*>("window_w"), py_get_generic(Pooling, window_w), py_set_generic(Pooling, window_w), const_cast<char*>("window_w"), NULL},
- {const_cast<char*>("format"), py_get_generic(Pooling, format), py_set_generic(Pooling, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("strategy"), py_get_generic(Pooling, strategy), py_set_generic(Pooling, strategy), const_cast<char*>("strategy"), NULL},
- {const_cast<char*>("workspace_limit"), py_get_generic(Pooling, workspace_limit), py_set_generic(Pooling, workspace_limit), const_cast<char*>("workspace_limit"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Pooling)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Pooling)::getstate, METH_NOARGS, "Pooling getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Pooling)::setstate, METH_VARARGS, "Pooling setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Pooling(py::module m) {
- using py_op = PyOp(Pooling);
- auto& py_type = PyOpType(Pooling);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Pooling";
- py_type.tp_basicsize = sizeof(PyOp(Pooling));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Pooling";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_Pooling_Mode(py_type);
- _init_py_Pooling_Format(py_type);
- _init_py_Pooling_Strategy(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("Pooling", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Pooling::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<RNN::NonlineMode> {
- static constexpr const char *name = "RNN.NonlineMode";
- static constexpr std::underlying_type_t<RNN::NonlineMode> max = 3 - 1;
- };
- template<> PyTypeObject* EnumWrapper<RNN::NonlineMode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<RNN::NonlineMode>::members[] = {"IDENTITY", "RELU", "TANH"};
-
- template<> std::unordered_map<std::string, RNN::NonlineMode>
- EnumWrapper<RNN::NonlineMode>::mem2value = {{normalize_enum("IDENTITY"), RNN::NonlineMode::IDENTITY}, {normalize_enum("RELU"), RNN::NonlineMode::RELU}, {normalize_enum("TANH"), RNN::NonlineMode::TANH}};
- template<> PyObject* EnumWrapper<RNN::NonlineMode>::pyobj_insts[3] = {nullptr};
-
- void _init_py_RNN_NonlineMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<RNN::NonlineMode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<RNN::NonlineMode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<RNN::NonlineMode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<RNN::NonlineMode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.RNN.NonlineMode",
- // basicsize
- sizeof(EnumWrapper<RNN::NonlineMode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("NonlineMode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("RNN.NonlineMode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<RNN::NonlineMode>*>(inst)->value = RNN::NonlineMode::IDENTITY;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "IDENTITY", inst) >= 0);
- EnumWrapper<RNN::NonlineMode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<RNN::NonlineMode>*>(inst)->value = RNN::NonlineMode::RELU;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "RELU", inst) >= 0);
- EnumWrapper<RNN::NonlineMode>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<RNN::NonlineMode>*>(inst)->value = RNN::NonlineMode::TANH;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "TANH", inst) >= 0);
- EnumWrapper<RNN::NonlineMode>::pyobj_insts[2] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "NonlineMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_RNN_FwdMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<RNN::FwdMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "FwdMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(RNN) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(RNN)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"num_layers", serialization<decltype(opdef.num_layers)>::dump(opdef.num_layers)},
- {"bidirectional", serialization<decltype(opdef.bidirectional)>::dump(opdef.bidirectional)},
- {"bias", serialization<decltype(opdef.bias)>::dump(opdef.bias)},
- {"hidden_size", serialization<decltype(opdef.hidden_size)>::dump(opdef.hidden_size)},
- {"dropout", serialization<decltype(opdef.dropout)>::dump(opdef.dropout)},
- {"nonlineMode", serialization<decltype(opdef.nonlineMode)>::dump(opdef.nonlineMode)},
- {"fwd_mode", serialization<decltype(opdef.fwd_mode)>::dump(opdef.fwd_mode)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(RNN)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("num_layers");
- if (iter != state.end()) {
- opdef.num_layers = serialization<decltype(opdef.num_layers)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("bidirectional");
- if (iter != state.end()) {
- opdef.bidirectional = serialization<decltype(opdef.bidirectional)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("bias");
- if (iter != state.end()) {
- opdef.bias = serialization<decltype(opdef.bias)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("hidden_size");
- if (iter != state.end()) {
- opdef.hidden_size = serialization<decltype(opdef.hidden_size)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dropout");
- if (iter != state.end()) {
- opdef.dropout = serialization<decltype(opdef.dropout)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("nonlineMode");
- if (iter != state.end()) {
- opdef.nonlineMode = serialization<decltype(opdef.nonlineMode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("fwd_mode");
- if (iter != state.end()) {
- opdef.fwd_mode = serialization<decltype(opdef.fwd_mode)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(RNN)
-
- int PyOp(RNN)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"num_layers", "bidirectional", "bias", "hidden_size", "dropout", "nonlineMode", "fwd_mode", "scope", NULL};
- PyObject *num_layers = NULL, *bidirectional = NULL, *bias = NULL, *hidden_size = NULL, *dropout = NULL, *nonlineMode = NULL, *fwd_mode = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOO", const_cast<char**>(kwlist), &num_layers, &bidirectional, &bias, &hidden_size, &dropout, &nonlineMode, &fwd_mode, &scope))
- return -1;
-
- if (num_layers) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RNN)*>(self)->inst().num_layers =
- py::cast<decltype(RNN::num_layers)>(py::handle(num_layers));
- } CATCH_ALL(-1)
- }
-
- if (bidirectional) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RNN)*>(self)->inst().bidirectional =
- py::cast<decltype(RNN::bidirectional)>(py::handle(bidirectional));
- } CATCH_ALL(-1)
- }
-
- if (bias) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RNN)*>(self)->inst().bias =
- py::cast<decltype(RNN::bias)>(py::handle(bias));
- } CATCH_ALL(-1)
- }
-
- if (hidden_size) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RNN)*>(self)->inst().hidden_size =
- py::cast<decltype(RNN::hidden_size)>(py::handle(hidden_size));
- } CATCH_ALL(-1)
- }
-
- if (dropout) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RNN)*>(self)->inst().dropout =
- py::cast<decltype(RNN::dropout)>(py::handle(dropout));
- } CATCH_ALL(-1)
- }
-
- if (nonlineMode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RNN)*>(self)->inst().nonlineMode =
- py::cast<decltype(RNN::nonlineMode)>(py::handle(nonlineMode));
- } CATCH_ALL(-1)
- }
-
- if (fwd_mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RNN)*>(self)->inst().fwd_mode =
- py::cast<decltype(RNN::fwd_mode)>(py::handle(fwd_mode));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(RNN)::py_getsetters[] = {
- {const_cast<char*>("num_layers"), py_get_generic(RNN, num_layers), py_set_generic(RNN, num_layers), const_cast<char*>("num_layers"), NULL},
- {const_cast<char*>("bidirectional"), py_get_generic(RNN, bidirectional), py_set_generic(RNN, bidirectional), const_cast<char*>("bidirectional"), NULL},
- {const_cast<char*>("bias"), py_get_generic(RNN, bias), py_set_generic(RNN, bias), const_cast<char*>("bias"), NULL},
- {const_cast<char*>("hidden_size"), py_get_generic(RNN, hidden_size), py_set_generic(RNN, hidden_size), const_cast<char*>("hidden_size"), NULL},
- {const_cast<char*>("dropout"), py_get_generic(RNN, dropout), py_set_generic(RNN, dropout), const_cast<char*>("dropout"), NULL},
- {const_cast<char*>("nonlineMode"), py_get_generic(RNN, nonlineMode), py_set_generic(RNN, nonlineMode), const_cast<char*>("nonlineMode"), NULL},
- {const_cast<char*>("fwd_mode"), py_get_generic(RNN, fwd_mode), py_set_generic(RNN, fwd_mode), const_cast<char*>("fwd_mode"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(RNN)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(RNN)::getstate, METH_NOARGS, "RNN getstate"},
- {const_cast<char*>("__setstate__"), PyOp(RNN)::setstate, METH_VARARGS, "RNN setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_RNN(py::module m) {
- using py_op = PyOp(RNN);
- auto& py_type = PyOpType(RNN);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.RNN";
- py_type.tp_basicsize = sizeof(PyOp(RNN));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "RNN";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_RNN_NonlineMode(py_type);
- _init_py_RNN_FwdMode(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("RNN", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(RNN::typeinfo(), &py_type).second);
- }
-
- void _init_py_RNNCell_NonlineMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<RNNCell::NonlineMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "NonlineMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(RNNCell) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(RNNCell)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"nonlineMode", serialization<decltype(opdef.nonlineMode)>::dump(opdef.nonlineMode)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(RNNCell)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("nonlineMode");
- if (iter != state.end()) {
- opdef.nonlineMode = serialization<decltype(opdef.nonlineMode)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(RNNCell)
-
- int PyOp(RNNCell)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"nonlineMode", "scope", NULL};
- PyObject *nonlineMode = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &nonlineMode, &scope))
- return -1;
-
- if (nonlineMode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RNNCell)*>(self)->inst().nonlineMode =
- py::cast<decltype(RNNCell::nonlineMode)>(py::handle(nonlineMode));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(RNNCell)::py_getsetters[] = {
- {const_cast<char*>("nonlineMode"), py_get_generic(RNNCell, nonlineMode), py_set_generic(RNNCell, nonlineMode), const_cast<char*>("nonlineMode"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(RNNCell)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(RNNCell)::getstate, METH_NOARGS, "RNNCell getstate"},
- {const_cast<char*>("__setstate__"), PyOp(RNNCell)::setstate, METH_VARARGS, "RNNCell setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_RNNCell(py::module m) {
- using py_op = PyOp(RNNCell);
- auto& py_type = PyOpType(RNNCell);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.RNNCell";
- py_type.tp_basicsize = sizeof(PyOp(RNNCell));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "RNNCell";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_RNNCell_NonlineMode(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("RNNCell", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(RNNCell::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<ROIAlign::Mode> {
- static constexpr const char *name = "ROIAlign.Mode";
- static constexpr std::underlying_type_t<ROIAlign::Mode> max = 2 - 1;
- };
- template<> PyTypeObject* EnumWrapper<ROIAlign::Mode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<ROIAlign::Mode>::members[] = {"MAX", "AVERAGE"};
-
- template<> std::unordered_map<std::string, ROIAlign::Mode>
- EnumWrapper<ROIAlign::Mode>::mem2value = {{normalize_enum("MAX"), ROIAlign::Mode::MAX}, {normalize_enum("AVERAGE"), ROIAlign::Mode::AVERAGE}};
- template<> PyObject* EnumWrapper<ROIAlign::Mode>::pyobj_insts[2] = {nullptr};
-
- void _init_py_ROIAlign_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<ROIAlign::Mode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<ROIAlign::Mode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<ROIAlign::Mode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<ROIAlign::Mode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.ROIAlign.Mode",
- // basicsize
- sizeof(EnumWrapper<ROIAlign::Mode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Mode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("ROIAlign.Mode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ROIAlign::Mode>*>(inst)->value = ROIAlign::Mode::MAX;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "MAX", inst) >= 0);
- EnumWrapper<ROIAlign::Mode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ROIAlign::Mode>*>(inst)->value = ROIAlign::Mode::AVERAGE;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "AVERAGE", inst) >= 0);
- EnumWrapper<ROIAlign::Mode>::pyobj_insts[1] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_ROIAlign_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<ROIAlign::Format>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(ROIAlign) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(ROIAlign)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"spatial_scale", serialization<decltype(opdef.spatial_scale)>::dump(opdef.spatial_scale)},
- {"offset", serialization<decltype(opdef.offset)>::dump(opdef.offset)},
- {"pooled_height", serialization<decltype(opdef.pooled_height)>::dump(opdef.pooled_height)},
- {"pooled_width", serialization<decltype(opdef.pooled_width)>::dump(opdef.pooled_width)},
- {"sample_height", serialization<decltype(opdef.sample_height)>::dump(opdef.sample_height)},
- {"sample_width", serialization<decltype(opdef.sample_width)>::dump(opdef.sample_width)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(ROIAlign)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("spatial_scale");
- if (iter != state.end()) {
- opdef.spatial_scale = serialization<decltype(opdef.spatial_scale)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("offset");
- if (iter != state.end()) {
- opdef.offset = serialization<decltype(opdef.offset)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pooled_height");
- if (iter != state.end()) {
- opdef.pooled_height = serialization<decltype(opdef.pooled_height)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pooled_width");
- if (iter != state.end()) {
- opdef.pooled_width = serialization<decltype(opdef.pooled_width)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("sample_height");
- if (iter != state.end()) {
- opdef.sample_height = serialization<decltype(opdef.sample_height)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("sample_width");
- if (iter != state.end()) {
- opdef.sample_width = serialization<decltype(opdef.sample_width)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(ROIAlign)
-
- int PyOp(ROIAlign)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "format", "spatial_scale", "offset", "pooled_height", "pooled_width", "sample_height", "sample_width", "scope", NULL};
- PyObject *mode = NULL, *format = NULL, *spatial_scale = NULL, *offset = NULL, *pooled_height = NULL, *pooled_width = NULL, *sample_height = NULL, *sample_width = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOO", const_cast<char**>(kwlist), &mode, &format, &spatial_scale, &offset, &pooled_height, &pooled_width, &sample_height, &sample_width, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ROIAlign)*>(self)->inst().mode =
- py::cast<decltype(ROIAlign::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ROIAlign)*>(self)->inst().format =
- py::cast<decltype(ROIAlign::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (spatial_scale) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ROIAlign)*>(self)->inst().spatial_scale =
- py::cast<decltype(ROIAlign::spatial_scale)>(py::handle(spatial_scale));
- } CATCH_ALL(-1)
- }
-
- if (offset) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ROIAlign)*>(self)->inst().offset =
- py::cast<decltype(ROIAlign::offset)>(py::handle(offset));
- } CATCH_ALL(-1)
- }
-
- if (pooled_height) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ROIAlign)*>(self)->inst().pooled_height =
- py::cast<decltype(ROIAlign::pooled_height)>(py::handle(pooled_height));
- } CATCH_ALL(-1)
- }
-
- if (pooled_width) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ROIAlign)*>(self)->inst().pooled_width =
- py::cast<decltype(ROIAlign::pooled_width)>(py::handle(pooled_width));
- } CATCH_ALL(-1)
- }
-
- if (sample_height) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ROIAlign)*>(self)->inst().sample_height =
- py::cast<decltype(ROIAlign::sample_height)>(py::handle(sample_height));
- } CATCH_ALL(-1)
- }
-
- if (sample_width) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ROIAlign)*>(self)->inst().sample_width =
- py::cast<decltype(ROIAlign::sample_width)>(py::handle(sample_width));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(ROIAlign)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(ROIAlign, mode), py_set_generic(ROIAlign, mode), const_cast<char*>("mode"), NULL},
- {const_cast<char*>("format"), py_get_generic(ROIAlign, format), py_set_generic(ROIAlign, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("spatial_scale"), py_get_generic(ROIAlign, spatial_scale), py_set_generic(ROIAlign, spatial_scale), const_cast<char*>("spatial_scale"), NULL},
- {const_cast<char*>("offset"), py_get_generic(ROIAlign, offset), py_set_generic(ROIAlign, offset), const_cast<char*>("offset"), NULL},
- {const_cast<char*>("pooled_height"), py_get_generic(ROIAlign, pooled_height), py_set_generic(ROIAlign, pooled_height), const_cast<char*>("pooled_height"), NULL},
- {const_cast<char*>("pooled_width"), py_get_generic(ROIAlign, pooled_width), py_set_generic(ROIAlign, pooled_width), const_cast<char*>("pooled_width"), NULL},
- {const_cast<char*>("sample_height"), py_get_generic(ROIAlign, sample_height), py_set_generic(ROIAlign, sample_height), const_cast<char*>("sample_height"), NULL},
- {const_cast<char*>("sample_width"), py_get_generic(ROIAlign, sample_width), py_set_generic(ROIAlign, sample_width), const_cast<char*>("sample_width"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(ROIAlign)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(ROIAlign)::getstate, METH_NOARGS, "ROIAlign getstate"},
- {const_cast<char*>("__setstate__"), PyOp(ROIAlign)::setstate, METH_VARARGS, "ROIAlign setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_ROIAlign(py::module m) {
- using py_op = PyOp(ROIAlign);
- auto& py_type = PyOpType(ROIAlign);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.ROIAlign";
- py_type.tp_basicsize = sizeof(PyOp(ROIAlign));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "ROIAlign";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_ROIAlign_Mode(py_type);
- _init_py_ROIAlign_Format(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("ROIAlign", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(ROIAlign::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<ROIPooling::Mode> {
- static constexpr const char *name = "ROIPooling.Mode";
- static constexpr std::underlying_type_t<ROIPooling::Mode> max = 2 - 1;
- };
- template<> PyTypeObject* EnumWrapper<ROIPooling::Mode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<ROIPooling::Mode>::members[] = {"MAX", "AVERAGE"};
-
- template<> std::unordered_map<std::string, ROIPooling::Mode>
- EnumWrapper<ROIPooling::Mode>::mem2value = {{normalize_enum("MAX"), ROIPooling::Mode::MAX}, {normalize_enum("AVERAGE"), ROIPooling::Mode::AVERAGE}};
- template<> PyObject* EnumWrapper<ROIPooling::Mode>::pyobj_insts[2] = {nullptr};
-
- void _init_py_ROIPooling_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<ROIPooling::Mode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<ROIPooling::Mode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<ROIPooling::Mode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<ROIPooling::Mode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.ROIPooling.Mode",
- // basicsize
- sizeof(EnumWrapper<ROIPooling::Mode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Mode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("ROIPooling.Mode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ROIPooling::Mode>*>(inst)->value = ROIPooling::Mode::MAX;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "MAX", inst) >= 0);
- EnumWrapper<ROIPooling::Mode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<ROIPooling::Mode>*>(inst)->value = ROIPooling::Mode::AVERAGE;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "AVERAGE", inst) >= 0);
- EnumWrapper<ROIPooling::Mode>::pyobj_insts[1] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(ROIPooling) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(ROIPooling)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)},
- {"scale", serialization<decltype(opdef.scale)>::dump(opdef.scale)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(ROIPooling)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("scale");
- if (iter != state.end()) {
- opdef.scale = serialization<decltype(opdef.scale)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(ROIPooling)
-
- int PyOp(ROIPooling)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "scale", "scope", NULL};
- PyObject *mode = NULL, *scale = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &mode, &scale, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ROIPooling)*>(self)->inst().mode =
- py::cast<decltype(ROIPooling::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (scale) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ROIPooling)*>(self)->inst().scale =
- py::cast<decltype(ROIPooling::scale)>(py::handle(scale));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(ROIPooling)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(ROIPooling, mode), py_set_generic(ROIPooling, mode), const_cast<char*>("mode"), NULL},
- {const_cast<char*>("scale"), py_get_generic(ROIPooling, scale), py_set_generic(ROIPooling, scale), const_cast<char*>("scale"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(ROIPooling)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(ROIPooling)::getstate, METH_NOARGS, "ROIPooling getstate"},
- {const_cast<char*>("__setstate__"), PyOp(ROIPooling)::setstate, METH_VARARGS, "ROIPooling setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_ROIPooling(py::module m) {
- using py_op = PyOp(ROIPooling);
- auto& py_type = PyOpType(ROIPooling);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.ROIPooling";
- py_type.tp_basicsize = sizeof(PyOp(ROIPooling));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "ROIPooling";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_ROIPooling_Mode(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("ROIPooling", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(ROIPooling::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<Reduce::Mode> {
- static constexpr const char *name = "Reduce.Mode";
- static constexpr std::underlying_type_t<Reduce::Mode> max = 6 - 1;
- };
- template<> PyTypeObject* EnumWrapper<Reduce::Mode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<Reduce::Mode>::members[] = {"SUM", "SUM_SQR", "PRODUCT", "MIN", "MAX", "MEAN"};
-
- template<> std::unordered_map<std::string, Reduce::Mode>
- EnumWrapper<Reduce::Mode>::mem2value = {{normalize_enum("SUM"), Reduce::Mode::SUM}, {normalize_enum("SUM_SQR"), Reduce::Mode::SUM_SQR}, {normalize_enum("PRODUCT"), Reduce::Mode::PRODUCT}, {normalize_enum("MIN"), Reduce::Mode::MIN}, {normalize_enum("MAX"), Reduce::Mode::MAX}, {normalize_enum("MEAN"), Reduce::Mode::MEAN}};
- template<> PyObject* EnumWrapper<Reduce::Mode>::pyobj_insts[6] = {nullptr};
-
- void _init_py_Reduce_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Reduce::Mode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<Reduce::Mode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<Reduce::Mode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<Reduce::Mode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.Reduce.Mode",
- // basicsize
- sizeof(EnumWrapper<Reduce::Mode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Mode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("Reduce.Mode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Reduce::Mode>*>(inst)->value = Reduce::Mode::SUM;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "SUM", inst) >= 0);
- EnumWrapper<Reduce::Mode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Reduce::Mode>*>(inst)->value = Reduce::Mode::SUM_SQR;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "SUM_SQR", inst) >= 0);
- EnumWrapper<Reduce::Mode>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Reduce::Mode>*>(inst)->value = Reduce::Mode::PRODUCT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "PRODUCT", inst) >= 0);
- EnumWrapper<Reduce::Mode>::pyobj_insts[2] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Reduce::Mode>*>(inst)->value = Reduce::Mode::MIN;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "MIN", inst) >= 0);
- EnumWrapper<Reduce::Mode>::pyobj_insts[3] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Reduce::Mode>*>(inst)->value = Reduce::Mode::MAX;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "MAX", inst) >= 0);
- EnumWrapper<Reduce::Mode>::pyobj_insts[4] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Reduce::Mode>*>(inst)->value = Reduce::Mode::MEAN;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "MEAN", inst) >= 0);
- EnumWrapper<Reduce::Mode>::pyobj_insts[5] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- template<> struct EnumTrait<Reduce::DataType> {
- static constexpr const char *name = "Reduce.DataType";
- static constexpr std::underlying_type_t<Reduce::DataType> max = 6 - 1;
- };
- template<> PyTypeObject* EnumWrapper<Reduce::DataType>::type = nullptr;
-
- template<> const char*
- EnumWrapper<Reduce::DataType>::members[] = {"DEFAULT", "FLOAT_IO16xC32", "FLOAT_O32xC32", "FLOAT_O16xC32", "QUINT_I8xO32", "QINT_I8xO32"};
-
- template<> std::unordered_map<std::string, Reduce::DataType>
- EnumWrapper<Reduce::DataType>::mem2value = {{normalize_enum("DEFAULT"), Reduce::DataType::DEFAULT}, {normalize_enum("FLOAT_IO16xC32"), Reduce::DataType::FLOAT_IO16xC32}, {normalize_enum("FLOAT_O32xC32"), Reduce::DataType::FLOAT_O32xC32}, {normalize_enum("FLOAT_O16xC32"), Reduce::DataType::FLOAT_O16xC32}, {normalize_enum("QUINT_I8xO32"), Reduce::DataType::QUINT_I8xO32}, {normalize_enum("QINT_I8xO32"), Reduce::DataType::QINT_I8xO32}};
- template<> PyObject* EnumWrapper<Reduce::DataType>::pyobj_insts[6] = {nullptr};
-
- void _init_py_Reduce_DataType(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Reduce::DataType>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<Reduce::DataType>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<Reduce::DataType>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<Reduce::DataType>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.Reduce.DataType",
- // basicsize
- sizeof(EnumWrapper<Reduce::DataType>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("DataType").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("Reduce.DataType").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Reduce::DataType>*>(inst)->value = Reduce::DataType::DEFAULT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "DEFAULT", inst) >= 0);
- EnumWrapper<Reduce::DataType>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Reduce::DataType>*>(inst)->value = Reduce::DataType::FLOAT_IO16xC32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FLOAT_IO16xC32", inst) >= 0);
- EnumWrapper<Reduce::DataType>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Reduce::DataType>*>(inst)->value = Reduce::DataType::FLOAT_O32xC32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FLOAT_O32xC32", inst) >= 0);
- EnumWrapper<Reduce::DataType>::pyobj_insts[2] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Reduce::DataType>*>(inst)->value = Reduce::DataType::FLOAT_O16xC32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "FLOAT_O16xC32", inst) >= 0);
- EnumWrapper<Reduce::DataType>::pyobj_insts[3] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Reduce::DataType>*>(inst)->value = Reduce::DataType::QUINT_I8xO32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QUINT_I8xO32", inst) >= 0);
- EnumWrapper<Reduce::DataType>::pyobj_insts[4] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Reduce::DataType>*>(inst)->value = Reduce::DataType::QINT_I8xO32;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "QINT_I8xO32", inst) >= 0);
- EnumWrapper<Reduce::DataType>::pyobj_insts[5] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "DataType", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(Reduce) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Reduce)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)},
- {"axis", serialization<decltype(opdef.axis)>::dump(opdef.axis)},
- {"data_type", serialization<decltype(opdef.data_type)>::dump(opdef.data_type)},
- {"keepdim", serialization<decltype(opdef.keepdim)>::dump(opdef.keepdim)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Reduce)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("axis");
- if (iter != state.end()) {
- opdef.axis = serialization<decltype(opdef.axis)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("data_type");
- if (iter != state.end()) {
- opdef.data_type = serialization<decltype(opdef.data_type)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("keepdim");
- if (iter != state.end()) {
- opdef.keepdim = serialization<decltype(opdef.keepdim)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Reduce)
-
- int PyOp(Reduce)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "axis", "data_type", "keepdim", "scope", NULL};
- PyObject *mode = NULL, *axis = NULL, *data_type = NULL, *keepdim = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOO", const_cast<char**>(kwlist), &mode, &axis, &data_type, &keepdim, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Reduce)*>(self)->inst().mode =
- py::cast<decltype(Reduce::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (axis) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Reduce)*>(self)->inst().axis =
- py::cast<decltype(Reduce::axis)>(py::handle(axis));
- } CATCH_ALL(-1)
- }
-
- if (data_type) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Reduce)*>(self)->inst().data_type =
- py::cast<decltype(Reduce::data_type)>(py::handle(data_type));
- } CATCH_ALL(-1)
- }
-
- if (keepdim) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Reduce)*>(self)->inst().keepdim =
- py::cast<decltype(Reduce::keepdim)>(py::handle(keepdim));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Reduce)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(Reduce, mode), py_set_generic(Reduce, mode), const_cast<char*>("mode"), NULL},
- {const_cast<char*>("axis"), py_get_generic(Reduce, axis), py_set_generic(Reduce, axis), const_cast<char*>("axis"), NULL},
- {const_cast<char*>("data_type"), py_get_generic(Reduce, data_type), py_set_generic(Reduce, data_type), const_cast<char*>("data_type"), NULL},
- {const_cast<char*>("keepdim"), py_get_generic(Reduce, keepdim), py_set_generic(Reduce, keepdim), const_cast<char*>("keepdim"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Reduce)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Reduce)::getstate, METH_NOARGS, "Reduce getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Reduce)::setstate, METH_VARARGS, "Reduce setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Reduce(py::module m) {
- using py_op = PyOp(Reduce);
- auto& py_type = PyOpType(Reduce);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Reduce";
- py_type.tp_basicsize = sizeof(PyOp(Reduce));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Reduce";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_Reduce_Mode(py_type);
- _init_py_Reduce_DataType(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("Reduce", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Reduce::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<Remap::InterpolationMode> {
- static constexpr const char *name = "Remap.InterpolationMode";
- static constexpr std::underlying_type_t<Remap::InterpolationMode> max = 5 - 1;
- };
- template<> PyTypeObject* EnumWrapper<Remap::InterpolationMode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<Remap::InterpolationMode>::members[] = {"NEAREST", "LINEAR", "AREA", "CUBIC", "LANCZOS4"};
-
- template<> std::unordered_map<std::string, Remap::InterpolationMode>
- EnumWrapper<Remap::InterpolationMode>::mem2value = {{normalize_enum("NEAREST"), Remap::InterpolationMode::NEAREST}, {normalize_enum("LINEAR"), Remap::InterpolationMode::LINEAR}, {normalize_enum("AREA"), Remap::InterpolationMode::AREA}, {normalize_enum("CUBIC"), Remap::InterpolationMode::CUBIC}, {normalize_enum("LANCZOS4"), Remap::InterpolationMode::LANCZOS4}};
- template<> PyObject* EnumWrapper<Remap::InterpolationMode>::pyobj_insts[5] = {nullptr};
-
- void _init_py_Remap_InterpolationMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Remap::InterpolationMode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<Remap::InterpolationMode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<Remap::InterpolationMode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<Remap::InterpolationMode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.Remap.InterpolationMode",
- // basicsize
- sizeof(EnumWrapper<Remap::InterpolationMode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("InterpolationMode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("Remap.InterpolationMode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Remap::InterpolationMode>*>(inst)->value = Remap::InterpolationMode::NEAREST;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "NEAREST", inst) >= 0);
- EnumWrapper<Remap::InterpolationMode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Remap::InterpolationMode>*>(inst)->value = Remap::InterpolationMode::LINEAR;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "LINEAR", inst) >= 0);
- EnumWrapper<Remap::InterpolationMode>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Remap::InterpolationMode>*>(inst)->value = Remap::InterpolationMode::AREA;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "AREA", inst) >= 0);
- EnumWrapper<Remap::InterpolationMode>::pyobj_insts[2] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Remap::InterpolationMode>*>(inst)->value = Remap::InterpolationMode::CUBIC;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "CUBIC", inst) >= 0);
- EnumWrapper<Remap::InterpolationMode>::pyobj_insts[3] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Remap::InterpolationMode>*>(inst)->value = Remap::InterpolationMode::LANCZOS4;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "LANCZOS4", inst) >= 0);
- EnumWrapper<Remap::InterpolationMode>::pyobj_insts[4] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "InterpolationMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- template<> struct EnumTrait<Remap::BorderMode> {
- static constexpr const char *name = "Remap.BorderMode";
- static constexpr std::underlying_type_t<Remap::BorderMode> max = 7 - 1;
- };
- template<> PyTypeObject* EnumWrapper<Remap::BorderMode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<Remap::BorderMode>::members[] = {"REPLICATE", "REFLECT", "REFLECT_101", "WRAP", "CONSTANT", "TRANSPARENT", "ISOLATED"};
-
- template<> std::unordered_map<std::string, Remap::BorderMode>
- EnumWrapper<Remap::BorderMode>::mem2value = {{normalize_enum("REPLICATE"), Remap::BorderMode::REPLICATE}, {normalize_enum("REFLECT"), Remap::BorderMode::REFLECT}, {normalize_enum("REFLECT_101"), Remap::BorderMode::REFLECT_101}, {normalize_enum("WRAP"), Remap::BorderMode::WRAP}, {normalize_enum("CONSTANT"), Remap::BorderMode::CONSTANT}, {normalize_enum("TRANSPARENT"), Remap::BorderMode::TRANSPARENT}, {normalize_enum("ISOLATED"), Remap::BorderMode::ISOLATED}};
- template<> PyObject* EnumWrapper<Remap::BorderMode>::pyobj_insts[7] = {nullptr};
-
- void _init_py_Remap_BorderMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Remap::BorderMode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<Remap::BorderMode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<Remap::BorderMode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<Remap::BorderMode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.Remap.BorderMode",
- // basicsize
- sizeof(EnumWrapper<Remap::BorderMode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("BorderMode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("Remap.BorderMode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Remap::BorderMode>*>(inst)->value = Remap::BorderMode::REPLICATE;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "REPLICATE", inst) >= 0);
- EnumWrapper<Remap::BorderMode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Remap::BorderMode>*>(inst)->value = Remap::BorderMode::REFLECT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "REFLECT", inst) >= 0);
- EnumWrapper<Remap::BorderMode>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Remap::BorderMode>*>(inst)->value = Remap::BorderMode::REFLECT_101;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "REFLECT_101", inst) >= 0);
- EnumWrapper<Remap::BorderMode>::pyobj_insts[2] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Remap::BorderMode>*>(inst)->value = Remap::BorderMode::WRAP;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "WRAP", inst) >= 0);
- EnumWrapper<Remap::BorderMode>::pyobj_insts[3] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Remap::BorderMode>*>(inst)->value = Remap::BorderMode::CONSTANT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "CONSTANT", inst) >= 0);
- EnumWrapper<Remap::BorderMode>::pyobj_insts[4] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Remap::BorderMode>*>(inst)->value = Remap::BorderMode::TRANSPARENT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "TRANSPARENT", inst) >= 0);
- EnumWrapper<Remap::BorderMode>::pyobj_insts[5] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<Remap::BorderMode>*>(inst)->value = Remap::BorderMode::ISOLATED;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "ISOLATED", inst) >= 0);
- EnumWrapper<Remap::BorderMode>::pyobj_insts[6] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "BorderMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_Remap_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Remap::Format>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(Remap) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Remap)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"imode", serialization<decltype(opdef.imode)>::dump(opdef.imode)},
- {"border_type", serialization<decltype(opdef.border_type)>::dump(opdef.border_type)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"scalar", serialization<decltype(opdef.scalar)>::dump(opdef.scalar)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Remap)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("imode");
- if (iter != state.end()) {
- opdef.imode = serialization<decltype(opdef.imode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("border_type");
- if (iter != state.end()) {
- opdef.border_type = serialization<decltype(opdef.border_type)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("scalar");
- if (iter != state.end()) {
- opdef.scalar = serialization<decltype(opdef.scalar)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Remap)
-
- int PyOp(Remap)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"imode", "border_type", "format", "scalar", "scope", NULL};
- PyObject *imode = NULL, *border_type = NULL, *format = NULL, *scalar = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOO", const_cast<char**>(kwlist), &imode, &border_type, &format, &scalar, &scope))
- return -1;
-
- if (imode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Remap)*>(self)->inst().imode =
- py::cast<decltype(Remap::imode)>(py::handle(imode));
- } CATCH_ALL(-1)
- }
-
- if (border_type) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Remap)*>(self)->inst().border_type =
- py::cast<decltype(Remap::border_type)>(py::handle(border_type));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Remap)*>(self)->inst().format =
- py::cast<decltype(Remap::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (scalar) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Remap)*>(self)->inst().scalar =
- py::cast<decltype(Remap::scalar)>(py::handle(scalar));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Remap)::py_getsetters[] = {
- {const_cast<char*>("imode"), py_get_generic(Remap, imode), py_set_generic(Remap, imode), const_cast<char*>("imode"), NULL},
- {const_cast<char*>("border_type"), py_get_generic(Remap, border_type), py_set_generic(Remap, border_type), const_cast<char*>("border_type"), NULL},
- {const_cast<char*>("format"), py_get_generic(Remap, format), py_set_generic(Remap, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("scalar"), py_get_generic(Remap, scalar), py_set_generic(Remap, scalar), const_cast<char*>("scalar"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Remap)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Remap)::getstate, METH_NOARGS, "Remap getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Remap)::setstate, METH_VARARGS, "Remap setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Remap(py::module m) {
- using py_op = PyOp(Remap);
- auto& py_type = PyOpType(Remap);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Remap";
- py_type.tp_basicsize = sizeof(PyOp(Remap));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Remap";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_Remap_InterpolationMode(py_type);
- _init_py_Remap_BorderMode(py_type);
- _init_py_Remap_Format(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("Remap", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Remap::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(RemoteRecv) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(RemoteRecv)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"key", serialization<decltype(opdef.key)>::dump(opdef.key)},
- {"addr", serialization<decltype(opdef.addr)>::dump(opdef.addr)},
- {"port", serialization<decltype(opdef.port)>::dump(opdef.port)},
- {"rank_from", serialization<decltype(opdef.rank_from)>::dump(opdef.rank_from)},
- {"cn", serialization<decltype(opdef.cn)>::dump(opdef.cn)},
- {"shape", serialization<decltype(opdef.shape)>::dump(opdef.shape)},
- {"dtype", serialization<decltype(opdef.dtype)>::dump(opdef.dtype)},
- {"backend", serialization<decltype(opdef.backend)>::dump(opdef.backend)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(RemoteRecv)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("key");
- if (iter != state.end()) {
- opdef.key = serialization<decltype(opdef.key)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("addr");
- if (iter != state.end()) {
- opdef.addr = serialization<decltype(opdef.addr)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("port");
- if (iter != state.end()) {
- opdef.port = serialization<decltype(opdef.port)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("rank_from");
- if (iter != state.end()) {
- opdef.rank_from = serialization<decltype(opdef.rank_from)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("cn");
- if (iter != state.end()) {
- opdef.cn = serialization<decltype(opdef.cn)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("shape");
- if (iter != state.end()) {
- opdef.shape = serialization<decltype(opdef.shape)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dtype");
- if (iter != state.end()) {
- opdef.dtype = serialization<decltype(opdef.dtype)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("backend");
- if (iter != state.end()) {
- opdef.backend = serialization<decltype(opdef.backend)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(RemoteRecv)
-
- int PyOp(RemoteRecv)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"key", "addr", "port", "rank_from", "cn", "shape", "dtype", "backend", "scope", NULL};
- PyObject *key = NULL, *addr = NULL, *port = NULL, *rank_from = NULL, *cn = NULL, *shape = NULL, *dtype = NULL, *backend = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOO", const_cast<char**>(kwlist), &key, &addr, &port, &rank_from, &cn, &shape, &dtype, &backend, &scope))
- return -1;
-
- if (key) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RemoteRecv)*>(self)->inst().key =
- py::cast<decltype(RemoteRecv::key)>(py::handle(key));
- } CATCH_ALL(-1)
- }
-
- if (addr) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RemoteRecv)*>(self)->inst().addr =
- py::cast<decltype(RemoteRecv::addr)>(py::handle(addr));
- } CATCH_ALL(-1)
- }
-
- if (port) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RemoteRecv)*>(self)->inst().port =
- py::cast<decltype(RemoteRecv::port)>(py::handle(port));
- } CATCH_ALL(-1)
- }
-
- if (rank_from) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RemoteRecv)*>(self)->inst().rank_from =
- py::cast<decltype(RemoteRecv::rank_from)>(py::handle(rank_from));
- } CATCH_ALL(-1)
- }
-
- if (cn) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RemoteRecv)*>(self)->inst().cn =
- py::cast<decltype(RemoteRecv::cn)>(py::handle(cn));
- } CATCH_ALL(-1)
- }
-
- if (shape) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RemoteRecv)*>(self)->inst().shape =
- py::cast<decltype(RemoteRecv::shape)>(py::handle(shape));
- } CATCH_ALL(-1)
- }
-
- if (dtype) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RemoteRecv)*>(self)->inst().dtype =
- py::cast<decltype(RemoteRecv::dtype)>(py::handle(dtype));
- } CATCH_ALL(-1)
- }
-
- if (backend) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RemoteRecv)*>(self)->inst().backend =
- py::cast<decltype(RemoteRecv::backend)>(py::handle(backend));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(RemoteRecv)::py_getsetters[] = {
- {const_cast<char*>("key"), py_get_generic(RemoteRecv, key), py_set_generic(RemoteRecv, key), const_cast<char*>("key"), NULL},
- {const_cast<char*>("addr"), py_get_generic(RemoteRecv, addr), py_set_generic(RemoteRecv, addr), const_cast<char*>("addr"), NULL},
- {const_cast<char*>("port"), py_get_generic(RemoteRecv, port), py_set_generic(RemoteRecv, port), const_cast<char*>("port"), NULL},
- {const_cast<char*>("rank_from"), py_get_generic(RemoteRecv, rank_from), py_set_generic(RemoteRecv, rank_from), const_cast<char*>("rank_from"), NULL},
- {const_cast<char*>("cn"), py_get_generic(RemoteRecv, cn), py_set_generic(RemoteRecv, cn), const_cast<char*>("cn"), NULL},
- {const_cast<char*>("shape"), py_get_generic(RemoteRecv, shape), py_set_generic(RemoteRecv, shape), const_cast<char*>("shape"), NULL},
- {const_cast<char*>("dtype"), py_get_generic(RemoteRecv, dtype), py_set_generic(RemoteRecv, dtype), const_cast<char*>("dtype"), NULL},
- {const_cast<char*>("backend"), py_get_generic(RemoteRecv, backend), py_set_generic(RemoteRecv, backend), const_cast<char*>("backend"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(RemoteRecv)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(RemoteRecv)::getstate, METH_NOARGS, "RemoteRecv getstate"},
- {const_cast<char*>("__setstate__"), PyOp(RemoteRecv)::setstate, METH_VARARGS, "RemoteRecv setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_RemoteRecv(py::module m) {
- using py_op = PyOp(RemoteRecv);
- auto& py_type = PyOpType(RemoteRecv);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.RemoteRecv";
- py_type.tp_basicsize = sizeof(PyOp(RemoteRecv));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "RemoteRecv";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("RemoteRecv", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(RemoteRecv::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(RemoteSend) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(RemoteSend)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"key", serialization<decltype(opdef.key)>::dump(opdef.key)},
- {"addr", serialization<decltype(opdef.addr)>::dump(opdef.addr)},
- {"port", serialization<decltype(opdef.port)>::dump(opdef.port)},
- {"rank_to", serialization<decltype(opdef.rank_to)>::dump(opdef.rank_to)},
- {"backend", serialization<decltype(opdef.backend)>::dump(opdef.backend)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(RemoteSend)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("key");
- if (iter != state.end()) {
- opdef.key = serialization<decltype(opdef.key)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("addr");
- if (iter != state.end()) {
- opdef.addr = serialization<decltype(opdef.addr)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("port");
- if (iter != state.end()) {
- opdef.port = serialization<decltype(opdef.port)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("rank_to");
- if (iter != state.end()) {
- opdef.rank_to = serialization<decltype(opdef.rank_to)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("backend");
- if (iter != state.end()) {
- opdef.backend = serialization<decltype(opdef.backend)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(RemoteSend)
-
- int PyOp(RemoteSend)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"key", "addr", "port", "rank_to", "backend", "scope", NULL};
- PyObject *key = NULL, *addr = NULL, *port = NULL, *rank_to = NULL, *backend = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOO", const_cast<char**>(kwlist), &key, &addr, &port, &rank_to, &backend, &scope))
- return -1;
-
- if (key) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RemoteSend)*>(self)->inst().key =
- py::cast<decltype(RemoteSend::key)>(py::handle(key));
- } CATCH_ALL(-1)
- }
-
- if (addr) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RemoteSend)*>(self)->inst().addr =
- py::cast<decltype(RemoteSend::addr)>(py::handle(addr));
- } CATCH_ALL(-1)
- }
-
- if (port) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RemoteSend)*>(self)->inst().port =
- py::cast<decltype(RemoteSend::port)>(py::handle(port));
- } CATCH_ALL(-1)
- }
-
- if (rank_to) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RemoteSend)*>(self)->inst().rank_to =
- py::cast<decltype(RemoteSend::rank_to)>(py::handle(rank_to));
- } CATCH_ALL(-1)
- }
-
- if (backend) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RemoteSend)*>(self)->inst().backend =
- py::cast<decltype(RemoteSend::backend)>(py::handle(backend));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(RemoteSend)::py_getsetters[] = {
- {const_cast<char*>("key"), py_get_generic(RemoteSend, key), py_set_generic(RemoteSend, key), const_cast<char*>("key"), NULL},
- {const_cast<char*>("addr"), py_get_generic(RemoteSend, addr), py_set_generic(RemoteSend, addr), const_cast<char*>("addr"), NULL},
- {const_cast<char*>("port"), py_get_generic(RemoteSend, port), py_set_generic(RemoteSend, port), const_cast<char*>("port"), NULL},
- {const_cast<char*>("rank_to"), py_get_generic(RemoteSend, rank_to), py_set_generic(RemoteSend, rank_to), const_cast<char*>("rank_to"), NULL},
- {const_cast<char*>("backend"), py_get_generic(RemoteSend, backend), py_set_generic(RemoteSend, backend), const_cast<char*>("backend"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(RemoteSend)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(RemoteSend)::getstate, METH_NOARGS, "RemoteSend getstate"},
- {const_cast<char*>("__setstate__"), PyOp(RemoteSend)::setstate, METH_VARARGS, "RemoteSend setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_RemoteSend(py::module m) {
- using py_op = PyOp(RemoteSend);
- auto& py_type = PyOpType(RemoteSend);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.RemoteSend";
- py_type.tp_basicsize = sizeof(PyOp(RemoteSend));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "RemoteSend";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("RemoteSend", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(RemoteSend::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(RemoveAxis) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(RemoveAxis)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"axis", serialization<decltype(opdef.axis)>::dump(opdef.axis)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(RemoveAxis)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("axis");
- if (iter != state.end()) {
- opdef.axis = serialization<decltype(opdef.axis)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(RemoveAxis)
-
- int PyOp(RemoveAxis)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"axis", "scope", NULL};
- PyObject *axis = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &axis, &scope))
- return -1;
-
- if (axis) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(RemoveAxis)*>(self)->inst().axis =
- py::cast<decltype(RemoveAxis::axis)>(py::handle(axis));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(RemoveAxis)::py_getsetters[] = {
- {const_cast<char*>("axis"), py_get_generic(RemoveAxis, axis), py_set_generic(RemoveAxis, axis), const_cast<char*>("axis"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(RemoveAxis)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(RemoveAxis)::getstate, METH_NOARGS, "RemoveAxis getstate"},
- {const_cast<char*>("__setstate__"), PyOp(RemoveAxis)::setstate, METH_VARARGS, "RemoveAxis setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_RemoveAxis(py::module m) {
- using py_op = PyOp(RemoveAxis);
- auto& py_type = PyOpType(RemoveAxis);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.RemoveAxis";
- py_type.tp_basicsize = sizeof(PyOp(RemoveAxis));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "RemoveAxis";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("RemoveAxis", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(RemoveAxis::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Reshape) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Reshape)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"axis", serialization<decltype(opdef.axis)>::dump(opdef.axis)},
- {"shape", serialization<decltype(opdef.shape)>::dump(opdef.shape)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Reshape)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("axis");
- if (iter != state.end()) {
- opdef.axis = serialization<decltype(opdef.axis)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("shape");
- if (iter != state.end()) {
- opdef.shape = serialization<decltype(opdef.shape)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Reshape)
-
- int PyOp(Reshape)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"axis", "shape", "scope", NULL};
- PyObject *axis = NULL, *shape = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &axis, &shape, &scope))
- return -1;
-
- if (axis) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Reshape)*>(self)->inst().axis =
- py::cast<decltype(Reshape::axis)>(py::handle(axis));
- } CATCH_ALL(-1)
- }
-
- if (shape) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Reshape)*>(self)->inst().shape =
- py::cast<decltype(Reshape::shape)>(py::handle(shape));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Reshape)::py_getsetters[] = {
- {const_cast<char*>("axis"), py_get_generic(Reshape, axis), py_set_generic(Reshape, axis), const_cast<char*>("axis"), NULL},
- {const_cast<char*>("shape"), py_get_generic(Reshape, shape), py_set_generic(Reshape, shape), const_cast<char*>("shape"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Reshape)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Reshape)::getstate, METH_NOARGS, "Reshape getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Reshape)::setstate, METH_VARARGS, "Reshape setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Reshape(py::module m) {
- using py_op = PyOp(Reshape);
- auto& py_type = PyOpType(Reshape);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Reshape";
- py_type.tp_basicsize = sizeof(PyOp(Reshape));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Reshape";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Reshape", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Reshape::typeinfo(), &py_type).second);
- }
-
- void _init_py_Resize_InterpolationMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Resize::InterpolationMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "InterpolationMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_Resize_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<Resize::Format>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(Resize) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Resize)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"imode", serialization<decltype(opdef.imode)>::dump(opdef.imode)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Resize)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("imode");
- if (iter != state.end()) {
- opdef.imode = serialization<decltype(opdef.imode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Resize)
-
- int PyOp(Resize)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"imode", "format", "scope", NULL};
- PyObject *imode = NULL, *format = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &imode, &format, &scope))
- return -1;
-
- if (imode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Resize)*>(self)->inst().imode =
- py::cast<decltype(Resize::imode)>(py::handle(imode));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Resize)*>(self)->inst().format =
- py::cast<decltype(Resize::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Resize)::py_getsetters[] = {
- {const_cast<char*>("imode"), py_get_generic(Resize, imode), py_set_generic(Resize, imode), const_cast<char*>("imode"), NULL},
- {const_cast<char*>("format"), py_get_generic(Resize, format), py_set_generic(Resize, format), const_cast<char*>("format"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Resize)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Resize)::getstate, METH_NOARGS, "Resize getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Resize)::setstate, METH_VARARGS, "Resize setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Resize(py::module m) {
- using py_op = PyOp(Resize);
- auto& py_type = PyOpType(Resize);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Resize";
- py_type.tp_basicsize = sizeof(PyOp(Resize));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Resize";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_Resize_InterpolationMode(py_type);
- _init_py_Resize_Format(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("Resize", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Resize::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(SVD) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(SVD)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"full_matrices", serialization<decltype(opdef.full_matrices)>::dump(opdef.full_matrices)},
- {"compute_uv", serialization<decltype(opdef.compute_uv)>::dump(opdef.compute_uv)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(SVD)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("full_matrices");
- if (iter != state.end()) {
- opdef.full_matrices = serialization<decltype(opdef.full_matrices)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("compute_uv");
- if (iter != state.end()) {
- opdef.compute_uv = serialization<decltype(opdef.compute_uv)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(SVD)
-
- int PyOp(SVD)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"full_matrices", "compute_uv", "scope", NULL};
- PyObject *full_matrices = NULL, *compute_uv = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &full_matrices, &compute_uv, &scope))
- return -1;
-
- if (full_matrices) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(SVD)*>(self)->inst().full_matrices =
- py::cast<decltype(SVD::full_matrices)>(py::handle(full_matrices));
- } CATCH_ALL(-1)
- }
-
- if (compute_uv) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(SVD)*>(self)->inst().compute_uv =
- py::cast<decltype(SVD::compute_uv)>(py::handle(compute_uv));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(SVD)::py_getsetters[] = {
- {const_cast<char*>("full_matrices"), py_get_generic(SVD, full_matrices), py_set_generic(SVD, full_matrices), const_cast<char*>("full_matrices"), NULL},
- {const_cast<char*>("compute_uv"), py_get_generic(SVD, compute_uv), py_set_generic(SVD, compute_uv), const_cast<char*>("compute_uv"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(SVD)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(SVD)::getstate, METH_NOARGS, "SVD getstate"},
- {const_cast<char*>("__setstate__"), PyOp(SVD)::setstate, METH_VARARGS, "SVD setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_SVD(py::module m) {
- using py_op = PyOp(SVD);
- auto& py_type = PyOpType(SVD);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.SVD";
- py_type.tp_basicsize = sizeof(PyOp(SVD));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "SVD";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("SVD", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(SVD::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(SetMeshIndexing) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(SetMeshIndexing)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"items", serialization<decltype(opdef.items)>::dump(opdef.items)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(SetMeshIndexing)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("items");
- if (iter != state.end()) {
- opdef.items = serialization<decltype(opdef.items)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(SetMeshIndexing)
-
- int PyOp(SetMeshIndexing)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"items", "scope", NULL};
- PyObject *items = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &items, &scope))
- return -1;
-
- if (items) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(SetMeshIndexing)*>(self)->inst().items =
- py::cast<decltype(SetMeshIndexing::items)>(py::handle(items));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(SetMeshIndexing)::py_getsetters[] = {
- {const_cast<char*>("items"), py_get_generic(SetMeshIndexing, items), py_set_generic(SetMeshIndexing, items), const_cast<char*>("items"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(SetMeshIndexing)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(SetMeshIndexing)::getstate, METH_NOARGS, "SetMeshIndexing getstate"},
- {const_cast<char*>("__setstate__"), PyOp(SetMeshIndexing)::setstate, METH_VARARGS, "SetMeshIndexing setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_SetMeshIndexing(py::module m) {
- using py_op = PyOp(SetMeshIndexing);
- auto& py_type = PyOpType(SetMeshIndexing);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.SetMeshIndexing";
- py_type.tp_basicsize = sizeof(PyOp(SetMeshIndexing));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "SetMeshIndexing";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("SetMeshIndexing", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(SetMeshIndexing::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(SetSubtensor) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(SetSubtensor)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"items", serialization<decltype(opdef.items)>::dump(opdef.items)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(SetSubtensor)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("items");
- if (iter != state.end()) {
- opdef.items = serialization<decltype(opdef.items)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(SetSubtensor)
-
- int PyOp(SetSubtensor)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"items", "scope", NULL};
- PyObject *items = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &items, &scope))
- return -1;
-
- if (items) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(SetSubtensor)*>(self)->inst().items =
- py::cast<decltype(SetSubtensor::items)>(py::handle(items));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(SetSubtensor)::py_getsetters[] = {
- {const_cast<char*>("items"), py_get_generic(SetSubtensor, items), py_set_generic(SetSubtensor, items), const_cast<char*>("items"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(SetSubtensor)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(SetSubtensor)::getstate, METH_NOARGS, "SetSubtensor getstate"},
- {const_cast<char*>("__setstate__"), PyOp(SetSubtensor)::setstate, METH_VARARGS, "SetSubtensor setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_SetSubtensor(py::module m) {
- using py_op = PyOp(SetSubtensor);
- auto& py_type = PyOpType(SetSubtensor);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.SetSubtensor";
- py_type.tp_basicsize = sizeof(PyOp(SetSubtensor));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "SetSubtensor";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("SetSubtensor", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(SetSubtensor::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(ShuffleRNG) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(ShuffleRNG)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"seed", serialization<decltype(opdef.seed)>::dump(opdef.seed)},
- {"handle", serialization<decltype(opdef.handle)>::dump(opdef.handle)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(ShuffleRNG)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("seed");
- if (iter != state.end()) {
- opdef.seed = serialization<decltype(opdef.seed)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("handle");
- if (iter != state.end()) {
- opdef.handle = serialization<decltype(opdef.handle)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(ShuffleRNG)
-
- int PyOp(ShuffleRNG)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"seed", "handle", "scope", NULL};
- PyObject *seed = NULL, *handle = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &seed, &handle, &scope))
- return -1;
-
- if (seed) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ShuffleRNG)*>(self)->inst().seed =
- py::cast<decltype(ShuffleRNG::seed)>(py::handle(seed));
- } CATCH_ALL(-1)
- }
-
- if (handle) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(ShuffleRNG)*>(self)->inst().handle =
- py::cast<decltype(ShuffleRNG::handle)>(py::handle(handle));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(ShuffleRNG)::py_getsetters[] = {
- {const_cast<char*>("seed"), py_get_generic(ShuffleRNG, seed), py_set_generic(ShuffleRNG, seed), const_cast<char*>("seed"), NULL},
- {const_cast<char*>("handle"), py_get_generic(ShuffleRNG, handle), py_set_generic(ShuffleRNG, handle), const_cast<char*>("handle"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(ShuffleRNG)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(ShuffleRNG)::getstate, METH_NOARGS, "ShuffleRNG getstate"},
- {const_cast<char*>("__setstate__"), PyOp(ShuffleRNG)::setstate, METH_VARARGS, "ShuffleRNG setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_ShuffleRNG(py::module m) {
- using py_op = PyOp(ShuffleRNG);
- auto& py_type = PyOpType(ShuffleRNG);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.ShuffleRNG";
- py_type.tp_basicsize = sizeof(PyOp(ShuffleRNG));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "ShuffleRNG";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("ShuffleRNG", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(ShuffleRNG::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(SlidingWindowTranspose) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(SlidingWindowTranspose)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"out_h", serialization<decltype(opdef.out_h)>::dump(opdef.out_h)},
- {"out_w", serialization<decltype(opdef.out_w)>::dump(opdef.out_w)},
- {"pad_h", serialization<decltype(opdef.pad_h)>::dump(opdef.pad_h)},
- {"pad_w", serialization<decltype(opdef.pad_w)>::dump(opdef.pad_w)},
- {"stride_h", serialization<decltype(opdef.stride_h)>::dump(opdef.stride_h)},
- {"stride_w", serialization<decltype(opdef.stride_w)>::dump(opdef.stride_w)},
- {"dilate_h", serialization<decltype(opdef.dilate_h)>::dump(opdef.dilate_h)},
- {"dilate_w", serialization<decltype(opdef.dilate_w)>::dump(opdef.dilate_w)},
- {"window_h", serialization<decltype(opdef.window_h)>::dump(opdef.window_h)},
- {"window_w", serialization<decltype(opdef.window_w)>::dump(opdef.window_w)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(SlidingWindowTranspose)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("out_h");
- if (iter != state.end()) {
- opdef.out_h = serialization<decltype(opdef.out_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("out_w");
- if (iter != state.end()) {
- opdef.out_w = serialization<decltype(opdef.out_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_h");
- if (iter != state.end()) {
- opdef.pad_h = serialization<decltype(opdef.pad_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("pad_w");
- if (iter != state.end()) {
- opdef.pad_w = serialization<decltype(opdef.pad_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_h");
- if (iter != state.end()) {
- opdef.stride_h = serialization<decltype(opdef.stride_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("stride_w");
- if (iter != state.end()) {
- opdef.stride_w = serialization<decltype(opdef.stride_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_h");
- if (iter != state.end()) {
- opdef.dilate_h = serialization<decltype(opdef.dilate_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dilate_w");
- if (iter != state.end()) {
- opdef.dilate_w = serialization<decltype(opdef.dilate_w)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("window_h");
- if (iter != state.end()) {
- opdef.window_h = serialization<decltype(opdef.window_h)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("window_w");
- if (iter != state.end()) {
- opdef.window_w = serialization<decltype(opdef.window_w)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(SlidingWindowTranspose)
-
- int PyOp(SlidingWindowTranspose)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"out_h", "out_w", "pad_h", "pad_w", "stride_h", "stride_w", "dilate_h", "dilate_w", "window_h", "window_w", "scope", NULL};
- PyObject *out_h = NULL, *out_w = NULL, *pad_h = NULL, *pad_w = NULL, *stride_h = NULL, *stride_w = NULL, *dilate_h = NULL, *dilate_w = NULL, *window_h = NULL, *window_w = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOOOOOOO", const_cast<char**>(kwlist), &out_h, &out_w, &pad_h, &pad_w, &stride_h, &stride_w, &dilate_h, &dilate_w, &window_h, &window_w, &scope))
- return -1;
-
- if (out_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(SlidingWindowTranspose)*>(self)->inst().out_h =
- py::cast<decltype(SlidingWindowTranspose::out_h)>(py::handle(out_h));
- } CATCH_ALL(-1)
- }
-
- if (out_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(SlidingWindowTranspose)*>(self)->inst().out_w =
- py::cast<decltype(SlidingWindowTranspose::out_w)>(py::handle(out_w));
- } CATCH_ALL(-1)
- }
-
- if (pad_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(SlidingWindowTranspose)*>(self)->inst().pad_h =
- py::cast<decltype(SlidingWindowTranspose::pad_h)>(py::handle(pad_h));
- } CATCH_ALL(-1)
- }
-
- if (pad_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(SlidingWindowTranspose)*>(self)->inst().pad_w =
- py::cast<decltype(SlidingWindowTranspose::pad_w)>(py::handle(pad_w));
- } CATCH_ALL(-1)
- }
-
- if (stride_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(SlidingWindowTranspose)*>(self)->inst().stride_h =
- py::cast<decltype(SlidingWindowTranspose::stride_h)>(py::handle(stride_h));
- } CATCH_ALL(-1)
- }
-
- if (stride_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(SlidingWindowTranspose)*>(self)->inst().stride_w =
- py::cast<decltype(SlidingWindowTranspose::stride_w)>(py::handle(stride_w));
- } CATCH_ALL(-1)
- }
-
- if (dilate_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(SlidingWindowTranspose)*>(self)->inst().dilate_h =
- py::cast<decltype(SlidingWindowTranspose::dilate_h)>(py::handle(dilate_h));
- } CATCH_ALL(-1)
- }
-
- if (dilate_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(SlidingWindowTranspose)*>(self)->inst().dilate_w =
- py::cast<decltype(SlidingWindowTranspose::dilate_w)>(py::handle(dilate_w));
- } CATCH_ALL(-1)
- }
-
- if (window_h) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(SlidingWindowTranspose)*>(self)->inst().window_h =
- py::cast<decltype(SlidingWindowTranspose::window_h)>(py::handle(window_h));
- } CATCH_ALL(-1)
- }
-
- if (window_w) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(SlidingWindowTranspose)*>(self)->inst().window_w =
- py::cast<decltype(SlidingWindowTranspose::window_w)>(py::handle(window_w));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(SlidingWindowTranspose)::py_getsetters[] = {
- {const_cast<char*>("out_h"), py_get_generic(SlidingWindowTranspose, out_h), py_set_generic(SlidingWindowTranspose, out_h), const_cast<char*>("out_h"), NULL},
- {const_cast<char*>("out_w"), py_get_generic(SlidingWindowTranspose, out_w), py_set_generic(SlidingWindowTranspose, out_w), const_cast<char*>("out_w"), NULL},
- {const_cast<char*>("pad_h"), py_get_generic(SlidingWindowTranspose, pad_h), py_set_generic(SlidingWindowTranspose, pad_h), const_cast<char*>("pad_h"), NULL},
- {const_cast<char*>("pad_w"), py_get_generic(SlidingWindowTranspose, pad_w), py_set_generic(SlidingWindowTranspose, pad_w), const_cast<char*>("pad_w"), NULL},
- {const_cast<char*>("stride_h"), py_get_generic(SlidingWindowTranspose, stride_h), py_set_generic(SlidingWindowTranspose, stride_h), const_cast<char*>("stride_h"), NULL},
- {const_cast<char*>("stride_w"), py_get_generic(SlidingWindowTranspose, stride_w), py_set_generic(SlidingWindowTranspose, stride_w), const_cast<char*>("stride_w"), NULL},
- {const_cast<char*>("dilate_h"), py_get_generic(SlidingWindowTranspose, dilate_h), py_set_generic(SlidingWindowTranspose, dilate_h), const_cast<char*>("dilate_h"), NULL},
- {const_cast<char*>("dilate_w"), py_get_generic(SlidingWindowTranspose, dilate_w), py_set_generic(SlidingWindowTranspose, dilate_w), const_cast<char*>("dilate_w"), NULL},
- {const_cast<char*>("window_h"), py_get_generic(SlidingWindowTranspose, window_h), py_set_generic(SlidingWindowTranspose, window_h), const_cast<char*>("window_h"), NULL},
- {const_cast<char*>("window_w"), py_get_generic(SlidingWindowTranspose, window_w), py_set_generic(SlidingWindowTranspose, window_w), const_cast<char*>("window_w"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(SlidingWindowTranspose)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(SlidingWindowTranspose)::getstate, METH_NOARGS, "SlidingWindowTranspose getstate"},
- {const_cast<char*>("__setstate__"), PyOp(SlidingWindowTranspose)::setstate, METH_VARARGS, "SlidingWindowTranspose setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_SlidingWindowTranspose(py::module m) {
- using py_op = PyOp(SlidingWindowTranspose);
- auto& py_type = PyOpType(SlidingWindowTranspose);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.SlidingWindowTranspose";
- py_type.tp_basicsize = sizeof(PyOp(SlidingWindowTranspose));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "SlidingWindowTranspose";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("SlidingWindowTranspose", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(SlidingWindowTranspose::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Softmax) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Softmax)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"axis", serialization<decltype(opdef.axis)>::dump(opdef.axis)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Softmax)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("axis");
- if (iter != state.end()) {
- opdef.axis = serialization<decltype(opdef.axis)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Softmax)
-
- int PyOp(Softmax)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"axis", "scope", NULL};
- PyObject *axis = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &axis, &scope))
- return -1;
-
- if (axis) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Softmax)*>(self)->inst().axis =
- py::cast<decltype(Softmax::axis)>(py::handle(axis));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Softmax)::py_getsetters[] = {
- {const_cast<char*>("axis"), py_get_generic(Softmax, axis), py_set_generic(Softmax, axis), const_cast<char*>("axis"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Softmax)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Softmax)::getstate, METH_NOARGS, "Softmax getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Softmax)::setstate, METH_VARARGS, "Softmax setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Softmax(py::module m) {
- using py_op = PyOp(Softmax);
- auto& py_type = PyOpType(Softmax);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Softmax";
- py_type.tp_basicsize = sizeof(PyOp(Softmax));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Softmax";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Softmax", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Softmax::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Split) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Split)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"axis", serialization<decltype(opdef.axis)>::dump(opdef.axis)},
- {"nsections", serialization<decltype(opdef.nsections)>::dump(opdef.nsections)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Split)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("axis");
- if (iter != state.end()) {
- opdef.axis = serialization<decltype(opdef.axis)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("nsections");
- if (iter != state.end()) {
- opdef.nsections = serialization<decltype(opdef.nsections)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Split)
-
- int PyOp(Split)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"axis", "nsections", "scope", NULL};
- PyObject *axis = NULL, *nsections = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &axis, &nsections, &scope))
- return -1;
-
- if (axis) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Split)*>(self)->inst().axis =
- py::cast<decltype(Split::axis)>(py::handle(axis));
- } CATCH_ALL(-1)
- }
-
- if (nsections) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Split)*>(self)->inst().nsections =
- py::cast<decltype(Split::nsections)>(py::handle(nsections));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Split)::py_getsetters[] = {
- {const_cast<char*>("axis"), py_get_generic(Split, axis), py_set_generic(Split, axis), const_cast<char*>("axis"), NULL},
- {const_cast<char*>("nsections"), py_get_generic(Split, nsections), py_set_generic(Split, nsections), const_cast<char*>("nsections"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Split)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Split)::getstate, METH_NOARGS, "Split getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Split)::setstate, METH_VARARGS, "Split setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Split(py::module m) {
- using py_op = PyOp(Split);
- auto& py_type = PyOpType(Split);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Split";
- py_type.tp_basicsize = sizeof(PyOp(Split));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Split";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Split", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Split::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(Subtensor) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(Subtensor)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"items", serialization<decltype(opdef.items)>::dump(opdef.items)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(Subtensor)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("items");
- if (iter != state.end()) {
- opdef.items = serialization<decltype(opdef.items)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(Subtensor)
-
- int PyOp(Subtensor)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"items", "scope", NULL};
- PyObject *items = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &items, &scope))
- return -1;
-
- if (items) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(Subtensor)*>(self)->inst().items =
- py::cast<decltype(Subtensor::items)>(py::handle(items));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(Subtensor)::py_getsetters[] = {
- {const_cast<char*>("items"), py_get_generic(Subtensor, items), py_set_generic(Subtensor, items), const_cast<char*>("items"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(Subtensor)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(Subtensor)::getstate, METH_NOARGS, "Subtensor getstate"},
- {const_cast<char*>("__setstate__"), PyOp(Subtensor)::setstate, METH_VARARGS, "Subtensor setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_Subtensor(py::module m) {
- using py_op = PyOp(Subtensor);
- auto& py_type = PyOpType(Subtensor);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.Subtensor";
- py_type.tp_basicsize = sizeof(PyOp(Subtensor));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "Subtensor";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("Subtensor", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(Subtensor::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(TQT) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(TQT)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"qmin", serialization<decltype(opdef.qmin)>::dump(opdef.qmin)},
- {"qmax", serialization<decltype(opdef.qmax)>::dump(opdef.qmax)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(TQT)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("qmin");
- if (iter != state.end()) {
- opdef.qmin = serialization<decltype(opdef.qmin)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("qmax");
- if (iter != state.end()) {
- opdef.qmax = serialization<decltype(opdef.qmax)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(TQT)
-
- int PyOp(TQT)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"qmin", "qmax", "scope", NULL};
- PyObject *qmin = NULL, *qmax = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &qmin, &qmax, &scope))
- return -1;
-
- if (qmin) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(TQT)*>(self)->inst().qmin =
- py::cast<decltype(TQT::qmin)>(py::handle(qmin));
- } CATCH_ALL(-1)
- }
-
- if (qmax) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(TQT)*>(self)->inst().qmax =
- py::cast<decltype(TQT::qmax)>(py::handle(qmax));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(TQT)::py_getsetters[] = {
- {const_cast<char*>("qmin"), py_get_generic(TQT, qmin), py_set_generic(TQT, qmin), const_cast<char*>("qmin"), NULL},
- {const_cast<char*>("qmax"), py_get_generic(TQT, qmax), py_set_generic(TQT, qmax), const_cast<char*>("qmax"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(TQT)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(TQT)::getstate, METH_NOARGS, "TQT getstate"},
- {const_cast<char*>("__setstate__"), PyOp(TQT)::setstate, METH_VARARGS, "TQT setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_TQT(py::module m) {
- using py_op = PyOp(TQT);
- auto& py_type = PyOpType(TQT);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.TQT";
- py_type.tp_basicsize = sizeof(PyOp(TQT));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "TQT";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("TQT", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(TQT::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(TensorRTRuntime) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(TensorRTRuntime)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"buf", serialization<decltype(opdef.buf)>::dump(opdef.buf)},
- {"buf_size", serialization<decltype(opdef.buf_size)>::dump(opdef.buf_size)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(TensorRTRuntime)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("buf");
- if (iter != state.end()) {
- opdef.buf = serialization<decltype(opdef.buf)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("buf_size");
- if (iter != state.end()) {
- opdef.buf_size = serialization<decltype(opdef.buf_size)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(TensorRTRuntime)
-
- int PyOp(TensorRTRuntime)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"buf", "buf_size", "scope", NULL};
- PyObject *buf = NULL, *buf_size = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOO", const_cast<char**>(kwlist), &buf, &buf_size, &scope))
- return -1;
-
- if (buf) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(TensorRTRuntime)*>(self)->inst().buf =
- py::cast<decltype(TensorRTRuntime::buf)>(py::handle(buf));
- } CATCH_ALL(-1)
- }
-
- if (buf_size) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(TensorRTRuntime)*>(self)->inst().buf_size =
- py::cast<decltype(TensorRTRuntime::buf_size)>(py::handle(buf_size));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(TensorRTRuntime)::py_getsetters[] = {
- {const_cast<char*>("buf"), py_get_generic(TensorRTRuntime, buf), py_set_generic(TensorRTRuntime, buf), const_cast<char*>("buf"), NULL},
- {const_cast<char*>("buf_size"), py_get_generic(TensorRTRuntime, buf_size), py_set_generic(TensorRTRuntime, buf_size), const_cast<char*>("buf_size"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(TensorRTRuntime)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(TensorRTRuntime)::getstate, METH_NOARGS, "TensorRTRuntime getstate"},
- {const_cast<char*>("__setstate__"), PyOp(TensorRTRuntime)::setstate, METH_VARARGS, "TensorRTRuntime setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_TensorRTRuntime(py::module m) {
- using py_op = PyOp(TensorRTRuntime);
- auto& py_type = PyOpType(TensorRTRuntime);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.TensorRTRuntime";
- py_type.tp_basicsize = sizeof(PyOp(TensorRTRuntime));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "TensorRTRuntime";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("TensorRTRuntime", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(TensorRTRuntime::typeinfo(), &py_type).second);
- }
-
- template<> struct EnumTrait<TopK::Mode> {
- static constexpr const char *name = "TopK.Mode";
- static constexpr std::underlying_type_t<TopK::Mode> max = 3 - 1;
- };
- template<> PyTypeObject* EnumWrapper<TopK::Mode>::type = nullptr;
-
- template<> const char*
- EnumWrapper<TopK::Mode>::members[] = {"KTH_ONLY", "VALUE_IDX_NOSORT", "VALUE_IDX_SORTED"};
-
- template<> std::unordered_map<std::string, TopK::Mode>
- EnumWrapper<TopK::Mode>::mem2value = {{normalize_enum("KTH_ONLY"), TopK::Mode::KTH_ONLY}, {normalize_enum("VALUE_IDX_NOSORT"), TopK::Mode::VALUE_IDX_NOSORT}, {normalize_enum("VALUE_IDX_SORTED"), TopK::Mode::VALUE_IDX_SORTED}};
- template<> PyObject* EnumWrapper<TopK::Mode>::pyobj_insts[3] = {nullptr};
-
- void _init_py_TopK_Mode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<TopK::Mode>::type;
-
- static PyMethodDef tp_methods[] = {
- {const_cast<char*>("dump"), (PyCFunction)EnumWrapper<TopK::Mode>::py_dump, METH_NOARGS, NULL},
- {NULL} /* Sentinel */
- };
-
- static PyType_Slot slots[] = {
- {Py_tp_repr, (void*)EnumWrapper<TopK::Mode>::py_repr},
- {Py_tp_richcompare, (void*)EnumWrapper<TopK::Mode>::tp_richcompare},
- {Py_tp_methods, tp_methods},
-
- {0, NULL}
- };
- static PyType_Spec spec = {
- // name
- "megengine.core._imperative_rt.ops.TopK.Mode",
- // basicsize
- sizeof(EnumWrapper<TopK::Mode>),
- // itemsize
- 0,
- // flags
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
- // slots
- slots
- };
- e_type = reinterpret_cast<PyTypeObject*>(PyType_FromSpec(&spec));
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__name__").release().ptr(),
- py::cast("Mode").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__module__").release().ptr(),
- py::cast("megengine.core._imperative_rt.ops").release().ptr()) >= 0);
-
- mgb_assert(
- e_type->tp_setattro(
- reinterpret_cast<PyObject*>(e_type),
- py::cast("__qualname__").release().ptr(),
- py::cast("TopK.Mode").release().ptr()) >= 0);
- {
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<TopK::Mode>*>(inst)->value = TopK::Mode::KTH_ONLY;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "KTH_ONLY", inst) >= 0);
- EnumWrapper<TopK::Mode>::pyobj_insts[0] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<TopK::Mode>*>(inst)->value = TopK::Mode::VALUE_IDX_NOSORT;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "VALUE_IDX_NOSORT", inst) >= 0);
- EnumWrapper<TopK::Mode>::pyobj_insts[1] = inst;
- }{
- PyObject* inst = e_type->tp_alloc(e_type, 0);
- reinterpret_cast<EnumWrapper<TopK::Mode>*>(inst)->value = TopK::Mode::VALUE_IDX_SORTED;
- mgb_assert(PyDict_SetItemString(e_type->tp_dict, "VALUE_IDX_SORTED", inst) >= 0);
- EnumWrapper<TopK::Mode>::pyobj_insts[2] = inst;
- }
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Mode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(TopK) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(TopK)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"mode", serialization<decltype(opdef.mode)>::dump(opdef.mode)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(TopK)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("mode");
- if (iter != state.end()) {
- opdef.mode = serialization<decltype(opdef.mode)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(TopK)
-
- int PyOp(TopK)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"mode", "scope", NULL};
- PyObject *mode = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &mode, &scope))
- return -1;
-
- if (mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(TopK)*>(self)->inst().mode =
- py::cast<decltype(TopK::mode)>(py::handle(mode));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(TopK)::py_getsetters[] = {
- {const_cast<char*>("mode"), py_get_generic(TopK, mode), py_set_generic(TopK, mode), const_cast<char*>("mode"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(TopK)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(TopK)::getstate, METH_NOARGS, "TopK getstate"},
- {const_cast<char*>("__setstate__"), PyOp(TopK)::setstate, METH_VARARGS, "TopK setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_TopK(py::module m) {
- using py_op = PyOp(TopK);
- auto& py_type = PyOpType(TopK);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.TopK";
- py_type.tp_basicsize = sizeof(PyOp(TopK));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "TopK";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_TopK_Mode(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("TopK", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(TopK::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(TypeCvt) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(TypeCvt)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"dtype", serialization<decltype(opdef.dtype)>::dump(opdef.dtype)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(TypeCvt)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("dtype");
- if (iter != state.end()) {
- opdef.dtype = serialization<decltype(opdef.dtype)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(TypeCvt)
-
- int PyOp(TypeCvt)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"dtype", "scope", NULL};
- PyObject *dtype = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO", const_cast<char**>(kwlist), &dtype, &scope))
- return -1;
-
- if (dtype) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(TypeCvt)*>(self)->inst().dtype =
- py::cast<decltype(TypeCvt::dtype)>(py::handle(dtype));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(TypeCvt)::py_getsetters[] = {
- {const_cast<char*>("dtype"), py_get_generic(TypeCvt, dtype), py_set_generic(TypeCvt, dtype), const_cast<char*>("dtype"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(TypeCvt)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(TypeCvt)::getstate, METH_NOARGS, "TypeCvt getstate"},
- {const_cast<char*>("__setstate__"), PyOp(TypeCvt)::setstate, METH_VARARGS, "TypeCvt setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_TypeCvt(py::module m) {
- using py_op = PyOp(TypeCvt);
- auto& py_type = PyOpType(TypeCvt);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.TypeCvt";
- py_type.tp_basicsize = sizeof(PyOp(TypeCvt));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "TypeCvt";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("TypeCvt", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(TypeCvt::typeinfo(), &py_type).second);
- }
-
- PyOpDefBegin(UniformRNG) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(UniformRNG)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"seed", serialization<decltype(opdef.seed)>::dump(opdef.seed)},
- {"dtype", serialization<decltype(opdef.dtype)>::dump(opdef.dtype)},
- {"handle", serialization<decltype(opdef.handle)>::dump(opdef.handle)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(UniformRNG)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("seed");
- if (iter != state.end()) {
- opdef.seed = serialization<decltype(opdef.seed)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("dtype");
- if (iter != state.end()) {
- opdef.dtype = serialization<decltype(opdef.dtype)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("handle");
- if (iter != state.end()) {
- opdef.handle = serialization<decltype(opdef.handle)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(UniformRNG)
-
- int PyOp(UniformRNG)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"seed", "dtype", "handle", "scope", NULL};
- PyObject *seed = NULL, *dtype = NULL, *handle = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", const_cast<char**>(kwlist), &seed, &dtype, &handle, &scope))
- return -1;
-
- if (seed) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(UniformRNG)*>(self)->inst().seed =
- py::cast<decltype(UniformRNG::seed)>(py::handle(seed));
- } CATCH_ALL(-1)
- }
-
- if (dtype) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(UniformRNG)*>(self)->inst().dtype =
- py::cast<decltype(UniformRNG::dtype)>(py::handle(dtype));
- } CATCH_ALL(-1)
- }
-
- if (handle) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(UniformRNG)*>(self)->inst().handle =
- py::cast<decltype(UniformRNG::handle)>(py::handle(handle));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(UniformRNG)::py_getsetters[] = {
- {const_cast<char*>("seed"), py_get_generic(UniformRNG, seed), py_set_generic(UniformRNG, seed), const_cast<char*>("seed"), NULL},
- {const_cast<char*>("dtype"), py_get_generic(UniformRNG, dtype), py_set_generic(UniformRNG, dtype), const_cast<char*>("dtype"), NULL},
- {const_cast<char*>("handle"), py_get_generic(UniformRNG, handle), py_set_generic(UniformRNG, handle), const_cast<char*>("handle"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(UniformRNG)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(UniformRNG)::getstate, METH_NOARGS, "UniformRNG getstate"},
- {const_cast<char*>("__setstate__"), PyOp(UniformRNG)::setstate, METH_VARARGS, "UniformRNG setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_UniformRNG(py::module m) {
- using py_op = PyOp(UniformRNG);
- auto& py_type = PyOpType(UniformRNG);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.UniformRNG";
- py_type.tp_basicsize = sizeof(PyOp(UniformRNG));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "UniformRNG";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
-
- PyType_Modified(&py_type);
- m.add_object("UniformRNG", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(UniformRNG::typeinfo(), &py_type).second);
- }
-
- void _init_py_WarpAffine_InterpolationMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<WarpAffine::InterpolationMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "InterpolationMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_WarpAffine_BorderMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<WarpAffine::BorderMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "BorderMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_WarpAffine_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<WarpAffine::Format>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(WarpAffine) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(WarpAffine)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"imode", serialization<decltype(opdef.imode)>::dump(opdef.imode)},
- {"border_mode", serialization<decltype(opdef.border_mode)>::dump(opdef.border_mode)},
- {"border_val", serialization<decltype(opdef.border_val)>::dump(opdef.border_val)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(WarpAffine)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("imode");
- if (iter != state.end()) {
- opdef.imode = serialization<decltype(opdef.imode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("border_mode");
- if (iter != state.end()) {
- opdef.border_mode = serialization<decltype(opdef.border_mode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("border_val");
- if (iter != state.end()) {
- opdef.border_val = serialization<decltype(opdef.border_val)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(WarpAffine)
-
- int PyOp(WarpAffine)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"imode", "border_mode", "border_val", "format", "scope", NULL};
- PyObject *imode = NULL, *border_mode = NULL, *border_val = NULL, *format = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOO", const_cast<char**>(kwlist), &imode, &border_mode, &border_val, &format, &scope))
- return -1;
-
- if (imode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(WarpAffine)*>(self)->inst().imode =
- py::cast<decltype(WarpAffine::imode)>(py::handle(imode));
- } CATCH_ALL(-1)
- }
-
- if (border_mode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(WarpAffine)*>(self)->inst().border_mode =
- py::cast<decltype(WarpAffine::border_mode)>(py::handle(border_mode));
- } CATCH_ALL(-1)
- }
-
- if (border_val) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(WarpAffine)*>(self)->inst().border_val =
- py::cast<decltype(WarpAffine::border_val)>(py::handle(border_val));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(WarpAffine)*>(self)->inst().format =
- py::cast<decltype(WarpAffine::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(WarpAffine)::py_getsetters[] = {
- {const_cast<char*>("imode"), py_get_generic(WarpAffine, imode), py_set_generic(WarpAffine, imode), const_cast<char*>("imode"), NULL},
- {const_cast<char*>("border_mode"), py_get_generic(WarpAffine, border_mode), py_set_generic(WarpAffine, border_mode), const_cast<char*>("border_mode"), NULL},
- {const_cast<char*>("border_val"), py_get_generic(WarpAffine, border_val), py_set_generic(WarpAffine, border_val), const_cast<char*>("border_val"), NULL},
- {const_cast<char*>("format"), py_get_generic(WarpAffine, format), py_set_generic(WarpAffine, format), const_cast<char*>("format"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(WarpAffine)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(WarpAffine)::getstate, METH_NOARGS, "WarpAffine getstate"},
- {const_cast<char*>("__setstate__"), PyOp(WarpAffine)::setstate, METH_VARARGS, "WarpAffine setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_WarpAffine(py::module m) {
- using py_op = PyOp(WarpAffine);
- auto& py_type = PyOpType(WarpAffine);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.WarpAffine";
- py_type.tp_basicsize = sizeof(PyOp(WarpAffine));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "WarpAffine";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_WarpAffine_InterpolationMode(py_type);
- _init_py_WarpAffine_BorderMode(py_type);
- _init_py_WarpAffine_Format(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("WarpAffine", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(WarpAffine::typeinfo(), &py_type).second);
- }
-
- void _init_py_WarpPerspective_InterpolationMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<WarpPerspective::InterpolationMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "InterpolationMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_WarpPerspective_BorderMode(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<WarpPerspective::BorderMode>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "BorderMode", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- void _init_py_WarpPerspective_Format(PyTypeObject& py_type) {
- auto& e_type = EnumWrapper<WarpPerspective::Format>::type;
-
- Py_INCREF(e_type);
- mgb_assert(PyDict_SetItemString(
- py_type.tp_dict, "Format", reinterpret_cast<PyObject*>(e_type)) >= 0);
- }
-
- PyOpDefBegin(WarpPerspective) // {
- static PyGetSetDef py_getsetters[];
- static PyMethodDef tp_methods[];
-
- static PyObject* getstate(PyObject* self, PyObject*) {
- auto& opdef = reinterpret_cast<PyOp(WarpPerspective)*>(self)->inst();
- static_cast<void>(opdef);
- std::unordered_map<std::string, py::object> state {
-
- {"imode", serialization<decltype(opdef.imode)>::dump(opdef.imode)},
- {"bmode", serialization<decltype(opdef.bmode)>::dump(opdef.bmode)},
- {"format", serialization<decltype(opdef.format)>::dump(opdef.format)},
- {"border_val", serialization<decltype(opdef.border_val)>::dump(opdef.border_val)}
- };
- return py::cast(state).release().ptr();
- }
- static PyObject* setstate(PyObject* self, PyObject* args) {
- PyObject* dict = PyTuple_GetItem(args, 0);
- if (!dict) return NULL;
- auto state = py::cast<std::unordered_map<std::string, py::object>>(dict);
- auto& opdef = reinterpret_cast<PyOp(WarpPerspective)*>(self)->inst();
- static_cast<void>(opdef);
-
- {
- auto&& iter = state.find("imode");
- if (iter != state.end()) {
- opdef.imode = serialization<decltype(opdef.imode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("bmode");
- if (iter != state.end()) {
- opdef.bmode = serialization<decltype(opdef.bmode)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("format");
- if (iter != state.end()) {
- opdef.format = serialization<decltype(opdef.format)>::load(iter->second);
- }
- }
-
- {
- auto&& iter = state.find("border_val");
- if (iter != state.end()) {
- opdef.border_val = serialization<decltype(opdef.border_val)>::load(iter->second);
- }
- }
- Py_RETURN_NONE;
- }
- static int py_init(PyObject *self, PyObject *args, PyObject *kwds);
- // };
- PyOpDefEnd(WarpPerspective)
-
- int PyOp(WarpPerspective)::py_init(PyObject *self, PyObject *args, PyObject *kwds) {
- static const char* kwlist[] = {"imode", "bmode", "format", "border_val", "scope", NULL};
- PyObject *imode = NULL, *bmode = NULL, *format = NULL, *border_val = NULL, *scope = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOO", const_cast<char**>(kwlist), &imode, &bmode, &format, &border_val, &scope))
- return -1;
-
- if (imode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(WarpPerspective)*>(self)->inst().imode =
- py::cast<decltype(WarpPerspective::imode)>(py::handle(imode));
- } CATCH_ALL(-1)
- }
-
- if (bmode) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(WarpPerspective)*>(self)->inst().bmode =
- py::cast<decltype(WarpPerspective::bmode)>(py::handle(bmode));
- } CATCH_ALL(-1)
- }
-
- if (format) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(WarpPerspective)*>(self)->inst().format =
- py::cast<decltype(WarpPerspective::format)>(py::handle(format));
- } CATCH_ALL(-1)
- }
-
- if (border_val) {
- try {
- // TODO: remove this guard which is used for pybind11 implicit conversion
- py::detail::loader_life_support guard{};
- reinterpret_cast<PyOp(WarpPerspective)*>(self)->inst().border_val =
- py::cast<decltype(WarpPerspective::border_val)>(py::handle(border_val));
- } CATCH_ALL(-1)
- }
-
- if (scope) {
- try {
- reinterpret_cast<PyOp(OpDef)*>(self)->op
- ->set_scope(py::cast<std::string>(py::handle(scope)));
- } CATCH_ALL(-1)
- }
-
- return 0;
- }
-
- PyGetSetDef PyOp(WarpPerspective)::py_getsetters[] = {
- {const_cast<char*>("imode"), py_get_generic(WarpPerspective, imode), py_set_generic(WarpPerspective, imode), const_cast<char*>("imode"), NULL},
- {const_cast<char*>("bmode"), py_get_generic(WarpPerspective, bmode), py_set_generic(WarpPerspective, bmode), const_cast<char*>("bmode"), NULL},
- {const_cast<char*>("format"), py_get_generic(WarpPerspective, format), py_set_generic(WarpPerspective, format), const_cast<char*>("format"), NULL},
- {const_cast<char*>("border_val"), py_get_generic(WarpPerspective, border_val), py_set_generic(WarpPerspective, border_val), const_cast<char*>("border_val"), NULL},
- {NULL} /* Sentinel */
- };
-
- PyMethodDef PyOp(WarpPerspective)::tp_methods[] = {
- {const_cast<char*>("__getstate__"), PyOp(WarpPerspective)::getstate, METH_NOARGS, "WarpPerspective getstate"},
- {const_cast<char*>("__setstate__"), PyOp(WarpPerspective)::setstate, METH_VARARGS, "WarpPerspective setstate"},
- {NULL} /* Sentinel */
- };
-
- void _init_py_WarpPerspective(py::module m) {
- using py_op = PyOp(WarpPerspective);
- auto& py_type = PyOpType(WarpPerspective);
- py_type = {PyVarObject_HEAD_INIT(NULL, 0)};
- py_type.tp_name = "megengine.core._imperative_rt.ops.WarpPerspective";
- py_type.tp_basicsize = sizeof(PyOp(WarpPerspective));
- py_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
- py_type.tp_doc = "WarpPerspective";
- py_type.tp_base = &PyOpType(OpDef);
- py_type.tp_dealloc = py_dealloc_generic<py_op>;
- py_type.tp_new = py_new_generic<py_op>;
- py_type.tp_init = py_op::py_init;
- py_type.tp_methods = py_op::tp_methods;
- py_type.tp_getset = py_op::py_getsetters;
- mgb_assert(PyType_Ready(&py_type) >= 0);
- _init_py_WarpPerspective_InterpolationMode(py_type);
- _init_py_WarpPerspective_BorderMode(py_type);
- _init_py_WarpPerspective_Format(py_type);
-
- PyType_Modified(&py_type);
- m.add_object("WarpPerspective", reinterpret_cast<PyObject*>(&py_type));
- mgb_assert(PyOp(OpDef)::ctype2pytype.emplace(WarpPerspective::typeinfo(), &py_type).second);
- }
- #define INIT_ALL_OP(m) \
- _init_py_AdaptivePooling(m); \
- _init_py_AddAxis(m); \
- _init_py_Argmax(m); \
- _init_py_Argmin(m); \
- _init_py_Argsort(m); \
- _init_py_AssertEqual(m); \
- _init_py_AtlasRuntime(m); \
- _init_py_Barrier(m); \
- _init_py_BatchConvBias(m); \
- _init_py_BatchNorm(m); \
- _init_py_BatchNormBackward(m); \
- _init_py_BatchedIncrMeshIndexing(m); \
- _init_py_BatchedMatrixMul(m); \
- _init_py_BatchedMeshIndexing(m); \
- _init_py_BatchedSetMeshIndexing(m); \
- _init_py_BetaRNG(m); \
- _init_py_Borrow(m); \
- _init_py_Broadcast(m); \
- _init_py_CambriconRuntime(m); \
- _init_py_CheckNonFinite(m); \
- _init_py_CollectiveComm(m); \
- _init_py_Concat(m); \
- _init_py_CondTake(m); \
- _init_py_ConvBias(m); \
- _init_py_Convolution(m); \
- _init_py_Convolution3D(m); \
- _init_py_Convolution3DBackwardData(m); \
- _init_py_ConvolutionBackwardData(m); \
- _init_py_Copy(m); \
- _init_py_Correlation(m); \
- _init_py_Cumsum(m); \
- _init_py_CvtColor(m); \
- _init_py_DeformableConv(m); \
- _init_py_DeformablePSROIPooling(m); \
- _init_py_Diag(m); \
- _init_py_Dimshuffle(m); \
- _init_py_Dot(m); \
- _init_py_Dropout(m); \
- _init_py_Elemwise(m); \
- _init_py_ElemwiseMultiType(m); \
- _init_py_ExternOpr(m); \
- _init_py_Eye(m); \
- _init_py_FakeQuant(m); \
- _init_py_FastpathCopy(m); \
- _init_py_GammaRNG(m); \
- _init_py_GaussianRNG(m); \
- _init_py_GetVarShape(m); \
- _init_py_GroupLocal(m); \
- _init_py_Identity(m); \
- _init_py_Images2Neibs(m); \
- _init_py_IncrMeshIndexing(m); \
- _init_py_IncrSubtensor(m); \
- _init_py_IndexingIncrMultiAxisVec(m); \
- _init_py_IndexingMultiAxisVec(m); \
- _init_py_IndexingOneHot(m); \
- _init_py_IndexingSetMultiAxisVec(m); \
- _init_py_IndexingSetOneHot(m); \
- _init_py_InplaceAdd(m); \
- _init_py_LAMBUpdate(m); \
- _init_py_LRN(m); \
- _init_py_LSQ(m); \
- _init_py_LSTM(m); \
- _init_py_LSTMCell(m); \
- _init_py_LayerNorm(m); \
- _init_py_Linspace(m); \
- _init_py_MagicMindRuntime(m); \
- _init_py_MatrixInverse(m); \
- _init_py_MatrixMul(m); \
- _init_py_MeshIndexing(m); \
- _init_py_NMSKeep(m); \
- _init_py_NvOf(m); \
- _init_py_Padding(m); \
- _init_py_ParamPackConcat(m); \
- _init_py_ParamPackSplit(m); \
- _init_py_PermutationRNG(m); \
- _init_py_PixelShuffle(m); \
- _init_py_PixelShuffleBackward(m); \
- _init_py_PoissonRNG(m); \
- _init_py_Pooling(m); \
- _init_py_RNN(m); \
- _init_py_RNNCell(m); \
- _init_py_ROIAlign(m); \
- _init_py_ROIPooling(m); \
- _init_py_Reduce(m); \
- _init_py_Remap(m); \
- _init_py_RemoteRecv(m); \
- _init_py_RemoteSend(m); \
- _init_py_RemoveAxis(m); \
- _init_py_Reshape(m); \
- _init_py_Resize(m); \
- _init_py_SVD(m); \
- _init_py_SetMeshIndexing(m); \
- _init_py_SetSubtensor(m); \
- _init_py_ShuffleRNG(m); \
- _init_py_SlidingWindowTranspose(m); \
- _init_py_Softmax(m); \
- _init_py_Split(m); \
- _init_py_Subtensor(m); \
- _init_py_TQT(m); \
- _init_py_TensorRTRuntime(m); \
- _init_py_TopK(m); \
- _init_py_TypeCvt(m); \
- _init_py_UniformRNG(m); \
- _init_py_WarpAffine(m); \
- _init_py_WarpPerspective(m);
- // clang-format on
|