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.

nn_training_ops.h 106 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
5 years ago
5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665
  1. /**
  2. * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
  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 nn_training_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_TRAINING_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_NN_TRAINING_OPS_H_
  22. #include "graph/operator_reg.h"
  23. namespace ge {
  24. /**
  25. *@brief Updates "var" according to the AdaMax algorithm.
  26. * t-1 mean previous period.
  27. * m_t <- beta1 * m{t-1} + (1 - beta1) * grad
  28. * v_t <- max(beta2 * v{t-1}, abs(grad))
  29. * var <- var - lr / (1 - beta1^t) * m_t / (v_t + epsilon)
  30. *
  31. *@attention Constraints:
  32. * the input tensors must have the same shape.
  33. *
  34. *@par Inputs:
  35. *@li var: A mutable tensor. Must be one of the following types: TensorType::NumberType().
  36. * Should be from a Variable().
  37. *@li m: A mutable tensor. Has the same type as "var".
  38. * Should be from a Variable().
  39. *@li v: A mutable tensor. Has the same type as "var".
  40. * Should be from a Variable().
  41. *@li beta1_power: A scalar. Has the same type as "var".
  42. *@li lr: learning_rate. A scalar. Has the same type as "var".
  43. *@li beta1: A scalar. Has the same type as "var".
  44. *@li beta2: A scalar. Has the same type as "var".
  45. *@li epsilon: A scalar. Has the same type as "var".
  46. *@li grad: A tensor for the gradient. Has the same type as "var".
  47. *
  48. *@par Attributes:
  49. * use_locking: An optional bool. Defaults to "False".
  50. * If "True", updating of the "var", "ms", and "mom" tensors is protected
  51. * by a lock; otherwise the behavior is undefined, but may exhibit less
  52. * contention.
  53. *
  54. *@par Outputs:
  55. * var: A mutable tensor. Has the same type as input "var".
  56. *
  57. *@par Third-party framework compatibility
  58. *Compatible with the TensorFlow operator ApplyAdaMax.
  59. *
  60. */
  61. REG_OP(ApplyAdaMax)
  62. .INPUT(var, TensorType::NumberType())
  63. .INPUT(m, TensorType::NumberType())
  64. .INPUT(v, TensorType::NumberType())
  65. .INPUT(beta1_power, TensorType::NumberType())
  66. .INPUT(lr, TensorType::NumberType())
  67. .INPUT(beta1, TensorType::NumberType())
  68. .INPUT(beta2, TensorType::NumberType())
  69. .INPUT(epsilon, TensorType::NumberType())
  70. .INPUT(grad, TensorType::NumberType())
  71. .OUTPUT(var, TensorType::NumberType())
  72. .ATTR(use_locking, Bool, false)
  73. .OP_END_FACTORY_REG(ApplyAdaMax)
  74. /**
  75. *@brief Updates "var" according to the AdaMax algorithm.
  76. * t-1 mean previous period.
  77. * m_t <- beta1 * m{t-1} + (1 - beta1) * grad
  78. * v_t <- max(beta2 * v{t-1}, abs(grad))
  79. * var <- var - lr / (1 - beta1^t) * m_t / (v_t + epsilon)
  80. *
  81. *@attention Constraints:
  82. * the input tensors must have the same shape.
  83. *
  84. *@par Inputs:
  85. *@li var: A mutable tensor. Must be one of the following types: TensorType::NumberType().
  86. * Should be from a Variable().
  87. *@li m: A mutable tensor. Has the same type as "var".
  88. * Should be from a Variable().
  89. *@li v: A mutable tensor. Has the same type as "var".
  90. * Should be from a Variable().
  91. *@li beta1_power: A scalar. Has the same type as "var".
  92. *@li lr: learning_rate. A scalar. Has the same type as "var".
  93. *@li beta1: A scalar. Has the same type as "var".
  94. *@li beta2: A scalar. Has the same type as "var".
  95. *@li epsilon: A scalar. Has the same type as "var".
  96. *@li grad: A tensor for the gradient. Has the same type as "var".
  97. *
  98. *@par Attributes:
  99. * use_locking: An optional bool. Defaults to "False".
  100. * If "True", updating of the "var", "ms", and "mom" tensors is protected
  101. * by a lock; otherwise the behavior is undefined, but may exhibit less
  102. * contention.
  103. *
  104. *@par Outputs:
  105. *@li var: A mutable tensor. Has the same type as input "var".
  106. *@li m: A mutable tensor. Has the same type as input "m".
  107. *@li v: A mutable tensor. Has the same type as input "v".
  108. *
  109. *@par Third-party framework compatibility
  110. *Compatible with the TensorFlow operator ApplyAdaMax.
  111. *
  112. * @par Restrictions:
  113. * Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyAdaMax instead.
  114. */
  115. REG_OP(ApplyAdaMaxD)
  116. .INPUT(var, TensorType::NumberType())
  117. .INPUT(m, TensorType::NumberType())
  118. .INPUT(v, TensorType::NumberType())
  119. .INPUT(beta1_power, TensorType::NumberType())
  120. .INPUT(lr, TensorType::NumberType())
  121. .INPUT(beta1, TensorType::NumberType())
  122. .INPUT(beta2, TensorType::NumberType())
  123. .INPUT(epsilon, TensorType::NumberType())
  124. .INPUT(grad, TensorType::NumberType())
  125. .OUTPUT(var, TensorType::NumberType())
  126. .OUTPUT(m, TensorType::NumberType())
  127. .OUTPUT(v, TensorType::NumberType())
  128. .ATTR(use_locking, Bool, false)
  129. .OP_END_FACTORY_REG(ApplyAdaMaxD)
  130. /**
  131. *@brief Updates relevant entries in "var" and "accum" according to the adagrad scheme . \n
  132. *@par Inputs:
  133. * Five inputs, including:
  134. *@li var: An NCHW, NHWC, or ND Tensor of type float32.
  135. *@li accum: An NCHW, NHWC, or ND Tensor of type float32.
  136. *@li lr: An NCHW, NHWC, or ND Tensor of type float32.
  137. *@li grad: An NCHW, NHWC, or ND Tensor of type float32.
  138. *@li indices: An NCHW, NHWC, or ND Tensor of type float32 . \n
  139. *@par Attributes:
  140. *@li use_locking: An optional bool. Defaults to "False". If "True", the operation will be protected by a lock.
  141. *@li update_slots: An optional bool. Defaults to "True". If "True", the calcution will be different as "False" . \n
  142. *@par Outputs:
  143. *var: A Tensor. Has the same type and format as input "var" . \n
  144. *@par Third-party framework compatibility
  145. * Compatible with the TensorFlow operator SparseApplyAdagrad.
  146. */
  147. REG_OP(SparseApplyAdagrad)
  148. .INPUT(var, TensorType({DT_FLOAT}))
  149. .INPUT(accum, TensorType({DT_FLOAT}))
  150. .INPUT(lr, TensorType({DT_FLOAT}))
  151. .INPUT(grad, TensorType({DT_FLOAT}))
  152. .INPUT(indices, TensorType({DT_INT32}))
  153. .OUTPUT(var, TensorType({DT_FLOAT}))
  154. .OUTPUT(accum, TensorType({DT_FLOAT}))
  155. .ATTR(use_locking, Bool, false)
  156. .ATTR(update_slots, Bool, true)
  157. .OP_END_FACTORY_REG(SparseApplyAdagrad)
  158. /**
  159. *@brief Updates relevant entries in "var" and "accum" according to the adagrad scheme . \n
  160. *@par Inputs:
  161. * Four inputs, including:
  162. *@li var: An NCHW, NHWC, or ND Tensor of type float32.
  163. *@li accum: An NCHW, NHWC, or ND Tensor of type float32.
  164. *@li grad: An NCHW, NHWC, or ND Tensor of type float32.
  165. *@li indices: An NCHW, NHWC, or ND Tensor of type int32 . \n
  166. *@par Attributes:
  167. *@li lr: Required, used for computation.
  168. *@li use_locking: An optional bool. Defaults to "False". If "True", the operation will be protected by a lock.
  169. *@li update_slots: An optional bool. Defaults to "True". If "True", the calcution will be different as "False" . \n
  170. *@par Outputs:
  171. *@li var: A Tensor. Has the same type and format as input "var".
  172. *@li accum: A Tensor. Has the same type and format as input "var" . \n
  173. *@par Third-party framework compatibility
  174. * Compatible with the TensorFlow operator SparseApplyAdagrad. \n
  175. *
  176. *@par Restrictions:
  177. *Warning: THIS FUNCTION IS DEPRECATED. Please use SparseApplyAdagrad instead.
  178. */
  179. REG_OP(SparseApplyAdagradD)
  180. .INPUT(var, TensorType({DT_FLOAT}))
  181. .INPUT(accum, TensorType({DT_FLOAT}))
  182. .INPUT(grad, TensorType({DT_FLOAT}))
  183. .INPUT(indices, TensorType({DT_INT32}))
  184. .OUTPUT(var, TensorType({DT_FLOAT}))
  185. .OUTPUT(accum, TensorType({DT_FLOAT}))
  186. .REQUIRED_ATTR(lr, Float)
  187. .ATTR(use_locking, Bool, false)
  188. .ATTR(update_slots, Bool, true)
  189. .OP_END_FACTORY_REG(SparseApplyAdagradD)
  190. /**
  191. *@brief Updates relevant entries in "var" and "accum" according to the adagrad scheme . \n
  192. *@par Inputs:
  193. *Six inputs, including:
  194. *@li var: An NCHW, NHWC, or ND Tensor of type float32.
  195. *@li accum: An NCHW, NHWC, or ND Tensor of type float32.
  196. *@li lr: An NCHW, NHWC, or ND Tensor of type float32.
  197. *@li epsilon: An NCHW, NHWC, or ND Tensor of type float32.
  198. *@li grad: An NCHW, NHWC, or ND Tensor of type float32.
  199. *@li indices: An NCHW, NHWC, or ND Tensor of type float32 . \n
  200. *@par Attributes:
  201. *@li use_locking: An optional bool. Defaults to "False". If "True", the operation will be protected by a lock.
  202. *@li update_slots: An optional bool. Defaults to "True". If "False", the computation logic will be different . \n
  203. *@par Outputs:
  204. *var: A Tensor. Has the same type and format as input "var" . \n
  205. *@par Third-party framework compatibility
  206. *Compatible with the TensorFlow operator SparseApplyAdagradV2.
  207. */
  208. REG_OP(SparseApplyAdagradV2)
  209. .INPUT(var, TensorType({DT_FLOAT}))
  210. .INPUT(accum, TensorType({DT_FLOAT}))
  211. .INPUT(lr, TensorType({DT_FLOAT}))
  212. .INPUT(epsilon, TensorType({DT_FLOAT}))
  213. .INPUT(grad, TensorType({DT_FLOAT}))
  214. .INPUT(indices, TensorType({DT_INT32}))
  215. .OUTPUT(var, TensorType({DT_FLOAT}))
  216. .ATTR(use_locking, Bool, false)
  217. .ATTR(update_slots, Bool, true)
  218. .OP_END_FACTORY_REG(SparseApplyAdagradV2)
  219. /**
  220. *@brief Updates relevant entries in "var" and "accum" according to the adagrad scheme . \n
  221. *@par Inputs:
  222. *Four inputs, including:
  223. *@li var: An NCHW, NHWC, or ND Tensor of type float32.
  224. *@li accum: An NCHW, NHWC, or ND Tensor of type float32.
  225. *@li grad: An NCHW, NHWC, or ND Tensor of type float32.
  226. *@li indices: An NCHW, NHWC, or ND Tensor of type int32 . \n
  227. *@par Attributes:
  228. *@li lr: Required, used for computation.
  229. *@li epsilon: Required, used for computation.
  230. *@li use_locking: An optional bool. Defaults to "False". If "True", the operation will be protected by a lock.
  231. *@li update_slots: An optional bool. Defaults to "True". If "False", the computation logic will be different . \n
  232. *@par Outputs:
  233. *@li var: A Tensor. Has the same type and format as input "var".
  234. *@li accum: A Tensor. Has the same type and format as input "accum" . \n
  235. *@par Third-party framework compatibility
  236. *Compatible with the TensorFlow operator SparseApplyAdagradV2. \n
  237. *
  238. *@par Restrictions:
  239. *Warning: THIS FUNCTION IS DEPRECATED. Please use SparseApplyAdagradV2 instead.
  240. */
  241. REG_OP(SparseApplyAdagradV2D)
  242. .INPUT(var, TensorType({DT_FLOAT}))
  243. .INPUT(accum, TensorType({DT_FLOAT}))
  244. .INPUT(grad, TensorType({DT_FLOAT}))
  245. .INPUT(indices, TensorType({DT_INT32}))
  246. .OUTPUT(var, TensorType({DT_FLOAT}))
  247. .OUTPUT(accum, TensorType({DT_FLOAT}))
  248. .REQUIRED_ATTR(lr, Float)
  249. .REQUIRED_ATTR(epsilon, Float)
  250. .ATTR(use_locking, Bool, false)
  251. .ATTR(update_slots, Bool, true)
  252. .OP_END_FACTORY_REG(SparseApplyAdagradV2D)
  253. /**
  254. *@brief Updates "var" according to the momentum scheme. Set use_nesterov = True if you
  255. * want to use Nesterov momentum.
  256. * computing process:
  257. * accum = accum * momentum + grad
  258. * var -= lr * accum
  259. *
  260. *@attention Constraints:
  261. * the input tensors must have the same shape.
  262. *
  263. *@par Inputs:
  264. *@li var: A mutable tensor. Should be from a Variable().
  265. *@li accum: A mutable tensor. Has the same type as "var".
  266. * Should be from a Variable().
  267. *@li lr: A scalar. Has the same type as "var".
  268. *@li grad: A tensor for the gradient. Has the same type as "var".
  269. *@li momentum: Momentum. Must be a scalar.
  270. *@par Attributes:
  271. *@li use_nesterov: An optional bool. Defaults to "False".
  272. * If "True", the tensor passed to compute grad will be
  273. * var - lr * momentum * accum, so in the end, the var you get is actually
  274. * var - lr * momentum * accum.
  275. *
  276. *@li use_locking: An optional bool. Defaults to "False".
  277. * If "True", updating of the "var", "ms", and "mom" tensors is protected by a lock;
  278. * otherwise the behavior is undefined, but may exhibit less contention.
  279. *
  280. *@par Outputs:
  281. * var: A mutable tensor. Has the same type as input "var".
  282. *
  283. *@par Third-party framework compatibility
  284. *Compatible with the TensorFlow operator ApplyMomentum.
  285. *
  286. */
  287. REG_OP(ApplyMomentum)
  288. .INPUT(var, TensorType::NumberType())
  289. .INPUT(accum, TensorType::NumberType())
  290. .INPUT(lr, TensorType::NumberType())
  291. .INPUT(grad, TensorType::NumberType())
  292. .INPUT(momentum, TensorType::NumberType())
  293. .OUTPUT(var, TensorType::NumberType())
  294. .ATTR(use_nesterov, Bool, false)
  295. .ATTR(use_locking, Bool, false)
  296. .OP_END_FACTORY_REG(ApplyMomentum)
  297. /**
  298. *@brief Updates "var" according to the momentum scheme. Set use_nesterov = True if you
  299. * want to use Nesterov momentum.
  300. * computing process:
  301. * accum = accum * momentum + grad
  302. * var -= lr * accum
  303. *
  304. *@attention Constraints:
  305. * the input tensors must have the same shape.
  306. *
  307. *@par Inputs:
  308. *@li var: A mutable tensor. Should be from a Variable().
  309. *@li accum: A mutable tensor. Has the same type as "var".
  310. * Should be from a Variable().
  311. *@li lr: A scalar. Has the same type as "var".
  312. *@li grad: A tensor for the gradient. Has the same type as "var".
  313. *
  314. *@par Attributes:
  315. *@li use_nesterov: An optional bool. Defaults to "False".
  316. * If "True", the tensor passed to compute grad will be
  317. * var - lr * momentum * accum, so in the end, the var you get is actually
  318. * var - lr * momentum * accum.
  319. *
  320. *@li use_locking: An optional bool. Defaults to "False".
  321. * If "True", updating of the "var", "ms", and "mom" tensors is protected by a lock;
  322. * otherwise the behavior is undefined, but may exhibit less contention.
  323. *
  324. *@par Outputs:
  325. * var: A mutable tensor. Has the same type as input "var".
  326. * accum: A mutable tensor. Has the same type as input "accum".
  327. *@par Third-party framework compatibility
  328. *Compatible with the TensorFlow operator ApplyMomentum.
  329. *
  330. * @par Restrictions:
  331. * Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyMomentum instead.
  332. */
  333. REG_OP(ApplyMomentumD)
  334. .INPUT(var, TensorType::NumberType())
  335. .INPUT(accum, TensorType::NumberType())
  336. .INPUT(lr, TensorType::NumberType())
  337. .INPUT(grad, TensorType::NumberType())
  338. .INPUT(momentum, TensorType::NumberType())
  339. .OUTPUT(var, TensorType::NumberType())
  340. .OUTPUT(accum, TensorType::NumberType())
  341. .ATTR(use_nesterov, Bool, false)
  342. .ATTR(use_locking, Bool, false)
  343. .OP_END_FACTORY_REG(ApplyMomentumD)
  344. /**
  345. *@brief Updates '*var' according to the momentum scheme.
  346. * accum = accum * momentum - grad * lr
  347. * if use_nesterov is True:
  348. * var += accum * momentum - grad * lr
  349. * else:
  350. * var += accum
  351. *
  352. *@par Inputs:
  353. *@li var: A mutable tensor. Must be one of the data types defined in
  354. * TensorType::NumberType(). Should be from a Variable().
  355. *@li accum: A mutable tensor. Has the same type as "var". Should be from a
  356. * Variable().
  357. *@li lr: A tensor for the learning rate. Has the same type as "var". Should be
  358. * from a Variable().
  359. *@li grad: A tensor for the gradient. Has the same type as "var". Should be
  360. * from a Variable().
  361. *@li momentum: A scalar. Has the same type as "var".
  362. *
  363. *@par Attributes:
  364. *@li use_nesterov: An optional bool. Defaults to "False".
  365. * If "True", var will be updated by using Nesterov momentum.
  366. *@li use_locking: An optional bool. Defaults to "False".
  367. * If "True", updating of the "var" tensor is protected by a lock;
  368. * otherwise the behavior is undefined, but may exhibit less contention.
  369. *
  370. *@par Outputs:
  371. * var: A mutable tensor. Has the same type as input "var".
  372. *
  373. *@attention Constraints:
  374. * The input tensors must have the same shape.
  375. *
  376. *@par Third-party framework compatibility
  377. * Compatible with the TensorFlow operator ResourceApplyKerasMomentum.
  378. *
  379. */
  380. REG_OP(ApplyKerasMomentum)
  381. .INPUT(var, TensorType::NumberType())
  382. .INPUT(accum, TensorType::NumberType())
  383. .INPUT(lr, TensorType::NumberType())
  384. .INPUT(grad, TensorType::NumberType())
  385. .INPUT(momentum, TensorType::NumberType())
  386. .OUTPUT(var, TensorType::NumberType())
  387. .ATTR(use_locking, Bool, false)
  388. .ATTR(use_nesterov, Bool, false)
  389. .OP_END_FACTORY_REG(ApplyKerasMomentum)
  390. /**
  391. *@brief Updates '*var' according to the momentum scheme.
  392. * accum = accum * momentum - grad * lr
  393. * if use_nesterov is True:
  394. * var += accum * momentum - grad * lr
  395. * else:
  396. * var += accum
  397. *
  398. *@par Inputs:
  399. *@li var: A mutable tensor. Must be one of the data types defined in
  400. * TensorType::NumberType(). Should be from a Variable().
  401. *@li accum: A mutable tensor. Has the same type as "var". Should be from a
  402. * Variable().
  403. *@li lr: A tensor for the learning rate. Has the same type as "var". Should be
  404. * from a Variable().
  405. *@li grad: A tensor for the gradient. Has the same type as "var". Should be
  406. * from a Variable().
  407. *@li momentum: A scalar. Has the same type as "var". Should be from a
  408. * Variable().
  409. *
  410. *@par Attributes:
  411. *@li use_nesterov: An optional bool. Defaults to "False".
  412. * If "True", var will be updated by using nesterov momentum
  413. *@li use_locking: An optional bool. Defaults to "False".
  414. * If "True", updating of the "var" tensor is protected by a lock;
  415. * otherwise the behavior is undefined, but may exhibit less contention.
  416. *
  417. *@par Outputs:
  418. *@li var: A mutable tensor. Has the same type as input "var".
  419. *@li accum: A mutable tensor. Has the same type as input "var"
  420. *
  421. *@attention Constraints:
  422. * The input tensors must have the same shape.
  423. *
  424. *@par Third-party framework compatibility
  425. * Compatible with the TensorFlow operator ResourceApplyKerasMomentum.
  426. *
  427. *@par Restrictions:
  428. *Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyKerasMomentum instead.
  429. */
  430. REG_OP(ApplyKerasMomentumD)
  431. .INPUT(var, TensorType::NumberType())
  432. .INPUT(accum, TensorType::NumberType())
  433. .INPUT(lr, TensorType::NumberType())
  434. .INPUT(grad, TensorType::NumberType())
  435. .INPUT(momentum, TensorType::NumberType())
  436. .OUTPUT(var, TensorType::NumberType())
  437. .OUTPUT(accum, TensorType::NumberType())
  438. .ATTR(use_locking, Bool, false)
  439. .ATTR(use_nesterov, Bool, false)
  440. .OP_END_FACTORY_REG(ApplyKerasMomentumD)
  441. /**
  442. *@brief Updates '*var' according to the Adam algorithm.
  443. * lr_t := {learning_rate} * sqrt{1 - beta_2^t} / (1 - beta_1^t)
  444. * m_t := beta_1 * m_{t-1} + (1 - beta_1) * g
  445. * v_t := beta_2 * v_{t-1} + (1 - beta_2) * g * g
  446. * vhat_t := max{vhat_{t-1}, v_t}
  447. * variable := variable - lr_t * m_t / (sqrt{vhat_t} + epsilon)
  448. *
  449. *@par Inputs:
  450. *@li var: A mutable tensor. Must be one of the data types defined in
  451. * TensorType::NumberType(). Should be from a Variable().
  452. *@li m: A mutable tensor. Has the same type as "var". Should be from a
  453. * Variable().
  454. *@li v: A mutable tensor. Has the same type as "var". Should be from a
  455. * Variable().
  456. *@li vhat: A mutable tensor. Has the same type as "var". Should be from a
  457. * Variable().
  458. *@li beta1_power: A mutable tensor. Has the same type as "var". Should be from a
  459. * Variable().
  460. *@li beta2_power: A mutable tensor. Has the same type as "var". Should be from a
  461. * Variable().
  462. *@li lr: A tensor for the learning rate. Has the same type as "var". Should be
  463. * from a Variable().
  464. *@li grad: A tensor for the gradient. Has the same type as "var". Should be
  465. * from a Variable().
  466. *
  467. *@par Attributes:
  468. *@li beta1: A scalar. Has the same type as "var".
  469. *@li beta2: A scalar. Has the same type as "var".
  470. *@li epsilon: A scalar. Has the same type as "var".
  471. *@li use_locking: An optional bool. Defaults to "False".
  472. * If "True", updating of the "var" tensor is protected by a lock;
  473. * otherwise the behavior is undefined, but may exhibit less contention.
  474. *
  475. *@par Outputs:
  476. *@li var: A mutable tensor. Has the same type as input "var".
  477. *@li m: A mutable tensor. Has the same type as input "var"
  478. *@li v: A mutable tensor. Has the same type as input "var"
  479. *@li vhat: A mutable tensor. Has the same type as input "var"
  480. *
  481. *@attention Constraints:
  482. * The input tensors must have the same shape.
  483. *
  484. *@par Third-party framework compatibility
  485. * Compatible with the TensorFlow operator ResourceApplyKerasMomentum.
  486. *
  487. *@par Restrictions:
  488. *Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyAdamWithAmsgrad instead.
  489. *
  490. */
  491. REG_OP(ApplyAdamWithAmsgradD)
  492. .INPUT(var, TensorType::NumberType())
  493. .INPUT(m, TensorType::NumberType())
  494. .INPUT(v, TensorType::NumberType())
  495. .INPUT(vhat, TensorType::NumberType())
  496. .INPUT(beta1_power, TensorType::NumberType())
  497. .INPUT(beta2_power, TensorType::NumberType())
  498. .INPUT(lr, TensorType::NumberType())
  499. .INPUT(grad, TensorType::NumberType())
  500. .OUTPUT(var, TensorType::NumberType())
  501. .OUTPUT(m, TensorType::NumberType())
  502. .OUTPUT(v, TensorType::NumberType())
  503. .OUTPUT(vhat, TensorType::NumberType())
  504. .REQUIRED_ATTR(beta1, Float)
  505. .REQUIRED_ATTR(beta2, Float)
  506. .REQUIRED_ATTR(epsilon, Float)
  507. .ATTR(use_locking, Bool, false)
  508. .OP_END_FACTORY_REG(ApplyAdamWithAmsgradD)
  509. /**
  510. *@brief Updates '*var' according to the Adam algorithm..
  511. * lr_t := {learning_rate} * sqrt{1 - beta_2^t} / (1 - beta_1^t)
  512. * m_t := beta_1 * m_{t-1} + (1 - beta_1) * g
  513. * v_t := beta_2 * v_{t-1} + (1 - beta_2) * g * g
  514. * vhat_t := max{vhat_{t-1}, v_t}
  515. * variable := variable - lr_t * m_t / (sqrt{vhat_t} + epsilon)
  516. *
  517. *@par Inputs:
  518. *@li var: A mutable tensor. Must be one of the data types defined in
  519. * TensorType::NumberType(). Should be from a Variable().
  520. *@li m: A mutable tensor. Has the same type as "var". Should be from a
  521. * Variable().
  522. *@li v: A mutable tensor. Has the same type as "var". Should be from a
  523. * Variable().
  524. *@li vhat: A mutable tensor. Has the same type as "var". Should be from a
  525. * Variable().
  526. *@li beta1_power: A mutable tensor. Has the same type as "var". Should be from a
  527. * Variable().
  528. *@li beta2_power: A mutable tensor. Has the same type as "var". Should be from a
  529. * Variable().
  530. *@li lr: A tensor for the learning rate. Has the same type as "var". Should be
  531. * from a Variable().
  532. *@li grad: A tensor for the gradient. Has the same type as "var". Should be
  533. * from a Variable().
  534. *
  535. *@par Attributes:
  536. *@li beta1: A scalar. Has the same type as "var".
  537. *@li beta2: A scalar. Has the same type as "var".
  538. *@li epsilon: A scalar. Has the same type as "var".
  539. *@li use_locking: An optional bool. Defaults to "False".
  540. * If "True", updating of the "var" tensor is protected by a lock;
  541. * otherwise the behavior is undefined, but may exhibit less contention.
  542. *
  543. *@par Outputs:
  544. *@li var: A mutable tensor. Has the same type as input "var".
  545. *@li m: A mutable tensor. Has the same type as input "var"
  546. *@li v: A mutable tensor. Has the same type as input "var"
  547. *@li vhat: A mutable tensor. Has the same type as input "var"
  548. *
  549. *@attention Constraints:
  550. * The input tensors must have the same shape.
  551. *
  552. *@par Third-party framework compatibility
  553. * Compatible with the TensorFlow operator ResourceApplyKerasMomentum.
  554. *
  555. */
  556. REG_OP(ApplyAdamWithAmsgrad)
  557. .INPUT(var, TensorType::NumberType())
  558. .INPUT(m, TensorType::NumberType())
  559. .INPUT(v, TensorType::NumberType())
  560. .INPUT(vhat, TensorType::NumberType())
  561. .INPUT(beta1_power, TensorType::NumberType())
  562. .INPUT(beta2_power, TensorType::NumberType())
  563. .INPUT(lr, TensorType::NumberType())
  564. .INPUT(beta1, TensorType::NumberType())
  565. .INPUT(beta2, TensorType::NumberType())
  566. .INPUT(epsilon, TensorType::NumberType())
  567. .INPUT(grad, TensorType::NumberType())
  568. .OUTPUT(var, TensorType::NumberType())
  569. .ATTR(use_locking, Bool, false)
  570. .OP_END_FACTORY_REG(ApplyAdamWithAmsgrad)
  571. /**
  572. *@brief Updates "var" according to the AddSign update.
  573. * t-1 mean previous period.
  574. * m_t <- beta1 * m_{t-1} + (1 - beta1) * grad
  575. * update <- exp(logbase * sign_decay * sign(grad) * sign(m_t)) * grad
  576. * var <- var - lr * update
  577. *
  578. *@attention Constraints:
  579. * the input tensors must have the same shape.
  580. *
  581. *@par Inputs:
  582. *@li var: A mutable tensor. Should be from a Variable().
  583. *@li m: A mutable tensor. Has the same type as "var".
  584. * Should be from a Variable().
  585. *@li lr: A scalar. Has the same type as "var".
  586. *@li logbase: A scalar. Has the same type as "var".
  587. *@li sign_decay: A scalar. Has the same type as "var".
  588. *@li beta: A scalar. Has the same type as "var".
  589. *@li grad: A tensor for the gradient. Has the same type as "var".
  590. *
  591. *@par Attributes:
  592. * use_locking: An optional bool. Defaults to "False".
  593. * If "True", updating of the "var", "ms", and "mom" tensors is protected
  594. * by a lock; otherwise the behavior is undefined, but may exhibit less
  595. * contention.
  596. *
  597. *@par Outputs:
  598. * var: A mutable tensor. Has the same type as input "var".
  599. *
  600. *@par Third-party framework compatibility
  601. *Compatible with the TensorFlow operator ApplyPowerSign.
  602. *
  603. */
  604. REG_OP(ApplyPowerSign)
  605. .INPUT(var, TensorType::NumberType())
  606. .INPUT(m, TensorType::NumberType())
  607. .INPUT(lr, TensorType::NumberType())
  608. .INPUT(logbase, TensorType::NumberType())
  609. .INPUT(sign_decay, TensorType::NumberType())
  610. .INPUT(beta, TensorType::NumberType())
  611. .INPUT(grad, TensorType::NumberType())
  612. .OUTPUT(var, TensorType::NumberType())
  613. .ATTR(use_locking, Bool, false)
  614. .OP_END_FACTORY_REG(ApplyPowerSign)
  615. /**
  616. *@brief Updates "var" according to the AddSign update.
  617. * t-1 mean previous period.
  618. * m_t <- beta1 * m_{t-1} + (1 - beta1) * grad
  619. * update <- exp(logbase * sign_decay * sign(grad) * sign(m_t)) * grad
  620. * var <- var - lr * update
  621. *
  622. *@attention Constraints:
  623. * the input tensors must have the same shape.
  624. *
  625. *@par Inputs:
  626. *@li var: A mutable tensor. Should be from a Variable().
  627. *@li m: A mutable tensor. Has the same type as "var".
  628. * Should be from a Variable().
  629. *@li lr: A scalar. Has the same type as "var".
  630. *@li logbase: A scalar. Has the same type as "var".
  631. *@li sign_decay: A scalar. Has the same type as "var".
  632. *@li beta: A scalar. Has the same type as "var".
  633. *@li grad: A tensor for the gradient. Has the same type as "var".
  634. *
  635. *@par Attributes:
  636. * use_locking: An optional bool. Defaults to "False".
  637. * If "True", updating of the "var", "ms", and "mom" tensors is protected
  638. * by a lock; otherwise the behavior is undefined, but may exhibit less
  639. * contention.
  640. *
  641. *@par Outputs:
  642. *@li var: A mutable tensor. Has the same type as input "var".
  643. *@li m: A mutable tensor. Has the same type as input "var".
  644. *
  645. *@par Third-party framework compatibility
  646. *Compatible with the TensorFlow operator ApplyPowerSign.
  647. *
  648. * @par Restrictions:
  649. * Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyPowerSign instead.
  650. */
  651. REG_OP(ApplyPowerSignD)
  652. .INPUT(var, TensorType::NumberType())
  653. .INPUT(m, TensorType::NumberType())
  654. .INPUT(lr, TensorType::NumberType())
  655. .INPUT(logbase, TensorType::NumberType())
  656. .INPUT(sign_decay, TensorType::NumberType())
  657. .INPUT(beta, TensorType::NumberType())
  658. .INPUT(grad, TensorType::NumberType())
  659. .OUTPUT(var, TensorType::NumberType())
  660. .OUTPUT(m, TensorType::NumberType())
  661. .ATTR(use_locking, Bool, false)
  662. .OP_END_FACTORY_REG(ApplyPowerSignD)
  663. /**
  664. *@brief Updates "var" as FOBOS algorithm with fixed learning rate.
  665. * prox_v = var - alpha * delta
  666. * var = sign(prox_v)/(1+alpha * l2) * max{|prox_v|-alpha * l1,0}
  667. *
  668. *@attention Constraints:
  669. * the input tensors must have the same shape.
  670. *
  671. *@par Inputs:
  672. *@li var: A mutable tensor. Should be from a Variable().
  673. *@li alpha: A scalar. Has the same type as "var".
  674. *@li l1: A scalar. Has the same type as "var".
  675. *@li l2: A scalar. Has the same type as "var".
  676. *@li delta: A tensor. Has the same type as "var". The change.
  677. *
  678. *@par Attributes:
  679. * use_locking: An optional bool. Defaults to "False".
  680. * If "True", updating of the "var", "ms", and "mom" tensors is protected
  681. * by a lock; otherwise the behavior is undefined, but may exhibit less
  682. * contention.
  683. *
  684. *@par Outputs:
  685. * var: A mutable tensor. Has the same type as input "var".
  686. *
  687. *@par Third-party framework compatibility
  688. *Compatible with the TensorFlow operator ApplyProximalGradientDescent.
  689. *
  690. */
  691. REG_OP(ApplyProximalGradientDescent)
  692. .INPUT(var, TensorType::NumberType())
  693. .INPUT(alpha, TensorType::NumberType())
  694. .INPUT(l1, TensorType::NumberType())
  695. .INPUT(l2, TensorType::NumberType())
  696. .INPUT(delta, TensorType::NumberType())
  697. .OUTPUT(var, TensorType::NumberType())
  698. .ATTR(use_locking, Bool, false)
  699. .OP_END_FACTORY_REG(ApplyProximalGradientDescent)
  700. /**
  701. *@brief Updates "var" according to the AddSign update . \n
  702. *@par Inputs:
  703. *Seven inputs, including:
  704. * @li var: A mutable Tensor of type TensorType::NumberType().
  705. * Should be a Variable Tensor.
  706. * @li m: A mutable Tensor of the same type as "var".
  707. * Should be a Variable Tensor.
  708. * @li lr: A Tensor of the same type as "var", for the scaling factor. Must be a scalar.
  709. * @li alpha: A Tensor of the same type as "var". Must be a scalar.
  710. * @li sign_decay: A Tensor of the same type as "var". Must be a scalar.
  711. * @li beta: A Tensor of the same type as "var". Must be a scalar.
  712. * @li grad: A Tensor of the same type as "var", for the gradient.
  713. *@par Attributes:
  714. *use_locking: An optional bool. Defaults to "False".
  715. * If "True", updating of the "var" and "m" tensors will be
  716. * protected by a lock; otherwise the behavior is undefined,
  717. * but may exhibit less contention . \n
  718. *@par Outputs:
  719. *var: A mutable Tensor. Has the same type as "var" . \n
  720. *@par Third-party framework compatibility
  721. * Compatible with the TensorFlow operator ApplyAddSign.
  722. */
  723. REG_OP(ApplyAddSign)
  724. .INPUT(var, TensorType::NumberType())
  725. .INPUT(m, TensorType::NumberType())
  726. .INPUT(lr, TensorType::NumberType())
  727. .INPUT(alpha, TensorType::NumberType())
  728. .INPUT(sign_decay, TensorType::NumberType())
  729. .INPUT(beta, TensorType::NumberType())
  730. .INPUT(grad, TensorType::NumberType())
  731. .OUTPUT(var, TensorType::NumberType())
  732. .ATTR(use_locking, Bool, false)
  733. .OP_END_FACTORY_REG(ApplyAddSign)
  734. /**
  735. *@brief Updates "var" according to the AddSign update . \n
  736. *@par Inputs:
  737. *Seven inputs, including:
  738. * @li var: A mutable Tensor of type TensorType::NumberType().
  739. * Should be a Variable Tensor.
  740. * @li m: A mutable Tensor of the same type as "var".
  741. * Should be a Variable Tensor.
  742. * @li lr: A Tensor of the same type as "var", for the scaling factor. Must be a scalar.
  743. * @li alpha: A Tensor of the same type as "var". Must be a scalar.
  744. * @li sign_decay: A Tensor of the same type as "var". Must be a scalar.
  745. * @li beta: A Tensor of the same type as "var". Must be a scalar.
  746. * @li grad: A Tensor of the same type as "var", for the gradient.
  747. *@par Attributes:
  748. *use_locking: An optional bool. Defaults to "False".
  749. * If "True", updating of the "var" and "m" tensors will be
  750. * protected by a lock; otherwise the behavior is undefined,
  751. * but may exhibit less contention . \n
  752. *@par Outputs:
  753. *@li var: A mutable Tensor. Has the same type as "var".
  754. *@li m: A mutable Tensor. Has the same type as "m" . \n
  755. *@par Third-party framework compatibility
  756. * Compatible with the TensorFlow operator ApplyAddSign.
  757. *
  758. * @par Restrictions:
  759. * Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyAddSign instead.
  760. */
  761. REG_OP(ApplyAddSignD)
  762. .INPUT(var, TensorType::NumberType())
  763. .INPUT(m, TensorType::NumberType())
  764. .INPUT(lr, TensorType::NumberType())
  765. .INPUT(alpha, TensorType::NumberType())
  766. .INPUT(sign_decay, TensorType::NumberType())
  767. .INPUT(beta, TensorType::NumberType())
  768. .INPUT(grad, TensorType::NumberType())
  769. .OUTPUT(var, TensorType::NumberType())
  770. .OUTPUT(m, TensorType::NumberType())
  771. .ATTR(use_locking, Bool, false)
  772. .OP_END_FACTORY_REG(ApplyAddSignD)
  773. /**
  774. *@brief Updates "var" according to the centered RMSProp algorithm.
  775. * The centered RMSProp algorithm uses an estimate of the centered second moment
  776. * (i.e., the variance) for normalization, as opposed to regular RMSProp, which
  777. * uses the (uncentered) second moment. This often helps with training, but is
  778. * slightly more expensive in terms of computation and memory.
  779. *
  780. * t-1 mean previous period.
  781. * mg <- rho * mg{t-1} + (1-rho) * grad
  782. * ms <- rho * ms{t-1} + (1-rho) * grad * grad
  783. * mom <- momentum * mom{t-1} + lr * grad / sqrt(ms - mg * mg + epsilon)
  784. * var <- var - mom
  785. *
  786. *@attention Constraints:
  787. *@li in dense implementation of this algorithm, mg, ms, and mom will
  788. * update even if the grad is zero, but in this sparse implementation, mg, ms,
  789. * and mom will not update in iterations during which the grad is zero.
  790. *@li the input tensors must have the same shape.
  791. *
  792. *@par Inputs:
  793. *@li var: A mutable tensor. Should be from a Variable().
  794. *@li mg: A mutable tensor. Has the same type as "var".
  795. * Should be from a Variable().
  796. *@li ms: A mutable tensor. Has the same type as "var".
  797. * Should be from a Variable().
  798. *@li mom: A mutable tensor. Has the same type as "var".
  799. * Should be from a Variable().
  800. *@li lr: A scalar. Has the same type as "var".
  801. *@li rho: A scalar. Has the same type as "var".
  802. *@li momentum: A tensor. Has the same type as "var".
  803. *@li epsilon: A scalar. Has the same type as "var".
  804. *@li grad: A tensor for the gradient. Has the same type as "var".
  805. *
  806. *@par Attributes:
  807. * use_locking: An optional bool. Defaults to "False".
  808. * If "True", updating of the "var", "ms", and "mom" tensors is protected
  809. * by a lock; otherwise the behavior is undefined, but may exhibit less
  810. * contention.
  811. *
  812. *@par Outputs:
  813. * var: A mutable tensor. Has the same type as input "var".
  814. *
  815. *@par Third-party framework compatibility
  816. *Compatible with the TensorFlow operator ApplyCenteredRMSProp.
  817. *
  818. */
  819. REG_OP(ApplyCenteredRMSProp)
  820. .INPUT(var, TensorType::NumberType())
  821. .INPUT(mg, TensorType::NumberType())
  822. .INPUT(ms, TensorType::NumberType())
  823. .INPUT(mom, TensorType::NumberType())
  824. .INPUT(lr, TensorType::NumberType())
  825. .INPUT(rho, TensorType::NumberType())
  826. .INPUT(momentum, TensorType::NumberType())
  827. .INPUT(epsilon, TensorType::NumberType())
  828. .INPUT(grad, TensorType::NumberType())
  829. .OUTPUT(var, TensorType::NumberType())
  830. .ATTR(use_locking, Bool, false)
  831. .OP_END_FACTORY_REG(ApplyCenteredRMSProp)
  832. /**
  833. *@brief Updates "var" according to the centered RMSProp algorithm.
  834. * The centered RMSProp algorithm uses an estimate of the centered second moment
  835. * (i.e., the variance) for normalization, as opposed to regular RMSProp, which
  836. * uses the (uncentered) second moment. This often helps with training, but is
  837. * slightly more expensive in terms of computation and memory.
  838. *
  839. * t-1 mean previous period.
  840. * mg <- rho * mg{t-1} + (1-rho) * grad
  841. * ms <- rho * ms{t-1} + (1-rho) * grad * grad
  842. * mom <- momentum * mom{t-1} + lr * grad / sqrt(ms - mg * mg + epsilon)
  843. * var <- var - mom
  844. *
  845. *@attention Constraints:
  846. *@li in dense implementation of this algorithm, mg, ms, and mom will
  847. * update even if the grad is zero, but in this sparse implementation, mg, ms,
  848. * and mom will not update in iterations during which the grad is zero.
  849. *@li the input tensors must have the same shape.
  850. *
  851. *@par Inputs:
  852. *@li var: A mutable tensor. Should be from a Variable().
  853. *@li mg: A mutable tensor. Has the same type as "var".
  854. * Should be from a Variable().
  855. *@li ms: A mutable tensor. Has the same type as "var".
  856. * Should be from a Variable().
  857. *@li mom: A mutable tensor. Has the same type as "var".
  858. * Should be from a Variable().
  859. *@li lr: A scalar. Has the same type as "var".
  860. *@li rho: A scalar. Has the same type as "var".
  861. *@li momentum: A tensor. Has the same type as "var".
  862. *@li epsilon: A scalar. Has the same type as "var".
  863. *@li grad: A tensor for the gradient. Has the same type as "var".
  864. *
  865. *@par Attributes:
  866. * use_locking: An optional bool. Defaults to "False".
  867. * If "True", updating of the "var", "ms", and "mom" tensors is protected
  868. * by a lock; otherwise the behavior is undefined, but may exhibit less
  869. * contention.
  870. *
  871. *@par Outputs:
  872. *@li var: A mutable Tensor. Has the same type as "var".
  873. *@li mg: A mutable Tensor. Has the same type as "mg".
  874. *@li ms: A mutable Tensor. Has the same type as "ms".
  875. *@li mom: A mutable Tensor. Has the same type as "mom" . \n
  876. *@par Third-party framework compatibility
  877. *Compatible with the TensorFlow operator ApplyCenteredRMSPropD.
  878. *
  879. * @par Restrictions:
  880. * Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyCenteredRMSProp instead.
  881. */
  882. REG_OP(ApplyCenteredRMSPropD)
  883. .INPUT(var, TensorType::NumberType())
  884. .INPUT(mg, TensorType::NumberType())
  885. .INPUT(ms, TensorType::NumberType())
  886. .INPUT(mom, TensorType::NumberType())
  887. .INPUT(lr, TensorType::NumberType())
  888. .INPUT(rho, TensorType::NumberType())
  889. .INPUT(momentum, TensorType::NumberType())
  890. .INPUT(epsilon, TensorType::NumberType())
  891. .INPUT(grad, TensorType::NumberType())
  892. .OUTPUT(var, TensorType::NumberType())
  893. .OUTPUT(mg, TensorType::NumberType())
  894. .OUTPUT(ms, TensorType::NumberType())
  895. .OUTPUT(mom, TensorType::NumberType())
  896. .ATTR(use_locking, Bool, false)
  897. .OP_END_FACTORY_REG(ApplyCenteredRMSPropD)
  898. /**
  899. *@brief Updates "var" by subtracting 'alpha' * 'delta' from it.
  900. * var -= delta * alpha
  901. *
  902. *@attention Constraints:
  903. * the input tensors must have the same shape.
  904. *
  905. *@par Inputs:
  906. *@li var: A mutable tensor. Should be from a Variable().
  907. *@li alpha: A scalar. Has the same type as "var".
  908. *@li delta: A tensor for the change. Has the same type as "var".
  909. *
  910. *@par Attributes:
  911. * use_locking: An optional bool. Defaults to "False".
  912. * If "True", updating of the "var" tensors is protected
  913. * by a lock; otherwise the behavior is undefined, but may exhibit less
  914. * contention.
  915. *
  916. *@par Outputs:
  917. * var: A mutable tensor. Has the same type as input "var".
  918. *
  919. *@par Third-party framework compatibility
  920. *Compatible with the TensorFlow operator ApplyGradientDescent.
  921. *
  922. */
  923. REG_OP(ApplyGradientDescent)
  924. .INPUT(var, TensorType::NumberType())
  925. .INPUT(alpha, TensorType::NumberType())
  926. .INPUT(delta, TensorType::NumberType())
  927. .OUTPUT(var, TensorType::NumberType())
  928. .ATTR(use_locking, Bool, false)
  929. .OP_END_FACTORY_REG(ApplyGradientDescent)
  930. /**
  931. *@brief Updates "var" according to the adagrad scheme.
  932. * accum += grad * grad
  933. * var -= lr * grad * (1 / sqrt(accum))
  934. *
  935. *@attention Constraints:
  936. * the input tensors must have the same shape.
  937. *
  938. *@par Inputs:
  939. *@li var: A mutable tensor. Should be from a Variable().
  940. *@li accum: A mutable tensor. Has the same type as "var".
  941. * Should be from a Variable().
  942. *@li lr: A scalar. Has the same type as "var".
  943. *@li grad: A tensor for the gradient. Has the same type as "var".
  944. *
  945. *@par Attributes:
  946. *@li update_slots: An optional bool. Defaults to "True". If "True", the calcution will be different as "False".
  947. *@li use_locking: An optional bool. Defaults to "False".
  948. * If "True", updating of the "var", "ms", and "mom" tensors is protected
  949. * by a lock; otherwise the behavior is undefined, but may exhibit less
  950. * contention.
  951. *
  952. *@par Outputs:
  953. * var: A mutable tensor. Has the same type as input "var".
  954. *
  955. *@par Third-party framework compatibility
  956. *Compatible with the TensorFlow operator ApplyAdagrad.
  957. *
  958. */
  959. REG_OP(ApplyAdagrad)
  960. .INPUT(var, TensorType::NumberType())
  961. .INPUT(accum, TensorType::NumberType())
  962. .INPUT(lr, TensorType::NumberType())
  963. .INPUT(grad, TensorType::NumberType())
  964. .OUTPUT(var, TensorType::NumberType())
  965. .ATTR(update_slots, Bool, true)
  966. .ATTR(use_locking, Bool, false)
  967. .OP_END_FACTORY_REG(ApplyAdagrad)
  968. /**
  969. *@brief Updates "var" according to the adagrad scheme.
  970. * accum += grad * grad
  971. * var -= lr * grad * (1 / sqrt(accum))
  972. *
  973. *@attention Constraints:
  974. * the input tensors must have the same shape.
  975. *
  976. *@par Inputs:
  977. *@li var: A mutable tensor. Should be from a Variable().
  978. *@li accum: A mutable tensor. Has the same type as "var".
  979. * Should be from a Variable().
  980. *@li lr: A scalar. Has the same type as "var".
  981. *@li grad: A tensor for the gradient. Has the same type as "var".
  982. *
  983. *@par Attributes:
  984. *@li update_slots: An optional bool. Defaults to "True". If "True", the calcution will be different as "False".
  985. *@li use_locking: An optional bool. Defaults to "False".
  986. * If "True", updating of the "var", "ms", and "mom" tensors is protected
  987. * by a lock; otherwise the behavior is undefined, but may exhibit less
  988. * contention.
  989. *
  990. *@par Outputs:
  991. *@li var: A mutable tensor. Has the same type as input "var".
  992. *@li accum: A mutable tensor. Has the same type as input "var".
  993. *
  994. *@par Third-party framework compatibility
  995. *Compatible with the TensorFlow operator ApplyAdagrad.
  996. *
  997. * @par Restrictions:
  998. * Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyAdagrad instead.
  999. */
  1000. REG_OP(ApplyAdagradD)
  1001. .INPUT(var, TensorType::NumberType())
  1002. .INPUT(accum, TensorType::NumberType())
  1003. .INPUT(lr, TensorType::NumberType())
  1004. .INPUT(grad, TensorType::NumberType())
  1005. .OUTPUT(var, TensorType::NumberType())
  1006. .OUTPUT(accum, TensorType::NumberType())
  1007. .ATTR(update_slots, Bool, true)
  1008. .ATTR(use_locking, Bool, false)
  1009. .OP_END_FACTORY_REG(ApplyAdagradD)
  1010. /**
  1011. * @brief Updates "var" according to the adagradv2 scheme.
  1012. * accum += grad * grad
  1013. * var -= lr * grad * (1 / sqrt(accum) + epsilon)
  1014. *
  1015. * @par Inputs:
  1016. * @li var: A mutable tensor. Must be one of the data types defined in
  1017. * TensorType::NumberType(). Should be from a Variable().
  1018. * @li accum: A mutable tensor. Has the same type as "var". Should be from a
  1019. * Variable().
  1020. * @li lr: A tensor for the learning rate. Has the same type as "var". Should be
  1021. * from a Variable().
  1022. * @li grad: A tensor for the gradient. Has the same type as "var". Should be
  1023. * from a Variable().
  1024. * @li epsilon: A scalar. Has the same type as "var".
  1025. *
  1026. * @par Attributes:
  1027. * @li update_slots: An optional bool. Defaults to "True".
  1028. * If "True", "accum" will be updated
  1029. * @li use_locking: An optional bool. Defaults to "False".
  1030. * If "True", updating of the "var" tensor is protected by a lock;
  1031. * otherwise the behavior is undefined, but may exhibit less contention.
  1032. *
  1033. * @par Outputs:
  1034. * var: A mutable tensor. Has the same type as input "var".
  1035. *
  1036. * @attention Constraints:
  1037. * The input tensors must have the same shape.
  1038. *
  1039. * @par Third-party framework compatibility
  1040. * Compatible with the TensorFlow operator ApplyAdagrad.
  1041. *
  1042. */
  1043. REG_OP(ApplyAdagradV2)
  1044. .INPUT(var, TensorType::NumberType())
  1045. .INPUT(accum, TensorType::NumberType())
  1046. .INPUT(lr, TensorType::NumberType())
  1047. .INPUT(epsilon, TensorType::NumberType())
  1048. .INPUT(grad, TensorType::NumberType())
  1049. .OUTPUT(var, TensorType::NumberType())
  1050. .ATTR(update_slots, Bool, true)
  1051. .ATTR(use_locking, Bool, false)
  1052. .OP_END_FACTORY_REG(ApplyAdagradV2)
  1053. /**
  1054. * @brief Updates "var" according to the adagradv2 scheme.
  1055. * accum += grad * grad
  1056. * var -= lr * grad * (1 / sqrt(accum) + epsilon)
  1057. *
  1058. * @par Inputs:
  1059. * @li var: A mutable tensor. Must be one of the data types defined in
  1060. * TensorType::NumberType(). Should be from a Variable().
  1061. * @li accum: A mutable tensor. Has the same type as "var". Should be from a
  1062. * Variable().
  1063. * @li lr: A tensor for the learning rate. Has the same type as "var". Should be
  1064. * from a Variable().
  1065. * @li grad: A tensor for the gradient. Has the same type as "var". Should be
  1066. * from a Variable().
  1067. *
  1068. * @par Attributes:
  1069. * @li epsilon: A scalar. Has the same type as "var".
  1070. * @li update_slots: An optional bool. Defaults to "True".
  1071. * If "True", "accum" will be updated
  1072. * @li use_locking: An optional bool. Defaults to "False".
  1073. * If "True", updating of the "var" tensor is protected by a lock;
  1074. * otherwise the behavior is undefined, but may exhibit less contention.
  1075. *
  1076. * @par Outputs:
  1077. * var: A mutable tensor. Has the same type as input "var".
  1078. *
  1079. * @attention Constraints:
  1080. * The input tensors must have the same shape.
  1081. *
  1082. * @par Third-party framework compatibility
  1083. * Compatible with the TensorFlow operator ApplyAdagrad.
  1084. *
  1085. *@par Restrictions:
  1086. *Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyAdagradV2 instead.
  1087. */
  1088. REG_OP(ApplyAdagradV2D)
  1089. .INPUT(var, TensorType::NumberType())
  1090. .INPUT(accum, TensorType::NumberType())
  1091. .INPUT(lr, TensorType::NumberType())
  1092. .INPUT(grad, TensorType::NumberType())
  1093. .OUTPUT(var, TensorType::NumberType())
  1094. .OUTPUT(accum, TensorType::NumberType())
  1095. .REQUIRED_ATTR(epsilon, Float)
  1096. .ATTR(update_slots, Bool, true)
  1097. .ATTR(use_locking, Bool, false)
  1098. .OP_END_FACTORY_REG(ApplyAdagradV2D)
  1099. /**
  1100. *@brief Updates "var" according to the proximal adagrad scheme . \n
  1101. *@par Inputs:
  1102. *Eight inputs, including:
  1103. * @li var: A mutable Tensor. Must be one of the following types:
  1104. * TensorType::NumberType(). Should be a Variable Tensor.
  1105. * @li gradient_accumulator: A mutable Tensor. Must have the same
  1106. * type as "var". Should be a Variable Tensor.
  1107. * @li gradient_squared_accumulator: A mutable Tensor of the same type as "var".
  1108. * Should be a Variable Tensor.
  1109. * @li grad: A Tensor of the same type as "var", for the gradient.
  1110. * @li lr: A Tensor of the same type as "var".
  1111. * Scaling factor. Must be a scalar.
  1112. * @li l1: A Tensor of the same type as "var".
  1113. * L1 regulariation. Must be a scalar.
  1114. * @li l2: A Tensor of the same type as "var".
  1115. * L2 regulariation. Must be a scalar.
  1116. * @li global_step: A Tensor of type int32 or int64.
  1117. * Training step number. Must be a scalar . \n
  1118. *@par Attributes:
  1119. *use_locking: An optional bool. Defaults to "False".
  1120. * If "True", updating of the var and accum tensors will be
  1121. * protected by a lock; otherwise the behavior is undefined,
  1122. * but may exhibit less contention . \n
  1123. *@par Outputs:
  1124. *var: A mutable Tensor. Has the same type as "var" . \n
  1125. *@par Third-party framework compatibility
  1126. *Compatible with the TensorFlow operator ApplyAdagradDA.
  1127. */
  1128. REG_OP(ApplyAdagradDA)
  1129. .INPUT(var, TensorType::NumberType())
  1130. .INPUT(gradient_accumulator, TensorType::NumberType())
  1131. .INPUT(gradient_squared_accumulator, TensorType::NumberType())
  1132. .INPUT(grad, TensorType::NumberType())
  1133. .INPUT(lr, TensorType::NumberType())
  1134. .INPUT(l1, TensorType::NumberType())
  1135. .INPUT(l2, TensorType::NumberType())
  1136. .INPUT(global_step, TensorType({DT_INT32, DT_INT64}))
  1137. .OUTPUT(var, TensorType::NumberType())
  1138. .ATTR(use_locking, Bool, false)
  1139. .OP_END_FACTORY_REG(ApplyAdagradDA)
  1140. /**
  1141. *@brief Updates "var" according to the proximal adagrad scheme . \n
  1142. *@par Inputs:
  1143. *Eight inputs, including:
  1144. * @li var: A mutable Tensor. Must be one of the following types:
  1145. * TensorType::NumberType(). Should be a Variable Tensor.
  1146. * @li gradient_accumulator: A mutable Tensor. Must have the same
  1147. * type as "var". Should be a Variable Tensor.
  1148. * @li gradient_squared_accumulator: A mutable Tensor of the same type as "var".
  1149. * Should be a Variable Tensor.
  1150. * @li grad: A Tensor of the same type as "var", for the gradient.
  1151. * @li lr: A Tensor of the same type as "var".
  1152. * Scaling factor. Must be a scalar.
  1153. * @li l1: A Tensor of the same type as "var".
  1154. * L1 regulariation. Must be a scalar.
  1155. * @li l2: A Tensor of the same type as "var".
  1156. * L2 regulariation. Must be a scalar.
  1157. * @li global_step: A Tensor of type int32 or int64.
  1158. * Training step number. Must be a scalar . \n
  1159. *@par Attributes:
  1160. *use_locking: An optional bool. Defaults to "False".
  1161. * If "True", updating of the var and accum tensors will be
  1162. * protected by a lock; otherwise the behavior is undefined,
  1163. * but may exhibit less contention . \n
  1164. *@par Outputs:
  1165. *var: A mutable Tensor. Has the same type as "var".
  1166. *gradient_accumulator: A mutable Tensor. Has the same type as "var".
  1167. *gradient_squared_accumulator: A mutable Tensor. Has the same type as "var" . \n
  1168. *@par Third-party framework compatibility
  1169. *Compatible with the TensorFlow operator ApplyAdagradDA.
  1170. *
  1171. * @par Restrictions:
  1172. * Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyAdagradDA instead.
  1173. */
  1174. REG_OP(ApplyAdagradDAD)
  1175. .INPUT(var, TensorType::NumberType())
  1176. .INPUT(gradient_accumulator, TensorType::NumberType())
  1177. .INPUT(gradient_squared_accumulator, TensorType::NumberType())
  1178. .INPUT(grad, TensorType::NumberType())
  1179. .INPUT(lr, TensorType::NumberType())
  1180. .INPUT(l1, TensorType::NumberType())
  1181. .INPUT(l2, TensorType::NumberType())
  1182. .INPUT(global_step, TensorType({DT_INT32, DT_INT64}))
  1183. .OUTPUT(var, TensorType::NumberType())
  1184. .OUTPUT(gradient_accumulator, TensorType::NumberType())
  1185. .OUTPUT(gradient_squared_accumulator, TensorType::NumberType())
  1186. .ATTR(use_locking, Bool, false)
  1187. .OP_END_FACTORY_REG(ApplyAdagradDAD)
  1188. /**
  1189. *@brief Returns the dimension index in the destination data format given the one in
  1190. * the source data format.
  1191. *
  1192. *@par Inputs:
  1193. * x: A tensor of type int32 or int64.
  1194. * A Tensor with each element as a dimension index in source data format.
  1195. * Must be in the range [-4, 4).
  1196. *
  1197. *@par Attributes:
  1198. *@li src_format: An optional string. Defaults to NHWC.
  1199. * source data format. Must of length 4.
  1200. *@li dst_format: An optional string. Defaults to NCHW.
  1201. * destination data format. Must of length 4.
  1202. *
  1203. *@par Outputs:
  1204. * y: A tensor. Has the same type as "x". Must be in the range [0, 4).
  1205. *
  1206. *@par Third-party framework compatibility
  1207. *Compatible with the TensorFlow operator DataFormatDimMap.
  1208. *
  1209. */
  1210. REG_OP(DataFormatDimMap)
  1211. .INPUT(x, TensorType::IndexNumberType())
  1212. .ATTR(src_format, String, "NHWC")
  1213. .ATTR(dst_format, String, "NCHW")
  1214. .OUTPUT(y, TensorType::IndexNumberType())
  1215. .OP_END_FACTORY_REG(DataFormatDimMap)
  1216. /**
  1217. * @brief Implements stochastic gradient descent (optionally with momentum).
  1218. * Nesterov momentum is based on the formula from
  1219. * On the importance of initialization and momentum in deep learning.
  1220. * @par Inputs:
  1221. * @li parameters: A mutable tensor of type float16 or float32.
  1222. * Specifies the iterable of parameters to optimize or dicts defining parameter
  1223. * groups.
  1224. * @li gradient: A tensor of type float16 or float32.
  1225. * Specifies the gradient of training step.
  1226. * @li learning_rate: A tensor of type float16 or float32.
  1227. * Specifies the learing_rate of training step.
  1228. * @li accum: A tensor of type float16 or float32.
  1229. * Specifies the velocity of training step.
  1230. * @li momentum: A tensor of type float16 or float32.
  1231. * Specifies the momentum factor.
  1232. * @li stat: A tensor of type float16 or float32.
  1233. * Specifies the status representing the first step or not . \n
  1234. * @par Attributes:
  1235. * @li dampening: An optional float, specifying the dampening for momentum.
  1236. * Defaults to "0.0".
  1237. * @li weight_decay: An optional float, specifying the L2 penalty. Defaults to
  1238. * "0.0".
  1239. * @li nesterov: An optional bool, specifying whether to enable Nesterov
  1240. * momentum. Defaults to "False" . \n
  1241. * @par Outputs:
  1242. * parameters: A mutable tensor same as input "parameters" . \n
  1243. * @see ApplyMomentum()
  1244. * @par Third-party framework compatibility
  1245. * @li Compatible with the PyTorch operator SGD.
  1246. */
  1247. REG_OP(SGD)
  1248. .INPUT(parameters, TensorType(DT_FLOAT, DT_FLOAT16))
  1249. .INPUT(gradient, TensorType(DT_FLOAT, DT_FLOAT16))
  1250. .INPUT(learning_rate, TensorType(DT_FLOAT, DT_FLOAT16))
  1251. .INPUT(accum, TensorType(DT_FLOAT, DT_FLOAT16))
  1252. .INPUT(momentum, TensorType(DT_FLOAT, DT_FLOAT16))
  1253. .INPUT(stat, TensorType(DT_FLOAT, DT_FLOAT16))
  1254. .OUTPUT(parameters, TensorType(DT_FLOAT, DT_FLOAT16))
  1255. .ATTR(dampening, Float, 0.0)
  1256. .ATTR(weight_decay, Float, 0.0)
  1257. .ATTR(nesterov, Bool, false)
  1258. .OP_END_FACTORY_REG(SGD)
  1259. /**
  1260. * @brief Updates "var" according to the RMSProp algorithm.
  1261. * mean_square = decay * mean_square + (1-decay) * gradient ** 2
  1262. * Delta = learning_rate * gradient / sqrt(mean_square + epsilon)
  1263. * ms <- rho * ms_{t-1} + (1-rho) * grad * grad
  1264. * mom <- momentum * mom_{t-1} + lr * grad / sqrt(ms + epsilon)
  1265. * var <- var - mom
  1266. *
  1267. * @par Inputs:
  1268. * @li var: A mutable tensor. Must be one of the data types defined in
  1269. * TensorType::NumberType(). Should be from a Variable().
  1270. * @li ms: A mutable tensor. Must have the same type as "var". Should be from a
  1271. * Variable().
  1272. * @li mom: A mutable tensor. Must have the same type as "var". Should be from a
  1273. * Variable().
  1274. * @li lr: A scalar. Must have the same type as "var".
  1275. * @li rho: A scalar. Must have the same type as "var".
  1276. * @li momentum: A scalar. Must have the same type as "var".
  1277. * @li epsilon: A scalar. Must have the same type as "var".
  1278. * @li grad: A tensor, specifying the gradient. Must have the same type as "var".
  1279. *
  1280. * @par Attributes:
  1281. * use_locking: An optional "bool". Defaults to "False". If "True", updating of
  1282. * the "var", "ms", and "mom" tensors will be protected by a lock; otherwise the
  1283. * behavior is undefined, but may exhibit less contention.
  1284. *
  1285. * @par Outputs:
  1286. * var: A mutable tensor. Has the same type as input "var".
  1287. *
  1288. * @attention Constraints:
  1289. * @li Note that in dense implementation of this algorithm, "ms" and "mom" will
  1290. * update even if "grad" is 0, but in this sparse implementation, "ms" and "mom"
  1291. * will not update in iterations during which "grad" is 0.
  1292. * @li The input tensors "var", "ms", "mom" and "grad" must have the same shape.
  1293. *
  1294. * @par Third-party framework compatibility
  1295. * @li Compatible with the TensorFlow operator ApplyRMSProp.
  1296. */
  1297. REG_OP(ApplyRMSProp)
  1298. .INPUT(var, TensorType::NumberType())
  1299. .INPUT(ms, TensorType::NumberType())
  1300. .INPUT(mom, TensorType::NumberType())
  1301. .INPUT(lr, TensorType::NumberType())
  1302. .INPUT(rho, TensorType::NumberType())
  1303. .INPUT(momentum, TensorType::NumberType())
  1304. .INPUT(epsilon, TensorType::NumberType())
  1305. .INPUT(grad, TensorType::NumberType())
  1306. .OUTPUT(var, TensorType::NumberType())
  1307. .ATTR(use_locking, Bool, false)
  1308. .OP_END_FACTORY_REG(ApplyRMSProp)
  1309. /**
  1310. * @brief Updates "var" according to the RMSProp algorithm, a const input will be
  1311. * considered as an attribute.
  1312. * mean_square = decay * mean_square + (1-decay) * gradient ** 2
  1313. * Delta = learning_rate * gradient / sqrt(mean_square + epsilon)
  1314. * ms <- rho * ms_{t-1} + (1-rho) * grad * grad
  1315. * mom <- momentum * mom_{t-1} + lr * grad / sqrt(ms + epsilon)
  1316. * var <- var - mom
  1317. *
  1318. * @par Inputs:
  1319. * @li var: A mutable tensor. Must be one of the data types defined in
  1320. * TensorType::NumberType(). Should be from a Variable().
  1321. * @li ms: A mutable tensor. Must have the same type as "var". Should be from a
  1322. * Variable().
  1323. * @li mom: A mutable tensor. Must have the same type as "var". Should be from a
  1324. * Variable().
  1325. * @li lr: A scalar. Must have the same type as "var".
  1326. * @li grad: A tensor, specifying the gradient. Must have the same type as "var".
  1327. *
  1328. * @par Attributes:
  1329. * @li use_locking: An optional "bool". Defaults to "False". If "True", updating
  1330. * of the "var", "ms", and "mom" tensors will be protected by a lock;
  1331. * otherwise the behavior is undefined, but may exhibit less contention.
  1332. * @li rho: A required scalar. Must have the same type as "var".
  1333. * @li momentum: A required scalar. Must have the same type as "var".
  1334. * @li epsilon: A required scalar. Must have the same type as "var".
  1335. *
  1336. * @par Outputs:
  1337. * var: A mutable tensor. Must have the same type as input "var".
  1338. *
  1339. * @attention Constraints:
  1340. * @li Note that in dense implementation of this algorithm, "ms" and "mom" will
  1341. * update even if "grad" is 0, but in this sparse implementation, "ms" and "mom"
  1342. * will not update in iterations during which "grad" is 0.
  1343. * @li The input tensors "var", "ms", "mom" and "grad" must have the same shape.
  1344. *
  1345. * @par Third-party framework compatibility
  1346. * @li Compatible with the TensorFlow operator ApplyRMSProp.
  1347. *
  1348. *@par Restrictions:
  1349. *Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyRMSProp instead.
  1350. */
  1351. REG_OP(ApplyRMSPropD)
  1352. .INPUT(var, TensorType::NumberType())
  1353. .INPUT(ms, TensorType::NumberType())
  1354. .INPUT(mom, TensorType::NumberType())
  1355. .INPUT(lr, TensorType::NumberType())
  1356. .INPUT(grad, TensorType::NumberType())
  1357. .OUTPUT(var, TensorType::NumberType())
  1358. .OUTPUT(ms, TensorType::NumberType())
  1359. .OUTPUT(mom, TensorType::NumberType())
  1360. .REQUIRED_ATTR(rho, Float)
  1361. .REQUIRED_ATTR(momentum, Float)
  1362. .REQUIRED_ATTR(epsilon, Float)
  1363. .ATTR(use_locking, Bool, false)
  1364. .OP_END_FACTORY_REG(ApplyRMSPropD)
  1365. /**
  1366. *@brief Update "var" and "accum" according to FOBOS with Adagrad learning rate . \n
  1367. *@par Inputs:
  1368. *Six inputs, including:
  1369. * @li var: A mutable Tensor of type TensorType::NumberType().
  1370. * Should be from a Variable().
  1371. * @li accum: A mutable Tensor of the same type as "var". Should be from a Variable().
  1372. * @li lr: A Tensor of the same type as "var", for the scaling factor. Must be a scalar.
  1373. * @li l1: A Tensor of the same type as "var", for L1 regulariation. Must be a scalar.
  1374. * @li l2: A Tensor of the same type as "var", for L2 regulariation. Must be a scalar.
  1375. * @li grad: A Tensor of the same type as "var", for the gradient . \n
  1376. *@par Attributes:
  1377. *use_locking: An optional bool. Defaults to "False". If "True", updating of the "var" and "accum" *tensors will be protected by a lock; otherwise the behavior is undefined, but may exhibit less *contention . \n
  1378. *@par Outputs:
  1379. *var: A mutable tensor. Must have the same type as input "var" . \n
  1380. *@par Third-party framework compatibility
  1381. *Compatible with the TensorFlow operator ApplyProximalAdagrad.
  1382. */
  1383. REG_OP(ApplyProximalAdagrad)
  1384. .INPUT(var, TensorType::NumberType())
  1385. .INPUT(accum, TensorType::NumberType())
  1386. .INPUT(lr, TensorType::NumberType())
  1387. .INPUT(l1, TensorType::NumberType())
  1388. .INPUT(l2, TensorType::NumberType())
  1389. .INPUT(grad, TensorType::NumberType())
  1390. .OUTPUT(var, TensorType::NumberType())
  1391. .ATTR(use_locking, Bool, false)
  1392. .OP_END_FACTORY_REG(ApplyProximalAdagrad)
  1393. /**
  1394. *@brief Update "var" and "accum" according to FOBOS with Adagrad learning rate . \n
  1395. *@par Inputs:
  1396. *Six inputs, including:
  1397. * @li var: A mutable Tensor of type TensorType::NumberType().
  1398. * Should be from a Variable().
  1399. * @li accum: A mutable Tensor of the same type as "var". Should be from a Variable().
  1400. * @li lr: A Tensor of the same type as "var", for the scaling factor. Must be a scalar.
  1401. * @li l1: A Tensor of the same type as "var", for L1 regulariation. Must be a scalar.
  1402. * @li l2: A Tensor of the same type as "var", for L2 regulariation. Must be a scalar.
  1403. * @li grad: A Tensor of the same type as "var", for the gradient . \n
  1404. *@par Attributes:
  1405. *use_locking: An optional bool. Defaults to "False". If "True", updating of the "var" and "accum" *tensors will be protected by a lock; otherwise the behavior is undefined, but may exhibit less *contention . \n
  1406. *@par Outputs:
  1407. * @li var: A mutable Tensor. Has the same type as "var".
  1408. * @li accum: A mutable Tensor. Has the same type as "var" . \n
  1409. *@par Third-party framework compatibility
  1410. *Compatible with the TensorFlow operator ApplyProximalAdagradD.
  1411. *
  1412. * @par Restrictions:
  1413. * Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyProximalAdagrad instead.
  1414. */
  1415. REG_OP(ApplyProximalAdagradD)
  1416. .INPUT(var, TensorType::NumberType())
  1417. .INPUT(accum, TensorType::NumberType())
  1418. .INPUT(lr, TensorType::NumberType())
  1419. .INPUT(l1, TensorType::NumberType())
  1420. .INPUT(l2, TensorType::NumberType())
  1421. .INPUT(grad, TensorType::NumberType())
  1422. .OUTPUT(var, TensorType::NumberType())
  1423. .OUTPUT(accum, TensorType::NumberType())
  1424. .ATTR(use_locking, Bool, false)
  1425. .OP_END_FACTORY_REG(ApplyProximalAdagradD)
  1426. /**
  1427. *@brief Updates entries in 'var' and 'accum' according to the Proximal Adagrad algorithm.
  1428. * Compared with op ApplyProximalAdagrad, an additional index tensor is input,
  1429. * Only the indices into the first dimensions of "var" and "accum" are updated . \n
  1430. *@par Inputs:
  1431. * Seven inputs, including:
  1432. * @li var: A mutable Tensor.
  1433. * TensorType::NumberType(). Should be a Variable Tensor.
  1434. * @li accum: A mutable Tensor of the same type as "var".
  1435. * Should be a Variable Tensor. Should be greater than or equal to zero.
  1436. * Accum and grad cannot be equal to zero at the same time.
  1437. * @li lr: A Tensor of the same type as "var".
  1438. * Scaling factor. Must be a scalar. Should be greater than zero.
  1439. * @li l1: A Tensor of the same type as "var".
  1440. * L1 regulariation. Must be a scalar. Should be greater than or equal to zero.
  1441. * @li l2: A Tensor of the same type as "var".
  1442. * L2 regulariation. Must be a scalar. Should be greater than or equal to zero.
  1443. * @li grad: A Tensor. Has the same type as "var".
  1444. * The gradient.
  1445. * @li indices: A vector of indices into the first dimension of "var" and "accum".
  1446. * TensorType::IndexNumberType(). Can contain duplicate values . \n
  1447. *@par Attributes:
  1448. *use_locking: An optional bool. Defaults to "False".
  1449. * If "True", updating of the var and accum tensors will be protected by a lock;
  1450. * If "False", the behavior is undefined, but may exhibit less contention.
  1451. *@par Outputs:
  1452. *var: A mutable Tensor. Has the same type as "var" . \n
  1453. *@par Third-party framework compatibility
  1454. *Compatible with the TensorFlow operator SparseApplyProximalAdagrad.
  1455. */
  1456. REG_OP(SparseApplyProximalAdagrad)
  1457. .INPUT(var, TensorType::NumberType())
  1458. .INPUT(accum, TensorType::NumberType())
  1459. .INPUT(lr, TensorType::NumberType())
  1460. .INPUT(l1, TensorType::NumberType())
  1461. .INPUT(l2, TensorType::NumberType())
  1462. .INPUT(grad, TensorType::NumberType())
  1463. .INPUT(indices, TensorType::IndexNumberType())
  1464. .OUTPUT(var, TensorType::NumberType())
  1465. .ATTR(use_locking, Bool, false)
  1466. .OP_END_FACTORY_REG(SparseApplyProximalAdagrad)
  1467. /**
  1468. *@brief Updates entries in 'var' and 'accum' according to the Proximal Adagrad algorithm.\ n
  1469. * Compared with op ApplyProximalAdagrad, an additional index tensor is input,
  1470. * Only the indices into the first dimensions of "var" and "accum" are updated . \n
  1471. *@par Inputs:
  1472. * Seven inputs, including:
  1473. * @li var: A mutable Tensor.
  1474. * TensorType::NumberType(). Should be a Variable Tensor.
  1475. * @li accum: A mutable Tensor of the same type as "var".
  1476. * Should be a Variable Tensor. Should be greater than or equal to zero.
  1477. * Accum and grad cannot be equal to zero at the same time.
  1478. * @li lr: A Tensor of the same type as "var".
  1479. * Scaling factor. Must be a scalar. Should be greater than zero.
  1480. * @li l1: A Tensor of the same type as "var".
  1481. * L1 regulariation. Must be a scalar. Should be greater than or equal to zero.
  1482. * @li l2: A Tensor of the same type as "var".
  1483. * L2 regulariation. Must be a scalar. Should be greater than or equal to zero.
  1484. * @li grad: A Tensor. Has the same type as "var".
  1485. * The gradient.
  1486. * @li indices: A vector of indices into the first dimension of "var" and "accum".
  1487. * TensorType::IndexNumberType(). Can contain duplicate values . \n
  1488. *@par Attributes:
  1489. *use_locking: An optional bool. Defaults to "False".
  1490. * If "True", updating of the var and accum tensors will be protected by a lock;
  1491. * If "False", the behavior is undefined, but may exhibit less contention . \n
  1492. *@par Outputs:
  1493. *@li var: A mutable Tensor. Has the same type as "var".
  1494. *@li accum: A mutable Tensor. Has the same type as "var" . \n
  1495. *@par Third-party framework compatibility
  1496. *Compatible with the TensorFlow operator SparseApplyProximalAdagrad.
  1497. * @par Restrictions:
  1498. * Warning: THIS FUNCTION IS DEPRECATED. Please use SparseApplyProximalAdagrad instead.
  1499. */
  1500. REG_OP(SparseApplyProximalAdagradD)
  1501. .INPUT(var, TensorType::NumberType())
  1502. .INPUT(accum, TensorType::NumberType())
  1503. .INPUT(lr, TensorType::NumberType())
  1504. .INPUT(l1, TensorType::NumberType())
  1505. .INPUT(l2, TensorType::NumberType())
  1506. .INPUT(grad, TensorType::NumberType())
  1507. .INPUT(indices, TensorType::IndexNumberType())
  1508. .OUTPUT(var, TensorType::NumberType())
  1509. .OUTPUT(accum, TensorType::NumberType())
  1510. .ATTR(use_locking, Bool, false)
  1511. .OP_END_FACTORY_REG(SparseApplyProximalAdagradD)
  1512. /**
  1513. *@brief Updates "var" according to the Ftrl-proximal scheme . \n
  1514. *@par Inputs:
  1515. *Eight inputs, including:
  1516. * @li var: A mutable Tensor. Must be of type TensorType::NumberType().
  1517. * Should be a Variable Tensor.
  1518. * @li accum: A mutable Tensor of the same type as "var".
  1519. * Should be a Variable Tensor.
  1520. * @li linear: A mutable Tensor of the same type as "var".
  1521. * Should be a Variable Tensor.
  1522. * @li grad: A Tensor of the same type as "var", for the gradient.
  1523. * @li lr: A Tensor of the same type as "var", for the scaling factor. Must be a scalar.
  1524. * @li l1: A Tensor of the same type as "var", for L1 regulariation. Must be a scalar.
  1525. * @li l2: A Tensor of the same type as "var", for L2 regulariation. Must be a scalar.
  1526. * @li lr_power: A Tensor of the same type as "var", for the scaling factor. Must be a scalar . \n
  1527. *@par Attributes:
  1528. *use_locking: An optional bool. Defaults to "False".
  1529. * If "True", updating of the "var" and "accum" tensors will be
  1530. * protected by a lock; otherwise the behavior is undefined,
  1531. * but may exhibit less contention . \n
  1532. *@par Outputs:
  1533. *var: A mutable Tensor. Has the same type as "var" . \n
  1534. *@par Third-party framework compatibility
  1535. *Compatible with the TensorFlow operator ApplyFtrl.
  1536. */
  1537. REG_OP(ApplyFtrl)
  1538. .INPUT(var, TensorType::NumberType())
  1539. .INPUT(accum, TensorType::NumberType())
  1540. .INPUT(linear, TensorType::NumberType())
  1541. .INPUT(grad, TensorType::NumberType())
  1542. .INPUT(lr, TensorType::NumberType())
  1543. .INPUT(l1, TensorType::NumberType())
  1544. .INPUT(l2, TensorType::NumberType())
  1545. .INPUT(lr_power, TensorType::NumberType())
  1546. .OUTPUT(var, TensorType::NumberType())
  1547. .ATTR(use_locking, Bool, false)
  1548. .OP_END_FACTORY_REG(ApplyFtrl)
  1549. /**
  1550. *@brief Updates "var" according to the Ftrl-proximal scheme . \n
  1551. *@par Inputs:
  1552. *Eight inputs, including:
  1553. * @li var: A mutable Tensor. Must be of type TensorType::NumberType().
  1554. * Should be a Variable Tensor.
  1555. * @li accum: A mutable Tensor of the same type as "var".
  1556. * Should be a Variable Tensor.
  1557. * @li linear: A mutable Tensor of the same type as "var".
  1558. * Should be a Variable Tensor.
  1559. * @li grad: A Tensor of the same type as "var", for the gradient.
  1560. * @li lr: A Tensor of the same type as "var", for the scaling factor. Must be a scalar.
  1561. * @li l1: A Tensor of the same type as "var", for L1 regulariation. Must be a scalar.
  1562. * @li l2: A Tensor of the same type as "var", for L2 regulariation. Must be a scalar.
  1563. * @li lr_power: A Tensor of the same type as "var", for the scaling factor. Must be a scalar . \n
  1564. *@par Attributes:
  1565. *use_locking: An optional bool. Defaults to "False".
  1566. * If "True", updating of the "var" and "accum" tensors will be
  1567. * protected by a lock; otherwise the behavior is undefined,
  1568. * but may exhibit less contention . \n
  1569. *@par Outputs:
  1570. *@li var: A mutable Tensor. Has the same type as "var".
  1571. *@li accum: A mutable Tensor. Has the same type as "accum".
  1572. *@li linear: A mutable Tensor. Has the same type as "linear" . \n
  1573. *@par Third-party framework compatibility
  1574. *Compatible with the TensorFlow operator ApplyFtrl.
  1575. *
  1576. * @par Restrictions:
  1577. * Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyFtrl instead.
  1578. */
  1579. REG_OP(ApplyFtrlD)
  1580. .INPUT(var, TensorType::NumberType())
  1581. .INPUT(accum, TensorType::NumberType())
  1582. .INPUT(linear, TensorType::NumberType())
  1583. .INPUT(grad, TensorType::NumberType())
  1584. .INPUT(lr, TensorType::NumberType())
  1585. .INPUT(l1, TensorType::NumberType())
  1586. .INPUT(l2, TensorType::NumberType())
  1587. .INPUT(lr_power, TensorType::NumberType())
  1588. .OUTPUT(var, TensorType::NumberType())
  1589. .OUTPUT(accum, TensorType::NumberType())
  1590. .OUTPUT(linear, TensorType::NumberType())
  1591. .ATTR(use_locking, Bool, false)
  1592. .OP_END_FACTORY_REG(ApplyFtrlD)
  1593. /**
  1594. *@brief Update "var" according to the Ftrl-proximal scheme . \n
  1595. *@par Inputs:
  1596. *Nine inputs, including:
  1597. * @li var: A mutable Tensor. Must be of type TensorType::NumberType().
  1598. * Should be a Variable Tensor.
  1599. * @li accum: A mutable Tensor of the same type as "var".
  1600. * Should be a Variable Tensor.
  1601. * @li linear: A mutable Tensor of the same type as "var".
  1602. * Should be a Variable Tensor.
  1603. * @li grad: A Tensor of the same type as "var", for the gradient.
  1604. * @li lr: A Tensor of the same type as "var", for the scaling factor. Must be a scalar.
  1605. * @li l1: A Tensor of the same type as "var", for L1 regulariation. Must be a scalar.
  1606. * @li l2: A Tensor of the same type as "var", for L2 regulariation. Must be a scalar.
  1607. * @li l2_shrinkage: A Tensor of the same type as "var".
  1608. * @li lr_power: A Tensor of the same type as "var", for the scaling factor. Must be a scalar . \n
  1609. *@par Attributes:
  1610. *use_locking: An optional bool. Defaults to "False".
  1611. * If "True", updating of the "var" and "accum" tensors will be
  1612. * protected by a lock; otherwise the behavior is undefined,
  1613. * but may exhibit less contention . \n
  1614. *@par Outputs:
  1615. *var: A mutable Tensor. Has the same type as "var" . \n
  1616. *@par Third-party framework compatibility
  1617. *Compatible with the TensorFlow operator ApplyFtrlV2.
  1618. */
  1619. REG_OP(ApplyFtrlV2)
  1620. .INPUT(var, TensorType::NumberType())
  1621. .INPUT(accum, TensorType::NumberType())
  1622. .INPUT(linear, TensorType::NumberType())
  1623. .INPUT(grad, TensorType::NumberType())
  1624. .INPUT(lr, TensorType::NumberType())
  1625. .INPUT(l1, TensorType::NumberType())
  1626. .INPUT(l2, TensorType::NumberType())
  1627. .INPUT(l2_shrinkage, TensorType::NumberType())
  1628. .INPUT(lr_power, TensorType::NumberType())
  1629. .OUTPUT(var, TensorType::NumberType())
  1630. .ATTR(use_locking, Bool, false)
  1631. .OP_END_FACTORY_REG(ApplyFtrlV2)
  1632. /**
  1633. *@brief Update "var" according to the Ftrl-proximal scheme . \n
  1634. *@par Inputs:
  1635. *Nine inputs, including:
  1636. * @li var: A mutable Tensor. Must be of type TensorType::NumberType().
  1637. * Should be a Variable Tensor.
  1638. * @li accum: A mutable Tensor of the same type as "var".
  1639. * Should be a Variable Tensor.
  1640. * @li linear: A mutable Tensor of the same type as "var".
  1641. * Should be a Variable Tensor.
  1642. * @li grad: A Tensor of the same type as "var", for the gradient.
  1643. * @li lr: A Tensor of the same type as "var", for the scaling factor. Must be a scalar.
  1644. * @li l1: A Tensor of the same type as "var", for L1 regulariation. Must be a scalar.
  1645. * @li l2: A Tensor of the same type as "var", for L2 regulariation. Must be a scalar.
  1646. * @li l2_shrinkage: A Tensor of the same type as "var".
  1647. * @li lr_power: A Tensor of the same type as "var", for the scaling factor. Must be a scalar . \n
  1648. *@par Attributes:
  1649. *use_locking: An optional bool. Defaults to "False".
  1650. * If "True", updating of the "var" and "accum" tensors will be
  1651. * protected by a lock; otherwise the behavior is undefined,
  1652. * but may exhibit less contention . \n
  1653. *@par Outputs:
  1654. *var: A mutable Tensor. Has the same type as "var".
  1655. *accum: A mutable Tensor. Has the same type as "accum".
  1656. *linear: A mutable Tensor. Has the same type as "linear" . \n
  1657. *@par Third-party framework compatibility
  1658. *Compatible with the TensorFlow operator ApplyFtrlV2.
  1659. *
  1660. * @par Restrictions:
  1661. * Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyFtrlV2 instead.
  1662. */
  1663. REG_OP(ApplyFtrlV2D)
  1664. .INPUT(var, TensorType::NumberType())
  1665. .INPUT(accum, TensorType::NumberType())
  1666. .INPUT(linear, TensorType::NumberType())
  1667. .INPUT(grad, TensorType::NumberType())
  1668. .INPUT(lr, TensorType::NumberType())
  1669. .INPUT(l1, TensorType::NumberType())
  1670. .INPUT(l2, TensorType::NumberType())
  1671. .INPUT(l2_shrinkage, TensorType::NumberType())
  1672. .INPUT(lr_power, TensorType::NumberType())
  1673. .OUTPUT(var, TensorType::NumberType())
  1674. .OUTPUT(accum, TensorType::NumberType())
  1675. .OUTPUT(linear, TensorType::NumberType())
  1676. .ATTR(use_locking, Bool, false)
  1677. .OP_END_FACTORY_REG(ApplyFtrlV2D)
  1678. /**
  1679. *@brief Updates "var" according to the Adam algorithm.
  1680. * lr_t <- text{learning\_rate} * sqrt{1 - beta_2^t} / (1 - beta_1^t)
  1681. * m_t <- beta_1 * m_{t-1} + (1 - beta_1) * g
  1682. * v_t <- max(beta2 * v{t-1}, abs(g))
  1683. * variable <- variable - lr_t * m_t / (sqrt{v_t} + epsilon)
  1684. *
  1685. *@attention Constraints:
  1686. * *The input tensors must have the same shape.*
  1687. *
  1688. *@par Inputs:
  1689. *@li var: A mutable Tensor of the type TensorType::NumberType().
  1690. * Should be from a Variable().
  1691. *@li m: A mutable Tensor of the same type as "var".
  1692. * Should be from a Variable().
  1693. *@li v: A mutable Tensor of the same type as "var".
  1694. * Should be from a Variable().
  1695. *@li beta1_power: A scalar of the same type as "var".
  1696. *@li beta2_power: A scalar of the same type as "var".
  1697. *@li lr: learning_rate. A scalar of the same type as "var".
  1698. *@li beta1: A scalar of the same type as "var".
  1699. *@li beta2: A scalar of the same type as "var".
  1700. *@li epsilon: A scalar of the same type as "var".
  1701. *@li grad: A Tensor of the same type as "var", for the gradient.
  1702. *
  1703. *@par Attributes:
  1704. *@li use_locking: An optional bool. Defaults to "False".
  1705. * If "True", updating of the "var", m", and "v" tensors will be protected
  1706. * by a lock; otherwise the behavior is undefined, but may exhibit less
  1707. * contention.
  1708. *@li use_nesterov: An optional bool. Defaults to "False".
  1709. If "True", uses the nesterov update.
  1710. *
  1711. *@par Outputs:
  1712. * var: A mutable Tensor. Has the same type as intput "var" . \n
  1713. *@par Third-party framework compatibility
  1714. *Compatible with the TensorFlow operator ApplyAdam.
  1715. */
  1716. REG_OP(ApplyAdam)
  1717. .INPUT(var, TensorType::NumberType())
  1718. .INPUT(m, TensorType::NumberType())
  1719. .INPUT(v, TensorType::NumberType())
  1720. .INPUT(beta1_power, TensorType::NumberType())
  1721. .INPUT(beta2_power, TensorType::NumberType())
  1722. .INPUT(lr, TensorType::NumberType())
  1723. .INPUT(beta1, TensorType::NumberType())
  1724. .INPUT(beta2, TensorType::NumberType())
  1725. .INPUT(epsilon, TensorType::NumberType())
  1726. .INPUT(grad, TensorType::NumberType())
  1727. .OUTPUT(var, TensorType::NumberType())
  1728. .ATTR(use_locking, Bool, false)
  1729. .ATTR(use_nesterov, Bool, false)
  1730. .OP_END_FACTORY_REG(ApplyAdam)
  1731. /**
  1732. *@brief Updates "var" according to the Adam algorithm.
  1733. * lr_t <- text{learning\_rate} * sqrt{1 - beta_2^t} / (1 - beta_1^t)
  1734. * m_t <- beta_1 * m_{t-1} + (1 - beta_1) * g
  1735. * v_t <- max(beta2 * v{t-1}, abs(g))
  1736. * variable <- variable - lr_t * m_t / (sqrt{v_t} + epsilon)
  1737. *
  1738. *@attention Constraints:
  1739. * *The input tensors must have the same shape.*
  1740. *
  1741. *@par Inputs:
  1742. *@li var: A mutable Tensor of the type TensorType::NumberType().
  1743. * Should be from a Variable().
  1744. *@li m: A mutable Tensor of the same type as "var".
  1745. * Should be from a Variable().
  1746. *@li v: A mutable Tensor of the same type as "var".
  1747. * Should be from a Variable().
  1748. *@li beta1_power: A scalar of the same type as "var".
  1749. *@li beta2_power: A scalar of the same type as "var".
  1750. *@li lr: learning_rate. A scalar of the same type as "var".
  1751. *@li beta1: A scalar of the same type as "var".
  1752. *@li beta2: A scalar of the same type as "var".
  1753. *@li epsilon: A scalar of the same type as "var".
  1754. *@li grad: A Tensor of the same type as "var", for the gradient.
  1755. *
  1756. *@par Attributes:
  1757. *@li use_locking: An optional bool. Defaults to "False".
  1758. * If "True", updating of the "var", m", and "v" tensors will be protected
  1759. * by a lock; otherwise the behavior is undefined, but may exhibit less
  1760. * contention.
  1761. *@li use_nesterov: An optional bool. Defaults to "False".
  1762. If "True", uses the nesterov update.
  1763. *
  1764. *@par Outputs:
  1765. *@li var: A mutable tensor. Has the same type as input "var".
  1766. *@li m: A mutable tensor. Has the same type as input "m".
  1767. *@li v: A mutable tensor. Has the same type as input "v" . \n
  1768. *@par Third-party framework compatibility
  1769. *Compatible with the TensorFlow operator ApplyAdam.
  1770. *
  1771. * @par Restrictions:
  1772. * Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyAdam instead.
  1773. */
  1774. REG_OP(ApplyAdamD)
  1775. .INPUT(var, TensorType::NumberType())
  1776. .INPUT(m, TensorType::NumberType())
  1777. .INPUT(v, TensorType::NumberType())
  1778. .INPUT(beta1_power, TensorType::NumberType())
  1779. .INPUT(beta2_power, TensorType::NumberType())
  1780. .INPUT(lr, TensorType::NumberType())
  1781. .INPUT(beta1, TensorType::NumberType())
  1782. .INPUT(beta2, TensorType::NumberType())
  1783. .INPUT(epsilon, TensorType::NumberType())
  1784. .INPUT(grad, TensorType::NumberType())
  1785. .OUTPUT(var, TensorType::NumberType())
  1786. .OUTPUT(m, TensorType::NumberType())
  1787. .OUTPUT(v, TensorType::NumberType())
  1788. .ATTR(use_locking, Bool, false)
  1789. .ATTR(use_nesterov, Bool, false)
  1790. .OP_END_FACTORY_REG(ApplyAdamD)
  1791. /**
  1792. *@brief Updates "var" according to the proximal adadelta scheme . \n
  1793. *@par Inputs:
  1794. *Seven inputs, including:
  1795. * @li var: A mutable Tensor of type TensorType::NumberType().
  1796. * Should be a Variable Tensor.
  1797. * @li accum: A mutable Tensor of the same type as "var".
  1798. * Should be a Variable Tensor.
  1799. * @li accum_update: A mutable Tensor of the same type as "var".
  1800. * Should be a Variable Tensor.
  1801. * @li lr: A scalar of the same type as "var", for the scaling factor.
  1802. * @li rho: A scalar of the same type as "var", for the decay factor.
  1803. * @li epsilon: A scalar of the same type as "var", for the constant factor.
  1804. * @li grad: A Tensor of the same type as "var", for the gradient . \n
  1805. *@par Attributes:
  1806. *use_locking: An optional bool. Defaults to "False".
  1807. * If "True", updating of the "var", "accum" and "accum_update" tensors will be
  1808. * protected by a lock; otherwise the behavior is undefined,
  1809. * but may exhibit less contention . \n
  1810. *@par Outputs:
  1811. *var: A mutable Tensor. Has the same type as "var" . \n
  1812. *@par Third-party framework compatibility
  1813. * Compatible with the TensorFlow operator ApplyAdadelta.
  1814. */
  1815. REG_OP(ApplyAdadelta)
  1816. .INPUT(var, TensorType::NumberType())
  1817. .INPUT(accum, TensorType::NumberType())
  1818. .INPUT(accum_update, TensorType::NumberType())
  1819. .INPUT(lr, TensorType::NumberType())
  1820. .INPUT(rho, TensorType::NumberType())
  1821. .INPUT(epsilon, TensorType::NumberType())
  1822. .INPUT(grad, TensorType::NumberType())
  1823. .OUTPUT(var, TensorType::NumberType())
  1824. .ATTR(use_locking, Bool, false)
  1825. .OP_END_FACTORY_REG(ApplyAdadelta)
  1826. /**
  1827. *@brief Updates "var" according to the proximal adadelta scheme . \n
  1828. *@par Inputs:
  1829. *Seven inputs, including:
  1830. * @li var: A mutable Tensor of type TensorType::NumberType().
  1831. * Should be a Variable Tensor.
  1832. * @li accum: A mutable Tensor of the same type as "var".
  1833. * Should be a Variable Tensor.
  1834. * @li accum_update: A mutable Tensor of the same type as "var".
  1835. * Should be a Variable Tensor.
  1836. * @li lr: A scalar of the same type as "var", for the scaling factor.
  1837. * @li rho: A scalar of the same type as "var", for the decay factor.
  1838. * @li epsilon: A scalar of the same type as "var", for the constant factor.
  1839. * @li grad: A Tensor of the same type as "var", for the gradient . \n
  1840. *@par Attributes:
  1841. *use_locking: An optional bool. Defaults to "False".
  1842. * If "True", updating of the "var", "accum" and "accum_update" tensors will be
  1843. * protected by a lock; otherwise the behavior is undefined,
  1844. * but may exhibit less contention . \n
  1845. *@par Outputs:
  1846. *@li var: A mutable Tensor. Has the same type as "var".
  1847. *@li accum: A mutable Tensor. Has the same type as "var".
  1848. *@li accum_update: A mutable Tensor. Has the same type as "var" . \n
  1849. *@par Third-party framework compatibility
  1850. * Compatible with the TensorFlow operator ApplyAdadelta.
  1851. * @par Restrictions:
  1852. * Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyAdadelta instead.
  1853. */
  1854. REG_OP(ApplyAdadeltaD)
  1855. .INPUT(var, TensorType::NumberType())
  1856. .INPUT(accum, TensorType::NumberType())
  1857. .INPUT(accum_update, TensorType::NumberType())
  1858. .INPUT(lr, TensorType::NumberType())
  1859. .INPUT(rho, TensorType::NumberType())
  1860. .INPUT(epsilon, TensorType::NumberType())
  1861. .INPUT(grad, TensorType::NumberType())
  1862. .OUTPUT(var, TensorType::NumberType())
  1863. .OUTPUT(accum, TensorType::NumberType())
  1864. .OUTPUT(accum_update, TensorType::NumberType())
  1865. .ATTR(use_locking, Bool, false)
  1866. .OP_END_FACTORY_REG(ApplyAdadeltaD)
  1867. /**
  1868. *@brief Updates "var" according to the ApplyMomentum algorithm.
  1869. * accum = accum * momentum + x1 * x2
  1870. * if use_nesterov is True:
  1871. * var -= x1 * x2 * lr + accum * momentum * lr
  1872. * else: var -= accum * lr
  1873. *
  1874. *@par Inputs:
  1875. * Six inputs, including:
  1876. *@li var: A mutable Tensor has type TensorType::NumberType().
  1877. * Should be a Variable Tensor.
  1878. *@li accum: A mutable Tensor has the same type as "var".
  1879. * Should be a Variable Tensor.
  1880. *@li lr: A scalar has the same type as "var", for the scaling factor.
  1881. *@li x1: A Tensor has type TensorType::NumberType().
  1882. *@li momentum: A scalar has the same type as "var".
  1883. *@li x2: A scalar has the same type as "var". \n
  1884. *
  1885. *@par Attributes:
  1886. * Two attributes, including:
  1887. *@li use_nesterov: An optional bool. Defaults to "False".
  1888. * If True, the tensor passed to compute grad will be
  1889. * var - lr * momentum * accum, so in the end,
  1890. * the var you get is actually var - lr * momentum * accum.
  1891. *@li use_locking: An optional bool. Defaults to "False".
  1892. * If "True", updating of the "var", m", and "v" tensors will be protected
  1893. * by a lock; otherwise the behavior is undefined, but may exhibit
  1894. * less contention. \n
  1895. *
  1896. *@par Outputs:
  1897. * Two outputs, including:
  1898. *@li var: A mutable Tensor has the same type as "var".
  1899. *@li accum: A mutable Tensor has the same type as "var". \n
  1900. *@par Restrictions:
  1901. * Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1902. */
  1903. REG_OP(FusedMulApplyMomentum)
  1904. .INPUT(var, TensorType::NumberType())
  1905. .INPUT(accum, TensorType::NumberType())
  1906. .INPUT(lr, TensorType::NumberType())
  1907. .INPUT(x1, TensorType::NumberType())
  1908. .INPUT(momentum, TensorType::NumberType())
  1909. .INPUT(x2, TensorType::NumberType())
  1910. .OUTPUT(var, TensorType::NumberType())
  1911. .OUTPUT(accum, TensorType::NumberType())
  1912. .ATTR(use_nesterov, Bool, false)
  1913. .ATTR(use_locking, Bool, false)
  1914. .OP_END_FACTORY_REG(FusedMulApplyMomentum)
  1915. /**
  1916. * @brief Updates "var" according to the ApplyMomentum algorithm.
  1917. * accum = accum * momentum + x1 * x2
  1918. * if use_nesterov is True:
  1919. * var -= x1 * x2 * lr + accum * momentum * lr
  1920. * else:
  1921. * var -= accum * lr
  1922. *
  1923. * @par Inputs:
  1924. * Seven inputs, including:
  1925. * @li var: A mutable Tensor of type float32.
  1926. * Should be a Variable Tensor.
  1927. * @li accum: A mutable Tensor has type TensorType::NumberType().
  1928. * Should be a Variable Tensor.
  1929. * @li lr: A scalar has the same type as "accum", for the scaling factor.
  1930. * @li x1: A Tensor has the same type as "accum".
  1931. * @li momentum: A scalar has the same type as "accum".
  1932. * @li x2: A scalar has the same type as "accum".
  1933. * @li var_copy: A Tensor has type float16.
  1934. *
  1935. * @par Attributes:
  1936. * Two Attributes, including:
  1937. * @li use_nesterov: An optional bool. Defaults to "False".
  1938. * If True, the tensor passed to compute grad will be var - lr * momentum * accum,
  1939. * so in the end, the var you get is actually var - lr * momentum * accum.
  1940. * @li use_locking: An optional bool. Defaults to "False".
  1941. * If "True", updating of the "var", m", and "v" tensors will be protected
  1942. * by a lock; otherwise the behavior is undefined, but may exhibit less contention.
  1943. *
  1944. * @par Outputs:
  1945. * Three outputs, including:
  1946. * @li var: A Tensor has the type float32.
  1947. * @li var_copy: A Tensor has the type float16.
  1948. * @li accum: A Tensor has the same type as input "accum".
  1949. *@par Restrictions:
  1950. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1951. */
  1952. REG_OP(FusedMulApplyMomentumExtern)
  1953. .INPUT(var, TensorType(DT_FLOAT))
  1954. .INPUT(accum, TensorType::NumberType())
  1955. .INPUT(lr, TensorType::NumberType())
  1956. .INPUT(x1, TensorType::NumberType())
  1957. .INPUT(momentum, TensorType::NumberType())
  1958. .INPUT(x2, TensorType::NumberType())
  1959. .INPUT(var_copy, TensorType(DT_FLOAT16))
  1960. .OUTPUT(var, TensorType(DT_FLOAT))
  1961. .OUTPUT(var_copy, TensorType(DT_FLOAT16))
  1962. .OUTPUT(accum, TensorType::NumberType())
  1963. .ATTR(use_nesterov, Bool, false)
  1964. .ATTR(use_locking, Bool, false)
  1965. .OP_END_FACTORY_REG(FusedMulApplyMomentumExtern)
  1966. /**
  1967. *@brief Updates '*var' according to the momentum scheme.
  1968. * accum = accum * momentum - x1 * x2 * lr
  1969. * if use_nesterov is True:
  1970. * var += accum * momentum - x1 * x2 * lr
  1971. * else:
  1972. * var += accum
  1973. *
  1974. *@par Inputs:
  1975. *@li var: A mutable tensor. Must be one of the data types defined in
  1976. * TensorType::NumberType(). Should be from a Variable().
  1977. *@li accum: A mutable tensor. Has the same type as "var". Should be from a
  1978. * Variable().
  1979. *@li lr: A tensor for the learning rate. Has the same type as "var". Should be
  1980. * from a Variable().
  1981. *@li x1: A Tensor has type TensorType::NumberType().
  1982. *@li momentum: A scalar. Has the same type as "var".
  1983. *@li x2: A scalar has the same type as "var".
  1984. *
  1985. *@par Attributes:
  1986. *@li use_nesterov: An optional bool. Defaults to "False".
  1987. * If "True", var will be updated by using Nesterov momentum.
  1988. *@li use_locking: An optional bool. Defaults to "False".
  1989. * If "True", updating of the "var" tensor is protected by a lock;
  1990. * otherwise the behavior is undefined, but may exhibit less contention.
  1991. *
  1992. *@par Outputs:
  1993. * @li var: A mutable tensor. Has the same type as input "var".
  1994. * @li accum: A mutable tensor. Has the same type as input "accum".
  1995. *
  1996. *@attention Constraints:
  1997. * @li var: A mutable tensor. Has the same type as input "var".
  1998. * @li accum: A mutable tensor. Has the same type as input "accum".
  1999. *
  2000. *@par Third-party framework compatibility
  2001. * Compatible with the TensorFlow operator ResourceApplyKerasMomentum.
  2002. *
  2003. */
  2004. REG_OP(FusedMulApplyKerasMomentum)
  2005. .INPUT(var, TensorType::NumberType())
  2006. .INPUT(accum, TensorType::NumberType())
  2007. .INPUT(lr, TensorType::NumberType())
  2008. .INPUT(x1, TensorType::NumberType())
  2009. .INPUT(momentum, TensorType::NumberType())
  2010. .INPUT(x2, TensorType::NumberType())
  2011. .OUTPUT(var, TensorType::NumberType())
  2012. .OUTPUT(accum, TensorType::NumberType())
  2013. .ATTR(use_locking, Bool, false)
  2014. .ATTR(use_nesterov, Bool, false)
  2015. .OP_END_FACTORY_REG(FusedMulApplyKerasMomentum)
  2016. /**
  2017. *@brief Update "g" according to the LARS algorithm . \n
  2018. *@par Inputs:
  2019. *Four inputs, including:
  2020. * @li w: A Tensor. Must be of type TensorType::DT_FLOAT.
  2021. * @li g: A Tensor of the same type and shape as "w".
  2022. * @li weight_decay: A Tensor of the same type as "w", Must be a scalar.
  2023. * @li learning_rate: A Tensor of the same type as "w", Must be a scalar . \n
  2024. *@par Attributes:
  2025. *Three Attributes, including:
  2026. * @li hyperpara: An optional float. Default value is 0.001.
  2027. * @li epsilon: An optional float. Default value is 1e-5.Avoid denominator is 0.
  2028. * @li use_clip: An optional bool. Defaults to "False".
  2029. * If "True", updating learning rate . \n
  2030. *@par Outputs:
  2031. *g_new: Tensor of the same type as "w".
  2032. */
  2033. REG_OP(LarsV2)
  2034. .INPUT(w, TensorType(DT_FLOAT))
  2035. .INPUT(g, TensorType(DT_FLOAT))
  2036. .INPUT(weight_decay, TensorType(DT_FLOAT))
  2037. .INPUT(learning_rate, TensorType(DT_FLOAT))
  2038. .OUTPUT(g_new, TensorType(DT_FLOAT))
  2039. .ATTR(hyperpara, Float, 0.001)
  2040. .ATTR(epsilon, Float, 0.00001)
  2041. .ATTR(use_clip, Bool, false)
  2042. .OP_END_FACTORY_REG(LarsV2)
  2043. /**
  2044. *@brief Update "g" according to the LARS algorithm . \n
  2045. *@par Inputs:
  2046. *Six inputs, including:
  2047. * @li w: A Tensor. Must be of type TensorType::DT_FLOAT.
  2048. * @li g: A Tensor of the same type and shape as "w".
  2049. * @li w_square_sum: A Tensor of square_sum(w), has the same type as "w", Must be a scalar.
  2050. * @li g_square_sum: A Tensor of square(g), has the same type as "w", Must be a scalar.
  2051. * @li weight_decay: A Tensor of the same type as "w", Must be a scalar.
  2052. * @li learning_rate: A Tensor of the same type as "w", Must be a scalar . \n
  2053. *@par Attributes:
  2054. *Three Attributes, including:
  2055. * @li hyperpara: An optional float. Default value is 0.001.
  2056. * @li epsilon: An optional float. Default value is 1e-5.Avoid denominator is 0.
  2057. * @li use_clip: An optional bool. Defaults to "False".
  2058. * If "True", updating learning rate . \n
  2059. *@par Outputs:
  2060. *g_new: Tensor of the same type as "w".
  2061. */
  2062. REG_OP(LarsV2Update)
  2063. .INPUT(w, TensorType(DT_FLOAT))
  2064. .INPUT(g, TensorType(DT_FLOAT))
  2065. .INPUT(w_square_sum, TensorType(DT_FLOAT))
  2066. .INPUT(g_square_sum, TensorType(DT_FLOAT))
  2067. .INPUT(weight_decay, TensorType(DT_FLOAT))
  2068. .INPUT(learning_rate, TensorType(DT_FLOAT))
  2069. .OUTPUT(g_new, TensorType(DT_FLOAT))
  2070. .ATTR(hyperpara, Float, 0.001)
  2071. .ATTR(epsilon, Float, 0.00001)
  2072. .ATTR(use_clip, Bool, false)
  2073. .OP_END_FACTORY_REG(LarsV2Update)
  2074. /**
  2075. * @brief Update relevant entries in '*var' according to the Ftrl-proximal scheme . \n
  2076. * @par Inputs:
  2077. * Nine inputs, including:
  2078. * @li var: A mutable Tensor. Must be of type TensorType::NumberType().
  2079. * Should be a Variable Tensor.
  2080. * @li accum: A mutable Tensor of the same type as "var".
  2081. * Should be a Variable Tensor. The value of accum must be greater than 0.
  2082. * @li linear: A mutable Tensor of the same type as "var".
  2083. * Should be a Variable Tensor.
  2084. * @li grad: A Tensor of the same type as "var", for the gradient.
  2085. * @li indices: A vector of indices into the first dimension of var and accum.
  2086. * The value of indices must be unique. Otherwise, the result is unpredictable.
  2087. * @li lr: A Tensor of the same type as "var", for the scaling factor. Must be a scalar.
  2088. * @li l1: A Tensor of the same type as "var", for L1 regulariation. Must be a scalar.
  2089. * @li l2: A Tensor of the same type as "var", for L2 regulariation. Must be a scalar.
  2090. * @li lr_power: A Tensor of the same type as "var", for the scaling factor. Must be a scalar . \n
  2091. * @par Attributes:
  2092. * use_locking: An optional bool. Defaults to "False".
  2093. * If "True", updating of the "var" and "accum" tensors will be
  2094. * protected by a lock; otherwise the behavior is undefined,
  2095. * but may exhibit less contention . \n
  2096. * @par Outputs:
  2097. * var: A Tensor. Has the same type and format as input "var" . \n
  2098. * @par Third-party framework compatibility
  2099. * Compatible with the TensorFlow operator SparseApplyFtrl.
  2100. */
  2101. REG_OP(SparseApplyFtrl)
  2102. .INPUT(var, TensorType({DT_FLOAT}))
  2103. .INPUT(accum, TensorType({DT_FLOAT}))
  2104. .INPUT(linear, TensorType({DT_FLOAT}))
  2105. .INPUT(grad, TensorType({DT_FLOAT}))
  2106. .INPUT(indices, TensorType({DT_INT32}))
  2107. .INPUT(lr, TensorType({DT_FLOAT}))
  2108. .INPUT(l1, TensorType({DT_FLOAT}))
  2109. .INPUT(l2, TensorType({DT_FLOAT}))
  2110. .INPUT(lr_power, TensorType({DT_FLOAT}))
  2111. .OUTPUT(var, TensorType({DT_FLOAT}))
  2112. .ATTR(use_locking, Bool, false)
  2113. .OP_END_FACTORY_REG(SparseApplyFtrl)
  2114. /**
  2115. * @brief Update relevant entries in '*var' according to the Ftrl-proximal scheme . \n
  2116. * @par Inputs:
  2117. * Five inputs, including:
  2118. * @li var: A mutable Tensor. Must be of type TensorType::NumberType().
  2119. * Should be a Variable Tensor.
  2120. * @li accum: A mutable Tensor of the same type as "var".
  2121. * Should be a Variable Tensor. The value of accum must be greater than 0.
  2122. * @li linear: A mutable Tensor of the same type as "var".
  2123. * Should be a Variable Tensor.
  2124. * @li grad: A Tensor of the same type as "var", for the gradient.
  2125. * @li indices: A vector of indices into the first dimension of var and accum.
  2126. * The value of indices must be unique. Otherwise, the result is unpredictable . \n
  2127. * @par Attributes:
  2128. * @li lr: A Tensor of the same type as "var", for the scaling factor. Must be a scalar.
  2129. * @li l1: A Tensor of the same type as "var", for L1 regulariation. Must be a scalar.
  2130. * @li l2: A Tensor of the same type as "var", for L2 regulariation. Must be a scalar.
  2131. * @li lr_power: A Tensor of the same type as "var", for the scaling factor. Must be a scalar.
  2132. * @li use_locking: An optional bool. Defaults to "False".
  2133. * If "True", updating of the "var" and "accum" tensors will be
  2134. * protected by a lock; otherwise the behavior is undefined,
  2135. * but may exhibit less contention . \n
  2136. * @par Outputs:
  2137. * @li var: A Tensor. Has the same type and format as input "var".
  2138. * @li accum: A Tensor. Has the same type and format as input "accum".
  2139. * @li linear: A Tensor. Has the same type and format as input "linear" . \n
  2140. * @par Third-party framework compatibility
  2141. * Compatible with the TensorFlow operator SparseApplyFtrl.
  2142. *
  2143. *@par Restrictions:
  2144. *Warning: THIS FUNCTION IS DEPRECATED. Please use SparseApplyFtrl instead.
  2145. */
  2146. REG_OP(SparseApplyFtrlD)
  2147. .INPUT(var, TensorType({DT_FLOAT}))
  2148. .INPUT(accum, TensorType({DT_FLOAT}))
  2149. .INPUT(linear, TensorType({DT_FLOAT}))
  2150. .INPUT(grad, TensorType({DT_FLOAT}))
  2151. .INPUT(indices, TensorType({DT_INT32}))
  2152. .OUTPUT(var, TensorType({DT_FLOAT}))
  2153. .OUTPUT(accum, TensorType({DT_FLOAT}))
  2154. .OUTPUT(linear, TensorType({DT_FLOAT}))
  2155. .REQUIRED_ATTR(lr, Float)
  2156. .REQUIRED_ATTR(l1, Float)
  2157. .REQUIRED_ATTR(l2, Float)
  2158. .REQUIRED_ATTR(lr_power, Float)
  2159. .ATTR(use_locking, Bool, false)
  2160. .OP_END_FACTORY_REG(SparseApplyFtrlD)
  2161. /**
  2162. * @brief Updates relevant entries in '*var' according to the Ftrl-proximal scheme.
  2163. * That is for rows we have grad for, "var", "accum" and "linear" are updated . \n
  2164. * @par Inputs:
  2165. * Ten inputs, including:
  2166. * @li var: A mutable Tensor. Must be of type TensorType::NumberType().
  2167. * Should be a Variable Tensor.
  2168. * @li accum: A mutable Tensor of the same type as "var".
  2169. * Should be a Variable Tensor.
  2170. * @li linear: A mutable Tensor of the same type as "var".
  2171. * Should be a Variable Tensor.
  2172. * @li grad: A Tensor of the same type as "var", for the gradient.
  2173. * @li indices: A vector of indices into the first dimension of "var" and "accum".
  2174. * @li lr: A Tensor of the same type as "var", for the scaling factor. Must be a scalar.
  2175. * @li l1: A Tensor of the same type as "var", for L1 regulariation. Must be a scalar.
  2176. * @li l2: A Tensor of the same type as "var", for L2 regulariation. Must be a scalar.
  2177. * @li l2_shrinkage: A Tensor of the same type as "var", L2 shrinkage regulariation. Must be a scalar.
  2178. * @li lr_power: A Tensor of the same type as "var", for the scaling factor. Must be a scalar . \n
  2179. * @par Attributes:
  2180. * use_locking: An optional bool. Defaults to "False".
  2181. * If "True", updating of the "var" and "accum" tensors will be
  2182. * protected by a lock; otherwise the behavior is undefined,
  2183. * but may exhibit less contention . \n
  2184. * @par Outputs:
  2185. * var: A Tensor. Has the same type and format as input "var" . \n
  2186. * @par Third-party framework compatibility
  2187. * Compatible with the TensorFlow operator SparseApplyFtrlV2.
  2188. */
  2189. REG_OP(SparseApplyFtrlV2)
  2190. .INPUT(var, TensorType({DT_FLOAT}))
  2191. .INPUT(accum, TensorType({DT_FLOAT}))
  2192. .INPUT(linear, TensorType({DT_FLOAT}))
  2193. .INPUT(grad, TensorType({DT_FLOAT}))
  2194. .INPUT(indices, TensorType({DT_INT32}))
  2195. .INPUT(lr, TensorType({DT_FLOAT}))
  2196. .INPUT(l1, TensorType({DT_FLOAT}))
  2197. .INPUT(l2, TensorType({DT_FLOAT}))
  2198. .INPUT(l2_shrinkage, TensorType({DT_FLOAT}))
  2199. .INPUT(lr_power, TensorType({DT_FLOAT}))
  2200. .OUTPUT(var, TensorType({DT_FLOAT}))
  2201. .ATTR(use_locking, Bool, false)
  2202. .OP_END_FACTORY_REG(SparseApplyFtrlV2)
  2203. /**
  2204. * @brief Updates relevant entries in '*var' according to the Ftrl-proximal scheme.
  2205. * That is for rows we have grad for, "var", "accum" and "linear" are updated . \n
  2206. * @par Inputs:
  2207. * Five inputs, including:
  2208. * @li var: A mutable Tensor. Must be of type TensorType::NumberType().
  2209. * Should be a Variable Tensor.
  2210. * @li accum: A mutable Tensor of the same type as "var".
  2211. * Should be a Variable Tensor.
  2212. * @li linear: A mutable Tensor of the same type as "var".
  2213. * Should be a Variable Tensor.
  2214. * @li grad: A Tensor of the same type as "var", for the gradient.
  2215. * @li indices: A vector of indices into the first dimension of "var" and "accum" . \n
  2216. * @par Attributes:
  2217. * @li lr: A Tensor of the same type as "var", for the scaling factor. Must be a scalar.
  2218. * @li l1: A Tensor of the same type as "var", for L1 regulariation. Must be a scalar.
  2219. * @li l2: A Tensor of the same type as "var", for L2 regulariation. Must be a scalar.
  2220. * @li l2_shrinkage: A Tensor of the same type as "var", L2 shrinkage regulariation. Must be a scalar.
  2221. * @li lr_power: A Tensor of the same type as "var", for the scaling factor. Must be a scalar.
  2222. * @li use_locking: An optional bool. Defaults to "False".
  2223. * If "True", updating of the "var" and "accum" tensors will be
  2224. * protected by a lock; otherwise the behavior is undefined,
  2225. * but may exhibit less contention . \n
  2226. * @par Outputs:
  2227. * @li var: A Tensor. Has the same type and format as input "var".
  2228. * @li accum: A Tensor. Has the same type and format as input "accum".
  2229. * @li linear: A Tensor. Has the same type and format as input "linear" . \n
  2230. * @par Third-party framework compatibility
  2231. * Compatible with the TensorFlow operator SparseApplyFtrlV2D.
  2232. *
  2233. * @par Restrictions:
  2234. * Warning: THIS FUNCTION IS DEPRECATED. Please use SparseApplyFtrlV2 instead.
  2235. */
  2236. REG_OP(SparseApplyFtrlV2D)
  2237. .INPUT(var, TensorType({DT_FLOAT}))
  2238. .INPUT(accum, TensorType({DT_FLOAT}))
  2239. .INPUT(linear, TensorType({DT_FLOAT}))
  2240. .INPUT(grad, TensorType({DT_FLOAT}))
  2241. .INPUT(indices, TensorType({DT_INT32}))
  2242. .OUTPUT(var, TensorType({DT_FLOAT}))
  2243. .OUTPUT(accum, TensorType({DT_FLOAT}))
  2244. .OUTPUT(linear, TensorType({DT_FLOAT}))
  2245. .REQUIRED_ATTR(lr, Float)
  2246. .REQUIRED_ATTR(l1, Float)
  2247. .REQUIRED_ATTR(l2, Float)
  2248. .REQUIRED_ATTR(l2_shrinkage, Float)
  2249. .REQUIRED_ATTR(lr_power, Float)
  2250. .ATTR(use_locking, Bool, false)
  2251. .OP_END_FACTORY_REG(SparseApplyFtrlV2D)
  2252. /**
  2253. * @brief Updates "var" in specified index according to the RMSProp algorithm.
  2254. * mean_square = decay * mean_square + (1-decay) * gradient ** 2
  2255. * Delta = learning_rate * gradient / sqrt(mean_square + epsilon)
  2256. * ms <- rho * ms_{t-1} + (1-rho) * grad * grad
  2257. * mom <- momentum * mom_{t-1} + lr * grad / sqrt(ms + epsilon)
  2258. * var <- var - mom
  2259. *
  2260. * @par Inputs:
  2261. * Nine inputs, including:
  2262. * @li var: A mutable tensor. Must be one of the data types defined in
  2263. * TensorType::NumberType(). Should be from a Variable().
  2264. * @li ms: A mutable tensor. Must have the same type as "var". Should be from a
  2265. * Variable().
  2266. * @li mom: A mutable tensor. Must have the same type as "var". Should be from a
  2267. * Variable().
  2268. * @li lr: A scalar. Must have the same type as "var".
  2269. * @li rho: A scalar. Must have the same type as "var".
  2270. * @li momentum: A scalar. Must have the same type as "var".
  2271. * @li epsilon: A scalar. Must have the same type as "var".
  2272. * @li grad: A tensor, specifying the gradient.
  2273. * @li indices: A vector of indices into the first dimension of "var", "mom" and "ms".
  2274. *
  2275. * @par Attributes:
  2276. * use_locking: An optional "bool". Defaults to "False". If "True", updating of
  2277. * the "var", "ms", and "mom" tensors will be protected by a lock; otherwise the
  2278. * behavior is undefined, but may exhibit less contention.
  2279. *
  2280. * @par Outputs:
  2281. * var: A mutable tensor. Has the same type as input "var".
  2282. *
  2283. * @attention Constraints:
  2284. * @li Note that in this sparse implementation, "ms" and "mom" will not update
  2285. * in iterations during which "grad" is 0.
  2286. * @li The input tensors "var", "ms", and "mom" must have the same shape.
  2287. *
  2288. * @par Third-party framework compatibility
  2289. * Compatible with the TensorFlow operator SparseApplyRMSProp.
  2290. */
  2291. REG_OP(SparseApplyRMSProp)
  2292. .INPUT(var, TensorType::NumberType())
  2293. .INPUT(ms, TensorType::NumberType())
  2294. .INPUT(mom, TensorType::NumberType())
  2295. .INPUT(lr, TensorType::NumberType())
  2296. .INPUT(rho, TensorType::NumberType())
  2297. .INPUT(momentum, TensorType::NumberType())
  2298. .INPUT(epsilon, TensorType::NumberType())
  2299. .INPUT(grad, TensorType::NumberType())
  2300. .INPUT(indices, TensorType::IndexNumberType())
  2301. .OUTPUT(var, TensorType::NumberType())
  2302. .ATTR(use_locking, Bool, false)
  2303. .OP_END_FACTORY_REG(SparseApplyRMSProp)
  2304. /**
  2305. * @brief Updates "var" in specified index according to the RMSProp algorithm.
  2306. * a const input will be considered as an attribute.
  2307. * mean_square = decay * mean_square + (1-decay) * gradient ** 2
  2308. * Delta = learning_rate * gradient / sqrt(mean_square + epsilon)
  2309. * ms <- rho * ms_{t-1} + (1-rho) * grad * grad
  2310. * mom <- momentum * mom_{t-1} + lr * grad / sqrt(ms + epsilon)
  2311. * var <- var - mom
  2312. *
  2313. * @par Inputs:
  2314. * Six inputs, including:
  2315. * @li var: A mutable tensor. Must be one of the data types defined in
  2316. * TensorType::NumberType(). Should be from a Variable().
  2317. * @li ms: A mutable tensor. Must have the same type as "var". Should be from a
  2318. * Variable().
  2319. * @li mom: A mutable tensor. Must have the same type as "var". Should be from a
  2320. * Variable().
  2321. * @li lr: A scalar. Must have the same type as "var".
  2322. * @li grad: A tensor, specifying the gradient.
  2323. *
  2324. * @par Attributes:
  2325. * @li use_locking: An optional "bool". Defaults to "False". If "True",
  2326. * updating of the "var", "ms", and "mom" tensors will be protected by a lock;
  2327. * otherwise the behavior is undefined, but may exhibit less contention.
  2328. * @li rho: A required scalar. Must have the same type as "var".
  2329. * @li momentum: A required scalar. Must have the same type as "var".
  2330. * @li epsilon: A required scalar. Must have the same type as "var".
  2331. *
  2332. * @par Outputs:
  2333. * @li var: A mutable tensor. Must have the same type as input "var".
  2334. * @li ms: A mutable tensor. Must have the same type as input "ms".
  2335. * @li mom: A mutable tensor. Must have the same type as input "mom".
  2336. *
  2337. * @attention Constraints:
  2338. * @li Note that in this sparse implementation, "ms" and "mom" will not update
  2339. * in iterations during which "grad" is 0.
  2340. * @li The input tensors "var", "ms" and "mom" must have the same shape.
  2341. *
  2342. * @par Restrictions:
  2343. * Warning: THIS FUNCTION IS DEPRECATED. Please use SparseApplyRMSProp instead.
  2344. */
  2345. REG_OP(SparseApplyRMSPropD)
  2346. .INPUT(var, TensorType::NumberType())
  2347. .INPUT(ms, TensorType::NumberType())
  2348. .INPUT(mom, TensorType::NumberType())
  2349. .INPUT(lr, TensorType::NumberType())
  2350. .INPUT(grad, TensorType::NumberType())
  2351. .INPUT(indices, TensorType::IndexNumberType())
  2352. .OUTPUT(var, TensorType::NumberType())
  2353. .OUTPUT(ms, TensorType::NumberType())
  2354. .OUTPUT(mom, TensorType::NumberType())
  2355. .REQUIRED_ATTR(rho, Float)
  2356. .REQUIRED_ATTR(momentum, Float)
  2357. .REQUIRED_ATTR(epsilon, Float)
  2358. .ATTR(use_locking, Bool, false)
  2359. .OP_END_FACTORY_REG(SparseApplyRMSPropD)
  2360. /**
  2361. * @brief Updates "var" in specified index according to the Adadelta algorithm.
  2362. * accum <- rho * accum + (1 - rho) * grad.square()
  2363. * update <- (accum_update + epsilon).sqrt() * (accum + epsilon()).rsqrt() * grad
  2364. * var <- var - update * lr
  2365. * accum_update <- rho() * accum_update + (1 - rho()) * update.square()
  2366. *
  2367. * @par Inputs:
  2368. * Eight inputs, including:
  2369. * @li var: A mutable tensor. Must be one of the data types defined in
  2370. * TensorType::NumberType(). Should be from a Variable().
  2371. * @li accum: A mutable tensor. Must have the same type as "var". Should be from a
  2372. * Variable().
  2373. * @li accum_update: A mutable tensor. Must have the same type as "var". Should be from a
  2374. * Variable().
  2375. * @li lr: A scalar. Must have the same type as "var".
  2376. * @li rho: A scalar. Must have the same type as "var".
  2377. * @li epsilon: A scalar. Must have the same type as "var".
  2378. * @li grad: A tensor, specifying the gradient.
  2379. * @li indices: A vector of indices into the first dimension of "var", "accum" and "accum_update".
  2380. *
  2381. * @par Attributes:
  2382. * use_locking: An optional "bool". Defaults to "False". If "True", updating of
  2383. * the "var", "accum", and "accum_update" tensors will be protected by a lock; otherwise the
  2384. * behavior is undefined, but may exhibit less contention.
  2385. *
  2386. * @par Outputs:
  2387. * var: A mutable tensor. Has the same type as input "var".
  2388. *
  2389. * @attention Constraints:
  2390. * @li Note that in this sparse implementation, "accum" and "accum_update" will not update
  2391. * in iterations during which "grad" is 0.
  2392. * @li The input tensors "var", "accum", and "accum_update" must have the same shape.
  2393. *
  2394. * @par Third-party framework compatibility
  2395. * Compatible with the TensorFlow operator SparseApplyAdadelta.
  2396. */
  2397. REG_OP(SparseApplyAdadelta)
  2398. .INPUT(var, TensorType::NumberType())
  2399. .INPUT(accum, TensorType::NumberType())
  2400. .INPUT(accum_update, TensorType::NumberType())
  2401. .INPUT(lr, TensorType::NumberType())
  2402. .INPUT(rho, TensorType::NumberType())
  2403. .INPUT(epsilon, TensorType::NumberType())
  2404. .INPUT(grad, TensorType::NumberType())
  2405. .INPUT(indices, TensorType::IndexNumberType())
  2406. .OUTPUT(var, TensorType::NumberType())
  2407. .ATTR(use_locking, Bool, false)
  2408. .OP_END_FACTORY_REG(SparseApplyAdadelta)
  2409. /**
  2410. * @brief Updates "var" in specified index according to the Adadelta algorithm.
  2411. * a const input will be considered as an attribute.
  2412. * accum <- rho * accum + (1 - rho) * grad.square()
  2413. * update <- (accum_update + epsilon).sqrt() * (accum + epsilon()).rsqrt() * grad
  2414. * var <- var - update * lr
  2415. * accum_update <- rho() * accum_update + (1 - rho()) * update.square()
  2416. *
  2417. * @par Inputs:
  2418. * Seven inputs, including:
  2419. * @li var: A mutable tensor. Must be one of the data types defined in
  2420. * TensorType::NumberType(). Should be from a Variable().
  2421. * @li accum: A mutable tensor. Must have the same type as "var". Should be from a
  2422. * Variable().
  2423. * @li accum_update: A mutable tensor. Must have the same type as "var". Should be from a
  2424. * Variable().
  2425. * @li lr: A scalar. Must have the same type as "var".
  2426. * @li rho: A scalar. Must have the same type as "var".
  2427. * @li grad: A tensor, specifying the gradient.
  2428. * @li indices: A vector of indices into the first dimension of "var", "accum" and "accum_update".
  2429. *
  2430. * @par Attributes:
  2431. * @li use_locking: An optional "bool". Defaults to "False". If "True",
  2432. * updating of the "var", "accum", and "accum_update" tensors will be protected by a lock;
  2433. * otherwise the behavior is undefined, but may exhibit less contention.
  2434. * @li epsilon: A required scalar. Must have the same type as "var".
  2435. *
  2436. * @par Outputs:
  2437. * @li var: A mutable tensor. Must have the same type as input "var".
  2438. * @li accum: A mutable tensor. Must have the same type as input "accum".
  2439. * @li accum_update: A mutable tensor. Must have the same type as input "accum_update".
  2440. *
  2441. * @attention Constraints:
  2442. * @li Note that in this sparse implementation, "accum" and "accum_update" will not update
  2443. * in iterations during which "grad" is 0.
  2444. * @li The input tensors "var", "accum" and "accum_update" must have the same shape.
  2445. *
  2446. * @par Restrictions:
  2447. * Warning: THIS FUNCTION IS DEPRECATED. Please use SparseApplyAdadelta instead.
  2448. */
  2449. REG_OP(SparseApplyAdadeltaD)
  2450. .INPUT(var, TensorType::NumberType())
  2451. .INPUT(accum, TensorType::NumberType())
  2452. .INPUT(accum_update, TensorType::NumberType())
  2453. .INPUT(lr, TensorType::NumberType())
  2454. .INPUT(rho, TensorType::NumberType())
  2455. .INPUT(grad, TensorType::NumberType())
  2456. .INPUT(indices, TensorType::IndexNumberType())
  2457. .OUTPUT(var, TensorType::NumberType())
  2458. .OUTPUT(accum, TensorType::NumberType())
  2459. .OUTPUT(accum_update, TensorType::NumberType())
  2460. .REQUIRED_ATTR(epsilon, Float)
  2461. .ATTR(use_locking, Bool, false)
  2462. .OP_END_FACTORY_REG(SparseApplyAdadeltaD)
  2463. /**
  2464. *@brief Clean memory of workspace list . \n
  2465. *@par Attributes:
  2466. * @li automic_add_mem_size: sizes of workspaces . \n
  2467. *@par Restrictions:
  2468. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2469. */
  2470. REG_OP(AtomicAddrClean)
  2471. .ATTR(automic_add_mem_size, ListInt, {})
  2472. .OP_END_FACTORY_REG(AtomicAddrClean)
  2473. /**
  2474. *@brief Clean memory of workspace list . \n
  2475. *@par Attributes:
  2476. * @li workspace_size: sizes of workspaces . \n
  2477. *@par Restrictions:
  2478. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  2479. */
  2480. REG_OP(DynamicAtomicAddrClean)
  2481. .ATTR(automic_add_mem_size, ListInt, {})
  2482. .OP_END_FACTORY_REG(DynamicAtomicAddrClean)
  2483. } // namespace ge
  2484. #endif // OPS_BUILT_IN_OP_PROTO_INC_NN_TRAINING_OPS_H_

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