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

elewise_calculation_ops.h 138 kB

5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831
  1. /**
  2. * Copyright 2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /*!
  17. * \file elewise_calculation_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_ELEWISE_CALCULATION_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_ELEWISE_CALCULATION_OPS_H_
  22. #include "graph/operator_reg.h"
  23. namespace ge {
  24. /**
  25. *@brief Adds all input tensors element-wise. \n
  26. *@par Inputs:
  27. *Dynamic inputs, including:
  28. * @li x: A list of Tensor objects, each with same shape and type. The supported types are:
  29. * float16, float32, double, int32, uint8, int16, int8, complex64, int64,
  30. * qint8, quint8, qint32, uint16, complex128, uint32, uint64. It's a dynamic input. \n
  31. *@par Attributes:
  32. *N: An required attribute of type int32, means nums of inputs. \n
  33. *@par Outputs:
  34. *y: A Tensor. Has the same shape and type as the elements of "x". \n
  35. *@par Third-party framework compatibility
  36. *Compatible with the TensorFlow operator AddN.
  37. */
  38. REG_OP(AddN)
  39. .DYNAMIC_INPUT(x, TensorType::NumberType())
  40. .OUTPUT(y, TensorType::NumberType())
  41. .REQUIRED_ATTR(N, Int)
  42. .OP_END_FACTORY_REG(AddN)
  43. /**
  44. *@brief Calculates the reversed outputs of the function "maximum"
  45. *@par Inputs:
  46. *Three inputs, including:
  47. * @li grads: A mutable Tensor. Must be one of the following types:
  48. * float16, float32, int32.
  49. * @li x1: A mutable Tensor of the same type as "grads".
  50. * @li x2: A mutable Tensor of the same type as "grads". \n
  51. *@par Attributes:
  52. *@li grad_x: An optional bool. Defaults to "True".
  53. * If "True", "y1" will be output.
  54. * If "False", "y1" will not be output. \n
  55. *@li grad_y: An optional bool. Defaults to "True".
  56. * If "True", "y2" will be output.
  57. * If "False", "y2" will not be output. \n
  58. *@par Outputs:
  59. * @li y1: A mutable Tensor. Has the same type as "grads".
  60. * @li y2: A mutable Tensor. Has the same type as "grads". \n
  61. *@par Third-party framework compatibility
  62. * Compatible with the TensorFlow operator MaximumGrad.
  63. */
  64. REG_OP(MaximumGrad)
  65. .INPUT(grads, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  66. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  67. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  68. .OUTPUT(y1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  69. .OUTPUT(y2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  70. .ATTR(grad_x, Bool, true)
  71. .ATTR(grad_y, Bool, true)
  72. .OP_END_FACTORY_REG(MaximumGrad)
  73. /**
  74. *@brief Calculates the reversed outputs of the function "minimum"
  75. *@par Inputs:
  76. *Three inputs, including:
  77. * @li grads: A mutable Tensor. Must be one of the following types:
  78. * float16, float32, int32.
  79. * @li x1: A mutable Tensor of the same type as "grads".
  80. * @li x2: A mutable Tensor of the same type as "grads". \n
  81. *@par Attributes:
  82. *@li grad_x: An optional bool. Defaults to "True".
  83. * If "True", "y1" will be output.
  84. * If "False", "y1" will not be output. \n
  85. *@li grad_y: An optional bool. Defaults to "True".
  86. * If "True", "y2" will be output.
  87. * If "False", "y2" will not be output. \n
  88. *@par Outputs:
  89. * @li y1: A mutable Tensor. Has the same type as "grads".
  90. * @li y2: A mutable Tensor. Has the same type as "grads". \n
  91. *@par Third-party framework compatibility
  92. * Compatible with the TensorFlow operator MinimumGrad.
  93. */
  94. REG_OP(MinimumGrad)
  95. .INPUT(grads, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  96. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  97. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  98. .OUTPUT(y1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  99. .OUTPUT(y2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  100. .ATTR(grad_x, Bool, true)
  101. .ATTR(grad_y, Bool, true)
  102. .OP_END_FACTORY_REG(MinimumGrad)
  103. /**
  104. *@brief Cast a tensor form src data type to dst data type. \n
  105. *@par Inputs:
  106. *One input:
  107. *x:A Tensor. Must be one of the following types: bool, float16, float, int8, int32, uint32, uint8,
  108. int64, uint64, int16, uint16, double, complex64, complex128, qint8, quint8, qint16, quint16, qint32.
  109. For float32 type, the actual calculation on the chip is based on float16. \n
  110. *@par Attributes:
  111. *dst_type: An required attribute of type int32, specifying the dst data type. \n
  112. *@par Outputs:
  113. *y:A Tensor. Has the same type as x.
  114. */
  115. REG_OP(Cast)
  116. .INPUT(x, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT32, DT_UINT8,
  117. DT_INT64, DT_UINT64, DT_INT16, DT_UINT16, DT_DOUBLE, DT_COMPLEX64,
  118. DT_COMPLEX128, DT_QINT8, DT_QUINT8, DT_QINT16, DT_QUINT16, DT_QINT32}))
  119. .OUTPUT(y, TensorType({DT_BOOL, DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT32, DT_UINT8,
  120. DT_INT64, DT_UINT64, DT_INT16, DT_UINT16, DT_DOUBLE, DT_COMPLEX64,
  121. DT_COMPLEX128, DT_QINT8, DT_QUINT8, DT_QINT16, DT_QUINT16, DT_QINT32}))
  122. .REQUIRED_ATTR(dst_type, Int)
  123. .OP_END_FACTORY_REG(Cast)
  124. /**
  125. *@brief Returns the truth value of (x1 >= x2) element-wise. \n
  126. *@par Inputs:
  127. *Two inputs, including:
  128. * @li x1: A Tensor. Must be one of the following types: float16, float32,
  129. * double, int32, int8, uint8, int64, uint16, uint32, uint64.
  130. * @li x2: A Tensor of the same type as "x1". \n
  131. *@par Outputs:
  132. *y: A Tensor. Has the same type as "x1". \n
  133. *@par Third-party framework compatibility:
  134. * Compatible with the TensorFlow operator GreaterEqual.
  135. */
  136. REG_OP(GreaterEqual)
  137. .INPUT(x1, TensorType::RealNumberType())
  138. .INPUT(x2, TensorType::RealNumberType())
  139. .OUTPUT(y, TensorType({DT_BOOL}))
  140. .OP_END_FACTORY_REG(GreaterEqual)
  141. /**
  142. *@brief Returns the truth value of (x1 < x2) element-wise. \n
  143. *@par Inputs:
  144. *Two inputs, including:
  145. * @li x1: A Tensor. Must be one of the following types: float16, float32, double, int32,
  146. * uint8, int16, int8, int64, uint16, uint32, uint64.
  147. * @li x2: A Tensor with the same type as "x1". \n
  148. *@par Outputs:
  149. *y: A Tensor of type bool. \n
  150. *@par Third-party framework compatibility:
  151. * Compatible with TensorFlow operator Less.
  152. */
  153. REG_OP(Less)
  154. .INPUT(x1, TensorType::RealNumberType())
  155. .INPUT(x2, TensorType::RealNumberType())
  156. .OUTPUT(y, TensorType({DT_BOOL}))
  157. .OP_END_FACTORY_REG(Less)
  158. /**
  159. *@brief Returns x1/x2 element-wise for real types. \n
  160. *@par Inputs:
  161. * Two inputs, including:
  162. *@li x1: A Tensor. Must be one of the following types: float16, float32, double, uint16,
  163. int8, uint8, int16, int32, int64, complex64, DT_COMPLEX128.
  164. *@li x2: A Tensor. Must be one of the following types: float16, float32, double, uint16,
  165. int8, uint8, int16, int32, int64, complex64, DT_COMPLEX128. \n
  166. *@par Outputs:
  167. * y: A Tensor. Has the same type and format as input "x1". \n
  168. *@par Third-party framework compatibility
  169. * Compatible with the TensorFlow operator RealDiv.
  170. */
  171. REG_OP(RealDiv)
  172. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_UINT8, DT_INT8,
  173. DT_UINT16, DT_INT16, DT_INT32, DT_INT64,
  174. DT_COMPLEX64, DT_COMPLEX128}))
  175. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_UINT8, DT_INT8,
  176. DT_UINT16, DT_INT16, DT_INT32, DT_INT64,
  177. DT_COMPLEX64, DT_COMPLEX128}))
  178. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_UINT8, DT_INT8,
  179. DT_UINT16, DT_INT16, DT_INT32, DT_INT64,
  180. DT_COMPLEX64, DT_COMPLEX128}))
  181. .OP_END_FACTORY_REG(RealDiv)
  182. /**
  183. *@brief Computes square root of x element-wise. \n
  184. *@par Inputs:
  185. * x: A Tensor. Must be one of the following types: float16, float32, complex128, complex64, float64. \n
  186. *@par Outputs:
  187. *y: A Tensor. Has the same type as "x".
  188. *@par Third-party framework compatibility
  189. *Compatible with the TensorFlow operator Sqrt.
  190. */
  191. REG_OP(Sqrt)
  192. .INPUT(x, TensorType{(DT_FLOAT. DT_FLOAT16, DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128)})
  193. .OUTPUT(y, TensorType{(DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128)})
  194. .OP_END_FACTORY_REG(Sqrt)
  195. /**
  196. *@brief Returns the max of "x" and "y" (i.e. x > y ? x: y) element-wise. \n
  197. *@par Inputs:
  198. *Two inputs, including:
  199. * @li x1: A Tensor. Must be one of the following types: float16, float32, double, int32, int64.
  200. * @li x2: A Tensor of the same type as "x1". \n
  201. *@par Outputs:
  202. *y: A Tensor. Has the same type as "x1". \n
  203. *@par Third-party framework compatibility
  204. *Compatible with the TensorFlow operator Maximum.
  205. */
  206. REG_OP(Maximum)
  207. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32,
  208. DT_INT64}))
  209. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32,
  210. DT_INT64}))
  211. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32,
  212. DT_INT64}))
  213. .OP_END_FACTORY_REG(Maximum)
  214. /**
  215. *@brief Returns the min of x and y (i.e. x1 < x2 ? x1 : x2) element-wise. \n
  216. *@par Inputs:
  217. *Two inputs, include:
  218. * @li x1: A Tensor. Must be one of the following types: float32, float16, double, int32, int64.
  219. * @li x2: A Tensor of the same type as "x1". \n
  220. *@par Outputs:
  221. *y: A Tensor of the same type as "x1". \n
  222. *@par Third-party framework compatibility:
  223. * Compatible with the TensorFlow operator Minimum.
  224. */
  225. REG_OP(Minimum)
  226. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_INT32,
  227. DT_INT64}))
  228. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_INT32,
  229. DT_INT64}))
  230. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_INT32,
  231. DT_INT64}))
  232. .OP_END_FACTORY_REG(Minimum)
  233. /**
  234. *@brief: Computes the reciprocal of "x". \n
  235. *@par Inputs:
  236. *One inputs, include:
  237. *x:A Tensor of type float16, float32, int32, int64, double,
  238. * complex64, complex128.the format can be [NCHW,NC1HWC0,NHWC,ND,NCHW,NC1HWC0,NHWC,ND]
  239. *@par Outputs:
  240. *y:A Tensor with same type as "x". \n
  241. *@par Third-party framework compatibility
  242. *Compatible with the TensorFlow operator Reciprocal.
  243. */
  244. REG_OP(Reciprocal)
  245. .INPUT(x, TensorType({DT_FLOAT, DT_DOUBLE, DT_INT32, DT_INT64, DT_FLOAT16,
  246. DT_COMPLEX64, DT_COMPLEX128}))
  247. .OUTPUT(y, TensorType({DT_FLOAT, DT_DOUBLE, DT_INT32, DT_INT64, DT_FLOAT16
  248. DT_COMPLEX64, DT_COMPLEX128}))
  249. .OP_END_FACTORY_REG(Reciprocal)
  250. /**
  251. *@brief Returns x - y element-wise.
  252. *@par Inputs:
  253. *Two inputs, including:
  254. * @li x1: A Tensor. Must be one of the following types: int8, int16, int32, int64, uint8, float64,
  255. * float16, float32, complex128, complex64, uint16.
  256. * @li x2: A Tensor of the same type as "x1". \n
  257. *@par Outputs:
  258. *y: A Tensor. Has the same type as "x".
  259. *@par Third-party framework compatibility
  260. *Compatible with the TensorFlow operator Subtract.
  261. */
  262. REG_OP(Sub)
  263. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_UINT8, DT_INT8,
  264. DT_UINT16, DT_INT16, DT_INT32, DT_INT64,
  265. DT_COMPLEX64, DT_COMPLEX128}))
  266. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_UINT8, DT_INT8,
  267. DT_UINT16, DT_INT16, DT_INT32, DT_INT64,
  268. DT_COMPLEX64, DT_COMPLEX128}))
  269. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_UINT8, DT_INT8,
  270. DT_UINT16, DT_INT16, DT_INT32, DT_INT64,
  271. DT_COMPLEX64, DT_COMPLEX128}))
  272. .OP_END_FACTORY_REG(Sub)
  273. /**
  274. *@brief computes the absolute value of a tensor. \n
  275. *@par Inputs:
  276. *One inputs, including:
  277. * @li x: A Tensor. Must be one of the following types: float16, float32, double, int32, int64. \n
  278. *@par Outputs:
  279. *y: A Tensor. Has the same type as "x". \n
  280. *@par Third-party framework compatibility
  281. *Compatible with the TensorFlow operator Abs.
  282. */
  283. REG_OP(Abs)
  284. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32, DT_INT64}))
  285. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32, DT_INT64}))
  286. .OP_END_FACTORY_REG(Abs)
  287. /**
  288. *@brief Computes gradients for absolute operation. \n
  289. *
  290. *@par Inputs:
  291. *@li y: A tensor of type float16 or float32.
  292. *@li dy: A tensor of the same type as "y".
  293. *
  294. *@attention Constraints:
  295. * "dy" has the same type as "y".
  296. *
  297. *@par Outputs:
  298. * z: A tensor. Has the same type as "y".
  299. *
  300. *@par Third-party framework compatibility
  301. *Compatible with the TensorFlow operator AbsGrad.
  302. *
  303. */
  304. REG_OP(AbsGrad)
  305. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  306. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  307. .OUTPUT(z, TensorType({DT_FLOAT16, DT_FLOAT}))
  308. .OP_END_FACTORY_REG(AbsGrad)
  309. /**
  310. *@brief: Computes the sign of "x". \n
  311. *@par Inputs:
  312. *x:An ND Tensor of type float16, float32, int32, int64, double,
  313. * complex64, complex128. \n
  314. *@par Outputs:
  315. *y:An ND Tensor with same type as "x". \n
  316. *@par Third-party framework compatibility
  317. *Compatible with the TensorFlow operator Sign.
  318. */
  319. REG_OP(Sign)
  320. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT, DT_DOUBLE, DT_INT32,
  321. DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  322. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32,
  323. DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  324. .OP_END_FACTORY_REG(Sign)
  325. /**
  326. *@brief Returns (x1 - x2)(x1 - x2) element-wise. \n
  327. *@par Inputs:
  328. *Two inputs, including: \n
  329. *@li x1: A Tensor. Must be one of the following types: float16, float32, float64, int32, int64, complex64,complex128
  330. *@li x2: A Tensor. Has the same type as "x1". \n
  331. *@par Outputs:
  332. *y: A Tensor. Has the same type as "x1". \n
  333. *@par Third-party framework compatibility
  334. * Compatible with TensorFlow operator SquaredDifference.
  335. */
  336. REG_OP(SquaredDifference)
  337. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32,
  338. DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  339. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32,
  340. DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  341. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32,
  342. DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  343. .OP_END_FACTORY_REG(SquaredDifference)
  344. /**
  345. *@brief Computes cosine of "x" element-wise. \n
  346. *@par Inputs:
  347. *x: A Tensor of type float16, float32, double, complex64, complex128.
  348. * the format can be [NCHW,NC1HWC0,NHWC,ND]
  349. *@par Outputs:
  350. *y: A Tensor of the same type as "x". \n
  351. *@par Third-party framework compatibility
  352. * Compatible with the TensorFlow operator Cos. \n
  353. */
  354. REG_OP(Cos)
  355. .INPUT(x, TensorType::UnaryDataType())
  356. .OUTPUT(y, TensorType::UnaryDataType())
  357. .OP_END_FACTORY_REG(Cos)
  358. /**
  359. *@brief Returns x1/x2 element-wise. \n
  360. *@par Inputs:
  361. * Two inputs, including:
  362. *@li x1: A Tensor. Must be one of the following types:
  363. * float16, float32, int32, int8, uint8, float64, int64, uint16, int16,
  364. * complex64, complex128, the format can be [NCHW,NC1HWC0,NHWC,ND].
  365. *@li x2: A Tensor. Has the same type and format as input "x1". \n
  366. *@par Outputs:
  367. * y: A Tensor. Has the same type and format as input "x1". \n
  368. *@par Third-party framework compatibility
  369. * Compatible with the TensorFlow operator Div.
  370. */
  371. REG_OP(Div)
  372. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_UINT8, DT_INT32,
  373. DT_DOUBLE, DT_INT64, DT_UINT16, DT_INT16,
  374. DT_COMPLEX64, DT_COMPLEX128}))
  375. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_UINT8, DT_INT32,
  376. DT_DOUBLE, DT_INT64, DT_UINT16, DT_INT16,
  377. DT_COMPLEX64, DT_COMPLEX128}))
  378. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_UINT8, DT_INT32,
  379. DT_DOUBLE, DT_INT64, DT_UINT16, DT_INT16,
  380. DT_COMPLEX64, DT_COMPLEX128}))
  381. .OP_END_FACTORY_REG(Div)
  382. /**
  383. *@brief: Returns the truth value of (x = y) element-wise. \n
  384. *@par Inputs:
  385. * Two inputs, including:
  386. *@li x1: A Tensor. Must be one of the following types:
  387. * float16, float32, int32, int8, uint8, double, int16, int64, complex64,
  388. * complex128, quint8, qint8, qint32, string, bool. the format can be
  389. * [NCHW, NC1HWC0, NHWC, ND]
  390. *@li x2: A Tensor of the same type and format as "x1". \n
  391. *@par Outputs:
  392. *y: A Tensor of type bool. \n
  393. *@par Third-party framework compatibility
  394. * Compatible with the TensorFlow operator Equal.
  395. */
  396. REG_OP(Equal)
  397. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8, DT_UINT8,
  398. DT_DOUBLE, DT_INT16, DT_INT64, DT_COMPLEX64,
  399. DT_COMPLEX128, DT_QUINT8, DT_QINT8, DT_QINT32,
  400. DT_STRING, DT_BOOL}))
  401. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8, DT_UINT8,
  402. DT_DOUBLE, DT_INT16, DT_INT64, DT_COMPLEX64,
  403. DT_COMPLEX128, DT_QUINT8, DT_QINT8, DT_QINT32,
  404. DT_STRING, DT_BOOL}))
  405. .OUTPUT(y, TensorType({DT_BOOL}))
  406. .OP_END_FACTORY_REG(Equal)
  407. /**
  408. *@brief Computes the exponential of "x" element-wise. \n
  409. *@par Inputs:
  410. *One input:\n
  411. *x: A Tensor. Must be one of the following types: float16, float32, double, complex64, complex128. \n
  412. *@par Attributes:
  413. *@li base: An optional attribute of type float32, specifying the base gamma. Defaults to "-1.0".
  414. *@li scale: An optional attribute of type float32, specifying the scale alpha. Defaults to "1.0".
  415. *@li shift: An optional attribute of type float32, specifying the shift beta. Defaults to "0.0". \n
  416. *@par Outputs:
  417. *y: A Tensor of the same type as "x". \n
  418. *@par Third-party framework compatibility
  419. * Compatible with TensorFlow operator Exp.
  420. */
  421. REG_OP(Exp)
  422. .INPUT(x, TensorType::UnaryDataType())
  423. .OUTPUT(y, TensorType::UnaryDataType())
  424. .ATTR(base, Float, -1.0)
  425. .ATTR(scale, Float, 1.0)
  426. .ATTR(shift, Float, 0.0)
  427. .OP_END_FACTORY_REG(Exp)
  428. /**
  429. *@brief Computes the exp(x) - 1 element-wise, y = e^x - 1. \n
  430. *@par Inputs:
  431. *One input:
  432. *x: A Tensor. Must be one of the following types: float16, float32, double, complex64, complex128. \n
  433. *@par Outputs:
  434. *y: A Tensor of the same type as "x". \n
  435. *@par Third-party framework compatibility
  436. * Compatible with TensorFlow operator Expm1.
  437. */
  438. REG_OP(Expm1)
  439. .INPUT(x, TensorType::UnaryDataType())
  440. .OUTPUT(y, TensorType::UnaryDataType())
  441. .OP_END_FACTORY_REG(Expm1)
  442. /**
  443. *@brief: Computes the reciprocal of "x". \n
  444. *@par Inputs:\n
  445. *x: A Tensor. Must be one of the following types: float16, float32, int32, int64, double, complex64, complex128. \n
  446. *@par Outputs:
  447. *y: A Tensor. Has the same type as "x". \n
  448. *@par Third-party framework compatibility
  449. * Compatible with the TensorFlow operator Inv.
  450. */
  451. REG_OP(Inv)
  452. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT,DT_DOUBLE,DT_INT32,DT_INT64,DT_COMPLEX64,DT_COMPLEX128}))
  453. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32}))
  454. .OP_END_FACTORY_REG(Inv)
  455. /**
  456. *@brief: Computes "x" reciprocal grad, dx = -1*dy*y*y, where, "y = 1/x", and "dy"
  457. is the corresponding input gradient. \n
  458. *@par Inputs:
  459. * Two inputs, including:
  460. * @li x: A Tensor. Must be one of the following types: float16, float32, int32, int8.
  461. * @li grad: A Tensor. Has the same type as "x". \n
  462. *@par Outputs:
  463. *y: A Tensor, Has the same type as "x". \n
  464. *@par Third-party framework compatibility
  465. * Compatible with the TensorFlow operator InvGrad.
  466. */
  467. REG_OP(InvGrad)
  468. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8}))
  469. .INPUT(grad, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8}))
  470. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8}))
  471. .OP_END_FACTORY_REG(InvGrad)
  472. /**
  473. *@brief: Returns the truth value of (x <= y) element-wise. \n
  474. *@par Inputs:
  475. * Two inputs, including:
  476. *@li x1: A Tensor. Must be one of the following types: float32, float64,
  477. * int32, uint8, int16, int8, int64, qint8, quint8, qint32, uint16,
  478. * float16, uint32, uint64.
  479. *@li x2: A Tensor of the same type as "x1". \n
  480. *@par Outputs:
  481. *y: A Tensor of type bool. \n
  482. *@par Third-party framework compatibility
  483. * Compatible with the TensorFlow operator LessEqual.
  484. */
  485. REG_OP(LessEqual)
  486. .INPUT(x1, TensorType::RealNumberType())
  487. .INPUT(x2, TensorType::RealNumberType())
  488. .OUTPUT(y, TensorType({DT_BOOL}))
  489. .OP_END_FACTORY_REG(LessEqual)
  490. /**
  491. *@brief Computes the logarithm of (x + 1) element-wise, y = ln(x + 1). \n
  492. *@par Inputs:
  493. *One input:\n
  494. *x: A Tensor. Must be one of the following types: float16, float32, double, complex64, complex128. \n
  495. *@par Outputs:
  496. *y: A Tensor of the same type as "x". \n
  497. *@par Third-party framework compatibility
  498. * Compatible with TensorFlow operator Log1p.
  499. */
  500. REG_OP(Log1p)
  501. .INPUT(x, TensorType::UnaryDataType())
  502. .OUTPUT(y, TensorType::UnaryDataType())
  503. .OP_END_FACTORY_REG(Log1p)
  504. /**
  505. *@brief Returns element-wise remainder of division.
  506. *@par Inputs:
  507. *Two inputs, including:
  508. * @li x1: A Tensor. Must be one of the following types: float16, float32,
  509. * int32, int64, int8, uint8, double.
  510. * @li x2: A Tensor of the same type as "x1". \n
  511. *@par Outputs:
  512. *y: A Tensor. Has the same type as "x1".
  513. *@attention Constraints:
  514. *@li x2: The input data does not support 0
  515. *@li When NUM exceeds 2048 , the accuracy of operator cannot guarantee the
  516. *requirement of double thousandths in the mini form
  517. *@li Due to different architectures, the calculation results of this operator
  518. *on NPU and CPU may be inconsistent
  519. *@li If shape is expressed as (D1,D2... ,Dn), then D1*D2... *DN<=1000000,n<=8
  520. *@par Third-party framework compatibility
  521. *Compatible with the TensorFlow operator Mod.
  522. */
  523. REG_OP(Mod)
  524. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8,
  525. DT_INT64, DT_DOUBLE}))
  526. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8,
  527. DT_INT64, DT_DOUBLE}))
  528. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8,
  529. DT_INT64, DT_DOUBLE}))
  530. .OP_END_FACTORY_REG(Mod)
  531. /**
  532. *@brief: Returns the truth value of (x != y) element-wise. \n
  533. *@par Inputs:
  534. * Two inputs, including:
  535. *@li x1: A Tensor. Must be one of the following types: float16, float32, int32,
  536. * int8, uint8, double, int16, int64, uint16, half, uint32, uint64
  537. *@li x2: A Tensor of the same type as "x1". \n
  538. *@par Outputs:
  539. *y: A Tensor of type bool. \n
  540. *@par Third-party framework compatibility
  541. * Compatible with the TensorFlow operator NotEqual.
  542. */
  543. REG_OP(NotEqual)
  544. .INPUT(x1, TensorType::RealNumberType())
  545. .INPUT(x2, TensorType::RealNumberType())
  546. .OUTPUT(y, TensorType({DT_BOOL}))
  547. .OP_END_FACTORY_REG(NotEqual)
  548. /**
  549. *@brief Computes numerical negative value element-wise (y = -x)
  550. *@par Inputs:
  551. * One input:
  552. *x: A Tensor. Must be one of the following types: float16, float32, int32,
  553. * int64, complex64, complex128. \n
  554. *@par Outputs:
  555. *y: A Tensor. Has the same type and format as input "x". \n
  556. *@par Third-party framework compatibility
  557. * Compatible with the TensorFlow operator Neg.
  558. */
  559. REG_OP(Neg)
  560. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  561. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  562. .OP_END_FACTORY_REG(Neg)
  563. /**
  564. *@brief Returns x1/x2 element-wise for integer types. \n
  565. *@par Inputs:
  566. *@li x1: A Tensor. Must be one of the following types:
  567. * float32, float64, int32, uint8, int16, int8,
  568. * complex64, int64, qint8, quint8, qint32, uint16,
  569. * complex128, float16, uint32, uint64, complex64, complex128.
  570. *@li x2: A Tensor of the same data type as "x1". \n
  571. *@par Outputs:
  572. *y: A Tensor. Has the same type as "x1".
  573. *@attention Constraints:
  574. * Broadcasting is supported. \n
  575. *@par Third-party framework compatibility
  576. * Compatible with the TensorFlow operator TruncateDiv. \n
  577. */
  578. REG_OP(TruncateDiv)
  579. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_UINT8, DT_INT32,
  580. DT_DOUBLE, DT_UINT16, DT_INT16, DT_INT64,
  581. DT_COMPLEX64, DT_COMPLEX128}))
  582. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_UINT8, DT_INT32,
  583. DT_DOUBLE, DT_UINT16, DT_INT16, DT_INT64,
  584. DT_COMPLEX64, DT_COMPLEX128}))
  585. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_UINT8, DT_INT32,
  586. DT_DOUBLE, DT_UINT16, DT_INT16, DT_INT64,
  587. DT_COMPLEX64, DT_COMPLEX128}))
  588. .OP_END_FACTORY_REG(TruncateDiv)
  589. /**
  590. *@brief Computes x1/x2 element-wise, if x1 == 0, return 0.
  591. *@par Inputs:
  592. * Two inputs, including:
  593. * @li x1: A Tensor. Must be one of the following types: float16, float32,
  594. * double, complex64, complex128.
  595. * @li x2: A Tensor. Has the same type as "x1". \n
  596. *@par Outputs:
  597. *y: A Tensor. Has the same type as "x1". \n
  598. *@par Third-party framework compatibility
  599. * Compatible with TensorFlow operator Xdivy.
  600. */
  601. REG_OP(Xdivy)
  602. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_COMPLEX64,
  603. DT_COMPLEX128}))
  604. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_COMPLEX64,
  605. DT_COMPLEX128}))
  606. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_COMPLEX64,
  607. DT_COMPLEX128}))
  608. .OP_END_FACTORY_REG(Xdivy)
  609. /**
  610. *@brief Computes "x" multiplied by the logarithm of y element-wise,
  611. * if "x" == 0, return "0". \n
  612. *@par Inputs:
  613. * Two inputs, including:
  614. * @li x1: A Tensor. Must be one of the following types: float16, float32,
  615. * double, complex64, complex128.
  616. * @li x2: A Tensor. Has the same type as "x1". \n
  617. *@par Outputs:
  618. *y: A Tensor. Has the same type as "x1". \n
  619. *@par Third-party framework compatibility
  620. * Compatible with TensorFlow operator Xlogy.
  621. */
  622. REG_OP(Xlogy)
  623. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_COMPLEX64,
  624. DT_COMPLEX128}))
  625. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_COMPLEX64,
  626. DT_COMPLEX128}))
  627. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_COMPLEX64,
  628. DT_COMPLEX128}))
  629. .OP_END_FACTORY_REG(Xlogy)
  630. /**
  631. *@brief Computes square of "x" element-wise. \n
  632. *@par Inputs:
  633. *One input: \n
  634. *x: A Tensor. Must be one of the following types: float16, float32, float64, int32, int64, complex64, complex128
  635. *@par Outputs:
  636. *y: A Tensor. Has the same type as "x". \n
  637. *@par Third-party framework compatibility
  638. * Compatible with TensorFlow operator Square.
  639. */
  640. REG_OP(Square)
  641. .INPUT(x, TensorType({DT_DOUBLE, DT_FLOAT16, DT_FLOAT,
  642. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  643. .OUTPUT(y, TensorType({DT_DOUBLE, DT_FLOAT16, DT_FLOAT,
  644. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  645. .OP_END_FACTORY_REG(Square)
  646. /**
  647. *@brief Computes reciprocal of square root of "x" element-wise: y = 1/sqrt{x}. \n
  648. *
  649. *@par Inputs:
  650. * x: An ND or 5HD tensor. Must be one of the following types: float, double, half,
  651. * complex64, complex128.
  652. *
  653. *@par Outputs:
  654. * y: An ND or 5HD tensor. Has the same type as "x".
  655. *
  656. *@par Third-party framework compatibility
  657. *Compatible with the TensorFlow operator Rsqrt.
  658. *
  659. */
  660. REG_OP(Rsqrt)
  661. .INPUT(x, TensorType::UnaryDataType())
  662. .OUTPUT(y, TensorType::UnaryDataType())
  663. .OP_END_FACTORY_REG(Rsqrt)
  664. /**
  665. *@brief Computes the trignometric inverse sine of "x" element-wise. \n
  666. *
  667. *@par Inputs:
  668. * x: A tensor. Must be one of the following types: float16, float32, float64, int32, int64, complex64, complex128.
  669. *
  670. *@par Outputs:
  671. * y: A tensor. Has the same type as "x".
  672. *
  673. *@par Third-party framework compatibility
  674. *Compatible with the TensorFlow operator Asin.
  675. *
  676. */
  677. REG_OP(Asin)
  678. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE,
  679. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  680. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE,
  681. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  682. .OP_END_FACTORY_REG(Asin)
  683. /**
  684. *@brief Computes gradients for Asin operation. \n
  685. *
  686. *@par Inputs:
  687. *@li y: A tensor of type float16, float32, float64, int32, int64, complex64, complex128.
  688. *@li dy: A tensor of the same type as "y".
  689. *
  690. *@attention Constraints:
  691. * "dy" has the same type as "y".
  692. *
  693. *@par Outputs:
  694. * z: A tensor. Has the same type as "y".
  695. *
  696. *@par Third-party framework compatibility
  697. *Compatible with the TensorFlow operator AsinGrad.
  698. *
  699. */
  700. REG_OP(AsinGrad)
  701. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE,
  702. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  703. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE,
  704. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  705. .OUTPUT(z, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE,
  706. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  707. .OP_END_FACTORY_REG(AsinGrad)
  708. /**
  709. *@brief Computes acos of x element-wise. \n
  710. *
  711. *@par Inputs:
  712. * x: A tensor. Must be one of the following types: float16, float32, float64, int32, int64, complex64, complex128.
  713. *
  714. *@par Outputs:
  715. * y: A tensor. Has the same type as "x".
  716. *
  717. *@par Third-party framework compatibility
  718. *Compatible with the TensorFlow operator Acos.
  719. *
  720. */
  721. REG_OP(Acos)
  722. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE,
  723. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  724. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE,
  725. DT_INT32, DT_INT64, DT_COMPLEX64, DT_COMPLEX128}))
  726. .OP_END_FACTORY_REG(Acos)
  727. /**
  728. *@brief Computes gradients for Acos operation. \n
  729. *
  730. *@par Inputs:
  731. *@li y: A tensor of type float16 or float32.
  732. *@li dy: A tensor of the same type as "y".
  733. *
  734. *@attention Constraints:
  735. * "dy" has the same shape as "y".
  736. *
  737. *@par Outputs:
  738. * z: A tensor. Has the same type as "y".
  739. *
  740. *@par Third-party framework compatibility
  741. *Compatible with the TensorFlow operator AcosGrad.
  742. *
  743. */
  744. REG_OP(AcosGrad)
  745. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  746. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  747. .OUTPUT(z, TensorType({DT_FLOAT16, DT_FLOAT}))
  748. .OP_END_FACTORY_REG(AcosGrad)
  749. /**
  750. *@brief Computes inverse hyperbolic cosine of x element-wise. \n
  751. *
  752. *@par Inputs:
  753. * x: A tensor. Must be one of the following types: float16, float32, float64, complex64, complex128.
  754. *
  755. *@attention Constraints:
  756. * x Given an input tensor, the function computes inverse hyperbolic cosine of every element.\n
  757. * Input range is [1, inf].
  758. *
  759. *@par Outputs:
  760. * y: A tensor. Has the same type as "x".
  761. *
  762. *@par Third-party framework compatibility
  763. *Compatible with the TensorFlow operator Acosh.
  764. *
  765. */
  766. REG_OP(Acosh)
  767. .INPUT(x, TensorType::UnaryDataType())
  768. .OUTPUT(y, TensorType::UnaryDataType())
  769. .OP_END_FACTORY_REG(Acosh)
  770. /**
  771. *@brief Computes gradients for Acosh operation. \n
  772. *
  773. *@par Inputs:
  774. *@li y: A tensor of type float16 or float32.
  775. *@li dy: A tensor of the same type as "y".
  776. *
  777. *@attention Constraints:
  778. * "dy" has the same type as "y".
  779. *
  780. *@par Outputs:
  781. * z: A tensor. Has the same type as "y".
  782. *
  783. *@par Third-party framework compatibility
  784. *Compatible with the TensorFlow operator AcoshGrad.
  785. *
  786. */
  787. REG_OP(AcoshGrad)
  788. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  789. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  790. .OUTPUT(z, TensorType({DT_FLOAT16, DT_FLOAT}))
  791. .OP_END_FACTORY_REG(AcoshGrad)
  792. /**
  793. *@brief Returns the truth value of x1 OR x2 element-wise. \n
  794. *
  795. *@par Inputs:
  796. *@li x1: A tensor of type bool.
  797. *@li x2: A tensor of the same type as "x1".
  798. *
  799. *@attention Constraints:
  800. * LogicalOr supports broadcasting.
  801. *
  802. *@par Outputs:
  803. * y: A tensor of the same type as "x1".
  804. *
  805. *@par Third-party framework compatibility
  806. *Compatible with the TensorFlow operator LogicalOr.
  807. *
  808. */
  809. REG_OP(LogicalOr)
  810. .INPUT(x1, TensorType({DT_BOOL}))
  811. .INPUT(x2, TensorType({DT_BOOL}))
  812. .OUTPUT(y, TensorType({DT_BOOL}))
  813. .OP_END_FACTORY_REG(LogicalOr)
  814. /**
  815. *@brief Returns the truth value of x1 AND x2 element-wise. \n
  816. *
  817. *@par Inputs:
  818. *@li x1: A tensor of type bool.
  819. *@li x2: A tensor of the same type as "x1".
  820. *
  821. *@attention Constraints:
  822. * LogicalAnd supports broadcasting.
  823. *
  824. *@par Outputs:
  825. * y: A tensor of the same type as "x1".
  826. *
  827. *@par Third-party framework compatibility
  828. *Compatible with the TensorFlow operator LogicalAnd.
  829. *
  830. */
  831. REG_OP(LogicalAnd)
  832. .INPUT(x1, TensorType({DT_BOOL}))
  833. .INPUT(x2, TensorType({DT_BOOL}))
  834. .OUTPUT(y, TensorType({DT_BOOL}))
  835. .OP_END_FACTORY_REG(LogicalAnd)
  836. /**
  837. *@brief Computes the Bessel i0e function of "x" element-wise.
  838. * Exponentially scaled modified Bessel function of order 0
  839. * defined as: bessel_i0e(x) = exp(-abs(x)) bessel_i0(x).
  840. * This function is faster and numerically stabler than "bessel_i0(x)".
  841. *
  842. *@par Inputs:
  843. * x: A tensor of type float16, float32, or float64.
  844. *
  845. *@par Outputs:
  846. * y: A tensor. Has the same type as "x".
  847. *
  848. *@par Third-party framework compatibility
  849. *Compatible with the TensorFlow operator BesselI0e.
  850. *
  851. */
  852. REG_OP(BesselI0e)
  853. .INPUT(x, TensorType::FloatingDataType())
  854. .OUTPUT(y, TensorType::FloatingDataType())
  855. .OP_END_FACTORY_REG(BesselI0e)
  856. /**
  857. *@brief Computes the Bessel i1e function of "x" element-wise.
  858. * Exponentially scaled modified Bessel function of order 0
  859. * defined as: bessel_i1e(x) = exp(-abs(x)) bessel_i1(x).
  860. * This function is faster and numerically stabler than "bessel_i1(x)".
  861. *
  862. *@par Inputs:
  863. * x: A tensor of type float16, float32, or float64.
  864. *
  865. *@par Outputs:
  866. * y: A tensor. Has the same type as "x".
  867. *
  868. *@par Third-party framework compatibility
  869. *Compatible with the TensorFlow operator BesselI1e.
  870. *
  871. */
  872. REG_OP(BesselI1e)
  873. .INPUT(x, TensorType::FloatingDataType())
  874. .OUTPUT(y, TensorType::FloatingDataType())
  875. .OP_END_FACTORY_REG(BesselI1e)
  876. /**
  877. * @brief Computes logarithm of x element-wise.
  878. * y = log_base(shift + scale * x), with "base" > 0. \n
  879. * @par Inputs:
  880. * @li x: A Tensor of type complex64, complex128, float16, float32 or double. \n
  881. * @par Attributes:
  882. * @li base: An optional float32, specifying the base "e". Defaults to "-1.0"
  883. * @li scale: An optional float32, specifying the scale of input "x". Defaults
  884. * to "1.0"
  885. * @li shift: An optional float32, specifying the shift. Defaults to "0.0"
  886. * @par Outputs:
  887. * y: A Tensor has same type as "x". \n
  888. * @attention Constraints:
  889. * @li "base" is supposed to be greater than 0. Retaining the default
  890. * value "-1" sets "base" to "e".
  891. * @li If the input value of operator Log is within the range (0, 0.01] or
  892. * [0.95, 1.05], the output accuracy is subject to change. \n
  893. * @par Third-party framework compatibility
  894. * @li Compatible with the TensorFlow operator Log.
  895. * @li Compatible with the Caffe operator Log.
  896. */
  897. REG_OP(Log)
  898. .INPUT(x, TensorType::UnaryDataType())
  899. .OUTPUT(y, TensorType::UnaryDataType())
  900. .ATTR(base, Float, -1.0)
  901. .ATTR(scale, Float, 1.0)
  902. .ATTR(shift, Float, 0.0)
  903. .OP_END_FACTORY_REG(Log)
  904. /**
  905. * @brief Returns x1 * x2 element-wise.
  906. * y = x1 * x2
  907. * @par Inputs:
  908. * @li x1: A Tensor. Must be one of the following types: float16, float32,
  909. * float64, uint8, int8, uint16, int16, int32, int64, complex64, complex128.
  910. * @li x2: A Tensor. Must be one of the following types: float16, float32,
  911. * float64, uint8, int8, uint16, int16, int32, int64, complex64, complex128. \n
  912. * @par Outputs:
  913. * y: A Tensor. Must be one of the following types: float16, float32, float64,
  914. * uint8, int8, uint16, int16, int32, int64, complex64, complex128. \n
  915. * @attention Constraints:
  916. * @li "x1" and "x2" have incompatible shapes or types. \n
  917. * @par Third-party framework compatibility
  918. * Compatible with the TensorFlow operator Multiply.
  919. */
  920. REG_OP(Mul)
  921. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_UINT8, DT_INT8,
  922. DI_UINT16, DT_INT16, DT_INT32, DT_INT64,
  923. DT_COMPLEX64, DT_COMPLEX128}))
  924. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_UINT8, DT_INT8,
  925. DI_UINT16, DT_INT16, DT_INT32, DT_INT64,
  926. DT_COMPLEX64, DT_COMPLEX128}))
  927. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_UINT8, DT_INT8,
  928. DI_UINT16, DT_INT16, DT_INT32, DT_INT64,
  929. DT_COMPLEX64, DT_COMPLEX128}))
  930. .OP_END_FACTORY_REG(Mul)
  931. /**
  932. * @brief Computes the gradient of the square root of "x" with regard to its
  933. * input. grad = dy * 0.5/y, where y = sqrt(x), and "dy" is the corresponding
  934. * input gradient. \n
  935. * @par Inputs:
  936. * Two inputs, including:
  937. * @li y: A Tensor of type float32 or float16.
  938. * @li dy: A Tensor. Has the same type as "y". \n
  939. * @par Outputs:
  940. * z: A Tensor. Has the same type as "y". \n
  941. * @attention Constraints:
  942. * "dy" has the same shape and type as "y".
  943. */
  944. REG_OP(SqrtGrad)
  945. .INPUT(y, TensorType(UnaryDataType))
  946. .INPUT(dy, TensorType(UnaryDataType))
  947. .OUTPUT(z, TensorType(UnaryDataType))
  948. .OP_END_FACTORY_REG(SqrtGrad)
  949. /**
  950. *@brief Returns x + y element-wise.
  951. *@par Inputs:
  952. *Two inputs, including:
  953. * @li x1: A Tensor. Must be one of the following types: int8, int16, int32, int64, uint8, float64,
  954. * float16, float32, complex128, complex64, string.
  955. * @li x2: A Tensor of the same type as "x1". \n
  956. *@par Outputs:
  957. *y: A Tensor. Has the same type as "x".
  958. *@par Third-party framework compatibility
  959. *Compatible with the TensorFlow operator Add.
  960. */
  961. REG_OP(Add)
  962. .INPUT(x1, TensorType({DT_FLOAT, DT_INT32, DT_INT64, DT_FLOAT16, DT_INT16,
  963. DT_INT8, DT_UINT8, DT_DOUBLE, DT_COMPLEX128,
  964. DT_COMPLEX64, DT_STRING}))
  965. .INPUT(x2, TensorType({DT_FLOAT, DT_INT32, DT_INT64, DT_FLOAT16, DT_INT16,
  966. DT_INT8, DT_UINT8, DT_DOUBLE, DT_COMPLEX128,
  967. DT_COMPLEX64, DT_STRING}))
  968. .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT64, DT_FLOAT16, DT_INT16,
  969. DT_INT8, DT_UINT8, DT_DOUBLE, DT_COMPLEX128,
  970. DT_COMPLEX64, DT_STRING}))
  971. .OP_END_FACTORY_REG(Add)
  972. /**
  973. *@brief Confuse broadcast, add and mul. \n
  974. *@par Inputs:
  975. *Five inputs, including:
  976. * @li x1: A Tensor. Must be one of the following types:int32 float16, float32.
  977. * @li x2: A Tensor of the same type as "x1".
  978. * @li x3: A Tensor of the same type as "x1". \n
  979. *@par Outputs:
  980. *@li y: A Tensor. Has the same type as "x1". \n
  981. *@par Third-party framework compatibility:
  982. * Compatible with the TensorFlow operator LRN.
  983. *@par Restrictions:
  984. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  985. */
  986. REG_OP(FusedMulAdd)
  987. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  988. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  989. .INPUT(x3, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  990. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
  991. .OP_END_FACTORY_REG(FusedMulAdd)
  992. /**
  993. *@brief Returns x1 + x2 element-wise. \n
  994. *
  995. *@par Inputs:
  996. *@li x1: A tensor. Must be one of the following types: float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.
  997. *@li x2: A tensor of the same type as "x1".
  998. *
  999. *@attention Constraints:
  1000. * AddV2 supports broadcasting.
  1001. *
  1002. *@par Outputs:
  1003. * y: A tensor. Has the same type as "x1".
  1004. *
  1005. *@par Third-party framework compatibility
  1006. *Compatible with the TensorFlow operator AddV2.
  1007. *
  1008. */
  1009. REG_OP(AddV2)
  1010. .INPUT(x1, TensorType({DT_FLOAT, DT_INT32, DT_INT64, DT_FLOAT16, DT_INT16,
  1011. DT_INT8, DT_UINT8, DT_DOUBLE, DT_COMPLEX64,
  1012. DT_COMPLEX128}))
  1013. .INPUT(x2, TensorType({DT_FLOAT, DT_INT32, DT_INT64, DT_FLOAT16, DT_INT16,
  1014. DT_INT8, DT_UINT8, DT_DOUBLE, DT_COMPLEX64,
  1015. DT_COMPLEX128}))
  1016. .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT64, DT_FLOAT16, DT_INT16,
  1017. DT_INT8, DT_UINT8, DT_DOUBLE, DT_COMPLEX64,
  1018. DT_COMPLEX128}))
  1019. .OP_END_FACTORY_REG(AddV2)
  1020. /**
  1021. *@brief Updates "ref" by adding "value" to it. \n
  1022. *@par Inputs:
  1023. *@li ref: A Tensor. Must be one of the following types: float16, float32, int8, int16, int32, int64, uint8, uint16, uint32, uint64.
  1024. *@li value: A Tensor of the same type as "ref". \n
  1025. *@par Attributes:
  1026. *use_locking: An optional bool. Defaults to "False".
  1027. If "True", the addition will be protected by a lock;
  1028. otherwise the behavior is undefined, but may exhibit less contention.
  1029. * This attribute is reserved. \n
  1030. *@par Outputs:
  1031. *ref: A Tensor that holds the new value of ref after the value has been added. \n
  1032. *@attention Constraints:
  1033. *An input tensor of type int64 must have a shape with size 1. \n
  1034. *@par Third-party framework compatibility
  1035. *Compatible with the TensorFlow operator AssignAdd.
  1036. */
  1037. REG_OP(AssignAdd)
  1038. .INPUT(ref, TensorType::BasicType())
  1039. .INPUT(value,TensorType::BasicType())
  1040. .OUTPUT(ref, TensorType::BasicType())
  1041. .ATTR(use_locking, Bool, false)
  1042. .OP_END_FACTORY_REG(AssignAdd)
  1043. /**
  1044. *@brief Updates "ref" by assigning "value" to it. \n
  1045. *@par Inputs:
  1046. *@li ref: A Tensor. Must be one of the following types: float16, float32, int8, int16, int32, int64, uint8, uint16, uint32, uint64.
  1047. *@li value: A Tensor of the same type as "ref". \n
  1048. *@par Attributes:
  1049. *@li validate_shape: An optional bool. Defaults to "true".
  1050. If "true", the operation will validate that the shape of "value" matches the shape of the Tensor being assigned to.
  1051. * If "false", "ref" will take on the shape of "value".
  1052. * This attribute is reserved.
  1053. *@li use_locking: An optional bool. Defaults to True.
  1054. If True, the assignment will be protected by a lock;
  1055. otherwise the behavior is undefined, but may exhibit less contention.
  1056. * This attribute is reserved. \n
  1057. *@par Outputs:
  1058. *ref: A Tensor that holds the new value of ref after the value has been assigned. \n
  1059. *@par Third-party framework compatibility
  1060. *Compatible with the TensorFlow operator Assign.
  1061. */
  1062. REG_OP(Assign)
  1063. .INPUT(ref, TensorType::BasicType())
  1064. .INPUT(value,TensorType::BasicType())
  1065. .OUTPUT(ref, TensorType::BasicType())
  1066. .ATTR(validate_shape, Bool, true)
  1067. .ATTR(use_locking, Bool, false)
  1068. .OP_END_FACTORY_REG(Assign)
  1069. /**
  1070. *@brief Updates "var" by subtracting "value" from it.\n
  1071. * This operation outputs "var" after the update is done. \n
  1072. * This makes it easier to chain operations that need to use the reset value. \n
  1073. *
  1074. *@par Inputs:
  1075. *@li var: A tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, qint8, quint8, qint32, uint16, complex128, uint32, uint64
  1076. *@li value: A tensor of the same type as "var".
  1077. *
  1078. *@par Attributes:
  1079. * use_locking: An optional bool. Defaults to "False". If "True", the subtraction will be protected \n
  1080. * by a lock; otherwise the behavior is undefined, but may exhibit less contention.
  1081. *
  1082. *@par Outputs:
  1083. * y: A tensor. Has the same type as "var".
  1084. *
  1085. *@par Third-party framework compatibility
  1086. *Compatible with the TensorFlow operator AssignSub.
  1087. *
  1088. */
  1089. REG_OP(AssignSub)
  1090. .INPUT(var, TensorType::NumberType())
  1091. .INPUT(value,TensorType::NumberType())
  1092. .OUTPUT(var, TensorType::NumberType())
  1093. .ATTR(use_locking, Bool, false)
  1094. .OP_END_FACTORY_REG(AssignSub)
  1095. /**
  1096. *@brief: Computes the backpropagation of the square root operation. \n
  1097. *@par Inputs:
  1098. * Two inputs, including:
  1099. *@li y: An NCHW, NC1HWC0, NHWC, ND Tensor. Must be one of the following types: \
  1100. * float, int32, int8, double, complex64, complex128, half.
  1101. *@li dy: A Tensor of the same type and format as "y". \n
  1102. *@par Outputs:
  1103. *z: A Tensor of the same type and format as "y". \n
  1104. *@see Matmul() | Rsqrt ()
  1105. *@par Third-party framework compatibility
  1106. * Compatible with the TensorFlow operator RsqrtGrad.
  1107. */
  1108. REG_OP(RsqrtGrad)
  1109. .INPUT(y, TensorType({UnaryDataType,int32,int8}))
  1110. .INPUT(dy, TensorType({UnaryDataType,int32,int8}))
  1111. .OUTPUT(z, TensorType({UnaryDataType,int32,int8}))
  1112. .OP_END_FACTORY_REG(RsqrtGrad)
  1113. /**
  1114. *@brief Computes hyperbolic sine of "x" element-wise. \n
  1115. *@par Inputs:
  1116. *x: An NCHW, NC1HWC0, NHWC,or ND Tensor of type float, double, complex64,
  1117. * complex128, half. \n
  1118. *@par Outputs:
  1119. *y: A NCHW, NC1HWC0, NHWC,or ND Tensor of type float, double, complex64,
  1120. * complex128, half. \n
  1121. *@par Third-party framework compatibility
  1122. * Compatible with the TensorFlow operator Sinh. \n
  1123. */
  1124. REG_OP(Sinh)
  1125. .INPUT(x, TensorType::UnaryDataType())
  1126. .OUTPUT(y, TensorType::UnaryDataType())
  1127. .OP_END_FACTORY_REG(Sinh)
  1128. /**
  1129. *@brief: Clips tensor values to a specified min and max. \n
  1130. *@par Inputs:
  1131. * Three inputs, including:
  1132. *@li x: A Tensor of type float32, float64, int32, uint8, int16, int8, complex64, int64,
  1133. *qint8, quint8, qint32, uint16, complex128, float16, uint32, uint64.
  1134. *@li clip_value_min: A Tensor of the same type as "x".
  1135. *@li clip_value_max: A Tensor of the same type as "x". \n
  1136. *@par Outputs:
  1137. *y: A Tensor. Has the same type as "x". \n
  1138. *@par Third-party framework compatibility
  1139. * Compatible with the TensorFlow operator ClipByValue.
  1140. */
  1141. REG_OP(ClipByValue)
  1142. .INPUT(x, TensorType::NumberType())
  1143. .INPUT(clip_value_min, TensorType::NumberType())
  1144. .INPUT(clip_value_max, TensorType::NumberType())
  1145. .OUTPUT(y, TensorType::NumberType())
  1146. .OP_END_FACTORY_REG(ClipByValue)
  1147. /**
  1148. *@brief Computes cosine of "x" element-wise. \n
  1149. *@par Inputs:
  1150. *x: A Tensor of type float16, float32, double, complex64, complex128.
  1151. * the format can be [NCHW,NC1HWC0,NHWC,ND]. \n
  1152. *@par Outputs:
  1153. *y: A Tensor. Has the same type as "x". \n
  1154. *@par Third-party framework compatibility
  1155. * Compatible with the TensorFlow operator Cosh. \n
  1156. */
  1157. REG_OP(Cosh)
  1158. .INPUT(x, TensorType::UnaryDataType())
  1159. .OUTPUT(y, TensorType::UnaryDataType())
  1160. .OP_END_FACTORY_REG(Cosh)
  1161. /**
  1162. *@brief: Returns 0 if the denominator is zero, else, like Div. \n
  1163. *@par Inputs:
  1164. * Two inputs, including:
  1165. *@li x1: A Tensor. Must be one of the following types:float16, float32, int32,
  1166. * int8, uint8, double, the format can be [NCHW,NC1HWC0,NHWC,ND].
  1167. *@li x2: A Tensor of the same type as "x1". \n
  1168. *@par Outputs:
  1169. *y: A Tensor. Has the same type as "x1". \n
  1170. *@par Third-party framework compatibility
  1171. * Compatible with the TensorFlow operator DivNoNan.
  1172. */
  1173. REG_OP(DivNoNan)
  1174. .INPUT(x1, TensorType({DT_FLOAT, DT_UINT8, DT_INT8, DT_INT32, DT_FLOAT16,
  1175. DT_DOUBLE}))
  1176. .INPUT(x2, TensorType({DT_FLOAT, DT_UINT8, DT_INT8, DT_INT32, DT_FLOAT16,
  1177. DT_DOUBLE}))
  1178. .OUTPUT(y, TensorType({DT_FLOAT, DT_UINT8, DT_INT8, DT_INT32, DT_FLOAT16,
  1179. DT_DOUBLE}))
  1180. .OP_END_FACTORY_REG(DivNoNan)
  1181. /**
  1182. *@brief Reverses specific dimensions of a tensor. \n
  1183. *@par Inputs:
  1184. * One input: \n
  1185. *x: A Tensor, Must be one of the following types:
  1186. * int32, uint8, int16, int8, int64, int64, uint16, uint32, uint64,
  1187. * and format can be [NCHW,NC1HWC0,NHWC,ND]
  1188. *@par Outputs:
  1189. *y: A Tensor. Has the same type and format as "x"
  1190. *@par Third-party framework compatibility
  1191. * Compatible with the TensorFlow operator Invert.
  1192. */
  1193. REG_OP(Invert)
  1194. .INPUT(x, TensorType::IntegerDataType())
  1195. .OUTPUT(y, TensorType::IntegerDataType())
  1196. .OP_END_FACTORY_REG(Invert)
  1197. /**
  1198. *@brief Returns a tensor of the same shape and type with all elements set to one.
  1199. *@par Inputs:
  1200. *One input: \n
  1201. *x: A Tensor. Must be one of the following types: float16, float32, int8, uint8,
  1202. * int16, uint16, int32, int64, complex128, bool. \n
  1203. *@par Outputs:
  1204. *y: A Tensor of the same type as "x". \n
  1205. *@par Third-party framework compatibility
  1206. * Compatible with TensorFlow operator OnesLike.
  1207. */
  1208. REG_OP(OnesLike)
  1209. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT8,
  1210. DT_UINT8, DT_INT16, DI_UINT16, DT_INT32,
  1211. DT_INT64, DT_COMPLEX128, DT_BOOL}))
  1212. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT8,
  1213. DT_UINT8, DT_INT16, DI_UINT16, DT_INT32,
  1214. DT_INT64, DT_COMPLEX128, DT_BOOL}))
  1215. .OP_END_FACTORY_REG(OnesLike)
  1216. /**
  1217. *@brief Computes the gradient for the inverse of "x" with regard its input. \n
  1218. *@par Inputs:
  1219. *@li input_y: A Tensor. Must be one of the following types: float, double,
  1220. * complex64, complex128, half.
  1221. *@li input_dy: A Tensor. Must be one of the following types: float, double,
  1222. * complex64, complex128, half. \n
  1223. *@par Outputs:
  1224. *output_data: A Tensor. Must be one of the following types: float, double,
  1225. * complex64, complex128, half. \n
  1226. *@attention Constraints:
  1227. * "input_dy" has the same shape and type as "input_y". \n
  1228. *@par Third-party framework compatibility
  1229. * Compatible with the TensorFlow operator reciprocal_grad.
  1230. */
  1231. REG_OP(ReciprocalGrad)
  1232. .INPUT(y, TensorType::UnaryDataType())
  1233. .INPUT(dy, TensorType::UnaryDataType())
  1234. .OUTPUT(z, TensorType::UnaryDataType())
  1235. .OP_END_FACTORY_REG(ReciprocalGrad)
  1236. /**
  1237. *@brief Returns the truth value of (x1 > x2) element-wise. \n
  1238. *@par Inputs:
  1239. *@li x1: A Tensor of type float16, float32, double, int64, int32, int16, int8,
  1240. * uint8, uint16, uint32, uint64.
  1241. *@li x2: A Tensor of the same data type as "x1". \n
  1242. *@par Outputs:
  1243. *y: A Tensor of type bool.
  1244. *@attention Constraints:
  1245. * Broadcasting is supported. \n
  1246. *@par Third-party framework compatibility
  1247. * Compatible with the TensorFlow operator Greater. \n
  1248. */
  1249. REG_OP(Greater)
  1250. .INPUT(x1, TensorType::RealNumberType())
  1251. .INPUT(x2, TensorType::RealNumberType())
  1252. .OUTPUT(y, TensorType({DT_BOOL}))
  1253. .OP_END_FACTORY_REG(Greater)
  1254. /**
  1255. *@brief Returns a tensor of the same type and shape as the input tensor with all elements set to zero. \n
  1256. *@par Inputs:
  1257. *x: A Tensor. Must be one of the following types:
  1258. * float32, float64, int32, uint8, int16, int8,
  1259. * complex64, int64, qint8, quint8, qint32, qint16, quint16, uint16,
  1260. * complex128, float16, uint32, uint64, complex64, complex128. \n
  1261. *@par Outputs:
  1262. *y: A Tensor of the same data type as "x". \n
  1263. *@attention Constraints:
  1264. * The output has the same shape and type as the input. \n
  1265. *@par Third-party framework compatibility
  1266. * Compatible with the TensorFlow operator zeros_like.
  1267. */
  1268. REG_OP(ZerosLike)
  1269. .INPUT(x, TensorType::BasicType())
  1270. .OUTPUT(y, TensorType::BasicType())
  1271. .OP_END_FACTORY_REG(ZerosLike)
  1272. /**
  1273. *@brief Returns the truth value of NOT "x" element-wise. \n
  1274. *@par Inputs:
  1275. *x: A Tensor of type bool. \n
  1276. *@par Outputs:
  1277. *y: A Tensor of type bool. \n
  1278. *@attention Constraints:
  1279. * The input and output values are "1" or "0", corresponding to bool values "true" and "false". \n
  1280. *@par Third-party framework compatibility
  1281. * Compatible with the TensorFlow operator logical_not.
  1282. */
  1283. REG_OP(LogicalNot)
  1284. .INPUT(x, TensorType({DT_BOOL}))
  1285. .OUTPUT(y, TensorType({DT_BOOL}))
  1286. .OP_END_FACTORY_REG(LogicalNot)
  1287. /**
  1288. *@brief Computes inverse hyperbolic sine of x element-wise.
  1289. * Given an input tensor, this function computes inverse hyperbolic sine for every element in the tensor. \n
  1290. *
  1291. *@par Inputs:
  1292. * x: A tensor. Must be one of the following types: float16, float32, float64, complex64, complex128.
  1293. *
  1294. *@par Outputs:
  1295. * y: A tensor. Has the same type as "x".
  1296. *
  1297. *@par Third-party framework compatibility
  1298. *Compatible with the TensorFlow operator Asinh.
  1299. *
  1300. */
  1301. REG_OP(Asinh)
  1302. .INPUT(x, TensorType::UnaryDataType())
  1303. .OUTPUT(y, TensorType::UnaryDataType())
  1304. .OP_END_FACTORY_REG(Asinh)
  1305. /**
  1306. *@brief Computes gradients for Asinh operation. \n
  1307. *
  1308. *@par Inputs:
  1309. *@li y: A tensor. Must be one of the following types: float16, float32.
  1310. *@li dy: A tensor of the same type as "y"
  1311. *
  1312. *@par Outputs:
  1313. * z: A tensor. Has the same type as "y".
  1314. *
  1315. *@par Third-party framework compatibility
  1316. *Compatible with the TensorFlow operator AsinhGrad.
  1317. *
  1318. */
  1319. REG_OP(AsinhGrad)
  1320. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1321. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  1322. .OUTPUT(z, TensorType({DT_FLOAT16, DT_FLOAT}))
  1323. .OP_END_FACTORY_REG(AsinhGrad)
  1324. /**
  1325. *@brief Computes inverse hyperbolic tangent of x element-wise.\n
  1326. * Given an input tensor, this function computes inverse hyperbolic tangent for every element in the tensor. \n Input range is [-1,1] and output range is [-inf, inf]. If input is -1, \n output will be -inf and if the input is 1, output will be inf.\n Values outside the range will have nan as output. \n
  1327. *
  1328. *@par Inputs:
  1329. * x: A tensor. Must be one of the following types: float16, float32, float64, complex64, complex128.
  1330. *
  1331. *@par Outputs:
  1332. * y: A tensor. Has the same type as "x".
  1333. *
  1334. *@par Third-party framework compatibility
  1335. *Compatible with the TensorFlow operator Atanh.
  1336. *
  1337. */
  1338. REG_OP(Atanh)
  1339. .INPUT(x, TensorType::UnaryDataType())
  1340. .OUTPUT(y, TensorType::UnaryDataType())
  1341. .OP_END_FACTORY_REG(Atanh)
  1342. /**
  1343. *@brief Computes the trignometric inverse tangent of x element-wise.
  1344. * The atan operation returns the inverse of tan, such that if y = tan(x) then, x = atan(y). \n
  1345. *
  1346. *@par Inputs:
  1347. * x: A tensor. Must be one of the following types: float16, float32, float64, complex64, complex128.
  1348. *
  1349. *@par Outputs:
  1350. * y: A tensor. Has the same type as "x". The output of atan will lie within the invertible range of tan, i.e (-pi/2, pi/2).
  1351. *
  1352. *@par Third-party framework compatibility
  1353. *Compatible with the TensorFlow operator Atan.
  1354. *
  1355. */
  1356. REG_OP(Atan)
  1357. .INPUT(x, TensorType::UnaryDataType())
  1358. .OUTPUT(y, TensorType::UnaryDataType())
  1359. .OP_END_FACTORY_REG(Atan)
  1360. /**
  1361. *@brief Computes gradients for Atan operation. \n
  1362. *
  1363. *@par Inputs:
  1364. *@li y: A tensor of type float16 or float32.
  1365. *@li dy: A tensor of the same type as "y"
  1366. *
  1367. *@par Outputs:
  1368. * z: A tensor. Has the same type as "y".
  1369. *
  1370. *@par Third-party framework compatibility
  1371. *Compatible with the TensorFlow operator AtanGrad.
  1372. *
  1373. */
  1374. REG_OP(AtanGrad)
  1375. .INPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1376. .INPUT(dy, TensorType({DT_FLOAT16, DT_FLOAT}))
  1377. .OUTPUT(z, TensorType({DT_FLOAT16, DT_FLOAT}))
  1378. .OP_END_FACTORY_REG(AtanGrad)
  1379. /**
  1380. *@brief Computes arctangent of x1/x2 element-wise, respecting signs of the arguments. \n
  1381. *
  1382. *@par Inputs:
  1383. *@li x1: A tensor. Must be one of the following types: float16, float32, float64
  1384. *@li x2: A tensor of the same type as "x1".
  1385. *
  1386. *@par Outputs:
  1387. * y: A tensor. Has the same type as "x1".
  1388. *
  1389. *@par Third-party framework compatibility
  1390. *Compatible with the TensorFlow operator Atan2.
  1391. *
  1392. */
  1393. REG_OP(Atan2)
  1394. .INPUT(x1, TensorType::FloatingDataType())
  1395. .INPUT(x2, TensorType::FloatingDataType())
  1396. .OUTPUT(y, TensorType::FloatingDataType())
  1397. .OP_END_FACTORY_REG(Atan2)
  1398. /**
  1399. *@brief Returns the truth value of abs(x1-x2) < tolerance element-wise. \n
  1400. *
  1401. *@par Inputs:
  1402. *@li x1: A tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, qint8, quint8, qint32, uint16, complex128, float16, uint32, uint64
  1403. *@li x2: A tensor of the same type as "x1".
  1404. *
  1405. *@par Attributes:
  1406. * tolerance: Defaults to "1e-05".
  1407. *
  1408. *@par Outputs:
  1409. * y: A tensor of type bool.
  1410. *
  1411. *@par Third-party framework compatibility
  1412. *Compatible with the TensorFlow operator ApproximateEqual.
  1413. *
  1414. */
  1415. REG_OP(ApproximateEqual)
  1416. .INPUT(x1, TensorType::NumberType())
  1417. .INPUT(x2, TensorType::NumberType())
  1418. .OUTPUT(y, TensorType({DT_BOOL}))
  1419. .ATTR(tolerance, Float, 1e-5)
  1420. .OP_END_FACTORY_REG(ApproximateEqual)
  1421. /**
  1422. *@brief Returns the element-wise sum of a list of tensors.\n
  1423. * AccumulateNV2 performs the same operation as AddN, but does not wait for all of its inputs
  1424. to be ready before beginning to sum.\n This can save memory if inputs are ready at different times,
  1425. since minimum temporary storage is proportional to the output size rather than the inputs size.
  1426. Returns a Tensor of same shape and type as the elements of inputs. \n
  1427. *
  1428. *@par Inputs:
  1429. *Dynamic inputs, including:
  1430. * x: A tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64,
  1431. qint8, quint8, qint32, uint16, complex128, float16, uint32, uint64. It's a dynamic input. \n
  1432. *
  1433. *@par Outputs:
  1434. * y: A tensor. Has the same type as "x".
  1435. *
  1436. *@par Attributes:
  1437. * N: the size of x.
  1438. *@par Third-party framework compatibility
  1439. *Compatible with the TensorFlow operator AccumulateNV2.
  1440. *
  1441. */
  1442. REG_OP(AccumulateNV2)
  1443. .DYNAMIC_INPUT(x, TensorType::NumberType())
  1444. .OUTPUT(y, TensorType::NumberType())
  1445. .REQUIRED_ATTR(N, Int)
  1446. .OP_END_FACTORY_REG(AccumulateNV2)
  1447. /**
  1448. *@brief Fake-quantizes the input Tensor, type float to output a Tensor of same type.
  1449. * [min, max] define the clamping range for the "inputs" data.\n
  1450. * the values of "x" are quantized into the quantization range ([0, 2^num_bits - 1] \n
  1451. * when "narrow_range" is "false" or [1, 2^num_bits - 1] when it is "true") and \n
  1452. * then de-quantized and output as float32 in [min; max] interval.\n
  1453. * num_bits is the bit width of the quantization, between 2 and 16, inclusive. \n
  1454. * Quantization is called fake since the output is still in floating point. \n
  1455. *@par Inputs:
  1456. *One input:
  1457. *x: A Tensor of type float32. \n
  1458. *@par Attributes:
  1459. *@li min: An optional attribute. Defaults to "-6.0".
  1460. *@li max: An optional attribute. Defaults to "6.0".
  1461. *@li num_bits: An optional attribute. Defaults to "8".
  1462. *@li narrow_range: An optional bool. Defaults to "false". \n
  1463. *@par Outputs:
  1464. *y: A Tensor. Has the same shape and type of "x". \n
  1465. *@par Third-party framework compatibility
  1466. * Compatible with TensorFlow operator FakeQuantWithMinMaxArgs.
  1467. */
  1468. REG_OP(FakeQuantWithMinMaxArgs)
  1469. .INPUT(x, TensorType({DT_FLOAT}))
  1470. .OUTPUT(y, TensorType({DT_FLOAT}))
  1471. .ATTR(min, Float, -6.0)
  1472. .ATTR(max, Float, 6.0)
  1473. .ATTR(num_bits, Int, 8)
  1474. .ATTR(narrow_range, Bool, false)
  1475. .OP_END_FACTORY_REG(FakeQuantWithMinMaxArgs)
  1476. /**
  1477. *@brief Computes gradients for a FakeQuantWithMinMaxArgs operation. \n
  1478. *@par Inputs:
  1479. *Two inputs, including: \n
  1480. *@li gradients: A Tensor of type float32. Backpropagated gradients above the FakeQuantWithMinMaxArgs operation.
  1481. *@li x: A Tensor of type float32. Has the same type and format as "gradients".\n
  1482. * This is the input Tensor of the FakeQuantWithMinMaxArgs operator.\n
  1483. *@par Attributes:
  1484. *@li min: An optional attribute. Defaults to "-6.0".
  1485. *@li max: An optional attribute. Defaults to "6.0".
  1486. *@li num_bits: An optional attribute. Defaults to "8".
  1487. *@li narrow_range: An optional bool. Defaults to "False". \n
  1488. *@par Outputs:
  1489. *y: A Tensor of type float32. \n
  1490. *@par Third-party framework compatibility
  1491. * Compatible with TensorFlow operator FakeQuantWithMinMaxArgsGradient.
  1492. */
  1493. REG_OP(FakeQuantWithMinMaxArgsGradient)
  1494. .INPUT(gradients, TensorType({DT_FLOAT}))
  1495. .INPUT(x, TensorType({DT_FLOAT}))
  1496. .OUTPUT(y, TensorType({DT_FLOAT}))
  1497. .ATTR(min, Float, -6.0)
  1498. .ATTR(max, Float, 6.0)
  1499. .ATTR(num_bits, Int, 8)
  1500. .ATTR(narrow_range, Bool, false)
  1501. .OP_END_FACTORY_REG(FakeQuantWithMinMaxArgsGradient)
  1502. /**
  1503. *@brief Fake-quantize the 'inputs' tensor of type float via global float scalars. \n
  1504. *@par Inputs:
  1505. *Three inputs, including:
  1506. *@li x: A Tensor of type float32.
  1507. *@li min: A Tensor of type float32. Has the same type and format as "x".
  1508. *@li max: A Tensor of type float32. Has the same type and format as "x".\n
  1509. *[min; max] define the clamping range for the inputs data
  1510. *@par Attributes:
  1511. *@li num_bits: An optional attribute. Defaults to "8".
  1512. *@li narrow_range: An optional bool. Defaults to "False". \n
  1513. *@par Outputs:
  1514. *y: A Tensor of type float32. \n
  1515. *@par Third-party framework compatibility
  1516. * Compatible with TensorFlow operator FakeQuantWithMinMaxVars.
  1517. */
  1518. REG_OP(FakeQuantWithMinMaxVars)
  1519. .INPUT(x, TensorType({DT_FLOAT}))
  1520. .INPUT(min, TensorType({DT_FLOAT}))
  1521. .INPUT(max, TensorType({DT_FLOAT}))
  1522. .OUTPUT(y, TensorType({DT_FLOAT}))
  1523. .ATTR(num_bits, Int, 8)
  1524. .ATTR(narrow_range, Bool, false)
  1525. .OP_END_FACTORY_REG(FakeQuantWithMinMaxVars)
  1526. /**
  1527. *@brief Computes gradients for a FakeQuantWithMinMaxVars operation. \n
  1528. *@par Inputs:
  1529. *Four inputs, including:
  1530. *@li gradients: A Tensor of type float32.
  1531. *@li x: A Tensor of type float32.
  1532. *@li min: A Tensor of type float32.
  1533. *@li max: A Tensor of type float32. \n
  1534. *@par Attributes:
  1535. *@li num_bits: An integer specifying the quantization bit width. Defaults to "8".
  1536. *@li narrow_range: A Boolean specifying whether to use a narrow range for quantization. Defaults to "False". \n
  1537. *@par Outputs:
  1538. *@li backprops_wrt_x: A Tensor. Has the same type as input "x".
  1539. *@li backprops_wrt_min: A Tensor. Has the same type as input "min".
  1540. *@li backprops_wrt_max: A Tensor. Has the same type as input "max". \n
  1541. *@attention Constraints:
  1542. *@li "gradients" has the same shape as "x".
  1543. *@li "min" and "max" are scalars.
  1544. *@li "num_bits" is between 2 and 16
  1545. *@see Region()
  1546. *@par Third-party framework compatibility
  1547. * Compatible with the operator FakeQuantWithMinMaxVarsGradient.
  1548. */
  1549. REG_OP(FakeQuantWithMinMaxVarsGradient)
  1550. .INPUT(gradients, TensorType({DT_FLOAT}))
  1551. .INPUT(x, TensorType({DT_FLOAT}))
  1552. .INPUT(min, TensorType({DT_FLOAT}))
  1553. .INPUT(max, TensorType({DT_FLOAT}))
  1554. .OUTPUT(backprops_wrt_x, TensorType({DT_FLOAT}))
  1555. .OUTPUT(backprops_wrt_min, TensorType({DT_FLOAT}))
  1556. .OUTPUT(backprops_wrt_max, TensorType({DT_FLOAT}))
  1557. .ATTR(num_bits, Int, 8)
  1558. .ATTR(narrow_range, Bool, false)
  1559. .OP_END_FACTORY_REG(FakeQuantWithMinMaxVarsGradient)
  1560. /**
  1561. *@brief Fake-quantizes the "inputs" tensor of type float
  1562. via per-channel floats min and max of shape [d] to "outputs" \n
  1563. tensor of same shape as inputs
  1564. *@par Inputs:
  1565. *Three inputs, including:
  1566. *@li x: A Tensor of type float32.
  1567. *@li min: A Tensor of type float32.
  1568. *@li max: A Tensor of type float32. \n
  1569. *@par Attributes:
  1570. *@li num_bits: An integer specifying the quantization bit width. Defaults to "8".
  1571. *@li narrow_range: A Boolean specifying whether to use a narrow range for quantization. Defaults to "False". \n
  1572. *@par Outputs:
  1573. *y: A Tensor. Has the same type as input "x".
  1574. *@attention Constraints:
  1575. *@li "min" and "max" have one-dimensional shapes.
  1576. *@li "min" has the same last dimension size as "x". "max" has the same last dimension size as "x".
  1577. *@li "num_bits" is between 2 and 16
  1578. *@see Region()
  1579. *@par Third-party framework compatibility
  1580. * Compatible with the TensorFlow operator FakeQuantWithMinMaxVarsPerChannel.
  1581. */
  1582. REG_OP(FakeQuantWithMinMaxVarsPerChannel)
  1583. .INPUT(x, TensorType({DT_FLOAT}))
  1584. .INPUT(min, TensorType({DT_FLOAT}))
  1585. .INPUT(max, TensorType({DT_FLOAT}))
  1586. .OUTPUT(y, TensorType({DT_FLOAT}))
  1587. .ATTR(num_bits, Int, 8)
  1588. .ATTR(narrow_range, Bool, false)
  1589. .OP_END_FACTORY_REG(FakeQuantWithMinMaxVarsPerChannel)
  1590. /**
  1591. *@brief Computes gradients for a FakeQuantWithMinMaxVarsPerChannel operation. \n
  1592. *@par Inputs:
  1593. *Four inputs, including:
  1594. *@li gradients: A Tensor of type float32.
  1595. *@li x: A Tensor of type float32.
  1596. *@li min: A Tensor of type float32.
  1597. *@li max: A Tensor of type float32. \n
  1598. *@par Attributes:
  1599. *@li num_bits: An integer specifying the quantization bit width. Defaults to "8".
  1600. *@li narrow_range: A Boolean specifying whether to use a narrow range for quantization. Defaults to "False". \n
  1601. *@par Outputs:
  1602. *@li backprops_wrt_x: A Tensor. Has the same type as input "x".
  1603. *@li backprops_wrt_min: A Tensor. Has the same type as input "min".
  1604. *@li backprops_wrt_max: A Tensor. Has the same type as input "max". \n
  1605. *@attention Constraints:
  1606. *@li "gradients" has the same shape as "x".
  1607. *@li "min" and "max" have one-dimensional shapes.
  1608. *@li "min" has the same last dimension size as "x". "max" has the same last dimension size as "x". "gradients" has the same last dimension size as "x".
  1609. *@li "num_bits" is between 2 and 16
  1610. *@see Region()
  1611. *@par Third-party framework compatibility
  1612. * Compatible with the TensorFlow operator FakeQuantWithMinMaxVarsPerChannelGradient.
  1613. */
  1614. REG_OP(FakeQuantWithMinMaxVarsPerChannelGradient)
  1615. .INPUT(gradients, TensorType({DT_FLOAT}))
  1616. .INPUT(x, TensorType({DT_FLOAT}))
  1617. .INPUT(min, TensorType({DT_FLOAT}))
  1618. .INPUT(max, TensorType({DT_FLOAT}))
  1619. .OUTPUT(backprops_wrt_x, TensorType({DT_FLOAT}))
  1620. .OUTPUT(backprops_wrt_min, TensorType({DT_FLOAT}))
  1621. .OUTPUT(backprops_wrt_max, TensorType({DT_FLOAT}))
  1622. .ATTR(num_bits, Int, 8)
  1623. .ATTR(narrow_range, Bool, false)
  1624. .OP_END_FACTORY_REG(FakeQuantWithMinMaxVarsPerChannelGradient)
  1625. /**
  1626. *@brief Element-wise computes the bitwise AND of "x1" and "x2". \n
  1627. *@par Inputs:
  1628. *Two inputs, including:
  1629. * @li x1: A Tensor. Must be one of the following types: int8, int16,
  1630. * int32, int64, uint8, uint16, uint32, uint64. Broadcasting is supported.
  1631. * @li x2: A Tensor of the same type as "x1". \n
  1632. *@par Outputs:
  1633. *y: A Tensor. Has the same type as "x1". \n
  1634. *@par Third-party framework compatibility
  1635. *Compatible with the TensorFlow operator BitwiseAnd.
  1636. */
  1637. REG_OP(BitwiseAnd)
  1638. .INPUT(x1, TensorType::IntegerDataType())
  1639. .INPUT(x2, TensorType::IntegerDataType())
  1640. .OUTPUT(y, TensorType::IntegerDataType())
  1641. .OP_END_FACTORY_REG(BitwiseAnd)
  1642. /**
  1643. *@brief Element-wise computes the bitwise OR of "x1" and "x2". \n
  1644. *@par Inputs:
  1645. *Two inputs, including:
  1646. * @li x1: A Tensor. Must be one of the following types: int8, int16,
  1647. * int32, int64, uint8, uint16, uint32, uint64. Broadcasting is supported.
  1648. * @li x2: A Tensor of the same type as "x1". \n
  1649. *@par Outputs:
  1650. *y: A Tensor. Has the same type as "x1". \n
  1651. *@par Third-party framework compatibility
  1652. *Compatible with the TensorFlow operator BitwiseOr.
  1653. */
  1654. REG_OP(BitwiseOr)
  1655. .INPUT(x1, TensorType::IntegerDataType())
  1656. .INPUT(x2, TensorType::IntegerDataType())
  1657. .OUTPUT(y, TensorType::IntegerDataType())
  1658. .OP_END_FACTORY_REG(BitwiseOr)
  1659. /**
  1660. *@brief Elementwise computes the bitwise XOR of "x1" and "x2". \n
  1661. *@par Inputs:
  1662. *Two inputs, including:
  1663. *@li x1: A Tensor. Must be one of the following types: int8, int16, int32, int64, uint8, uint16, uint32, uint64.
  1664. * The format is NC1HWC0 or ND. Broadcasting is supported.
  1665. *@li x2: A Tensor. Has the same type and format as "x1". \n
  1666. *@par Outputs:
  1667. *y: Output result. Has the same type as "x1". \n
  1668. *@par Third-party framework compatibility
  1669. * Compatible with TensorFlow operator BitwiseXor.
  1670. */
  1671. REG_OP(BitwiseXor)
  1672. .INPUT(x1, TensorType::IntegerDataType())
  1673. .INPUT(x2, TensorType::IntegerDataType())
  1674. .OUTPUT(y, TensorType::IntegerDataType())
  1675. .OP_END_FACTORY_REG(BitwiseXor)
  1676. /**
  1677. *@brief Returns element-wise smallest integer not less than "x". \n
  1678. *@par Inputs:
  1679. * x: A Tensor of type float16 or float32 or float64. \n
  1680. *@par Outputs:
  1681. *y: A Tensor. Has the same type as "x".
  1682. *@par Third-party framework compatibility
  1683. *Compatible with the TensorFlow operator Ceil.
  1684. */
  1685. REG_OP(Ceil)
  1686. .INPUT(x, TensorType::FloatingDataType())
  1687. .OUTPUT(y, TensorType::FloatingDataType())
  1688. .OP_END_FACTORY_REG(Ceil)
  1689. /**
  1690. *@brief Returns element-wise largest integer not greater than "x". \n
  1691. *@par Inputs:
  1692. *x: A Tensor of type float16, float32 or double. \n
  1693. *@par Outputs:
  1694. *y: A Tensor of the same type as "x". \n
  1695. *@par Third-party framework compatibility:
  1696. * Compatible with TensorFlow operator Floor.
  1697. */
  1698. REG_OP(Floor)
  1699. .INPUT(x, TensorType::FloatingDataType())
  1700. .OUTPUT(y, TensorType::FloatingDataType())
  1701. .OP_END_FACTORY_REG(Floor)
  1702. /**
  1703. *@brief Divides "x1/x2" element-wise, rounding toward the
  1704. * most negative integer. \n
  1705. *@par Inputs:
  1706. *Two inputs, including:
  1707. * @li x1: A Tensor. Must be one of the following types: float16, float32, int32, int64, int8,
  1708. * uint8, int16, uint16, double, complex64, complex128.
  1709. * @li x2: A Tensor of the same type as "x1". \n
  1710. *@par Outputs:
  1711. *y: A Tensor. Has the same type as "x1". \n
  1712. *@par Third-party framework compatibility
  1713. * Compatible with the TensorFlow operator FloorDiv.
  1714. */
  1715. REG_OP(FloorDiv)
  1716. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8,
  1717. DT_INT64, DT_INT16, DT_UINT16, DT_DOUBLE,
  1718. DT_COMPLEX64, DT_COMPLEX128}))
  1719. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8,
  1720. DT_INT64, DT_INT16,DT_UINT16, DT_DOUBLE,
  1721. DT_COMPLEX64, DT_COMPLEX128}))
  1722. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8,
  1723. DT_INT64, DT_INT16,DT_UINT16, DT_DOUBLE,
  1724. DT_COMPLEX64, DT_COMPLEX128}))
  1725. .OP_END_FACTORY_REG(FloorDiv)
  1726. /**
  1727. *@brief Returns element-wise remainder of division. Consistent with: floor(x1/x2) * x2 + mod(x1, x2) = x1. \n
  1728. *@par Inputs:
  1729. * Two inputs, including:
  1730. *@li x1: A Tensor. Must be one of the following types:
  1731. * int32, int64, float, float16, double
  1732. *@li x2: A Tensor. Must have the same type as "x1".
  1733. *
  1734. *@par Outputs:
  1735. *y: Result remainder.
  1736. *@attention Constraints:
  1737. *@li x2: The input data does not support 0
  1738. *@li When NUM exceeds 2048 , the accuracy of operator cannot guarantee the
  1739. *requirement of double thousandths in the mini form
  1740. *@li Due to different architectures, the calculation results of this operator
  1741. *on NPU and CPU may be inconsistent
  1742. *@li If shape is expressed as (D1,D2... ,Dn), then D1*D2... *DN<=1000000,n<=8
  1743. *@par Third-party framework compatibility
  1744. * Compatible with the TensorFlow operator FloorMod.
  1745. */
  1746. REG_OP(FloorMod)
  1747. .INPUT(x1, TensorType({DT_INT32, DT_INT64, DT_FLOAT, DT_FLOAT16,
  1748. DT_DOUBLE}))
  1749. .INPUT(x2, TensorType({DT_INT32, DT_INT64, DT_FLOAT, DT_FLOAT16,
  1750. DT_DOUBLE}))
  1751. .OUTPUT(y, TensorType({DT_INT32, DT_INT64, DT_FLOAT, DT_FLOAT16,
  1752. DT_DOUBLE}))
  1753. .OP_END_FACTORY_REG(FloorMod)
  1754. /**
  1755. *@brief Computes the power of "x1" to "x2". \n
  1756. *@par Inputs:
  1757. *Two inputs, including:
  1758. * @li x1: A Tensor. Must be one of the following types:
  1759. * float16, float32, int32, int64, int8, uint8, double, complex64, complex128.
  1760. * @li x2: A Tensor of the same type as "x1". \n
  1761. *@par Outputs:
  1762. *y: A Tensor. Has the same type as "x1". \n
  1763. *@par Third-party framework compatibility
  1764. *Compatible with the TensorFlow operator Pow.
  1765. */
  1766. REG_OP(Pow)
  1767. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64, DT_INT8,
  1768. DT_UINT8, DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128}))
  1769. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64, DT_INT8,
  1770. DT_UINT8, DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128}))
  1771. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64, DT_INT8,
  1772. DT_UINT8, DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128}))
  1773. .OP_END_FACTORY_REG(Pow)
  1774. /**
  1775. *@brief Return element-wise integer closest to x. \n
  1776. *@par Inputs:
  1777. *One input, include:
  1778. *x: A mutable Tensor. Must be one of the following types:
  1779. * float16, float32, double. \n
  1780. *@par Outputs:
  1781. *y: A mutable Tensor. Has the same type as "x". \n
  1782. *@par Third-party framework compatibility
  1783. * Compatible with the TensorFlow operator Rint.
  1784. */
  1785. REG_OP(Rint)
  1786. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1787. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1788. .OP_END_FACTORY_REG(Rint)
  1789. /**
  1790. *@brief Rounds the values of a tensor to the nearest integer, element-wise.
  1791. * Rounds half to even. \n
  1792. *@par Inputs:
  1793. *Inputs including:
  1794. *x: A required ND Tensor of type float16, float, int64, double, complex64,
  1795. * complex128 or int32.
  1796. *@par Outputs:
  1797. *y: A required ND Tensor. Has the same data type and shape as "x".
  1798. *@par Third-party framework compatibility
  1799. * Compatible with the TensorFlow operator Round.
  1800. */
  1801. REG_OP(Round)
  1802. .INPUT(x, TensorType(DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64,
  1803. DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128))
  1804. .OUTPUT(y, TensorType(DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64,
  1805. DT_DOUBLE, DT_COMPLEX64, DT_COMPLEX128))
  1806. .OP_END_FACTORY_REG(Round)
  1807. /**
  1808. *@brief: Computes sine of "x" element-wise. \n
  1809. *@par Inputs:
  1810. *One input:
  1811. *x: An ND Tensor. Must be one of the following types: float16, float32, double,
  1812. * complex64, complex128, int32, int64
  1813. *@par Outputs:
  1814. *y: An ND Tensor. Has the same type as "x". \n
  1815. *@par Third-party framework compatibility
  1816. * Compatible with TensorFlow operator Sin.
  1817. */
  1818. REG_OP(Sin)
  1819. .INPUT(x, TensorType::UnaryDataType())
  1820. .OUTPUT(y, TensorType::UnaryDataType())
  1821. .OP_END_FACTORY_REG(Sin)
  1822. /**
  1823. *@brief: Computes tan of "x" element-wise. \n
  1824. *@par Inputs:
  1825. *One input:
  1826. *x: A Tensor. Must be one of the following types: float16, float32, double, complex64, complex128, int32, int64
  1827. *@par Outputs:
  1828. *y: A Tensor. Has the same type as "x". \n
  1829. *@par Third-party framework compatibility
  1830. * Compatible with TensorFlow operator Tan.
  1831. */
  1832. REG_OP(Tan)
  1833. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_COMPLEX64,
  1834. DT_COMPLEX128, DT_INT32, DT_INT64}))
  1835. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_COMPLEX64,
  1836. DT_COMPLEX128, DT_INT32, DT_INT64}))
  1837. .OP_END_FACTORY_REG(Tan)
  1838. /**
  1839. *@brief Returns element-wise remainder of division. \n
  1840. *@par Inputs:
  1841. *Two inputs, including:
  1842. * @li x1: A Tensor. Must be one of the following types: float16, float32,
  1843. * double, int32, int64.
  1844. * @li x2: A Tensor of the same type as "x1". \n
  1845. *@par Outputs:
  1846. *y: A Tensor. Has the same type as "x1". \n
  1847. *@attention Constraints:
  1848. *@li x2: The input data does not support 0
  1849. *@li When NUM exceeds 2048 , the accuracy of operator cannot guarantee the
  1850. *requirement of double thousandths in the mini form
  1851. *@li Due to different architectures, the calculation results of this operator
  1852. *on NPU and CPU may be inconsistent
  1853. *@li If shape is expressed as (D1,D2... ,Dn), then D1*D2... *DN<=1000000,n<=8
  1854. *@par Third-party framework compatibility
  1855. *@li Compatible with the TensorFlow operator TruncateMod.
  1856. */
  1857. REG_OP(TruncateMod)
  1858. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT64,
  1859. DT_INT32}))
  1860. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT64,
  1861. DT_INT32}))
  1862. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT64,
  1863. DT_INT32}))
  1864. .OP_END_FACTORY_REG(TruncateMod)
  1865. /**
  1866. *@brief Adds 'bias' to 'x'. \n
  1867. *@par Inputs:
  1868. *Two inputs, including:
  1869. * @li x: A Tensor of type NumberType. Must be one of the following types: float32, float64, int32, uint8, int16,
  1870. *int8, complex64, int64, qint8, quint8, qint32, bfloat16, uint16, complex128, float16, uint32, uint64.
  1871. * @li bias: A 1D Tensor with size the C dimension of value. \n
  1872. *@par Attributes:
  1873. *data_format: An optional string. Defaults to "NHWC". \n
  1874. *@par Outputs:
  1875. *y: A Tensor with same type as "x". \n
  1876. *@par Third-party framework compatibility
  1877. *Compatible with the TensorFlow operator BiasAdd.
  1878. */
  1879. REG_OP(BiasAdd)
  1880. .INPUT(x, TensorType::NumberType())
  1881. .INPUT(bias, TensorType::NumberType())
  1882. .OUTPUT(y, TensorType::NumberType())
  1883. .ATTR(data_format, String, "NHWC")
  1884. .OP_END_FACTORY_REG(BiasAdd)
  1885. /**
  1886. *@brief Returns the index with the smallest value across dimensions of a tensor. \n
  1887. *@par Inputs:
  1888. *Two inputs, including:
  1889. *@li x: A Tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, qint8, quint8, qint32, bfloat16, uint16, complex128, float16, uint32, uint64.
  1890. *format is ND.
  1891. *@li dimension: A Tensor. Must be one of the following types: int32, int64. Must be in the range [-rank(input x), rank(input x)]. Describes which dimension of the input Tensor to reduce across.
  1892. * The format is ND.
  1893. *@par Attributes:
  1894. *dtype: The output type, either "int32" or "int64". Defaults to "int64". \n
  1895. *@par Outputs:
  1896. *y: A Tensor of type "dtype". \n
  1897. *@par Third-party framework compatibility
  1898. * Compatible with TensorFlow operator ArgMin.
  1899. */
  1900. REG_OP(ArgMin)
  1901. .INPUT(x, TensorType::NumberType())
  1902. .INPUT(dimension, TensorType::IndexNumberType())
  1903. .OUTPUT(y, TensorType({DT_INT32, DT_INT64}))
  1904. .ATTR(dtype, Type, DT_INT64)
  1905. .OP_END_FACTORY_REG(ArgMin)
  1906. /**
  1907. *@brief Returns the index with the smallest value across dimensions of a tensor. \n
  1908. *@par Inputs:
  1909. *One input:
  1910. *x: A Tensor of type float16 or float32 in ND format. \n
  1911. *@par Attributes:
  1912. *@li dimension: The dimension of the input Tensor to reduce across.
  1913. *@li dtype: An optional attribute, specifying the output data type. Must be "int32". Defaults to "int64". \n
  1914. *@par Outputs:
  1915. *y: A Tensor of type dtype. \n
  1916. *@par Third-party framework compatibility
  1917. * Compatible with TensorFlow operator ArgMin.
  1918. *
  1919. * @par Restrictions:
  1920. * Warning: THIS FUNCTION IS DEPRECATED. Please use ArgMin instead.
  1921. */
  1922. REG_OP(ArgMinD)
  1923. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16}))
  1924. .OUTPUT(y, TensorType({DT_INT32}))
  1925. .REQUIRED_ATTR(dimension, Int)
  1926. .ATTR(dtype, Type, DT_INT64)
  1927. .OP_END_FACTORY_REG(ArgMinD)
  1928. /**
  1929. *@brief Returns the index with the largest value across axes of a tensor. \n
  1930. *@par Inputs:
  1931. * Two inputs, including:
  1932. *@li x: A multi-dimensional Tensor of type float16, float32, or int16.
  1933. *@li dimension: A Scalar of type int32, specifying the index with the largest value. \n
  1934. *@par Attributes:
  1935. *dtype: The output type, either "int32" or "int64". Defaults to "int64". \n
  1936. *@par Outputs:
  1937. *y: A multi-dimensional Tensor of type int32 or int64, specifying the index with the largest value. The dimension is one less than that of "x". \n
  1938. *@attention Constraints:
  1939. *@li x: If there are multiple maximum values, the index of the first maximum value is used.
  1940. *@li The value range of "dimension" is [-dims, dims - 1]. "dims" is the dimension length of "x". \n
  1941. *@par Third-party framework compatibility
  1942. * Compatible with TensorFlow operator ArgMax.
  1943. */
  1944. REG_OP(ArgMaxV2)
  1945. .INPUT(x, TensorType::NumberType())
  1946. .INPUT(dimension, TensorType::IndexNumberType())
  1947. .OUTPUT(y, TensorType({DT_INT32, DT_INT64}))
  1948. .ATTR(dtype, Type, DT_INT64)
  1949. .OP_END_FACTORY_REG(ArgMaxV2)
  1950. /**
  1951. *@brief Returns the index with the largest value across axes of a tensor. \n
  1952. *@par Inputs:
  1953. * One input, including:
  1954. *x: A multi-dimensional Tensor of type float16, float32. \n
  1955. *@par Attributes:
  1956. *@li dimension: An integer of type int32, specifying the axis information of the index with the maximum value.
  1957. *@li dtype: The output type, either "int32" or "int64". Defaults to "int64". \n
  1958. *@par Outputs:
  1959. *y: A multi-dimensional Tensor of type int32, specifying the index with the largest value. The dimension is one less than that of "x". \n
  1960. *@attention Constraints:
  1961. *@li x: If there are multiple maximum values, the index of the first maximum value is used.
  1962. *@li The value range of "dimension" is [-dims, dims - 1]. "dims" is the dimension length of "x". \n
  1963. *@par Third-party framework compatibility
  1964. * Compatible with TensorFlow operator ArgMax.
  1965. *
  1966. * @par Restrictions:
  1967. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1968. */
  1969. REG_OP(ArgMaxD)
  1970. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16}))
  1971. .OUTPUT(y, TensorType({DT_INT32}))
  1972. .REQUIRED_ATTR(dimension, Int)
  1973. .ATTR(dtype, Type, DT_INT64)
  1974. .OP_END_FACTORY_REG(ArgMaxD)
  1975. /**
  1976. *@brief Returns the maximum value of all elements in the input in the given
  1977. * dimension. \n
  1978. *@par Inputs:
  1979. *One input: \n
  1980. *x: A multi-dimensional Tensor of type float16 or float32. \n
  1981. *@par Attributes:
  1982. *@li dimension: An integer of type int32, specifying the axis information of
  1983. * the index with the maximum value.
  1984. *@li keep_dims: A bool, specifying whether to keep dimensions for the output
  1985. * Tensor. Defaults to "false". \n
  1986. *@par Outputs:
  1987. *@li indice: A multi-dimensional Tensor of type int32, specifying the index.
  1988. * (If "keep_dims" is set to "false", the output dimensions are reduced by
  1989. * "dimension" compared with that of "x". Otherwise, the output has one fewer
  1990. * dimension than "x".)
  1991. *@li values: A Tensor, specifying the maximum value. Has the same dimensions
  1992. * as "indice" and the same type as "x". \n
  1993. *@attention Constraints:
  1994. *@li If there are multiple maximum values, the index of the first maximum
  1995. * value is used.
  1996. *@li The value range of "dimension" is [-dims, dims - 1]. "dims" is the
  1997. * dimension length of "x". \n
  1998. *@par Third-party framework compatibility
  1999. * Compatible with the two output scenarios of PyTorch operator Max (the output
  2000. * sequence is opposite to that of PyTorch).
  2001. */
  2002. REG_OP(ArgMaxWithValue)
  2003. .INPUT(x, TensorType({DT_FLOAT,DT_FLOAT16}))
  2004. .OUTPUT(indice,TensorType({DT_INT32}))
  2005. .OUTPUT(values, TensorType({DT_FLOAT,DT_FLOAT16}))
  2006. .REQUIRED_ATTR(dimension, Int)
  2007. .ATTR(keep_dims, Bool, false)
  2008. .OP_END_FACTORY_REG(ArgMaxWithValue)
  2009. /**
  2010. *@par Inputs:
  2011. *One input: \n
  2012. *x: A multi-dimensional Tensor of type float16 or float32. \n
  2013. *@par Attributes:
  2014. *@li dimension: An integer of type int32, specifying the axis information of
  2015. * the index with the maximum value.
  2016. *@li keep_dims: A bool, specifying whether to keep dimensions for the output
  2017. * Tensor. Defaults to "false". \n
  2018. *@par Outputs:
  2019. *@li indice: A multi-dimensional Tensor of type int32, specifying the index.
  2020. * (If "keep_dims" is set to "false", the output dimensions are reduced by
  2021. * "dimension" compared with that of "x". Otherwise, the output has one fewer
  2022. * dimension than "x".)
  2023. *@li values: A Tensor, specifying the minimum value. Has the same dimensions
  2024. * as "indice" and the same type as "x". \n
  2025. *@attention Constraints:
  2026. *@li If there are multiple minimum values, the index of the first minimum
  2027. * value is used.
  2028. *@li The value range of "dimension" is [-dims, dims - 1]. "dims" is the
  2029. * dimension length of "x".
  2030. *@li Performing the ArgMinWithValue operation on the last axis of float32 data
  2031. * is not supported on a mini platform. \n
  2032. *@par Third-party framework compatibility
  2033. * Compatible with the two output scenarios of PyTorch operator Min (the output
  2034. * sequence is opposite to that of PyTorch).
  2035. */
  2036. REG_OP(ArgMinWithValue)
  2037. .INPUT(x, TensorType({DT_FLOAT,DT_FLOAT16}))
  2038. .OUTPUT(indice,TensorType({DT_INT32}))
  2039. .OUTPUT(values, TensorType({DT_FLOAT,DT_FLOAT16}))
  2040. .REQUIRED_ATTR(dimension, Int)
  2041. .ATTR(keep_dims, Bool, false)
  2042. .OP_END_FACTORY_REG(ArgMinWithValue)
  2043. /**
  2044. *@brief Compute elementwise modes, such as 0: PRODUCT, 1: SUM, 2: MAX
  2045. *@par Inputs:
  2046. *One input: \n
  2047. *x: the list of input data, the type of element in Tensor should be same.
  2048. * the max size of x is 32.
  2049. * should met one of the following types: float16, float32. It's a dynamic input. \n
  2050. *@par Outputs:
  2051. *y: A Tensor. Has the same type and format as "x". \n
  2052. *@par Attributes:
  2053. *@li N: A required attribute. the number of input x, max size is 32. Type is int.
  2054. *@li model: An optional attribute. Type is int. Defaults to "1".
  2055. * "0": product, "1": sum, "2": max.
  2056. *@li coeff: A required attribute. Must met all of following rules:
  2057. * size of "coeff" must be equal to len("x") or is null.
  2058. * the absolute value of "coeff" must less than or equal to 1.
  2059. */
  2060. REG_OP(Eltwise)
  2061. .DYNAMIC_INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  2062. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  2063. .REQUIRED_ATTR(N, Int)
  2064. .ATTR(mode, Int, 1)
  2065. .ATTR(coeff, ListFloat, {})
  2066. .OP_END_FACTORY_REG(Eltwise)
  2067. /**
  2068. *@brief Computes the inverse error function of each element of input. \n
  2069. *@par Inputs:
  2070. *One inputs, including:
  2071. * @li input_x: A tensor. Must be one of the following types:
  2072. * float16, float32. \n
  2073. *@par Outputs:
  2074. *y: A Tensor with the same type and shape of input_x's. \n
  2075. *@par Third-party framework compatibility
  2076. *Compatible with the Pytorch operator Erfinv. \n
  2077. */
  2078. REG_OP(Erfinv)
  2079. .INPUT(input_x, TensorType({DT_FLOAT, DT_FLOAT16}))
  2080. .OUTPUT(output_y, TensorType({DT_FLOAT, DT_FLOAT16}))
  2081. .OP_END_FACTORY_REG(Erfinv)
  2082. /**
  2083. *@brief Computes element-wise population count. \n
  2084. *@par Inputs:
  2085. *x: A Tensor of type TensorType::IntegerDataType(). \n
  2086. *@par Outputs:
  2087. *y: A Tensor of type uint8. \n
  2088. *@par Third-party framework compatibility
  2089. * Compatible with the TensorFlow operator PopulationCount.
  2090. */
  2091. REG_OP(PopulationCount)
  2092. .INPUT(x, TensorType::IntegerDataType())
  2093. .OUTPUT(y, TensorType({DT_UINT8}))
  2094. .OP_END_FACTORY_REG(PopulationCount)
  2095. /**
  2096. *@brief A fusion operator for bert lamb. \n
  2097. *@par Inputs:
  2098. *Thirteen inputs, including:
  2099. * @li input_mul3: A Tensor. Must be one of the following types: float16, float32.
  2100. * @li input_mul2: A Tensor. Must be one of the following types: float16, float32.
  2101. * @li input_realdiv1: A Tensor. Must be one of the following types: float16, float32.
  2102. * @li input_mul1: A Tensor. Must be one of the following types: float16, float32.
  2103. * @li input_mul0: A Tensor. Must be one of the following types: float16, float32.
  2104. * @li input_realdiv0: A Tensor. Must be one of the following types: float16, float32.
  2105. * @li input_mul4: A Tensor. Must be one of the following types: float16, float32.
  2106. * @li mul0_x: A Tensor. Must be one of the following types: float16, float32.
  2107. * @li mul1_sub: A Tensor. Must be one of the following types: float16, float32.
  2108. * @li mul2_x: A Tensor. Must be one of the following types: float16, float32.
  2109. * @li mul3_sub1: A Tensor. Must be one of the following types: float16, float32.
  2110. * @li mul4_x: A Tensor. Must be one of the following types: float16, float32.
  2111. * @li add2_y: A Tensor. Must be one of the following types: float16, float32. \n
  2112. *@par Outputs:
  2113. *Four outputs, including:
  2114. * @li y1: A Tensor. Must be one of the following types: float16, float32.
  2115. * @li y2: A Tensor. Must be one of the following types: float16, float32.
  2116. * @li y3: A Tensor. Must be one of the following types: float16, float32.
  2117. * @li y4: A Tensor. Must be one of the following types: float16, float32. \n
  2118. *@par Restrictions:
  2119. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2120. */
  2121. REG_OP(LambNextMVWithDecay)
  2122. .INPUT(input_mul3, TensorType({DT_FLOAT16,DT_FLOAT}))
  2123. .INPUT(input_mul2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2124. .INPUT(input_realdiv1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2125. .INPUT(input_mul1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2126. .INPUT(input_mul0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2127. .INPUT(input_realdiv0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2128. .INPUT(input_mul4, TensorType({DT_FLOAT16,DT_FLOAT}))
  2129. .INPUT(mul0_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2130. .INPUT(mul1_sub, TensorType({DT_FLOAT16,DT_FLOAT}))
  2131. .INPUT(mul2_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2132. .INPUT(mul3_sub1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2133. .INPUT(mul4_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2134. .INPUT(add2_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  2135. .OUTPUT(y1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2136. .OUTPUT(y2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2137. .OUTPUT(y3, TensorType({DT_FLOAT16,DT_FLOAT}))
  2138. .OUTPUT(y4, TensorType({DT_FLOAT16,DT_FLOAT}))
  2139. .OP_END_FACTORY_REG(LambNextMVWithDecay)
  2140. /**
  2141. *@brief Confuse real_div, rsqrt, sqrt, maximum, minimum, sub and add. \n
  2142. *@par Inputs:
  2143. *Thirteen inputs, including:
  2144. * @li input_mul3: A Tensor. Must be one of the following types: float16, float32.
  2145. * @li input_mul2: A Tensor of the same type as "input1".
  2146. * @li input_realdiv1: A Tensor of the same type as "input1".
  2147. * @li input_mul1: A Tensor of the same type as "input1".
  2148. * @li input_mul0: A Tensor of the same type as "input1".
  2149. * @li input_realdiv0: A Tensor. Must be one of the following types: float16, float32.
  2150. * @li input_mul4: A Tensor of the same type as "input1".
  2151. * @li mul0_x: A Tensor of the same type as "input1".
  2152. * @li mul1_sub: A Tensor of the same type as "input1".
  2153. * @li mul2_x: A Tensor of the same type as "input1".
  2154. * @li mul3_sub1: A Tensor. Must be one of the following types: float16, float32.
  2155. * @li mul4_x: A Tensor of the same type as "input1".
  2156. * @li add2_y: A Tensor of the same type as "input1". \n
  2157. *@par Outputs:
  2158. *Four outputs, including:
  2159. *@li y1: A Tensor. Has the same type as "input_mul3".
  2160. *@li y2: A Tensor. Has the same type as "input_mul3".
  2161. *@li y3: A Tensor. Has the same type as "input_mul3".
  2162. *@li y4: A Tensor. Has the same type as "input_mul3".
  2163. *@par Restrictions:
  2164. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2165. */
  2166. REG_OP(LambNextMV)
  2167. .INPUT(input_mul3, TensorType({DT_FLOAT16,DT_FLOAT}))
  2168. .INPUT(input_mul2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2169. .INPUT(input_realdiv1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2170. .INPUT(input_mul1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2171. .INPUT(input_mul0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2172. .INPUT(input_realdiv0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2173. .INPUT(input_mul4, TensorType({DT_FLOAT16,DT_FLOAT}))
  2174. .INPUT(mul0_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2175. .INPUT(mul1_sub, TensorType({DT_FLOAT16,DT_FLOAT}))
  2176. .INPUT(mul2_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2177. .INPUT(mul3_sub1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2178. .INPUT(mul4_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2179. .INPUT(add2_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  2180. .OUTPUT(y1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2181. .OUTPUT(y2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2182. .OUTPUT(y3, TensorType({DT_FLOAT16,DT_FLOAT}))
  2183. .OUTPUT(y4, TensorType({DT_FLOAT16,DT_FLOAT}))
  2184. .OP_END_FACTORY_REG(LambNextMV)
  2185. /**
  2186. *@brief A fusion operator for bert lamb. \n
  2187. *@par Inputs:
  2188. *Six inputs, including:
  2189. * @li input_square: A Tensor. Must be one of the following types: float16, float32.
  2190. * @li input_mul2: A Tensor. Must be one of the following types: float16, float32.
  2191. * @li mul2_x: A Tensor. Must be one of the following types: float16, float32.
  2192. * @li mul3_x: A Tensor. Must be one of the following types: float16, float32.
  2193. * @li truediv1_recip: A Tensor. Must be one of the following types: float16, float32.
  2194. * @li add2_y: A Tensor. Must be one of the following types: float16, float32. \n
  2195. *@par Outputs:
  2196. *Two outputs, including:
  2197. * @li y1: A Tensor of the same type as "input_square".
  2198. * @li y2: A Tensor of the same type as "input_square". \n
  2199. *@par Restrictions:
  2200. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2201. */
  2202. REG_OP(LambNextRight)
  2203. .INPUT(input_square, TensorType({DT_FLOAT16,DT_FLOAT}))
  2204. .INPUT(input_mul2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2205. .INPUT(mul2_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2206. .INPUT(mul3_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2207. .INPUT(truediv1_recip, TensorType({DT_FLOAT16,DT_FLOAT}))
  2208. .INPUT(add2_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  2209. .OUTPUT(y1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2210. .OUTPUT(y2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2211. .OP_END_FACTORY_REG(LambNextRight)
  2212. /**
  2213. *@brief A fusion operator for bert lamb. \n
  2214. *@par Inputs:
  2215. *Six inputs, including:
  2216. * @li input_greater1: A Tensor. Must be one of the following types: float16, float32.
  2217. * @li input_greater_realdiv: A Tensor. Must be one of the following types: float16, float32.
  2218. * @li input_realdiv: A Tensor. Must be one of the following types: float16, float32.
  2219. * @li input_mul0: A Tensor. Must be one of the following types: float16, float32.
  2220. * @li input_mul1: A Tensor. Must be one of the following types: float16, float32.
  2221. * @li input_sub: A Tensor. Must be one of the following types: float16, float32.
  2222. * @li greater_y: A Tensor. Must be one of the following types: float16, float32.
  2223. * @li select_e: A Tensor. Must be one of the following types: float16, float32.
  2224. * @li minimum_y: A Tensor. Must be one of the following types: float16, float32. \n
  2225. *@par Outputs:
  2226. *y: A Tensor of the same type as "input_greater1". \n
  2227. *@par Restrictions:
  2228. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2229. */
  2230. REG_OP(LambUpdateWithLr)
  2231. .INPUT(input_greater1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2232. .INPUT(input_greater_realdiv, TensorType({DT_FLOAT16,DT_FLOAT}))
  2233. .INPUT(input_realdiv, TensorType({DT_FLOAT16,DT_FLOAT}))
  2234. .INPUT(input_mul0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2235. .INPUT(input_mul1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2236. .INPUT(input_sub, TensorType({DT_FLOAT16,DT_FLOAT}))
  2237. .INPUT(greater_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  2238. .INPUT(select_e, TensorType({DT_FLOAT16,DT_FLOAT}))
  2239. .INPUT(minimum_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  2240. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  2241. .OP_END_FACTORY_REG(LambUpdateWithLr)
  2242. /**
  2243. *@brief A fusion operator for bert lamb. \n
  2244. *@par Inputs:
  2245. *Seven inputs, including:
  2246. * @li x1: A Tensor. Must be one of the following types: float16, float32.
  2247. * @li x2: A Tensor. Must be one of the following types: float16, float32.
  2248. * @li x3: A Tensor. Must be one of the following types: float16, float32.
  2249. * @li x4: A Tensor. Must be one of the following types: float16, float32.
  2250. * @li x5: A Tensor. Must be one of the following types: float16, float32.
  2251. * @li greater_y: A Tensor. Must be one of the following types: float16, float32.
  2252. * @li select_e: A Tensor. Must be one of the following types: float16, float32. \n
  2253. *@par Outputs:
  2254. *y: A Tensor of the same type as input. \n
  2255. *@par Restrictions:
  2256. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2257. */
  2258. REG_OP(LambUpdateWithLrV2)
  2259. .INPUT(x1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2260. .INPUT(x2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2261. .INPUT(x3, TensorType({DT_FLOAT16,DT_FLOAT}))
  2262. .INPUT(x4, TensorType({DT_FLOAT16,DT_FLOAT}))
  2263. .INPUT(x5, TensorType({DT_FLOAT16,DT_FLOAT}))
  2264. .INPUT(greater_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  2265. .INPUT(select_e, TensorType({DT_FLOAT16,DT_FLOAT}))
  2266. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  2267. .OP_END_FACTORY_REG(LambUpdateWithLrV2)
  2268. /**
  2269. *@brief A fusion operator for bert lamb. \n
  2270. *@par Inputs:
  2271. *Eleven inputs, including:
  2272. * @li input0: A Tensor. Must be one of the following types: float16, float32.
  2273. * @li input1: A Tensor. Must be one of the following types: float16, float32.
  2274. * @li input2: A Tensor. Must be one of the following types: float16, float32.
  2275. * @li input3: A Tensor. Must be one of the following types: float16, float32.
  2276. * @li input4: A Tensor. Must be one of the following types: float16, float32.
  2277. * @li mul0_x: A Tensor. Must be one of the following types: float16, float32.
  2278. * @li mul1_x: A Tensor. Must be one of the following types: float16, float32.
  2279. * @li mul2_x: A Tensor. Must be one of the following types: float16, float32.
  2280. * @li mul3_x: A Tensor. Must be one of the following types: float16, float32.
  2281. * @li mul4_x: A Tensor. Must be one of the following types: float16, float32.
  2282. * @li add2_y: A Tensor. Must be one of the following types: float16, float32. \n
  2283. *@par Outputs:
  2284. *Three outputs, including:
  2285. * @li output0: A Tensor. Must be one of the following types: float16, float32.
  2286. * @li output1: A Tensor. Must be one of the following types: float16, float32.
  2287. * @li output2: A Tensor. Must be one of the following types: float16, float32. \n
  2288. *@par Restrictions:
  2289. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2290. */
  2291. REG_OP(AdamApplyOneWithDecay)
  2292. .INPUT(input0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2293. .INPUT(input1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2294. .INPUT(input2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2295. .INPUT(input3, TensorType({DT_FLOAT16,DT_FLOAT}))
  2296. .INPUT(input4, TensorType({DT_FLOAT16,DT_FLOAT}))
  2297. .INPUT(mul0_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2298. .INPUT(mul1_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2299. .INPUT(mul2_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2300. .INPUT(mul3_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2301. .INPUT(mul4_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2302. .INPUT(add2_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  2303. .OUTPUT(output0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2304. .OUTPUT(output1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2305. .OUTPUT(output2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2306. .OP_END_FACTORY_REG(AdamApplyOneWithDecay)
  2307. /**
  2308. *@brief A fusion operator for bert lamb. \n
  2309. *@par Inputs:
  2310. *Ten inputs, including:
  2311. * @li input0: A Tensor. Must be one of the following types: float16, float32.
  2312. * @li input1: A Tensor. Must be one of the following types: float16, float32.
  2313. * @li input2: A Tensor. Must be one of the following types: float16, float32.
  2314. * @li input3: A Tensor. Must be one of the following types: float16, float32.
  2315. * @li input4: A Tensor. Must be one of the following types: float16, float32.
  2316. * @li mul0_x: A Tensor. Must be one of the following types: float16, float32.
  2317. * @li mul1_x: A Tensor. Must be one of the following types: float16, float32.
  2318. * @li mul2_x: A Tensor. Must be one of the following types: float16, float32.
  2319. * @li mul3_x: A Tensor. Must be one of the following types: float16, float32.
  2320. * @li add2_y: A Tensor. Must be one of the following types: float16, float32. \n
  2321. *@par Outputs:
  2322. *Three outputs, including:
  2323. * @li output0: A Tensor. Must be one of the following types: float16, float32.
  2324. * @li output1: A Tensor. Must be one of the following types: float16, float32.
  2325. * @li output2: A Tensor. Must be one of the following types: float16, float32. \n
  2326. *@par Restrictions:
  2327. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2328. */
  2329. REG_OP(AdamApplyOne)
  2330. .INPUT(input0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2331. .INPUT(input1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2332. .INPUT(input2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2333. .INPUT(input3, TensorType({DT_FLOAT16,DT_FLOAT}))
  2334. .INPUT(input4, TensorType({DT_FLOAT16,DT_FLOAT}))
  2335. .INPUT(mul0_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2336. .INPUT(mul1_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2337. .INPUT(mul2_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2338. .INPUT(mul3_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2339. .INPUT(add2_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  2340. .OUTPUT(output0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2341. .OUTPUT(output1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2342. .OUTPUT(output2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2343. .OP_END_FACTORY_REG(AdamApplyOne)
  2344. /**
  2345. *@brief A fusion operator for bert lamb. \n
  2346. *@par Inputs:
  2347. *Eleven inputs, including:
  2348. * @li input0: A Tensor. Must be one of the following types: float16, float32.
  2349. * @li input1: A Tensor. Must be one of the following types: float16, float32.
  2350. * @li input2: A Tensor. Must be one of the following types: float16, float32.
  2351. * @li input3: A Tensor. Must be one of the following types: float16, float32.
  2352. * @li input4: A Tensor. Must be one of the following types: float16, float32.
  2353. * @li mul0_x: A Tensor. Must be one of the following types: float16, float32.
  2354. * @li mul1_x: A Tensor. Must be one of the following types: float16, float32.
  2355. * @li mul2_x: A Tensor. Must be one of the following types: float16, float32.
  2356. * @li mul3_x: A Tensor. Must be one of the following types: float16, float32.
  2357. * @li mul4_x: A Tensor. Must be one of the following types: float16, float32.
  2358. * @li add2_y: A Tensor. Must be one of the following types: float16, float32. \n
  2359. *@par Outputs:
  2360. *Three outputs, including:
  2361. * @li output0: A Tensor. Must be one of the following types: float16, float32.
  2362. * @li output1: A Tensor. Must be one of the following types: float16, float32.
  2363. * @li output2: A Tensor. Must be one of the following types: float16, float32. \n
  2364. *@par Restrictions:
  2365. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2366. */
  2367. REG_OP(AdamApplyOneWithDecayAssign)
  2368. .INPUT(input0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2369. .INPUT(input1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2370. .INPUT(input2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2371. .INPUT(input3, TensorType({DT_FLOAT16,DT_FLOAT}))
  2372. .INPUT(input4, TensorType({DT_FLOAT16,DT_FLOAT}))
  2373. .INPUT(mul0_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2374. .INPUT(mul1_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2375. .INPUT(mul2_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2376. .INPUT(mul3_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2377. .INPUT(mul4_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2378. .INPUT(add2_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  2379. .OUTPUT(output0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2380. .OUTPUT(output1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2381. .OUTPUT(output2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2382. .OP_END_FACTORY_REG(AdamApplyOneWithDecayAssign)
  2383. /**
  2384. *@brief A fusion operator for bert lamb. \n
  2385. *@par Inputs:
  2386. *Ten inputs, including:
  2387. * @li input0: A Tensor. Must be one of the following types: float16, float32.
  2388. * @li input1: A Tensor. Must be one of the following types: float16, float32.
  2389. * @li input2: A Tensor. Must be one of the following types: float16, float32.
  2390. * @li input3: A Tensor. Must be one of the following types: float16, float32.
  2391. * @li input4: A Tensor. Must be one of the following types: float16, float32.
  2392. * @li mul0_x: A Tensor. Must be one of the following types: float16, float32.
  2393. * @li mul1_x: A Tensor. Must be one of the following types: float16, float32.
  2394. * @li mul2_x: A Tensor. Must be one of the following types: float16, float32.
  2395. * @li mul3_x: A Tensor. Must be one of the following types: float16, float32.
  2396. * @li add2_y: A Tensor. Must be one of the following types: float16, float32. \n
  2397. *@par Outputs:
  2398. *Three outputs, including:
  2399. * @li output0: A Tensor. Must be one of the following types: float16, float32.
  2400. * @li output1: A Tensor. Must be one of the following types: float16, float32.
  2401. * @li output2: A Tensor. Must be one of the following types: float16, float32. \n
  2402. *@par Restrictions:
  2403. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2404. */
  2405. REG_OP(AdamApplyOneAssign)
  2406. .INPUT(input0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2407. .INPUT(input1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2408. .INPUT(input2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2409. .INPUT(input3, TensorType({DT_FLOAT16,DT_FLOAT}))
  2410. .INPUT(input4, TensorType({DT_FLOAT16,DT_FLOAT}))
  2411. .INPUT(mul0_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2412. .INPUT(mul1_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2413. .INPUT(mul2_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2414. .INPUT(mul3_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2415. .INPUT(add2_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  2416. .OUTPUT(output0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2417. .OUTPUT(output1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2418. .OUTPUT(output2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2419. .OP_END_FACTORY_REG(AdamApplyOneAssign)
  2420. /**
  2421. *@brief A fusion operator for bert lamb. \n
  2422. *@par Inputs:
  2423. *Ten inputs, including:
  2424. * @li input0: A Tensor. Must be one of the following types: float16, float32.
  2425. * @li input1: A Tensor. Must be one of the following types: float16, float32.
  2426. * @li input2: A Tensor. Must be one of the following types: float16, float32.
  2427. * @li input3: A Tensor. Must be one of the following types: float16, float32.
  2428. * @li input4: A Tensor. Must be one of the following types: float16, float32.
  2429. * @li mul0_x: A Tensor. Must be one of the following types: float16, float32.
  2430. * @li mul1_x: A Tensor. Must be one of the following types: float16, float32.
  2431. * @li mul2_x: A Tensor. Must be one of the following types: float16, float32.
  2432. * @li mul3_x: A Tensor. Must be one of the following types: float16, float32.
  2433. * @li steps: A Tensor. Must be one of the following types: float16, float32.
  2434. * @li do_use_weight: A Tensor. Must be one of the following types: float16, float32.
  2435. * @li weight_decay_rate: A Tensor. Must be one of the following types: float16, float32.
  2436. * @li add2_y: A Tensor. Must be one of the following types: float16, float32. \n
  2437. *@par Outputs:
  2438. *Three outputs, including:
  2439. * @li output0: A Tensor. Must be one of the following types: float16, float32. \n
  2440. *@par Restrictions:
  2441. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2442. */
  2443. REG_OP(LambApplyOptimizerAssign)
  2444. .INPUT(grad, TensorType({DT_FLOAT16,DT_FLOAT}))
  2445. .INPUT(inputv, TensorType({DT_FLOAT16,DT_FLOAT}))
  2446. .INPUT(inputm, TensorType({DT_FLOAT16,DT_FLOAT}))
  2447. .INPUT(input3, TensorType({DT_FLOAT16,DT_FLOAT}))
  2448. .INPUT(mul0_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2449. .INPUT(mul1_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2450. .INPUT(mul2_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2451. .INPUT(mul3_x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2452. .INPUT(add2_y, TensorType({DT_FLOAT16,DT_FLOAT}))
  2453. .INPUT(steps, TensorType({DT_FLOAT16,DT_FLOAT}))
  2454. .INPUT(do_use_weight, TensorType({DT_FLOAT16,DT_FLOAT}))
  2455. .INPUT(weight_decay_rate, TensorType({DT_FLOAT16,DT_FLOAT}))
  2456. .OUTPUT(output0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2457. .OUTPUT(inputv, TensorType({DT_FLOAT16,DT_FLOAT}))
  2458. .OUTPUT(inputm, TensorType({DT_FLOAT16,DT_FLOAT}))
  2459. .OP_END_FACTORY_REG(LambApplyOptimizerAssign)
  2460. /**
  2461. *@brief A fusion operator for bert lamb. \n
  2462. *@par Inputs:
  2463. *Ten inputs, including:
  2464. * @li input0: A Tensor. Must be one of the following types: float16, float32.
  2465. * @li input1: A Tensor. Must be one of the following types: float16, float32.
  2466. * @li input2: A Tensor. Must be one of the following types: float16, float32.
  2467. * @li input3: A Tensor. Must be one of the following types: float16, float32.
  2468. * @li input4: A Tensor. Must be one of the following types: float16, float32.
  2469. * @li mul0_x: A Tensor. Must be one of the following types: float16, float32.
  2470. * @li mul1_x: A Tensor. Must be one of the following types: float16, float32.
  2471. * @li mul2_x: A Tensor. Must be one of the following types: float16, float32.
  2472. * @li mul3_x: A Tensor. Must be one of the following types: float16, float32.
  2473. * @li steps: A Tensor. Must be one of the following types: float16, float32.
  2474. * @li do_use_weight: A Tensor. Must be one of the following types: float16, float32.
  2475. * @li weight_decay_rate: A Tensor. Must be one of the following types: float16, float32.
  2476. * @li add2_y: A Tensor. Must be one of the following types: float16, float32. \n
  2477. *@par Outputs:
  2478. *No outputs
  2479. *@par Restrictions:
  2480. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2481. */
  2482. REG_OP(LambApplyWeightAssign)
  2483. .INPUT(input0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2484. .INPUT(input1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2485. .INPUT(input2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2486. .INPUT(input3, TensorType({DT_FLOAT16,DT_FLOAT}))
  2487. .INPUT(input_param, TensorType({DT_FLOAT16,DT_FLOAT}))
  2488. .OUTPUT(input_param, TensorType({DT_FLOAT16,DT_FLOAT}))
  2489. .OP_END_FACTORY_REG(LambApplyWeightAssign)
  2490. /**
  2491. *@brief Confuse select, maximum, greater and sqrt. \n
  2492. *@par Inputs:
  2493. *Four inputs, including:
  2494. * @li x: A Tensor. Must be one of the following types: float16, float32.
  2495. * @li greater_zeros: A Tensor. Must be one of the following types: float16, float32.
  2496. * @li select_ones: A Tensor. Must be one of the following types: float16, float32.
  2497. * @li maximum_ones: A Tensor. Must be one of the following types: float16, float32. \n
  2498. *@par Outputs:
  2499. *y: A Tensor of the same type as "x". \n
  2500. *@par Restrictions:
  2501. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2502. */
  2503. REG_OP(ClipByNormNoDivSum)
  2504. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2505. .INPUT(greater_zeros, TensorType({DT_FLOAT16,DT_FLOAT}))
  2506. .INPUT(select_ones, TensorType({DT_FLOAT16,DT_FLOAT}))
  2507. .INPUT(maximum_ones, TensorType({DT_FLOAT16,DT_FLOAT}))
  2508. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  2509. .OP_END_FACTORY_REG(ClipByNormNoDivSum)
  2510. /**
  2511. *@brief Confuse reducesumd and square. \n
  2512. *@par Inputs:
  2513. *x: A Tensor of type float16, float32. \n
  2514. *@par Attributes:
  2515. * Two attributes, including: \n
  2516. *@li axis: A optional listint, specifies the dimensions to reduce.
  2517. *@li keep_dims: A bool, specifying whether to keep dimensions for the output Tensor. Defaults to "false". \n
  2518. *@par Outputs:
  2519. *Two outputs, including: \n
  2520. *@li y1: A Tensor. Has the same type as "x".
  2521. *@li y2: A Tensor. Has the same type as "x".
  2522. *@par Restrictions:
  2523. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2524. */
  2525. REG_OP(SquareSumV2)
  2526. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2527. .OUTPUT(y1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2528. .OUTPUT(y2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2529. .REQUIRED_ATTR(axis, ListInt)
  2530. .ATTR(keep_dims, Bool, false)
  2531. .OP_END_FACTORY_REG(SquareSumV2)
  2532. /**
  2533. *@brief Confuse reducesumd and square. \n
  2534. *@par Inputs:
  2535. *x: A Tensor of type float16, float32. \n
  2536. *@par Attributes:
  2537. * Two attributes, including: \n
  2538. *@li axis: A optional listint, specifies the dimensions to reduce.
  2539. *@li keep_dims: A bool, specifying whether to keep dimensions for the output Tensor. Defaults to "false". \n
  2540. *@par Outputs:
  2541. y: A Tensor. Has the same type as "x".
  2542. *@par Restrictions:
  2543. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2544. */
  2545. REG_OP(SquareSumV1)
  2546. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT}))
  2547. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  2548. .REQUIRED_ATTR(axis, ListInt)
  2549. .ATTR(keep_dims, Bool, false)
  2550. .OP_END_FACTORY_REG(SquareSumV1)
  2551. /**
  2552. *@brief Calculate square of Tensor and then reducesum
  2553. *@par Inputs:
  2554. *x1: A Tensor of type float32.
  2555. *x2: A Tensor of type float32. \n
  2556. *@par Outputs:
  2557. y1: A Tensor. Has the same type as "x1".The result of "x1".
  2558. y2: A Tensor. Has the same type as "x2".The result of "x2".
  2559. *@par Restrictions:
  2560. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2561. */
  2562. REG_OP(SquareSumAll)
  2563. .INPUT(x1, TensorType({DT_FLOAT}))
  2564. .INPUT(x2, TensorType({DT_FLOAT}))
  2565. .OUTPUT(y1, TensorType({DT_FLOAT}))
  2566. .OUTPUT(y2, TensorType({DT_FLOAT}))
  2567. .OP_END_FACTORY_REG(SquareSumAll)
  2568. /**
  2569. *@brief Confuse broadcast, addn and mul. \n
  2570. *@par Inputs:
  2571. *Three inputs, including:
  2572. * @li x1: A Tensor. Must be one of the following types:int32, int16, float16, float32.
  2573. * @li x2: A Tensor of the same type as "x1".
  2574. * @li x3: A Tensor of the same type as "x1". \n
  2575. *@par Outputs:
  2576. * y: A Tensor. Has the same type as "x1".
  2577. *@par Restrictions:
  2578. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2579. */
  2580. REG_OP(FusedMulAddN)
  2581. .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT16}))
  2582. .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT16}))
  2583. .INPUT(x3, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT16}))
  2584. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT16}))
  2585. .OP_END_FACTORY_REG(FusedMulAddN)
  2586. /**
  2587. *@brief Add 'bias' to 'x'. \n
  2588. *@par Inputs:
  2589. * Two inputs, including:
  2590. *@li x: An ND tensor of type float16 or float32.
  2591. *@li bias: An ND tensor of type float16 or float32. \n
  2592. *@par Attributes:
  2593. *@li axis: An optional int32 used to compute the shape of bias input from the online bottoms. Defaults to "1".
  2594. *@li num_axes: An optional int32 used to compute the shape of bias input from a Caffe model trained offline. Defaults to "1".
  2595. *@li bias_from_blob: An optional bool. If "true", bias is input from a Caffe model trained offline. If "false", bias is input from online bottoms. Defaults to "true". \n
  2596. *@par Outputs:
  2597. *y: An ND tensor of type float16 or float32. \n
  2598. *@attention Constraints:\n
  2599. * Assume that the shape length of "x" is "n" and that of "bias" is "m".
  2600. *@li "axis" is within the range [-n, n-1]. num_axes >= -1.
  2601. *@li If "bias_from_blob = true", "num_axes = -1", and "axis >= 0", the ith axis of "bias" and the (i+"axis")th axis of "x" must have the same size (0 <= i < n-axis).\n
  2602. * If "axis < 0", the ith axis of "bias" and the (i+n+"axis")th axis of "x" must have the same size (0 <= i < -axis).
  2603. *@li If "bias_from_blob = true" and "num_axes = 0", "bias" is a scalar with shape length 1 and dimension size 1.
  2604. *@li If "bias_from_blob = true", "num_axes > 0, and "axis >= 0", "axis + num_axes" must be less than or equal to "n" and the ith axis of "bias" and the (i+"axis")th axis of "x" must have the same size (0 <= i < num_axes).\n
  2605. * If "axis < 0", "n + axis + num_axes" must be less than or equal to "n" and the ith axis of "bias" and the (i+n+"axis")th axis of "x" must have the same size (0 <= i < num_axes).
  2606. *@li If "bias_from_blob = false", "bias" is not a scalar, and "axis >= 0","axis + m" must be less than or equal to "n" and the ith axis of "bias" and the (i+"axis")th axis of "x" must have the same size (0 <= i < m).\n
  2607. * If "axis < 0", "n + axis + m" must be less than or equal to "n" and the ith axis of "bias" and the (i+n+"axis")th axis of "x" must have the same size (0 <= i < m).
  2608. *@par Third-party framework compatibility
  2609. * Compatible with the Caffe operator Bias.
  2610. */
  2611. REG_OP(Bias)
  2612. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16})) /* "First operand." */
  2613. .INPUT(bias, TensorType({DT_FLOAT, DT_FLOAT16})) /* "Second operand." */
  2614. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16})) /* "Result, has same element type as x" */
  2615. .ATTR(axis, Int, 1)
  2616. .ATTR(num_axes, Int, 1)
  2617. .ATTR(bias_from_blob, Bool, true)
  2618. .OP_END_FACTORY_REG(Bias)
  2619. /**
  2620. *@brief Function multiply gradients calculation.
  2621. output0 is the result of which input0 dot multily input1.
  2622. output1 is the result of which input0 dot multily input1, then reducesum it. \n
  2623. *@par Inputs:
  2624. *@li input0: A Tensor of input of mul, and dtype supports float16, float32.
  2625. *@li input1: A Tensor of input of mul and mul_1, and dtype supports float16, float32.
  2626. *@li input2: A Tensor of input of mul_1, and dtype supports float16, float32. \n
  2627. *@par Attributes:
  2628. *@li axes: The dimensions to reduce. Default:(), reduce all dimensions. \n
  2629. Only constant value is allowed.
  2630. *@li keep_dims: If true, keep these reduced dimensions and the length is 1. \n
  2631. If false, don’t keep these dimensions. Default:False. \n
  2632. *@par Outputs:
  2633. *@li output0: A Tensor result of which input0 dot multily input1.
  2634. *@li output1: A Tensor result of which input0 dot multily input1, then reducesum it.
  2635. *@par Restrictions:
  2636. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2637. */
  2638. REG_OP(ConfusionMulGrad)
  2639. .INPUT(input0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2640. .INPUT(input1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2641. .INPUT(input2, TensorType({DT_FLOAT16,DT_FLOAT}))
  2642. .OUTPUT(output0, TensorType({DT_FLOAT16,DT_FLOAT}))
  2643. .OUTPUT(output1, TensorType({DT_FLOAT16,DT_FLOAT}))
  2644. .ATTR(axes, ListInt, {})
  2645. .ATTR(keep_dims, Bool, false)
  2646. .OP_END_FACTORY_REG(ConfusionMulGrad)
  2647. /**
  2648. *@brief Function fused multiply l2 loss calculation. \n
  2649. *@par Inputs:
  2650. *@li x1: A Tensor of type float16, float32.
  2651. *@li x2: A Tensor of type float16, float32.
  2652. *@li x3: A Tensor of type float16, float32. \n
  2653. *@par Outputs:
  2654. *@li y1: A Tensor of shape and dtype of first output, which should have \n
  2655. shape (1,) and dtype as input.
  2656. *@li y2: A Tensor of shape and dtype of second output, should be same shape and type as input.
  2657. *@par Restrictions:
  2658. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2659. */
  2660. REG_OP(FusedMulAddNL2loss)
  2661. .INPUT(x1, TensorType::NumberType())
  2662. .INPUT(x2, TensorType::NumberType())
  2663. .INPUT(x3, TensorType::NumberType())
  2664. .OUTPUT(y1, TensorType::NumberType())
  2665. .OUTPUT(y2, TensorType::NumberType())
  2666. .OP_END_FACTORY_REG(FusedMulAddNL2loss)
  2667. /**
  2668. *@brief Tests whether the input exceeds a threshold. \n
  2669. *@par Inputs:
  2670. *@li x: A Tensor with any format. Must be one of the following types: float16, float32. \n
  2671. *@par Attributes:
  2672. *@li threshold: A required float32. Defaults to "0.0". "x" is compared with "threshold", outputs "1" for inputs above threshold; "0" otherwise. \n
  2673. *@par Outputs:
  2674. *@li y: A Tensor with any format. Has the same type as the input. Must be one of the following types: float16, float32.
  2675. *@par Third-party framework compatibility
  2676. * Compatible with the Caffe operator Threshold.
  2677. */
  2678. REG_OP(Threshold)
  2679. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16}))
  2680. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16}))
  2681. .ATTR(threshold, Float, 0.0)
  2682. .OP_END_FACTORY_REG(Threshold);
  2683. /**
  2684. *@brief Returns the index number corresponding to the maximum value entered. \n
  2685. *@par Inputs:
  2686. *@li x: A tensor. Must be one of the following types: float16, float32. \n
  2687. *@par Attributes:
  2688. *@li axis: An optional int. Specify the axis to be cut at the input tensor. If this parameter is not provided, find the topk for each batch. Defaults to 10000
  2689. *@li out_max_val: An optional bool. Whether to output the maximum value. If it is True, the maximum value and index are output, otherwise only the index is output.
  2690. * Defaults to False
  2691. *@li topk: An optional int. It means the number of top tok in each axis (the value is greater than or equal to 1), and the value range must be in [1,x.shape(axis)].
  2692. * Defaults to 1
  2693. *@par Outputs:
  2694. *@li indices: A tensor of type float16, float32, int32. The index of the maximum value of the output.
  2695. *@li values: A tensor of type float16, float32.Output tensor, including maximum index or maximum value.
  2696. *@par Third-party framework compatibility
  2697. * Compatible with the Caffe operator ArgMax.
  2698. */
  2699. REG_OP(ArgMaxWithK)
  2700. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16}))
  2701. .OUTPUT(indices, TensorType({DT_INT32, DT_FLOAT, DT_FLOAT16}))
  2702. .OUTPUT(values, TensorType({DT_FLOAT, DT_FLOAT16}))
  2703. .ATTR(axis, Int, 10000)
  2704. .ATTR(out_max_val, Bool, false)
  2705. .ATTR(topk, Int, 1)
  2706. .OP_END_FACTORY_REG(ArgMaxWithK)
  2707. /**
  2708. *@brief Multiply tensor with scale. \n
  2709. *@par Inputs:
  2710. *Five inputs, including:
  2711. * @li x1: A Tensor. Must be one of the following types:int32,int16, float16, float32.
  2712. * @li x2: A scale. Must be float. \n
  2713. *@par Outputs:
  2714. *@li y: A Tensor. Has the same type and shape as "x1". \n
  2715. *@par Third-party framework compatibility:
  2716. * Compatible with the Pytorch operator muls.
  2717. */
  2718. REG_OP(Muls)
  2719. .INPUT(x, TensorType({DT_FLOAT,DT_INT16,DT_INT32,DT_FLOAT16}))
  2720. .OUTPUT(y, TensorType({DT_FLOAT,DT_INT16,DT_INT32,DT_FLOAT16}))
  2721. .REQUIRED_ATTR(value, Float)
  2722. .OP_END_FACTORY_REG(Muls)
  2723. /**
  2724. *@brief Fill tensor with scale. \n
  2725. *@par Inputs:
  2726. *Five inputs, including:
  2727. * @li x1: A Tensor. Must be one of the following types:int32,int16, float16, float32.
  2728. * @li x2: A scale. Must be float. \n
  2729. *@par Outputs:
  2730. *@li y: A Tensor. Has the same type and shape as "x1". \n
  2731. *@par Third-party framework compatibility:
  2732. * Compatible with the Pytorch operator fills.
  2733. */
  2734. REG_OP(Fills)
  2735. .INPUT(x, TensorType({DT_FLOAT,DT_INT16,DT_INT32,DT_FLOAT16}))
  2736. .OUTPUT(y, TensorType({DT_FLOAT,DT_INT16,DT_INT32,DT_FLOAT16}))
  2737. .REQUIRED_ATTR(value,Float)
  2738. .OP_END_FACTORY_REG(Fills)
  2739. /**
  2740. *@brief Add tensor with scale. \n
  2741. *@par Inputs:
  2742. *Five inputs, including:
  2743. * @li x1: A Tensor. Must be one of the following types:int32,int16, float16, float32.
  2744. * @li x2: A scale. Must be float. \n
  2745. *@par Outputs:
  2746. *@li y: A Tensor. Has the same type and shape as "x1". \n
  2747. *@par Third-party framework compatibility:
  2748. * Compatible with the Pytorch operator adds.
  2749. */
  2750. REG_OP(Adds)
  2751. .INPUT(x, TensorType({DT_FLOAT,DT_INT16,DT_INT32,DT_FLOAT16}))
  2752. .OUTPUT(y, TensorType({DT_FLOAT,DT_INT16,DT_INT32,DT_FLOAT16}))
  2753. .REQUIRED_ATTR(value,Float)
  2754. .OP_END_FACTORY_REG(Adds)
  2755. /**
  2756. *@brief Computes the product of x and y and returns 0 if the y is zero, even if x is NaN or infinite. \n
  2757. *@par Inputs:
  2758. * @li x1: A Tensor. Must be one of the following types:float16, float32, double, complex64, complex128.
  2759. * @li x2: A Tensor. Has the same type and shape as "x1". \n
  2760. *@par Outputs:
  2761. *y: A Tensor. Has the same type and shape as "x1". \n
  2762. *@par Third-party framework compatibility:
  2763. * Compatible with the TensorFlow operator MulNoNan.
  2764. */
  2765. REG_OP(MulNoNan)
  2766. .INPUT(x1, TensorType::NumberType()) /* "First operand." */
  2767. .INPUT(x2, TensorType::NumberType()) /* "Second operand." */
  2768. .OUTPUT(y, TensorType::NumberType()) /* "Result, has same element type as two inputs" */
  2769. .OP_END_FACTORY_REG(MulNoNan)
  2770. /**
  2771. *@brief Add tensor with scale. \n
  2772. *@par Inputs:
  2773. * @li x1: A Tensor dtype of int32, float16, float32.
  2774. * @li x2: A Tensor dtype of int32, float16, float32. \n
  2775. *@par Attributes:
  2776. *alpha: Float scalar apply to x2:x2*alpha
  2777. *@par Outputs:
  2778. *y: A Tensor. should be same shape and type as "x1". \n
  2779. *@par Third-party framework compatibility:
  2780. * Compatible with the Pytorch operator Axpy.
  2781. */
  2782. REG_OP(Axpy)
  2783. .INPUT(x1, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16}))
  2784. .INPUT(x2, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16}))
  2785. .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16}))
  2786. .REQUIRED_ATTR(alpha, Float)
  2787. .OP_END_FACTORY_REG(Axpy)
  2788. /**
  2789. *@brief Creates a criterion that measures the loss given input tensors x1 x2 and a Tensor label y with values 1 or -1. \n
  2790. *@par Inputs:
  2791. *@li x1: A ND Tensor with one of the following types: int8, uint8, int32, float16, float32.
  2792. *@li x2: A ND Tensor with one of the following types: int8, uint8, int32, float16, float32.
  2793. *@li target: A ND Tensor with one of the following types: int8, int32, float16, float32. \n
  2794. *@par Attributes:
  2795. *@li margin: A optional float32. Defaults to "0.0".
  2796. *@li reduction: A optional string. Defaults to "mean". \n
  2797. *@par Outputs:
  2798. *@li y: A ND Tensor with Must be float32.
  2799. *@par Third-party framework compatibility
  2800. * Compatible with the PyTorch operator CosineEmbeddingLoss.
  2801. */
  2802. REG_OP(CosineEmbeddingLoss)
  2803. .INPUT(x1, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  2804. .INPUT(x2, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  2805. .INPUT(target, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  2806. .ATTR(margin, Float, 0)
  2807. .ATTR(reduction, String, "mean")
  2808. .OUTPUT(y, TensorType({DT_FLOAT}))
  2809. .OP_END_FACTORY_REG(CosineEmbeddingLoss)
  2810. /**
  2811. *@brief Kullback-Leibler divergence. \n
  2812. *@par Inputs:
  2813. * Two inputs, including:
  2814. *@li x: Tensor of arbitrary shape.
  2815. *@li target: Tensor of the same shape and dtype as x. \n
  2816. *@par Attributes:
  2817. *reduction: An required "string", Specifies the reduction to apply to the output;
  2818. * Reduction only supports the two modes of "sum" and "batchmean". \n
  2819. *@par Outputs:
  2820. *y: A ND Tensor of the same dtype as x.
  2821. *@par Third-party framework compatibility
  2822. *Compatible with the PyTorch operator kl_div.
  2823. */
  2824. REG_OP(KLDiv)
  2825. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  2826. .INPUT(target, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  2827. .REQUIRED_ATTR(reduction, String)
  2828. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  2829. .OP_END_FACTORY_REG(KLDiv)
  2830. /**
  2831. *@brief copy data from x to y.. \n
  2832. *@par Inputs:
  2833. *One inputs, including:
  2834. * @li x: A Tensor. Must be one of the following types: float16, float32, int8, uint8, int32, bool. \n
  2835. *@par Outputs:
  2836. *y: A Tensor. Has the same type as "x". \n
  2837. *@par Third-party framework compatibility
  2838. *@par Restrictions:
  2839. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2840. */
  2841. REG_OP(TensorMove)
  2842. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8, DT_BOOL}))
  2843. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8, DT_BOOL}))
  2844. .OP_END_FACTORY_REG(TensorMove)
  2845. /**
  2846. *@brief copy data from x to x. \n
  2847. *@par Inputs:
  2848. *One inputs, including:
  2849. * @li x: A Tensor. Must be one of the following types: float16, float32, int8, uint8, int16, uint16, int32, uint32, int64, uint64. \n
  2850. *@par Outputs:
  2851. *output_x: A Tensor. Has the same type as "x". \n
  2852. *@par Third-party framework compatibility
  2853. */
  2854. REG_OP(TensorRedirect)
  2855. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8,
  2856. DT_INT64, DT_INT16, DT_UINT16, DT_UINT64, DT_UINT32}))
  2857. .OUTPUT(output_x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8,
  2858. DT_INT64, DT_INT16, DT_UINT16, DT_UINT64, DT_UINT32}))
  2859. .OP_END_FACTORY_REG(TensorRedirect)
  2860. /**
  2861. * @brief Performs the element-wise division of tensor x2 by tensor x3,
  2862. * multiply the result by the scalar value and add it to tensor x1
  2863. * @par Inputs:
  2864. * Three inputs, including:
  2865. * @li input_data: A mutable input Tensor. Must be one of the following types:
  2866. * float16, float32.
  2867. * @li x1: A mutable input Tensor of the same type as x1.
  2868. * @li x2: A mutable input Tensor of the same type as x1.
  2869. * @li value: A mutable input Tensor. Must be one of the following types:
  2870. * float16, float32, int32. \n
  2871. * @par Outputs:
  2872. * @li y: A mutable Tensor. Has the same type as "x1". \n
  2873. * @par Third-party framework compatibility
  2874. * Compatible with the Pytorch operator Addcdiv.
  2875. */
  2876. REG_OP(Addcdiv)
  2877. .INPUT(input_data, TensorType({DT_FLOAT16, DT_FLOAT}))
  2878. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT}))
  2879. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT}))
  2880. .INPUT(value, TensorType({ DT_FLOAT16, DT_FLOAT, DT_INT32 }))
  2881. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  2882. .OP_END_FACTORY_REG(Addcdiv)
  2883. /**
  2884. * @brief Performs the element-wise multiplication of tensor x2 by tensor x3,
  2885. * multiply the result by the scalar value and add it to tensor input_data
  2886. * @par Inputs:
  2887. * Three inputs, including:
  2888. * @li input_data: A mutable input Tensor. Must be one of the following types:
  2889. * float16, float32, int8, int32, uint8.
  2890. * @li x1: A mutable input Tensor of the same type as x1.
  2891. * @li x2: A mutable input Tensor of the same type as x1.
  2892. * @li value: A tensor which includes only one element of the same type as x1. \n
  2893. * @par Outputs:
  2894. * @li y: A mutable output Tensor. Has the same type as "x1". \n
  2895. * @par Third-party framework compatibility
  2896. * Compatible with the Pytorch operator Addcmul.
  2897. */
  2898. REG_OP(Addcmul)
  2899. .INPUT(input_data, TensorType({ DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8 }))
  2900. .INPUT(x1, TensorType({ DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8 }))
  2901. .INPUT(x2, TensorType({ DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8 }))
  2902. .INPUT(value, TensorType({ DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8 }))
  2903. .OUTPUT(y, TensorType({ DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8 }))
  2904. .OP_END_FACTORY_REG(Addcmul)
  2905. /**
  2906. * @brief Computes the result of x2 * alpha + x1.
  2907. * @par Inputs:
  2908. * @li x1: An ND tensor of type float16, float32, int32.
  2909. * @li x2: An ND tensor of type float16, float32, int32.
  2910. * @li alpha: A scalar tensor of type float16, float32. \n
  2911. * @par Outputs:
  2912. * @li y: An ND tensor tensor with the same shape and type as "x1". \n
  2913. * @par Third-party framework compatibility
  2914. * Compatible with the Pytorch operator Axpy.
  2915. */
  2916. REG_OP(AxpyV2)
  2917. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  2918. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  2919. .INPUT(alpha, TensorType({DT_FLOAT16, DT_FLOAT}))
  2920. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  2921. .OP_END_FACTORY_REG(AxpyV2)
  2922. /**
  2923. * @brief Computes the result of x1 + x2.
  2924. * @par Inputs:
  2925. * @li x1: An ND tensor of type float16, float, int32.
  2926. * @li x2: An ND tensor of type float16, float, int32. \n
  2927. * @par Outputs:
  2928. * @li y: An ND tensor tensor with the same type as "x1". \n
  2929. * @par Third-party framework compatibility
  2930. * Compatible with the Pytorch operator Add.
  2931. */
  2932. REG_OP(PtAdd)
  2933. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  2934. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  2935. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  2936. .OP_END_FACTORY_REG(PtAdd)
  2937. /**
  2938. * @brief Computes the result of x1 * x2.
  2939. * @par Inputs:
  2940. * @li x1: An ND tensor of type float16, float32, int32.
  2941. * @li x2: An ND tensor of type float16, float32, int32. \n
  2942. * @par Outputs:
  2943. * @li y: Same shape and type as the largest ND tensor in x1 x2. \n
  2944. * @par Third-party framework compatibility
  2945. * Compatible with the Pytorch operator muls.
  2946. */
  2947. REG_OP(PtMuls)
  2948. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  2949. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  2950. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  2951. .OP_END_FACTORY_REG(PtMuls)
  2952. /**
  2953. * @brief Computes the result of x1 - x2.
  2954. * @par Inputs:
  2955. * @li x1: An ND tensor of type float16, float, int32.
  2956. * @li x2: An ND tensor of type float16, float, int32. \n
  2957. * @par Outputs:
  2958. * @li y: An ND tensor tensor with the same type as "x1". \n
  2959. * @par Third-party framework compatibility
  2960. * Compatible with the Pytorch operator Sub.
  2961. */
  2962. REG_OP(PtSub)
  2963. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  2964. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  2965. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  2966. .OP_END_FACTORY_REG(PtSub)
  2967. /**
  2968. * @brief Add the partial values of two tensors in format NC1HWC0.
  2969. * @par Inputs:
  2970. * @li x1: A Tensor in 5HD, and must be one of the following types: float16,
  2971. * float32. \n
  2972. * @li x2: A Tensor of the same type as "x1", and the same shape as "x1",
  2973. * except for the C1 value. \n
  2974. * @par Attributes:
  2975. * @li x1_c1_offset: A required int. Offset value of C1 in "x1". \n
  2976. * @li x2_c1_offset: A required int. Offset value of C1 in "x2". \n
  2977. * @li c1_len: A required int. C1 len of "y". The value must be less than
  2978. * the difference between C1 and offset in "x1" and "x2". \n
  2979. * @par Outputs:
  2980. * @li y: A Tensor of the same type as "x1", and the same shape as "x1",
  2981. * except for the C1 value. Record the result after adding. \n
  2982. */
  2983. REG_OP(StrideAdd)
  2984. .INPUT(x1, TensorType({ DT_FLOAT, DT_FLOAT16 }))
  2985. .INPUT(x2, TensorType({ DT_FLOAT, DT_FLOAT16 }))
  2986. .OUTPUT(y, TensorType({ DT_FLOAT, DT_FLOAT16 }))
  2987. .REQUIRED_ATTR(x1_c1_offset, Int)
  2988. .REQUIRED_ATTR(x2_c1_offset, Int)
  2989. .REQUIRED_ATTR(c1_len, Int)
  2990. .OP_END_FACTORY_REG(StrideAdd)
  2991. /**
  2992. * @brief Compare two tensors are totally equal or not, only output a bool value"
  2993. * @par Inputs:
  2994. * Two inputs, including:
  2995. * @li input_x: A Tensor. the first tensor. \n
  2996. * @li input_y: A Tensor. the second tensor. \n
  2997. * @par Outputs:
  2998. * @li output_z: A Tensor. Bool type, compare result of the two inputs. \n
  2999. * @par Third-party framework compatibility
  3000. * Compatible with the Pytorch equal operator. \n
  3001. */
  3002. REG_OP(TensorEqual)
  3003. .INPUT(input_x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8}))
  3004. .INPUT(input_y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8}))
  3005. .OUTPUT(output_z, TensorType({DT_BOOL}))
  3006. .OP_END_FACTORY_REG(TensorEqual)
  3007. /**
  3008. * @brief Element-wise min of each of the input tensors (with Numpy-style broadcasting support).
  3009. * All inputs and outputs must have the same data type. This operator supports multidirectional
  3010. * (i.e., Numpy-style) broadcasting
  3011. *
  3012. * @par inputs
  3013. * one input including:
  3014. * @li x: dynamic input A Tensor. Must be one of the following types: float32, float16, double, int32, int64
  3015. *
  3016. * @par output
  3017. * one output including:
  3018. * @li y:A Tensor of the same type as x
  3019. *
  3020. */
  3021. REG_OP(MaxN)
  3022. .DYNAMIC_INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_FLOAT64, DT_INT32, DT_INT64}))
  3023. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_FLOAT64, DT_INT32, DT_INT64}))
  3024. .OP_END_FACTORY_REG(MaxN)
  3025. /**
  3026. * @brief Calculates x * maske * value.
  3027. *
  3028. * @par Inputs:
  3029. * @li x: An tensor of type float16 or float32, specifying the input to the data layer.
  3030. * @li mask: An tensor of type int8 or float16 or float32, be same shape with x. \n
  3031. *
  3032. * @par Attributes:
  3033. * value: A optional float. \n
  3034. *
  3035. * @par Outputs:
  3036. * y: The output tensor of type float16 or float32.
  3037. @ li y:A Tensor of the same type and shape as x
  3038. *
  3039. */
  3040. REG_OP(MaskedScale)
  3041. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT32}))
  3042. .INPUT(mask, TensorType({DT_INT8, DT_FLOAT16, DT_FLOAT32}))
  3043. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT32}))
  3044. .REQUIRED_ATTR(value, Float)
  3045. .OP_END_FACTORY_REG(MaskedScale)
  3046. /**
  3047. * @brief Calculate the lerp function. \n
  3048. * @par Inputs:
  3049. * Three inputs, including:
  3050. * @li start: A tensor. Must be one of the following types:
  3051. * float16, float32. \n
  3052. * @li end: A tensor. Must be one of the following types:
  3053. * float16, float32. \n
  3054. * @li weight: A tensor. Must be one of the following types:
  3055. * float16, float32. \n
  3056. * @par Outputs:
  3057. * y: A Tensor with the same type and shape of input_x's. \n
  3058. * @par Third-party framework compatibility
  3059. * Compatible with the Pytorch operator Lerp. \n
  3060. */
  3061. REG_OP(Lerp)
  3062. .INPUT(start, TensorType({DT_FLOAT16, DT_FLOAT}))
  3063. .INPUT(end, TensorType({DT_FLOAT16, DT_FLOAT}))
  3064. .INPUT(weight, TensorType({DT_FLOAT16, DT_FLOAT}))
  3065. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  3066. .OP_END_FACTORY_REG(Lerp)
  3067. /**
  3068. *@brief Returns the num value of abs(x1-x2) > atol+rtol*abs(x2) element-wise. \n
  3069. *
  3070. *@par Inputs:
  3071. *@li x1: A tensor. Must be one of the following types: float32, int32, uint8, int8, float16
  3072. *@li x2: A tensor of the same type as "x1".
  3073. *
  3074. *@par Attributes:
  3075. * atol: Defaults to "1e-05".
  3076. * rtol: Defaults to "1e-03".
  3077. *
  3078. *@par Outputs:
  3079. * num: A tensor of type float32.
  3080. *
  3081. *@par Restrictions:
  3082. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  3083. *
  3084. */
  3085. REG_OP(DataCompare)
  3086. .INPUT(x1, TensorType({ DT_FLOAT16, DT_FLOAT,DT_INT8, DT_UINT8, DT_INT32 }))
  3087. .INPUT(x2, TensorType({ DT_FLOAT16, DT_FLOAT,DT_INT8, DT_UINT8, DT_INT32 }))
  3088. .OUTPUT(num, TensorType({DT_FLOAT}))
  3089. .ATTR(atol, Float, 1e-5)
  3090. .ATTR(rtol, Float, 1e-3)
  3091. .OP_END_FACTORY_REG(DataCompare)
  3092. /**
  3093. *@brief Hardmax(element in input, axis) = 1 if the element is the first maximum value along the specified axis, 0
  3094. *otherwise The input does not need to explicitly be a 2D vector.The "axis" attribute indicates the dimension along
  3095. *which Hardmax will be performed.The output tensor has the same shape and contains the Hardmax values of the
  3096. *corresponding input.
  3097. *
  3098. *@par inputs
  3099. *one input including:
  3100. *@li x: input A Tensor.Must be one of the following types:float32,float16
  3101. *
  3102. *@par Attributes:
  3103. *@li axis:A required int attribute that decides which dimension will be used to cal the hard_max
  3104. *
  3105. *@par output:
  3106. *one output including:
  3107. *@li y:A Tensor of the same type as x
  3108. *
  3109. */
  3110. REG_OP(HardMax)
  3111. .INPUT(x, TensorType({ DT_FLOAT16, DT_FLOAT }))
  3112. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  3113. .ATTR(axis, Int, -1)
  3114. .OP_END_FACTORY_REG(HardMax)
  3115. /**
  3116. * @brief Computes the dot product (inner product) of two tensors. This function does not broadcast.
  3117. * @par Inputs:
  3118. * Two inputs, including:
  3119. * @li input_x: A Tensor. the first tensor must be 1d. \n
  3120. * @li input_y: A Tensor. the second tensor must be 1d. \n
  3121. * @par Outputs:
  3122. * @li output: A Tensor. Result of the two inputs, must be 1d. \n
  3123. * @par Third-party framework compatibility
  3124. * Compatible with the Pytorch dot operator. \n
  3125. */
  3126. REG_OP(Dot)
  3127. .INPUT(input_x, TensorType({DT_FLOAT, DT_FLOAT16, DT_UINT8, DT_INT8, DT_INT32}))
  3128. .INPUT(input_y, TensorType({DT_FLOAT, DT_FLOAT16, DT_UINT8, DT_INT8, DT_INT32}))
  3129. .OUTPUT(output, TensorType({DT_FLOAT, DT_FLOAT16, DT_UINT8, DT_INT8, DT_INT32}))
  3130. .OP_END_FACTORY_REG(Dot)
  3131. /**
  3132. *@brief Returns a new tensor with boolean elements representing \n
  3133. *if each element of input is “close” to the corresponding element of other \n
  3134. *@par Inputs:
  3135. *Two inputs, including:
  3136. * @li x1: A tensor. Must be one of the following types:
  3137. * float16, float32, int32. \n
  3138. * @li x2: A tensor with the same type and shape of x1's. \n
  3139. *@par Attributes:
  3140. *@li rtol: An optional float.Defaults to 1e-05. \n
  3141. *@li atol: An optional float.Defaults to 1e-08. \n
  3142. *@li equal_nan: An optional bool.Defaults to false. \n
  3143. *@par Outputs:
  3144. *y: A Tensor bool with the same shape of x1's. \n
  3145. *@par Third-party framework compatibility
  3146. *Compatible with the Pytorch operator isclose. \n
  3147. */
  3148. REG_OP(IsClose)
  3149. .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  3150. .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  3151. .OUTPUT(y, TensorType({DT_BOOL}))
  3152. .ATTR(rtol, Float, 1e-05)
  3153. .ATTR(atol, Float, 1e-08)
  3154. .ATTR(equal_nan, Bool, false)
  3155. .OP_END_FACTORY_REG(IsClose)
  3156. /**
  3157. * @brief Returns the reverse tensor of the ArgMax operator of a tensor. \n
  3158. * @par Inputs:
  3159. * three input, including:
  3160. * var: A Tensor of type float16, float32, int32 or int8. \n
  3161. * indices: A Tensor of type int32. \n
  3162. * updates: A Tensor of type float16, float32, int32 or int8. \n
  3163. * @par Attributes:
  3164. * @li dimension: An integer of type int, specifying the axis information of the index with the maximum value.\n
  3165. * @par Outputs:
  3166. * y: A Tensor of type float16, float32, int32 or int8. \n
  3167. *
  3168. *@attention Constraints:
  3169. *@li indices: only support int32,and shape same to "updates"
  3170. *@li The value range of "dimension" is [-dims, dims - 1]. "dims" is the dimension length of "x".
  3171. *@li y:A Tensor, the type and shape is same to "var" \n
  3172. *@par Third-party framework compatibility
  3173. * not support all scene like pytorch operator scatter
  3174. * exp:
  3175. * var.shape=[2,3,4,5], dim=2, the shape of indices and updates should be [2,3,5]
  3176. * not support the shape of indices and updates is [2,3,2,5] like pytorch operator scatter. \n
  3177. */
  3178. REG_OP(ArgMaxGrad)
  3179. .INPUT(var, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8}))
  3180. .INPUT(indices, TensorType({DT_INT32}))
  3181. .INPUT(updates, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8}))
  3182. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8}))
  3183. .REQUIRED_ATTR(dimension, Int)
  3184. .OP_END_FACTORY_REG(ArgMaxGrad)
  3185. /**
  3186. * @brief Returns the reverse tensor of the ArgMax operator of a tensor. \n
  3187. * @par Inputs:
  3188. * three input, including:
  3189. * var: A Tensor of type float16, float32, int32 or int8. \n
  3190. * indices: A Tensor of type int32. \n
  3191. * updates: A Tensor of type float16, float32, int32 or int8. \n
  3192. * assist: A Tensor of int32,also a assist matrix and it's shape must match the shape of var \n
  3193. * @par Attributes:
  3194. * @li dimension: An integer of type int, specifying the axis information of the index with the maximum value.\n
  3195. * @par Outputs:
  3196. * y: A Tensor of type float16, float32, int32 or int8. \n
  3197. *@attention Constraints:
  3198. *@li indices: only support int32,and shape same to "updates"
  3199. *@li The value range of "dimension" is [-dims, dims - 1]. "dims" is the dimension length of "x".
  3200. *@li y:A Tensor, the type and shape is same to "var" \n
  3201. *@par Third-party framework compatibility
  3202. * not support all scene like pytorch operator scatter
  3203. * exp:
  3204. * var.shape=[2,3,4,5], dim=2, the shape of indices and updates should be [2,3,5]
  3205. * not support the shape of indices and updates is [2,3,2,5] like pytorch operator scatter. \n
  3206. */
  3207. REG_OP(ArgMaxGradD)
  3208. .INPUT(var, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8}))
  3209. .INPUT(indices, TensorType({DT_INT32}))
  3210. .INPUT(updates, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8}))
  3211. .INPUT(assist, TensorType({DT_INT32}))
  3212. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8}))
  3213. .REQUIRED_ATTR(dimension, Int)
  3214. .OP_END_FACTORY_REG(ArgMaxGradD)
  3215. /**
  3216. *@brief Returns cosine similarity between x1 and x2,computed along dim. \n
  3217. *@par Inputs:
  3218. *Two inputs, including:
  3219. * @li input_x1: A tensor. Must be the following types:
  3220. * float32. \n
  3221. *@par Inputs:
  3222. *@li input_x2: A tensor. Must of the following types:
  3223. * float32. \n
  3224. *@par Outputs:
  3225. *@li output_y: A Tensor with the same type of input_x's. \n
  3226. *@par Third-party framework compatibility
  3227. *Compatible with the Pytorch operator CosineSimilarity. \n
  3228. */
  3229. REG_OP(CosineSimilarity)
  3230. .INPUT(input_x1, TensorType({DT_FLOAT})) /* "First operand." */
  3231. .INPUT(input_x2, TensorType({DT_FLOAT})) /* "Second operand." */
  3232. .OUTPUT(output_y, TensorType({DT_FLOAT})) /* "Result, has same element type as two inputs" */
  3233. .ATTR(dim, Int, 1)
  3234. .ATTR(eps, Float, 1e-8)
  3235. .OP_END_FACTORY_REG(CosineSimilarity)
  3236. } // namespace ge
  3237. #endif // OPS_BUILT_IN_OP_PROTO_INC_ELEWISE_CALCULATION_OPS_H_

图引擎模块(GE)是MindSpore的一个子模块,其代码由C++实现,位于前端模块ME和底层硬件之间,起到承接作用。图引擎模块以ME下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示