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.

image_ops.h 91 kB

5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
3 years ago
5 years ago
3 years ago
3 years ago
5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
5 years ago
3 years ago
3 years ago
3 years ago
5 years ago
3 years ago
3 years ago
5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
3 years ago
3 years ago
3 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
3 years ago
5 years ago
3 years ago
3 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
3 years ago
3 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
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
3 years ago
3 years ago
5 years ago
5 years ago
5 years ago
3 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
3 years ago
3 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
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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
3 years ago
3 years ago
3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387
  1. /**
  2. * Copyright 2019 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /*!
  17. * \file image_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_IMAGE_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_IMAGE_OPS_H_
  22. #include "graph/operator_reg.h"
  23. namespace ge {
  24. /**
  25. *@brief Decode the frame(s) of a GIF-encoded image to a uint8 tensor . \n
  26. *@par Inputs:
  27. *contents:A Tensor of type string. 0-D. The GIF-encoded image. \n
  28. *@par Outputs:
  29. *image:A Tensor of type uint8. \n
  30. *@par Third-party framework compatibility
  31. *Compatible with tensorflow DecodeGif operator.
  32. */
  33. REG_OP(DecodeGif)
  34. .INPUT(contents, TensorType({DT_STRING}))
  35. .OUTPUT(image, TensorType({DT_UINT8}))
  36. .OP_END_FACTORY_REG(DecodeGif)
  37. /**
  38. *@brief Adjust the hue of one or more images . \n
  39. *@par Inputs:
  40. *Input images is a tensor of at least 3 dimensions. The last dimension is
  41. interpretted as channels, and must be three. Inputs include:
  42. *@li images:A Tensor of type float. Images to adjust. At least 3-D. The format
  43. must be NHWC.
  44. *@li delta:A Tensor of type float. A float delta to add to the hue . \n
  45. *@par Outputs:
  46. *y:A Tensor of type float. The format must be NHWC. \n
  47. *@attention Constraints:
  48. *Input images is a tensor of at least 3 dimensions. The last dimension is
  49. interpretted as channels, and must be three . \n
  50. *@par Third-party framework compatibility
  51. *Compatible with tensorflow AdjustHue operator.
  52. */
  53. REG_OP(AdjustHue)
  54. .INPUT(images, TensorType({DT_FLOAT16,DT_FLOAT}))
  55. .INPUT(delta, TensorType({DT_FLOAT}))
  56. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  57. .OP_END_FACTORY_REG(AdjustHue)
  58. /**
  59. *@brief Adjust the saturation of one or more images . \n
  60. *@par Inputs:
  61. *Input images is a tensor of at least 3 dimensions. The last dimension is
  62. interpretted as channels, and must be three. Inputs include:
  63. *@li images:A Tensor of type float. Images to adjust. At least 3-D. The format
  64. must be NHWC.
  65. *@li scale:A Tensor of type float. A float scale to add to the saturation . \n
  66. *@par Outputs:
  67. *y:A Tensor of type float. The format must be NHWC. \n
  68. *@attention Constraints:
  69. *Input images is a tensor of at least 3 dimensions. The last dimension is
  70. interpretted as channels, and must be three . \n
  71. *@par Third-party framework compatibility
  72. *Compatible with tensorflow AdjustSaturation operator.
  73. */
  74. REG_OP(AdjustSaturation)
  75. .INPUT(images, TensorType({DT_FLOAT16,DT_FLOAT}))
  76. .INPUT(scale, TensorType({DT_FLOAT}))
  77. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  78. .OP_END_FACTORY_REG(AdjustSaturation)
  79. /**
  80. *@brief Adjust the contrast of one or more images . \n
  81. *@par Inputs:
  82. *Input images is a tensor of at least 3 dimensions. The last 3 dimensions are
  83. interpreted as '[height, width, channels]'. Inputs include:
  84. *@li images:A Tensor of type float. Images to adjust. At least 3-D. The format
  85. must be NHWC.
  86. *@li scale:A Tensor of type float. A float multiplier for adjusting contrast . \n
  87. *@par Outputs:
  88. *y:A Tensor of type float. The format must be NHWC. \n
  89. *@attention Constraints:
  90. *Input images is a tensor of at least 3 dimensions. The last dimension is
  91. interpretted as channels, and must be three . \n
  92. *@par Third-party framework compatibility
  93. *Compatible with tensorflow AdjustContrast operator.
  94. */
  95. REG_OP(AdjustContrast)
  96. .INPUT(images, TensorType({DT_FLOAT16,DT_FLOAT}))
  97. .INPUT(contrast_factor, TensorType({DT_FLOAT}))
  98. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  99. .OP_END_FACTORY_REG(AdjustContrast)
  100. /**
  101. *@brief Extracts crops from the input image tensor and resizes them. Extracts
  102. crops from the input image tensor and resizes them using bilinear sampling or
  103. nearest neighbor sampling to a common output size specified by crop_size . \n
  104. *@par Inputs:
  105. *Input x must be a 4-D tensor. Inputs include:
  106. *@li x:A Tensor. Must be one of the following types:uint8, uint16, int8,
  107. int16, int32, int64, float16, float, double. A 4-D tensor of shape
  108. [batch, image_height, image_width, depth]. The format must be NHWC.
  109. *@li boxes: A Tensor. Must be one of the following types: float16, float. A 2-D tensor of shape [num_boxes, 4].
  110. *@li box_index: A Tensor of type int32. A 1-D tensor of shape [num_boxes] with
  111. int32 values in [0, batch).
  112. *@li crop_size: A Tensor of type int32. A 1-D tensor of 2 elements, crop_size
  113. = [crop_height, crop_width]. All cropped image patches are resized to this size . \n
  114. *@par Attributes:
  115. *@li extrapolation_value: An optional float. Defaults to 0. Value used for
  116. extrapolation, when applicable.
  117. *@li method: An optional string from: '"bilinear", "nearest"'. Defaults to
  118. "bilinear". Currently two sampling methods are supported: Bilinear and
  119. NearestNeighbor . \n
  120. *@par Outputs:
  121. *y: A Tensor. Must be one of the following types: float16, float. The format must be NHWC. \n
  122. *@attention Constraints:
  123. *Input images must be a 4-D tensor . \n
  124. *@par Third-party framework compatibility
  125. *Compatible with tensorflow CropAndResize operator.
  126. */
  127. REG_OP(CropAndResize)
  128. .INPUT(x, TensorType({DT_UINT8, DT_UINT16, DT_INT8, \
  129. DT_INT16, DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  130. .INPUT(boxes, TensorType({DT_FLOAT16, DT_FLOAT}))
  131. .INPUT(box_index, TensorType({DT_INT32}))
  132. .INPUT(crop_size, TensorType({DT_INT32}))
  133. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  134. .ATTR(extrapolation_value, Float, 0)
  135. .ATTR(method, String, "bilinear")
  136. .OP_END_FACTORY_REG(CropAndResize)
  137. /**
  138. *@brief Extracts crops from the input image tensor and resizes them.
  139. * Extracts crops from the input image tensor and resizes them using bilinear sampling or
  140. * nearest neighbor sampling to a common output size specified by crop_size . \n
  141. *@par Inputs:
  142. *Input images must be a 5HD tensor. Inputs include:
  143. *@li x:A Tensor. Must be one of the following types:float16, float. A 5HD tensor of shape
  144. * [batch, C1, image_height, image_width, C0].
  145. *@li boxes: A Tensor. Must be one of the following types: float16, float. A 2-D tensor of shape [num_boxes, 4].
  146. *@li box_index: A Tensor of type int32. A 1-D tensor of shape [num_boxes] with int32 values in [0, batch) . \n
  147. *@par Attributes:
  148. *@li crop_size: list int. [crop_height, crop_width]. All cropped image patches are resized to this size.
  149. *@li extrapolation_value: An optional float. Defaults to 0. Value used for extrapolation, when applicable.
  150. *@li method: An optional string from: '"bilinear"'. Defaults to "bilinear" . \n
  151. *@par Outputs:
  152. *y: A Tensor. Must be one of the following types: float16, float. \n
  153. *@attention Constraints:
  154. *Input images must be a 5HD tensor . \n
  155. *@par Third-party framework compatibility
  156. *Compatible with tensorflow CropAndResize operator.
  157. * @par Restrictions:
  158. * Warning: THIS FUNCTION IS DEPRECATED. Please use CropAndResize instead.
  159. */
  160. REG_OP(CropAndResizeD)
  161. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  162. .INPUT(boxes, TensorType({DT_FLOAT16, DT_FLOAT}))
  163. .INPUT(box_index, TensorType({DT_INT32}))
  164. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  165. .REQUIRED_ATTR(crop_size, ListInt)
  166. .ATTR(extrapolation_value, Float, 0)
  167. .ATTR(method, String, "bilinear")
  168. .OP_END_FACTORY_REG(CropAndResizeD)
  169. /**
  170. *@brief Computes the gradient of the crop_and_resize op wrt the input
  171. boxes tensor . \n
  172. *@par Inputs:
  173. *Input images and grads must be a 4-D tensor. Inputs include:
  174. *@li grads: A 4-D tensor of shape [num_boxes, crop_height, crop_width, depth].
  175. The format must be NHWC.
  176. *@li images: A 4-D tensor of shape [batch, image_height, image_width, depth].
  177. The format must be NHWC.
  178. Both image_height and image_width need to be positive.
  179. *@li boxes: A 2-D tensor of shape [num_boxes, 4]. The i-th row of the tensor
  180. specifies the coordinates of a box in the box_ind[i] image and is specified in
  181. normalized coordinates [y1, x1, y2, x2].
  182. *@li box_index: A 1-D tensor of shape [num_boxes] with int32 values in
  183. [0, batch). The value of box_ind[i] specifies the image that the i-th box
  184. refers to . \n
  185. *@par Attributes:
  186. method: A string specifying the interpolation method. Only 'bilinear' is
  187. supported for now . \n
  188. *@par Outputs:
  189. *y:A 2-D tensor of shape [num_boxes, 4] . \n
  190. *@attention Constraints:
  191. *Input images and grads must be a 4-D tensor . \n
  192. *@par Third-party framework compatibility
  193. *Compatible with tensorflow CropAndResizeGradBoxes operator.
  194. */
  195. REG_OP(CropAndResizeGradBoxes)
  196. .INPUT(grads, TensorType({DT_FLOAT}))
  197. .INPUT(images, TensorType({DT_UINT8, DT_UINT16, DT_INT8, DT_INT16, \
  198. DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  199. .INPUT(boxes, TensorType({DT_FLOAT}))
  200. .INPUT(box_index, TensorType({DT_INT32}))
  201. .OUTPUT(y, TensorType({DT_FLOAT}))
  202. .ATTR(method, String, "bilinear")
  203. .OP_END_FACTORY_REG(CropAndResizeGradBoxes)
  204. /**
  205. *@brief Computes the gradient of the crop_and_resize op wrt the input
  206. images tensor . \n
  207. *@par Inputs:
  208. *Input grads must be a 4-D tensor. Inputs include:
  209. *@li grads: A 4-D tensor of shape [num_boxes, crop_height, crop_width, depth].
  210. The format must be NHWC.
  211. *@li boxes: A 2-D tensor of shape [num_boxes, 4]. The i-th row of the tensor
  212. specifies the coordinates of a box in the box_ind[i] image and is specified
  213. in normalized coordinates [y1, x1, y2, x2].
  214. *@li box_index: A 1-D tensor of shape [num_boxes] with int32 values in
  215. [0, batch). The value of box_ind[i] specifies the image that the i-th box
  216. refers to.
  217. *@li image_size: A 1-D tensor with value [batch, image_height, image_width,
  218. depth] containing the original image size. Both image_height and image_width
  219. need to be positive . \n
  220. *@par Attributes:
  221. *@li method: A string specifying the interpolation method. Only 'bilinear' is
  222. supported for now .
  223. *@li T: output of type \n
  224. *@par Outputs:
  225. *y:A 4-D tensor of shape [batch, image_height, image_width, depth]. The format
  226. must be NHWC. \n
  227. *@attention Constraints:
  228. *Input grads must be a 4-D tensor . \n
  229. *@par Third-party framework compatibility
  230. *Compatible with tensorflow CropAndResizeGradImage operator.
  231. */
  232. REG_OP(CropAndResizeGradImage)
  233. .INPUT(grads, TensorType({DT_FLOAT}))
  234. .INPUT(boxes, TensorType({DT_FLOAT}))
  235. .INPUT(box_index, TensorType({DT_INT32}))
  236. .INPUT(image_size, TensorType({DT_INT32}))
  237. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  238. .ATTR(method, String, "bilinear")
  239. .REQUIRED_ATTR(T, Type)
  240. .OP_END_FACTORY_REG(CropAndResizeGradImage)
  241. /**
  242. *@brief Extracts a glimpse from the input tensor . \n
  243. *@par Inputs:
  244. *Input x must be a 4-D tensor. Inputs include:
  245. *@li x: A 4-D float tensor of shape [batch_size, height, width, channels].
  246. The format must be NHWC.
  247. *@li size: A 1-D tensor of 2 elements containing the size of the glimpses to
  248. extract. The glimpse height must be specified first, following by the glimpse
  249. width.
  250. *@li offsets: A 2-D integer tensor of shape [batch_size, 2] containing the y,
  251. x locations of the center of each window . \n
  252. *@par Attributes:
  253. *@li centered: indicates if the offset coordinates are centered relative to
  254. the image, in which case the (0, 0) offset is relative to the center of the
  255. input images. If false, the (0,0) offset corresponds to the upper left corner
  256. of the input images.
  257. *@li normalized: indicates if the offset coordinates are normalized.
  258. *@li uniform_noise: indicates if the noise should be generated using a
  259. uniform distribution or a Gaussian distribution.
  260. *@li noise: indicates if the noise should uniform, gaussian, or zero.
  261. The default is uniform which means the the noise type will be decided by
  262. uniform_noise . \n
  263. *@par Outputs:
  264. *y:A tensor representing the glimpses [batch_size, glimpse_height,
  265. glimpse_width, channels]. The format must be NHWC. \n
  266. *@attention Constraints:
  267. *Input x must be a 4-D tensor . \n
  268. *@par Third-party framework compatibility
  269. *Compatible with tensorflow CropAndResizeGradImage operator.
  270. */
  271. REG_OP(ExtractGlimpse)
  272. .INPUT(x, TensorType({DT_FLOAT}))
  273. .INPUT(size, TensorType({DT_INT32}))
  274. .INPUT(offsets, TensorType({DT_FLOAT}))
  275. .OUTPUT(y, TensorType({DT_FLOAT}))
  276. .ATTR(centered, Bool, true)
  277. .ATTR(normalized, Bool, true)
  278. .ATTR(uniform_noise, Bool, true)
  279. .ATTR(noise, String, "uniform")
  280. .OP_END_FACTORY_REG(ExtractGlimpse)
  281. /**
  282. *@brief Convert one or more images from HSV to RGB . \n
  283. *@par Inputs:
  284. *Last dimension of input x must be size 3. Inputs include:
  285. *images: 1-D or higher rank. HSV data to convert. Last dimension must be size 3 . \n
  286. *@par Outputs:
  287. *y:images converted to RGB . \n
  288. *@attention Constraints:
  289. *Input images currently supports DT_FLOAT, DT_DOUBLE .
  290. *Last dimension of input x must be size 3 . \n
  291. *@par Third-party framework compatibility
  292. *Compatible with tensorflow HSVToRGB operator.
  293. */
  294. REG_OP(HSVToRGB)
  295. .INPUT(images, TensorType({DT_FLOAT16,DT_FLOAT,DT_DOUBLE}))
  296. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT,DT_DOUBLE}))
  297. .OP_END_FACTORY_REG(HSVToRGB)
  298. /**
  299. *@brief Resize quantized images to size using quantized bilinear interpolation . \n
  300. *@par Inputs:
  301. *Input images must be a 4-D tensor. Inputs include:
  302. *@li images: 4-D with shape [batch, height, width, channels]. The format must
  303. be NHWC.
  304. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width. The new
  305. size for the images.
  306. *@li min: A Tensor of type float.
  307. *@li max: A Tensor of type float . \n
  308. *@par Attributes:
  309. *@li align_corners: An optional bool. Defaults to False. If true, the centers
  310. of the 4 corner pixels of the input and output tensors are aligned, preserving
  311. the values at the corner pixels. Defaults to false.
  312. *@li half_pixel_centers: indicates if the offset coordinates are normalized . \n
  313. *@par Outputs:
  314. *@li resized_images: 4-D with shape [batch, new_height, new_width, channels].
  315. The format must be NHWC.
  316. *@li y_min: A Tensor of type float.
  317. *@li y_max: A Tensor of type float . \n
  318. *@attention Constraints:
  319. *Input images and output images must be quantized types . \n
  320. *@par Third-party framework compatibility
  321. *Compatible with tensorflow QuantizedResizeBilinear operator.
  322. */
  323. REG_OP(QuantizedResizeBilinear)
  324. .INPUT(images, TensorType({DT_QUINT8,DT_QINT32,DT_FLOAT}))
  325. .INPUT(size, TensorType({ DT_INT32 }))
  326. .INPUT(min, TensorType({ DT_FLOAT }))
  327. .INPUT(max, TensorType({ DT_FLOAT }))
  328. .OUTPUT(resized_images, TensorType({DT_QUINT8,DT_QINT32,DT_FLOAT }))
  329. .OUTPUT(y_min, TensorType({ DT_FLOAT }))
  330. .OUTPUT(y_max, TensorType({ DT_FLOAT }))
  331. .ATTR(align_corners, Bool, false)
  332. .ATTR(half_pixel_centers, Bool, false)
  333. .OP_END_FACTORY_REG(QuantizedResizeBilinear)
  334. /**
  335. *@brief Resize images to size using area interpolation . \n
  336. *@par Inputs:
  337. *Input images must be a 4-D tensor. Inputs include:
  338. *@li images: 4-D with shape [batch, height, width, channels]. The format must
  339. be NHWC.
  340. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width.
  341. The new size for the images . \n
  342. *@par Attributes:
  343. *align_corners: If true, the centers of the 4 corner pixels of the input and
  344. output tensors are aligned, preserving the values at the corner pixels.
  345. Defaults to false . \n
  346. *@par Outputs:
  347. *y: 4-D with shape [batch, new_height, new_width, channels]. The format must
  348. be NHWC. \n
  349. *@attention Constraints:
  350. *Input images can be of different types but output images are always float . \n
  351. *@par Third-party framework compatibility
  352. *Compatible with tensorflow ResizeArea operator.
  353. */
  354. REG_OP(ResizeArea)
  355. .INPUT(images, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, \
  356. DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  357. .INPUT(size, TensorType({DT_INT32}))
  358. .OUTPUT(y, TensorType({DT_FLOAT}))
  359. .ATTR(align_corners, Bool, false)
  360. .OP_END_FACTORY_REG(ResizeArea)
  361. /**
  362. *@brief Computes the gradient of bicubic interpolation . \n
  363. *@par Inputs:
  364. *Input grads must be a 4-D tensor. Inputs include:
  365. *@li grads: A Tensor of type float. 4-D with shape [batch, height, width,
  366. channels]. The format must be NHWC.
  367. *@li original_image: A Tensor. Must be one of the following types: float,
  368. double. 4-D with shape [batch, orig_height, orig_width, channels], The image
  369. tensor that was resized. The format must be NHWC. \n
  370. *@par Attributes:
  371. *@li align_corners: An optional bool. Defaults to False. If true, the centers
  372. of the 4 corner pixels of the input and grad tensors are aligned. Defaults to
  373. false.
  374. *@li half_pixel_centers: An optional bool. Defaults to False . \n
  375. *@par Outputs:
  376. *y: A Tensor. Has the same type as original_image. The format must be NHWC. \n
  377. *@attention Constraints:
  378. *Input images can be of different types but output images are always float .
  379. *@par Third-party framework compatibility
  380. *Compatible with tensorflow ResizeBicubicGrad operator.
  381. */
  382. REG_OP(ResizeBicubicGrad)
  383. .INPUT(grads, TensorType({DT_FLOAT}))
  384. .INPUT(original_image, TensorType({DT_FLOAT, DT_DOUBLE}))
  385. .OUTPUT(y, TensorType({DT_FLOAT, DT_DOUBLE}))
  386. .ATTR(align_corners, Bool, false)
  387. .ATTR(half_pixel_centers, Bool, false)
  388. .OP_END_FACTORY_REG(ResizeBicubicGrad)
  389. /**
  390. *@brief Resize images to size using bicubic interpolation . \n
  391. *@par Inputs:
  392. *Input images must be a 4-D tensor. Inputs include:
  393. *@li images: 4-D with shape [batch, height, width, channels]. The format
  394. must be NHWC.
  395. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width. The new
  396. size for the images . \n
  397. *@par Attributes:
  398. *@li align_corners: If true, the centers of the 4 corner pixels of the input
  399. and output tensors are aligned, preserving the values at the corner pixels.
  400. Defaults to false.
  401. *@li half_pixel_centers: An optional bool. Defaults to False . \n
  402. *@par Outputs:
  403. *y: 4-D with shape [batch, new_height, new_width, channels]. The format
  404. must be NHWC. \n
  405. *@attention Constraints:
  406. *Input images can be of different types but output images are always float .
  407. *@par Third-party framework compatibility
  408. *Compatible with tensorflow ResizeBicubic operator.
  409. */
  410. REG_OP(ResizeBicubic)
  411. .INPUT(images, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, \
  412. DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  413. .INPUT(size, TensorType({DT_INT32}))
  414. .OUTPUT(y, TensorType({DT_FLOAT}))
  415. .ATTR(align_corners, Bool, false)
  416. .ATTR(half_pixel_centers, Bool, false)
  417. .OP_END_FACTORY_REG(ResizeBicubic)
  418. /**
  419. *@brief Computes the gradient of nearest neighbor interpolation . \n
  420. *@par Inputs:
  421. *Input grads must be a 4-D tensor. Inputs include:
  422. *@li grads: A Tensor. Must be one of the following types: uint8, int8, int32,
  423. float16, float, double. Must set the format, supported format list ["NCHW, NHWC"]
  424. *@li size: A 1-D int32 Tensor of 2 elements: orig_height, orig_width.
  425. The original input size . \n
  426. *@par Attributes:
  427. *@li align_corners: An optional bool. Defaults to False. If true, the centers
  428. of the 4 corner pixels of the input and grad tensors are aligned. Defaults to
  429. false.
  430. *@li half_pixel_centers: An optional bool. Defaults to False . \n
  431. *@par Outputs:
  432. *y: A Tensor. Has the same type as grads . \n
  433. *@attention Constraints:
  434. *Input grads must be a 4-D tensor . \n
  435. *@par Third-party framework compatibility
  436. *Compatible with tensorflow ResizeNearestNeighborV2Grad operator.
  437. */
  438. REG_OP(ResizeNearestNeighborV2Grad)
  439. .INPUT(grads, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32,
  440. DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  441. .INPUT(size, TensorType({DT_INT32}))
  442. .OUTPUT(y, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32,
  443. DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  444. .ATTR(align_corners, Bool, false)
  445. .ATTR(half_pixel_centers, Bool, false)
  446. .OP_END_FACTORY_REG(ResizeNearestNeighborV2Grad)
  447. /**
  448. *@brief Computes the gradient of nearest neighbor interpolation . \n
  449. *@par Inputs:
  450. *Input grads must be a 4-D tensor. Inputs include:
  451. *grads: A Tensor. 4-D with shape [batch, height, width, channels].
  452. *@par Attributes:
  453. *@li align_corners: An optional bool. Defaults to False. If true, the centers
  454. of the 4 corner pixels of the input and grad tensors are aligned. Defaults to
  455. false.
  456. *@li size: An list type. Specify the images size . \n
  457. *@par Outputs:
  458. *y: A Tensor. Has the same type as grads . \n
  459. *@par Third-party framework compatibility
  460. *Compatible with tensorflow ResizeNearestNeighborV2GradD operator.
  461. *
  462. * @par Restrictions:
  463. * Warning: THIS FUNCTION IS DEPRECATED. Please use ResizeNearestNeighborV2Grad instead.
  464. */
  465. REG_OP(ResizeNearestNeighborV2GradD)
  466. .INPUT(grads, TensorType({DT_FLOAT}))
  467. .OUTPUT(y, TensorType({DT_FLOAT}))
  468. .REQUIRED_ATTR(size, ListInt)
  469. .ATTR(align_corners, Bool, false)
  470. .ATTR(half_pixel_centers, Bool, false)
  471. .OP_END_FACTORY_REG(ResizeNearestNeighborV2GradD)
  472. /**
  473. *@brief Computes the gradient of bilinear interpolation . \n
  474. *@par Inputs:
  475. *Input grads must be a 4-D tensor. Inputs include:
  476. *@li grads: A Tensor of type float32. Must set the format, supported format list ["NCHW, NHWC"]
  477. *@li original_image: A Tensor. 4-D shape. Must set the format, supported format list ["NCHW, NHWC"]
  478. channels], The image tensor that was resized . \n
  479. *@par Attributes:
  480. *@li align_corners: An optional bool. Defaults to False. If true, the centers of
  481. the 4 corner pixels of the input and grad tensors are aligned. Defaults to
  482. false .
  483. *@li half_pixel_centers: indicates if the offset coordinates are normalized. Defaults
  484. to false . \n
  485. *@par Outputs:
  486. *y: A Tensor. Has the same type as original_image . \n
  487. *@attention Constraints:
  488. *Input grads must be a 4-D tensor . \n
  489. *@par Third-party framework compatibility
  490. *Compatible with tensorflow ResizeBilinearV2Grad operator.
  491. */
  492. REG_OP(ResizeBilinearV2Grad)
  493. .INPUT(grads, TensorType({DT_FLOAT}))
  494. .INPUT(original_image, TensorType::FloatingDataType())
  495. .OUTPUT(y, TensorType({DT_FLOAT}))
  496. .ATTR(align_corners, Bool, false)
  497. .ATTR(half_pixel_centers, Bool, false)
  498. .OP_END_FACTORY_REG(ResizeBilinearV2Grad)
  499. /**
  500. *@brief Computes the gradient of bilinear interpolation . \n
  501. *@par Inputs:
  502. *Input grads must be a 4-D tensor. Inputs include:
  503. *@li grads: A Tensor of type float32. Must set the format, supported format list ["NCHW, NHWC"]
  504. *@li original_image: A Tensor. 4-D shape. Must set the format, supported format list ["NCHW, NHWC"]
  505. channels], The image tensor that was resized . \n
  506. *@par Attributes:
  507. *@li size: An optional listint. Defaults to {}.
  508. *@par Attributes:
  509. *@li ori_image_size: An optional listint. Defaults to {}.
  510. *@par Attributes:
  511. *@li src_start_w: An optional int. Defaults to 0.
  512. *@par Attributes:
  513. *@li dst_start_w: An optional int. Defaults to 0.
  514. *@par Attributes:
  515. *@li align_corners: An optional bool. Defaults to False. If true, the centers of
  516. the 4 corner pixels of the input and grad tensors are aligned. Defaults to
  517. false .
  518. *@li half_pixel_centers: indicates if the offset coordinates are normalized. Defaults
  519. to false . \n
  520. *@par Outputs:
  521. *y: A Tensor. Has the same type as original_image . \n
  522. *@attention Constraints:
  523. *Input grads must be a 4-D tensor . \n
  524. *@par Third-party framework compatibility
  525. *Compatible with mindspore ResizeBilinearV2Grad operator.
  526. */
  527. REG_OP(SyncResizeBilinearV2Grad)
  528. .INPUT(grads, TensorType({DT_FLOAT}))
  529. .INPUT(original_image, TensorType::FloatingDataType())
  530. .OUTPUT(y, TensorType({DT_FLOAT}))
  531. .ATTR(size, ListInt, {})
  532. .ATTR(ori_image_size, ListInt, {})
  533. .ATTR(src_start_w, Int, 0)
  534. .ATTR(dst_start_w, Int, 0)
  535. .ATTR(align_corners, Bool, false)
  536. .ATTR(half_pixel_centers, Bool, false)
  537. .OP_END_FACTORY_REG(SyncResizeBilinearV2Grad)
  538. /**
  539. *@brief Resize images to size using bilinear interpolation . \n
  540. *@par Inputs:
  541. *Input images must be a 4-D tensor. Inputs include:
  542. *@li x: 4-D tensor. Must set the format, supported format list ["NCHW, NHWC"]
  543. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width. The new
  544. size for the images . \n
  545. *@par Attributes:
  546. * @li align_corners: If true, the centers of the 4 corner pixels of the input and
  547. output tensors are aligned, preserving the values at the corner pixels.
  548. Defaults to false .
  549. * @li half_pixel_centers: An optional bool. Defaults to False . \n
  550. * @li dtype: An Type attr, support type list [DT_FP32, DT_U8]. Defaults to DT_FP32 . \n
  551. *@par Outputs:
  552. *y: 4-D with shape [batch, new_height, new_width, channels] . \n
  553. *@attention Constraints:
  554. *Input images can be of different types but output images are always float . \n
  555. *@par Third-party framework compatibility
  556. *Compatible with tensorflow ResizeBilinearV2 operator.
  557. */
  558. REG_OP(ResizeBilinearV2)
  559. .INPUT(x, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32,
  560. DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  561. .INPUT(size, TensorType({DT_INT32}))
  562. .OUTPUT(y, TensorType({DT_UINT8, DT_FLOAT}))
  563. .ATTR(align_corners, Bool, false)
  564. .ATTR(half_pixel_centers, Bool, false)
  565. .ATTR(dtype, Type, DT_FLOAT)
  566. .OP_END_FACTORY_REG(ResizeBilinearV2)
  567. /**
  568. *@brief Resize images to size using bilinear interpolation . \n
  569. *@par Inputs:
  570. *Input images must be a 4-D tensor. Inputs include:
  571. *@li x: 4-D tensor. Must set the format, supported format list ["NCHW, NHWC"]
  572. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width. The new
  573. size for the images . \n
  574. *@par Attributes:
  575. * @li align_corners: If true, the centers of the 4 corner pixels of the input and
  576. output tensors are aligned, preserving the values at the corner pixels.
  577. Defaults to false .
  578. * @li half_pixel_centers: An optional bool. Defaults to False . \n
  579. *@li ori_image_size: An optional listint. Defaults to {}.
  580. *@li split_size: An optional listint. Defaults to {}.
  581. *@li src_start_w: An optional int. Defaults to 0.
  582. *@li dst_start_w: An optional int. Defaults to 0.
  583. *@par Outputs:
  584. *y: 4-D with shape [batch, new_height, new_width, channels] . \n
  585. *@attention Constraints:
  586. *Input images can be of different types but output images are always float . \n
  587. *@par Third-party framework compatibility
  588. *Compatible with mindspore ResizeBilinearV2 operator.
  589. */
  590. REG_OP(SyncResizeBilinearV2)
  591. .INPUT(x, TensorType({DT_FLOAT}))
  592. .INPUT(size, TensorType({DT_INT32}))
  593. .OUTPUT(y, TensorType({DT_FLOAT}))
  594. .ATTR(ori_image_size, ListInt, {})
  595. .ATTR(split_size, ListInt, {})
  596. .ATTR(src_start_w, Int, 0)
  597. .ATTR(dst_start_w, Int, 0)
  598. .ATTR(align_corners, Bool, false)
  599. .ATTR(half_pixel_centers, Bool, false)
  600. .OP_END_FACTORY_REG(SyncResizeBilinearV2)
  601. /**
  602. *@brief Converts one or more images from RGB to HSV . \n
  603. *@par Inputs:
  604. *Last dimension of input images must be size 3. Inputs include:
  605. *images: A Tensor. Must be one of the following types: float, double. 1-D or
  606. higher rank. RGB data to convert. Last dimension must be size 3 . \n
  607. *@par Outputs:
  608. *y: A Tensor. Has the same type as images . \n
  609. *@attention Constraints:
  610. *Outputs a tensor of the same shape as the images tensor, containing the HSV
  611. value of the pixels. The output is only well defined if the value in images
  612. are in [0,1] . \n
  613. *@par Third-party framework compatibility
  614. *Compatible with tensorflow RGBToHSV operator.
  615. */
  616. REG_OP(RGBToHSV)
  617. .INPUT(images, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE }))
  618. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE }))
  619. .OP_END_FACTORY_REG(RGBToHSV)
  620. /**
  621. *@brief Generate a single randomly distorted bounding box for an image . \n
  622. *@par Inputs:
  623. *Input images must be a 4-D tensor. Inputs include:
  624. *@li image_size: 1-D, containing [height, width, channels].
  625. *@li bounding_boxes: 3-D with shape [batch, N, 4] describing the N bounding
  626. boxes associated with the image. \n
  627. *@par Attributes:
  628. *@li seed: If either seed or seed2 are set to non-zero, the random number
  629. generator is seeded by the given seed. Otherwise, it is seeded by a random seed.
  630. *@li seed2: A second seed to avoid seed collision.
  631. *@li min_object_covered: The cropped area of the image must contain at least
  632. this fraction of any bounding box supplied. The value of this parameter should
  633. be non-negative. In the case of 0, the cropped area does not need to overlap
  634. any of the bounding boxes supplied .
  635. *@li aspect_ratio_range: The cropped area of the image must have an aspect
  636. ratio = width / height within this range.
  637. *@li area_range: An optional list of `floats`. Defaults to `[0.05, 1]`. The
  638. cropped area of the image must contain a fraction of the supplied image
  639. within this range.
  640. *@li max_attempts: Number of attempts at generating a cropped region of the
  641. image of the specified constraints. After max_attempts failures, return the
  642. entire image.
  643. *@li use_image_if_no_bounding_boxes: Controls behavior if no bounding boxes
  644. supplied. If true, assume an implicit bounding box covering the whole input.
  645. If false, raise an error . \n
  646. *@par Outputs:
  647. *@li begin: 1-D, containing [offset_height, offset_width, 0].
  648. *@li size: 1-D, containing [target_height, target_width, -1].
  649. *@li bboxes: 3-D with shape [1, 1, 4] containing the distorted bounding box . \n
  650. *@attention Constraints:
  651. *Input images can be of different types but output images are always float . \n
  652. *@par Third-party framework compatibility
  653. *Compatible with tensorflow SampleDistortedBoundingBox operator.
  654. */
  655. REG_OP(SampleDistortedBoundingBox)
  656. .INPUT(image_size, TensorType({ DT_UINT8, DT_INT8, DT_INT16, \
  657. DT_INT32, DT_INT64 }))
  658. .INPUT(bounding_boxes, TensorType({ DT_FLOAT }))
  659. .OUTPUT(begin, TensorType({ DT_UINT8, DT_INT8, DT_INT16, \
  660. DT_INT32, DT_INT64 }))
  661. .OUTPUT(size, TensorType({ DT_UINT8, DT_INT8, DT_INT16, \
  662. DT_INT32, DT_INT64 }))
  663. .OUTPUT(bboxes, TensorType({ DT_FLOAT }))
  664. .ATTR(seed, Int, 0)
  665. .ATTR(seed2, Int, 0)
  666. .ATTR(min_object_covered, Float, 0.1f)
  667. .ATTR(aspect_ratio_range, ListFloat, { 0.75f, 1.33f })
  668. .ATTR(area_range, ListFloat, { 0.05f, 1.0f })
  669. .ATTR(max_attempts, Int, 100)
  670. .ATTR(use_image_if_no_bounding_boxes, Bool, false)
  671. .OP_END_FACTORY_REG(SampleDistortedBoundingBox)
  672. /**
  673. *@brief Generate a single randomly distorted bounding box for an image . \n
  674. *@par Inputs:
  675. *Input images must be a 4-D tensor. Inputs include:
  676. *@li image_size: 1-D, containing [height, width, channels].
  677. *@li bounding_boxes: 3-D with shape [batch, N, 4] describing the N bounding
  678. boxes associated with the image.
  679. *@li min_object_covered: The cropped area of the image must contain at least
  680. this fraction of any bounding box supplied. The value of this parameter should
  681. be non-negative. In the case of 0, the cropped area does not need to overlap
  682. any of the bounding boxes supplied . \n
  683. *@par Attributes:
  684. *@li seed: If either seed or seed2 are set to non-zero, the random number
  685. generator is seeded by the given seed. Otherwise, it is seeded by a random seed.
  686. *@li seed2: A second seed to avoid seed collision.
  687. *@li aspect_ratio_range: The cropped area of the image must have an aspect
  688. ratio = width / height within this range.
  689. *@li area_range: An optional list of `floats`. Defaults to `[0.05, 1]`. The
  690. cropped area of the image must contain a fraction of the supplied image
  691. within this range.
  692. *@li max_attempts: Number of attempts at generating a cropped region of the
  693. image of the specified constraints. After max_attempts failures, return the
  694. entire image.
  695. *@li use_image_if_no_bounding_boxes: Controls behavior if no bounding boxes
  696. supplied. If true, assume an implicit bounding box covering the whole input.
  697. If false, raise an error . \n
  698. *@par Outputs:
  699. *@li begin: 1-D, containing [offset_height, offset_width, 0].
  700. *@li size: 1-D, containing [target_height, target_width, -1].
  701. *@li bboxes: 3-D with shape [1, 1, 4] containing the distorted bounding box . \n
  702. *@attention Constraints:
  703. *Input images can be of different types but output images are always float . \n
  704. *@par Third-party framework compatibility
  705. *Compatible with tensorflow SampleDistortedBoundingBoxExt2 operator.
  706. */
  707. REG_OP(SampleDistortedBoundingBoxExt2)
  708. .INPUT(image_size, TensorType({ DT_UINT8, DT_INT8, DT_INT16, \
  709. DT_INT32, DT_INT64 }))
  710. .INPUT(bounding_boxes, TensorType({ DT_FLOAT }))
  711. .INPUT(min_object_covered, TensorType({ DT_FLOAT }))
  712. .OUTPUT(begin, TensorType({ DT_UINT8, DT_INT8, DT_INT16, \
  713. DT_INT32, DT_INT64 }))
  714. .OUTPUT(size, TensorType({ DT_UINT8, DT_INT8, DT_INT16, \
  715. DT_INT32, DT_INT64 }))
  716. .OUTPUT(bboxes, TensorType({ DT_FLOAT }))
  717. .ATTR(seed, Int, 0)
  718. .ATTR(seed2, Int, 0)
  719. .ATTR(aspect_ratio_range, ListFloat, { 0.75f, 1.33f })
  720. .ATTR(area_range, ListFloat, { 0.05f, 1.0f })
  721. .ATTR(max_attempts, Int, 100)
  722. .ATTR(use_image_if_no_bounding_boxes, Bool, false)
  723. .OP_END_FACTORY_REG(SampleDistortedBoundingBoxExt2)
  724. /**
  725. *@brief Resize images to size using nearest neighbor interpolation . \n
  726. *@par Inputs:
  727. *Input x must be a 4-D tensor. Inputs include:
  728. *@li x: 4-D tensor. Must set the format, supported format list ["NCHW, NHWC"].
  729. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width.
  730. The new size for the images . \n
  731. *@par Attributes:
  732. *@li align_corners: If true, the centers of the 4 corner pixels of the input and
  733. output tensors are aligned, preserving the values at the corner pixels.
  734. Defaults to false . \n
  735. *@li half_pixel_centers: An optional bool. Defaults to False . \n
  736. *@par Outputs:
  737. *y: A Tensor with the same type and format as input "images" . \n
  738. *@par Third-party framework compatibility
  739. *Compatible with tensorflow ResizeNearestNeighbor operator.
  740. */
  741. REG_OP(ResizeNearestNeighborV2)
  742. .INPUT(x, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32,
  743. DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  744. .INPUT(size, TensorType({DT_INT32}))
  745. .OUTPUT(y, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32,
  746. DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  747. .ATTR(align_corners, Bool, false)
  748. .ATTR(half_pixel_centers, Bool, false)
  749. .OP_END_FACTORY_REG(ResizeNearestNeighborV2)
  750. /**
  751. *@brief Draw bounding boxes on a batch of images . \n
  752. *@par Inputs:
  753. *Input images must be a 4-D tensor. Inputs include:
  754. *@li images: A Tensor. Must be one of the following types: float. 4-D with
  755. shape [batch, height, width, depth]. A batch of images. The format must be NHWC.
  756. *@li boxes: A Tensor of type float32. 3-D with shape [batch,
  757. num_bounding_boxes, 4] containing bounding boxes . \n
  758. *@par Outputs:
  759. *A Tensor. Has the same type as images. The format must be NHWC. \n
  760. *@attention Constraints:
  761. *Input images must be a 4-D tensor . \n
  762. *@par Third-party framework compatibility
  763. *Compatible with tensorflow DrawBoundingBoxes operator.
  764. */
  765. REG_OP(DrawBoundingBoxes)
  766. .INPUT(images, TensorType({DT_FLOAT}))
  767. .INPUT(boxes, TensorType({DT_FLOAT}))
  768. .OUTPUT(y, TensorType({DT_FLOAT}))
  769. .OP_END_FACTORY_REG(DrawBoundingBoxes)
  770. /**
  771. *@brief Greedily selects a subset of bounding boxes in descending order of
  772. score . \n
  773. *@par Inputs:
  774. *Input boxes and scores must be float type. Inputs include:
  775. *@li boxes: A 2-D float tensor of shape [num_boxes, 4].
  776. *@li scores: A 1-D float tensor of shape [num_boxes] representing a single
  777. score corresponding to each box (each row of boxes).
  778. *@li max_output_size: A scalar integer tensor representing the maximum number
  779. of boxes to be selected by non max suppression . \n
  780. *@par Attributes:
  781. *iou_threshold: A float representing the threshold for deciding whether boxes
  782. overlap too much with respect to IOU . \n
  783. *@par Outputs:
  784. *selected_indices: A 1-D integer tensor of shape [M] representing the selected
  785. indices from the boxes tensor, where M <= max_output_size . \n
  786. *@attention Constraints:
  787. *Input boxes and scores must be float type . \n
  788. *@par Third-party framework compatibility
  789. *Compatible with tensorflow NonMaxSuppression operator.
  790. */
  791. REG_OP(NonMaxSuppression)
  792. .INPUT(boxes, TensorType({DT_FLOAT}))
  793. .INPUT(scores, TensorType({DT_FLOAT}))
  794. .INPUT(max_output_size, TensorType({DT_INT32}))
  795. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  796. .ATTR(iou_threshold, Float, 0.5f)
  797. .OP_END_FACTORY_REG(NonMaxSuppression)
  798. /**
  799. *@brief Greedily selects a subset of bounding boxes in descending order of
  800. score . \n
  801. *@par Inputs:
  802. *Input boxes and scores must be float type. Inputs include:
  803. *@li boxes: A 2-D float tensor of shape [num_boxes, 4].
  804. *@li scores: A 1-D float tensor of shape [num_boxes] representing a single
  805. score corresponding to each box (each row of boxes).
  806. *@li max_output_size: A scalar integer tensor representing the maximum number
  807. of boxes to be selected by non max suppression.
  808. *@li iou_threshold: A 0-D float tensor representing the threshold for deciding
  809. whether boxes overlap too much with respect to IOU . \n
  810. *@par Outputs:
  811. *selected_indices: A 1-D integer tensor of shape [M] representing the selected
  812. indices from the boxes tensor, where M <= max_output_size . \n
  813. *@attention Constraints:
  814. *Input boxes and scores must be float type . \n
  815. *@par Third-party framework compatibility
  816. *Compatible with tensorflow NonMaxSuppressionV2 operator.
  817. */
  818. REG_OP(NonMaxSuppressionV2)
  819. .INPUT(boxes, TensorType({DT_FLOAT16, DT_FLOAT}))
  820. .INPUT(scores, TensorType({DT_FLOAT16, DT_FLOAT}))
  821. .INPUT(max_output_size, TensorType({DT_INT32}))
  822. .INPUT(iou_threshold, TensorType({DT_FLOAT16,DT_FLOAT}))
  823. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  824. .OP_END_FACTORY_REG(NonMaxSuppressionV2)
  825. /**
  826. *@brief Greedily selects a subset of bounding boxes in descending order of
  827. score . \n
  828. *@par Inputs:
  829. *Input boxes and scores must be float type. Inputs include:
  830. *@li boxes: A 2-D float tensor of shape [num_boxes, 4].
  831. *@li scores: A 1-D float tensor of shape [num_boxes] representing a single
  832. score corresponding to each box (each row of boxes).
  833. *@li max_output_size: A scalar integer tensor representing the maximum number
  834. of boxes to be selected by non max suppression.
  835. *@li iou_threshold: A 0-D float tensor representing the threshold for deciding
  836. whether boxes overlap too much with respect to IOU.
  837. *@li score_threshold: A 0-D float tensor representing the threshold for
  838. deciding when to remove boxes based on score . \n
  839. *@par Outputs:
  840. *selected_indices: A 1-D integer tensor of shape [M] representing the selected
  841. indices from the boxes tensor, where M <= max_output_size . \n
  842. *@attention Constraints:
  843. *Input boxes and scores must be float type . \n
  844. *@par Third-party framework compatibility
  845. *Compatible with tensorflow NonMaxSuppressionV3 operator.
  846. */
  847. REG_OP(NonMaxSuppressionV3)
  848. .INPUT(boxes, TensorType({DT_FLOAT16, DT_FLOAT}))
  849. .INPUT(scores, TensorType({DT_FLOAT16, DT_FLOAT}))
  850. .INPUT(max_output_size, TensorType({DT_INT32}))
  851. .INPUT(iou_threshold, TensorType({DT_FLOAT16,DT_FLOAT}))
  852. .INPUT(score_threshold, TensorType({DT_FLOAT16,DT_FLOAT}))
  853. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  854. .OP_END_FACTORY_REG(NonMaxSuppressionV3)
  855. /**
  856. *@brief Greedily selects a subset of bounding boxes in descending order of
  857. score . \n
  858. *@par Inputs:
  859. *Input boxes and scores must be float type. Inputs include:
  860. *@li boxes: A 2-D float tensor of shape [num_boxes, 4].
  861. *@li scores: A 1-D float tensor of shape [num_boxes] representing a single
  862. score corresponding to each box (each row of boxes).
  863. *@li max_output_size: A scalar integer tensor representing the maximum number
  864. of boxes to be selected by non max suppression.
  865. *@li iou_threshold: A 0-D float tensor representing the threshold for deciding
  866. whether boxes overlap too much with respect to IOU.
  867. *@li score_threshold: A 0-D float tensor representing the threshold for
  868. deciding when to remove boxes based on score . \n
  869. *@par Attributes:
  870. *pad_to_max_output_size: If true, the output selected_indices is padded
  871. to be of length max_output_size. Defaults to false . \n
  872. *@par Outputs:
  873. *@li selected_indices: A 1-D integer tensor of shape [M] representing the
  874. selected indices from the boxes tensor, where M <= max_output_size.
  875. *@li valid_outputs: A 0-D integer tensor representing the number of valid
  876. elements in selected_indices, with the valid elements appearing first . \n
  877. *@attention Constraints:
  878. *Input boxes and scores must be float type . \n
  879. *@par Third-party framework compatibility
  880. *Compatible with tensorflow NonMaxSuppressionV4 operator.
  881. */
  882. REG_OP(NonMaxSuppressionV4)
  883. .INPUT(boxes, TensorType({DT_FLOAT16, DT_FLOAT}))
  884. .INPUT(scores, TensorType({DT_FLOAT16, DT_FLOAT}))
  885. .INPUT(max_output_size, TensorType({DT_INT32}))
  886. .INPUT(iou_threshold, TensorType({DT_FLOAT16,DT_FLOAT}))
  887. .INPUT(score_threshold, TensorType({DT_FLOAT16,DT_FLOAT}))
  888. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  889. .OUTPUT(valid_outputs, TensorType({DT_INT32}))
  890. .ATTR(pad_to_max_output_size, Bool, false)
  891. .OP_END_FACTORY_REG(NonMaxSuppressionV4)
  892. /**
  893. *@brief Greedily selects a subset of bounding boxes in descending order of
  894. score . \n
  895. *@par Inputs:
  896. *Input overlaps and scores must be float type. Inputs include:
  897. *@li overlaps: A 2-D float tensor of shape [num_boxes, num_boxes]
  898. representing the n-by-n box overlap values.
  899. *@li scores: A 1-D float tensor of shape [num_boxes] representing a single
  900. score corresponding to each box (each row of boxes).
  901. *@li max_output_size: A scalar integer tensor representing the maximum number
  902. of boxes to be selected by non max suppression.
  903. *@li overlap_threshold: A 0-D float tensor representing the threshold for
  904. deciding whether boxes overlap too.
  905. *@li score_threshold: A 0-D float tensor representing the threshold for
  906. deciding when to remove boxes based on score . \n
  907. *@par Outputs:
  908. *selected_indices: A 1-D integer tensor of shape [M] representing the
  909. selected indices from the boxes tensor, where M <= max_output_size . \n
  910. *@par Third-party framework compatibility
  911. *Compatible with tensorflow NonMaxSuppressionWithOverlaps operator.
  912. */
  913. REG_OP(NonMaxSuppressionWithOverlaps)
  914. .INPUT(overlaps, TensorType({DT_FLOAT}))
  915. .INPUT(scores, TensorType({DT_FLOAT}))
  916. .INPUT(max_output_size, TensorType({DT_INT32}))
  917. .INPUT(overlap_threshold, TensorType({DT_FLOAT}))
  918. .INPUT(score_threshold, TensorType({DT_FLOAT}))
  919. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  920. .OP_END_FACTORY_REG(NonMaxSuppressionWithOverlaps)
  921. /**
  922. *@brief JPEG-encode an image . \n
  923. *@par Inputs:
  924. *Input image must be unit8 type. Inputs include:
  925. *image: A 3-D uint8 Tensor of shape [height, width, channels] . \n
  926. *@par Attributes:
  927. *@li format: Per pixel image format.
  928. *@li quality: Quality of the compression from 0 to 100 (higher is better
  929. and slower).
  930. *@li progressive: If True, create a JPEG that loads progressively (coarse
  931. to fine).
  932. *@li optimize_size: If True, spend CPU/RAM to reduce size with no quality
  933. change.
  934. *@li chroma_downsampling: A boolean, default is true.
  935. *@li density_unit: Unit used to specify x_density and y_density: pixels per
  936. inch ('in') or centimeter ('cm').
  937. *@li x_density: Horizontal pixels per density unit.
  938. *@li y_density: Vertical pixels per density unit.
  939. *@li xmp_metadata: If not empty, embed this XMP metadata in the image header . \n
  940. *@par Outputs:
  941. *contents: 0-D. JPEG-encoded image . \n
  942. *@par Third-party framework compatibility
  943. *Compatible with tensorflow EncodeJpeg operator.
  944. */
  945. REG_OP(EncodeJpeg)
  946. .INPUT(image, TensorType({DT_UINT8}))
  947. .OUTPUT(contents, TensorType({DT_STRING}))
  948. .ATTR(format, String, "")
  949. .ATTR(quality, Int, 95)
  950. .ATTR(progressive, Bool, false)
  951. .ATTR(optimize_size, Bool, false)
  952. .ATTR(chroma_downsampling, Bool, true)
  953. .ATTR(density_unit, String, "in")
  954. .ATTR(x_density, Int, 300)
  955. .ATTR(y_density, Int, 300)
  956. .ATTR(xmp_metadata, String, "")
  957. .OP_END_FACTORY_REG(EncodeJpeg)
  958. /**
  959. *@brief PNG-encode an image.
  960. *@par Inputs:
  961. *Input image must be unit8 or uint16 type. Inputs include:
  962. *image: is a 3-D uint8 or uint16 Tensor of shape [height, width, channels]
  963. where channels is: 1: for grayscale; 2: for grayscale + alpha; 3: for RGB;
  964. 4: for RGBA . \n
  965. *@par Attributes:
  966. *compression: Compression level . \n
  967. *@par Outputs:
  968. *contents: 0-D. PNG-encoded image . \n
  969. *@par Third-party framework compatibility
  970. *Compatible with tensorflow EncodePng operator.
  971. */
  972. REG_OP(EncodePng)
  973. .INPUT(image, TensorType({DT_UINT8, DT_UINT16}))
  974. .OUTPUT(contents, TensorType({DT_STRING}))
  975. .ATTR(compression, Int, -1)
  976. .OP_END_FACTORY_REG(EncodePng)
  977. /**
  978. *@brief PNG-decode an image.
  979. *@par Inputs:
  980. *contents: 0-D. PNG-decoded image .
  981. *@par Attributes:
  982. *@li channels: graph channels \n
  983. *@li dtype: type of image
  984. *@par Outputs:
  985. *image: is a 3-D uint8 or uint16 Tensor of shape [height, width, channels]
  986. where channels is: 1: for grayscale; 2: for grayscale + alpha; 3: for RGB;
  987. 4: for RGBA . \n
  988. *@par Third-party framework compatibility
  989. *Compatible with tensorflow DecodePng operator.
  990. */
  991. REG_OP(DecodePng)
  992. .INPUT(contents, TensorType({DT_STRING}))
  993. .OUTPUT(image, TensorType({DT_UINT8, DT_UINT16}))
  994. .ATTR(dtype, Type, DT_UINT8)
  995. .ATTR(channels, Int, 0)
  996. .OP_END_FACTORY_REG(DecodePng)
  997. /**
  998. *@brief Bmp-decode an image. \n
  999. *@par Inputs:
  1000. *contents: A Tensor of type string. 0-D. The BMP-encoded image. \n
  1001. *@par Attributes:
  1002. *channels: Decode the desired number of color channels of the image. \n
  1003. *@par Outputs:
  1004. *image: A Tensor dtype of uint8.
  1005. * @par Third-party framework compatibility
  1006. * Compatible with tensorflow DecodeBmp operator.
  1007. */
  1008. REG_OP(DecodeBmp)
  1009. .INPUT(contents, TensorType({DT_STRING}))
  1010. .OUTPUT(image, TensorType({DT_UINT8}))
  1011. .ATTR(channels, Int, 0)
  1012. .OP_END_FACTORY_REG(DecodeBmp)
  1013. /**
  1014. *@brief Function parse image from string to int. \n
  1015. *@par Inputs:
  1016. *@li contents: A Tensor of type string. 0-D. The JPEG-encoded image. \n
  1017. *@li crop_window: 1-D. The crop window: [crop_y, crop_x, crop_height, crop_width]. \n
  1018. *@par Attributes:
  1019. *@li channels: An optional int. Defaults to 0. Number of color channels for the
  1020. *decoded image.
  1021. *@li ratio: An optional int. Defaults to 1. Downscaling ratio.
  1022. *@li fancy_upscaling: An optional bool. Defaults to True. If true use a slower
  1023. *but nicer upscaling of the chroma planes
  1024. *@li try_recover_truncated: An optional bool. Defaults to False. If true try to
  1025. *recover an image from truncated input.
  1026. *@li acceptable_fraction: An optional float. Defaults to 1. The minimum required
  1027. fraction of lines before a truncated input is accepted.
  1028. *@li dct_method: An optional string. Defaults to "". string specifying a hint
  1029. *about the algorithm used for decompression. \n
  1030. *@par Outputs:
  1031. *image: A Tensor dtype of uint8.
  1032. */
  1033. REG_OP(DecodeAndCropJpeg)
  1034. .INPUT(contents, TensorType({DT_STRING}))
  1035. .INPUT(crop_window, TensorType({DT_INT32}))
  1036. .OUTPUT(image, TensorType({DT_UINT8}))
  1037. .ATTR(channels, Int, 0)
  1038. .ATTR(ratio, Int, 1)
  1039. .ATTR(fancy_upscaling, Bool, true)
  1040. .ATTR(try_recover_truncated, Bool, false)
  1041. .ATTR(acceptable_fraction, Float, 1.0)
  1042. .ATTR(dct_method, String, "")
  1043. .OP_END_FACTORY_REG(DecodeAndCropJpeg)
  1044. /**
  1045. *@brief Resizes "images" to "size" using bilinear interpolation . \n
  1046. *@par Inputs:
  1047. * One input:
  1048. *x: A Tensor.
  1049. * Must be one of the following types: float16, float32 . \n
  1050. *@par Attributes:
  1051. *@li size: A required int32 Tensor specifying the new size for the images.
  1052. No default value.
  1053. *@li align_corners: An optional bool. If "true", the centers of the corner
  1054. pixels of the input and output tensors are aligned. Defaults to "false" . \n
  1055. *@par Outputs:
  1056. *y: A Tensor with type float32 and the same format as input "images" . \n
  1057. *@attention Constraints:
  1058. *@li The input "size" must be a tensor of 2 elements: size[0] <= 2048,
  1059. size[1] <= 2048.
  1060. *@li The input "images" must be a tensor of 5 elements: images[2] <= 2048,
  1061. images[3] <= 2048 . \n
  1062. *@par Third-party framework compatibility
  1063. * Compatible with TensorFlow operator ResizeBilinearV2D.
  1064. *
  1065. * @par Restrictions:
  1066. * Warning: THIS FUNCTION IS DEPRECATED. Please use ResizeBilinearV2 instead.
  1067. */
  1068. REG_OP(ResizeBilinearV2D)
  1069. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1070. .OUTPUT(y, TensorType({DT_FLOAT}))
  1071. .ATTR(align_corners, Bool, false)
  1072. .ATTR(half_pixel_centers, Bool, false)
  1073. .REQUIRED_ATTR(size, ListInt)
  1074. .OP_END_FACTORY_REG(ResizeBilinearV2D)
  1075. /**
  1076. *@brief Resizes "images" to "size" using bilinear interpolation and keep ratio at the time. \n
  1077. *@par Inputs:
  1078. * One input:
  1079. *images: A Tensor.
  1080. * Must be one of the following types: float16, float32 . \n
  1081. *@par Attributes:
  1082. *@li min_dimension: A required int32 attribute for the min dimension for the images.
  1083. * No default value.
  1084. *@li max_dimension: A required int32 attribute for the max dimension for the images.
  1085. * No default value.
  1086. *@li align_corners: An optional bool. If "true", the centers of the corner
  1087. * pixels of the input and output tensors are aligned. Defaults to "false".
  1088. *@li half_pixel_centers: indicates if the offset coordinates are normalized
  1089. * Defaults to "false" . \n
  1090. *@par Outputs:
  1091. *y: A Tensor with type float32 and the same format as input "images" . \n
  1092. *@attention Constraints:
  1093. * The input "images" must be a tensor of 5 elements: images[2] <= 2048,
  1094. images[3] <= 2048.
  1095. */
  1096. REG_OP(KeepRatioResizeBilinear)
  1097. .INPUT(images, TensorType({DT_FLOAT16, DT_FLOAT}))
  1098. .OUTPUT(y, TensorType({DT_FLOAT}))
  1099. .REQUIRED_ATTR(min_dimension, Int)
  1100. .REQUIRED_ATTR(max_dimension, Int)
  1101. .ATTR(align_corners, Bool, false)
  1102. .ATTR(half_pixel_centers, Bool, false)
  1103. .OP_END_FACTORY_REG(KeepRatioResizeBilinear)
  1104. /**
  1105. *@brief Resizes "images" to "size" using nearest neighbor interpolation . \n
  1106. *@par Inputs:
  1107. * One input:
  1108. *x: A Tensor.
  1109. * Must be one of the following types: float16, float32, int32, int8, uint8
  1110. *@par Attributes:
  1111. *@li size: A required int32 Tensor specifying the new size for the images.
  1112. No default value.
  1113. *@li align_corners: An optional bool. If "true", the centers of the corner
  1114. pixels of the input and output tensors are aligned. Defaults to "false" . \n
  1115. *@li half_pixel_centers: An optional bool. Defaults to False . \n
  1116. *@par Outputs:
  1117. *y: A Tensor with the same type and format as input "images" . \n
  1118. *@attention Constraints:
  1119. * The input "size" must be a tensor of 2 elements: size[0] <= 7680,
  1120. size[1] <= 4320
  1121. *@par Third-party framework compatibility
  1122. * Compatible with TensorFlow operator ResizeNearestNeighborV2.
  1123. *
  1124. * @par Restrictions:
  1125. * Warning: THIS FUNCTION IS DEPRECATED. Please use ResizeNearestNeighborV2 instead.
  1126. */
  1127. REG_OP(ResizeNearestNeighborV2D)
  1128. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  1129. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  1130. .REQUIRED_ATTR(size, ListInt)
  1131. .ATTR(align_corners, Bool, false)
  1132. .ATTR(half_pixel_centers, Bool, false)
  1133. .OP_END_FACTORY_REG(ResizeNearestNeighborV2D)
  1134. /**
  1135. *@brief Extract the shape information of a JPEG-encoded image . \n
  1136. *@par Inputs:
  1137. *Input contents must be 0-D. Inputs include:
  1138. *contents: 0-D. The JPEG-encoded image . \n
  1139. *@par Attributes:
  1140. *output_type: The output type of the operation (int32 or int64). Defaults
  1141. to int32 . \n
  1142. *@par Outputs:
  1143. *image_shape: 1-D. The image shape with format [height, width, channels] . \n
  1144. *@par Third-party framework compatibility
  1145. *Compatible with tensorflow ExtractJpegShape operator.
  1146. */
  1147. REG_OP(ExtractJpegShape)
  1148. .INPUT(contents, TensorType({DT_STRING}))
  1149. .OUTPUT(image_shape, TensorType({DT_INT32, DT_INT64}))
  1150. .REQUIRED_ATTR(output_type, Type)
  1151. .OP_END_FACTORY_REG(ExtractJpegShape)
  1152. /**
  1153. *@brief Draw bounding boxes on a batch of images . \n
  1154. *@par Inputs:
  1155. *@li images: 4-D with shape `[batch, height, width, depth]`.
  1156. A batch of images.
  1157. *@li boxes: 3-D with shape `[batch, num_bounding_boxes, 4]`
  1158. containing bounding boxes.
  1159. *@li colors: 2-D. A list of RGBA colors to cycle through for the boxes . \n
  1160. *@par Outputs:
  1161. *y: Returns 4-D with the same shape as `images`.
  1162. The batch of input images with bounding boxes drawn on the images . \n
  1163. *@par Third-party framework compatibility
  1164. * Compatible with tensorflow DrawBoundingBoxesV2 operator.
  1165. */
  1166. REG_OP(DrawBoundingBoxesV2)
  1167. .INPUT(images, TensorType({DT_FLOAT}))
  1168. .INPUT(boxes, TensorType({DT_FLOAT}))
  1169. .INPUT(colors, TensorType({DT_FLOAT}))
  1170. .OUTPUT(y, TensorType({DT_FLOAT}))
  1171. .OP_END_FACTORY_REG(DrawBoundingBoxesV2)
  1172. /**
  1173. *@brief Greedily selects a subset of bounding boxes in descending order of score,
  1174. pruning away boxes that have high intersection-over-union (IOU) overlap
  1175. with previously selected boxes . \n
  1176. *@par Inputs:
  1177. *@li boxes: A 2-D float tensor of shape `[num_boxes, 4]`.
  1178. *@li scores: A 1-D float tensor of shape `[num_boxes]` representing a single
  1179. score corresponding to each box (each row of boxes).
  1180. *@li max_output_size: A scalar integer tensor representing the maximum number of
  1181. boxes to be selected by non max suppression.
  1182. *@li iou_threshold: A 0-D float tensor representing the threshold for deciding whether
  1183. boxes overlap too much with respect to IOU.
  1184. *@li score_threshold: A 0-D float tensor representing the threshold for deciding when to
  1185. remove boxes based on score.
  1186. *@li soft_nms_sigma: A 0-D float tensor representing the sigma parameter for Soft NMS . \n
  1187. *@par Attributes:
  1188. pad_to_max_output_size: If true, the output `selected_indices` is padded to be of length
  1189. `max_output_size`. Defaults to false. If not specified, defaults to false . \n
  1190. *@par Outputs:
  1191. *@li selected_indices: A 1-D integer tensor of shape [M] representing the
  1192. selected indices from the boxes tensor, where M <= max_output_size.
  1193. *@li selected_scores: A 1-D float tensor of shape `[M]` representing the corresponding
  1194. scores for each selected box, where `M <= max_output_size`.
  1195. *@li valid_outputs: A 0-D integer tensor representing the number of valid
  1196. elements in selected_indices, with the valid elements appearing first . \n
  1197. *@par Third-party framework compatibility
  1198. * Compatible with tensorflow NonMaxSuppressionV5 operator.
  1199. */
  1200. REG_OP(NonMaxSuppressionV5)
  1201. .INPUT(boxes, TensorType({DT_FLOAT16, DT_FLOAT}))
  1202. .INPUT(scores, TensorType({DT_FLOAT16, DT_FLOAT}))
  1203. .INPUT(max_output_size, TensorType({DT_INT32}))
  1204. .INPUT(iou_threshold, TensorType({DT_FLOAT16, DT_FLOAT}))
  1205. .INPUT(score_threshold, TensorType({DT_FLOAT16, DT_FLOAT}))
  1206. .INPUT(soft_nms_sigma, TensorType({DT_FLOAT16, DT_FLOAT}))
  1207. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  1208. .OUTPUT(selected_scores, TensorType({DT_FLOAT16, DT_FLOAT}))
  1209. .OUTPUT(valid_outputs, TensorType({DT_INT32}))
  1210. .ATTR(pad_to_max_output_size, Bool, false)
  1211. .REQUIRED_ATTR(T, Type)
  1212. .OP_END_FACTORY_REG(NonMaxSuppressionV5)
  1213. /**
  1214. *@brief Resizes "images" to "size" by scale and translate . \n
  1215. *@par Inputs:
  1216. *@li images: A `Tensor`. Must be one of the following types: `int8`, `uint8`,
  1217. `int16`, `uint16`, `int32`, `int64`, `bfloat16`, `float32`, `float64`.
  1218. *@li size: A `Tensor` of type `int32`.
  1219. *@li scale: A `Tensor` of type `float32`.
  1220. *@li translation: A `Tensor` of type `float32` . \n
  1221. *@par Attributes:
  1222. *@li kernel_type: type is string, default lanczos3
  1223. *@li antialias: type is bool, default true \n
  1224. *@par Outputs:
  1225. *y: A Tensor with type float32 . \n
  1226. *@par Third-party framework compatibility
  1227. * Compatible with TensorFlow ScaleAndTranslate operator.
  1228. */
  1229. REG_OP(ScaleAndTranslate)
  1230. .INPUT(images, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16,
  1231. DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1232. .INPUT(size, TensorType({DT_INT32}))
  1233. .INPUT(scale, TensorType({DT_FLOAT}))
  1234. .INPUT(translation, TensorType({DT_FLOAT}))
  1235. .OUTPUT(y, TensorType({DT_FLOAT}))
  1236. .ATTR(kernel_type, String, "lanczos3")
  1237. .ATTR(antialias, Bool, true)
  1238. .OP_END_FACTORY_REG(ScaleAndTranslate)
  1239. /**
  1240. *@brief Computes the gradient by scale and translate . \n
  1241. *@par Inputs:
  1242. *@li grads: A `Tensor`. Must be one of the following types: `float32`.
  1243. *@li original_image: A `Tensor`. Must have the same type as `grads`.
  1244. *@li scale: A `Tensor` of type `float32`.
  1245. *@li translation: A `Tensor` of type `float32` . \n
  1246. *@par Attributes:
  1247. *@li kernel_type: type is string, default lanczos3
  1248. *@li antialias: type is bool, default true
  1249. *@par Outputs:
  1250. *y: A `Tensor`. Has the same type as `grads` . \n
  1251. *@par Third-party framework compatibility
  1252. * Compatible with TensorFlow ScaleAndTranslateGrad operator.
  1253. */
  1254. REG_OP(ScaleAndTranslateGrad)
  1255. .INPUT(grads, TensorType({DT_FLOAT}))
  1256. .INPUT(original_image, TensorType({DT_FLOAT}))
  1257. .INPUT(scale, TensorType({DT_FLOAT}))
  1258. .INPUT(translation, TensorType({DT_FLOAT}))
  1259. .OUTPUT(y, TensorType({DT_FLOAT}))
  1260. .ATTR(kernel_type, String, "lanczos3")
  1261. .ATTR(antialias, Bool, true)
  1262. .OP_END_FACTORY_REG(ScaleAndTranslateGrad)
  1263. /**
  1264. *@brief Greedily selects a subset of bounding boxes in descending order of score,
  1265. This operation performs non_max_suppression on the inputs per batch, across all classes . \n
  1266. *@par Inputs:
  1267. *@li boxes: A 4-D float tensor of shape `[batch_size, num_boxes, q, 4]`. If `q` is 1 then
  1268. same boxes are used for all classes otherwise, if `q` is equal to number of
  1269. classes, class-specific boxes are used.
  1270. *@li scores: A 3-D float tensor of shape `[batch_size, num_boxes, num_classes]`
  1271. representing a single score corresponding to each box (each row of boxes).
  1272. *@li max_output_size_per_class: A scalar integer tensor representing the maximum number of
  1273. boxes to be selected by non max suppression per class.
  1274. *@li max_total_size: A scalar representing maximum number of boxes retained over all classes.
  1275. *@li iou_threshold: A 0-D float tensor representing the threshold for deciding whether
  1276. boxes overlap too much with respect to IOU.
  1277. *@li score_threshold: A 0-D float tensor representing the threshold for deciding when to remove
  1278. boxes based on score . \n
  1279. *@par Attributes:
  1280. *@li pad_per_class: If false, the output nmsed boxes, scores and classes
  1281. are padded/clipped to `max_total_size`. If true, the
  1282. output nmsed boxes, scores and classes are padded to be of length
  1283. `max_size_per_class`*`num_classes`, unless it exceeds `max_total_size` in
  1284. which case it is clipped to `max_total_size`. Defaults to false.
  1285. *@li clip_boxes: If true, assume the box coordinates are between [0, 1] and clip the output boxes
  1286. if they fall beyond [0, 1]. If false, do not do clipping and output the box
  1287. coordinates as it is. If not specified, defaults to true . \n
  1288. *@par Outputs:
  1289. *@li nmsed_boxes:type is float
  1290. *@li nmsed_scores:type is float
  1291. *@li nmsed_classes:type is float
  1292. *@li valid_detections:type is INT32 \n
  1293. *@par Third-party framework compatibility
  1294. * Compatible with tensorflow CombinedNonMaxSuppression operator.
  1295. */
  1296. REG_OP(CombinedNonMaxSuppression)
  1297. .INPUT(boxes, TensorType({DT_FLOAT}))
  1298. .INPUT(scores, TensorType({DT_FLOAT}))
  1299. .INPUT(max_output_size_per_class, TensorType({DT_INT32}))
  1300. .INPUT(max_total_size, TensorType({DT_INT32}))
  1301. .INPUT(iou_threshold, TensorType({DT_FLOAT}))
  1302. .INPUT(score_threshold, TensorType({DT_FLOAT}))
  1303. .OUTPUT(nmsed_boxes, TensorType({DT_FLOAT}))
  1304. .OUTPUT(nmsed_scores, TensorType({DT_FLOAT}))
  1305. .OUTPUT(nmsed_classes, TensorType({DT_FLOAT}))
  1306. .OUTPUT(valid_detections, TensorType({DT_INT32}))
  1307. .ATTR(pad_per_class, Bool, false)
  1308. .ATTR(clip_boxes, Bool, true)
  1309. .OP_END_FACTORY_REG(CombinedNonMaxSuppression)
  1310. /**
  1311. *@brief Resizes "images" with "offset" using bilinear interpolation. \n
  1312. *@par Inputs:
  1313. *@li img: input image, A 4-D tensor of shape `[n, h, w, c]`.
  1314. *@li warp_offset: the resize offset A 4-D float tensor of shape `[n, h, w, 2]`, 2 means (x, y) for offset point.
  1315. *@par Outputs:
  1316. *warp_img: A Tensor after resize. \n
  1317. */
  1318. REG_OP(IMGWarp)
  1319. .INPUT(img, TensorType({DT_UINT8, DT_FLOAT16, DT_FLOAT32}))
  1320. .INPUT(warp_offset, TensorType({DT_FLOAT32}))
  1321. .OUTPUT(warp_img, TensorType({DT_UINT8, DT_FLOAT16, DT_FLOAT32}))
  1322. .OP_END_FACTORY_REG(IMGWarp)
  1323. /**
  1324. *@brief Resizes "images" with "offset" using bilinear interpolation. \n
  1325. *@par Inputs:
  1326. *@li img: input image, A 4-D tensor of shape `[n, h, w, c]`.
  1327. *@li map_offset: the resize offset A 4-D float tensor of shape `[n, h, w, 2]`, 2 means (x, y) for resize point.
  1328. *@par Outputs:
  1329. *map_img: A Tensor after resize. \n
  1330. *@par Restrictions:
  1331. *Warning:THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1332. */
  1333. REG_OP(Remap)
  1334. .INPUT(img, TensorType({DT_UINT8, DT_FLOAT16, DT_FLOAT32}))
  1335. .INPUT(map_offset, TensorType({DT_FLOAT32}))
  1336. .OUTPUT(map_img, TensorType({DT_UINT8, DT_FLOAT16, DT_FLOAT32}))
  1337. .OP_END_FACTORY_REG(Remap)
  1338. /**
  1339. *@brief Resizes "images" with "offset" using bilinear interpolation. \n
  1340. *@par Inputs:
  1341. *@li img: input image, A 5-D tensor of shape `[n, 4, c, h, w]`,
  1342. and 4 mean input[(h_top, w_left), (h_top, w_right), (h_bottom, w_left), (h_bottom, w_right)].
  1343. *@li warp_index: the resize offset A 4-D float tensor of shape `[n, 2, h, w]`, 2 means (x, y) for resize point.
  1344. *@par Outputs:
  1345. *warp_img: A Tensor after ResizeBilinear, A 4-D tensor of shape `[n, c, h, w]`. \n
  1346. */
  1347. REG_OP(IMGWarpResize)
  1348. .INPUT(img, TensorType({DT_FLOAT32}))
  1349. .INPUT(warp_index, TensorType({DT_FLOAT32}))
  1350. .OUTPUT(warp_img, TensorType({DT_FLOAT32}))
  1351. .OP_END_FACTORY_REG(IMGWarpResize)
  1352. /**
  1353. *@brief Function spatial transformer . \n
  1354. *@par Inputs:
  1355. *@li x: A Tensor dtype of float16, float32.
  1356. *@li theta: A Tensor dtype of float16, float32, auxiliary coefficients . \n
  1357. *@par Attributes:
  1358. *@li output_size: A tuple output size.
  1359. *@li default_theta: A tuple default theta
  1360. *@li use_default_theta: List use default theta
  1361. *@li align_corners: Align corners
  1362. *@par Outputs:
  1363. *y: A Tensor dtype of float16, float32, should be same shape and type as x.
  1364. */
  1365. REG_OP(SpatialTransformerD)
  1366. .INPUT(x, TensorType({DT_FLOAT,DT_FLOAT16}))
  1367. .OPTIONAL_INPUT(theta, TensorType({DT_FLOAT,DT_FLOAT16}))
  1368. .OUTPUT(y, TensorType({DT_FLOAT,DT_FLOAT16}))
  1369. .ATTR(output_size, ListInt, {-1, -1})
  1370. .ATTR(default_theta, ListFloat, {})
  1371. .ATTR(align_corners, Bool, false)
  1372. .ATTR(use_default_theta, ListBool, {})
  1373. .OP_END_FACTORY_REG(SpatialTransformerD)
  1374. /**
  1375. *@brief Function spatial transformer . \n
  1376. *@par Inputs:
  1377. *@li x: A Tensor dtype of float16, float32, double, uint8, int8, uint16, int16, int32, uint32, uint64, int64.
  1378. *@li theta: A Tensor dtype of float16, float32, double, uint8, int8, uint16, int16, int32, uint32, uint64, int64,
  1379. auxiliary coefficients . \n
  1380. *@par Attributes:
  1381. *@li output_size: A tuple output size.
  1382. *@li default_theta: A tuple default theta
  1383. *@li use_default_theta: List use default theta
  1384. *@par Outputs:
  1385. *y: A Tensor dtype of float16, float32, double, uint8, int8, uint16, int16, int32, uint32, uint64, int64,
  1386. should be same shape and type as x.
  1387. *@par Restrictions:
  1388. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1389. */
  1390. REG_OP(SpatialTransformer)
  1391. .INPUT(x, TensorType({DT_FLOAT,DT_FLOAT16,DT_DOUBLE,DT_UINT8,DT_INT8,DT_UINT16,
  1392. DT_INT16,DT_INT32,DT_UINT32,DT_UINT64,DT_INT64}))
  1393. .OPTIONAL_INPUT(theta, TensorType({DT_FLOAT,DT_FLOAT16,DT_DOUBLE,DT_UINT8,DT_INT8,
  1394. DT_UINT16,DT_INT16,DT_INT32,DT_UINT32,DT_UINT64,DT_INT64}))
  1395. .OUTPUT(y, TensorType({DT_FLOAT,DT_FLOAT16,DT_DOUBLE,DT_UINT8,DT_INT8,DT_UINT16,
  1396. DT_INT16,DT_INT32,DT_UINT32,DT_UINT64,DT_INT64}))
  1397. .ATTR(output_size, ListInt, {-1, -1})
  1398. .ATTR(default_theta, ListFloat, {})
  1399. .ATTR(align_corners, Bool, false)
  1400. .ATTR(use_default_theta, ListInt, {})
  1401. .OP_END_FACTORY_REG(SpatialTransformer)
  1402. /**
  1403. * @brief Resize the input tensor. \n
  1404. currently, only support resize image tensor using nearest neighbor and linear interpolation.
  1405. * @par Inputs:
  1406. * Input x must be a 4-D tensor. Inputs include: \n
  1407. * @li x: A Tensor. Must be one of the following types: uint8, int8, int16, \n
  1408. int32, int64, float16, float, double. 4-D with shape [batch, height, width, channels] \n
  1409. or shape [batch, channels, height, width].
  1410. * @li roi: A 1-D float Tensor. only takes effect when attr coordinate_transformation_mode \n
  1411. is "tf_crop_and_resize"
  1412. * @li scales: A 1-D float Tensor, the scale array along each dimension, Only one of \n
  1413. 'scales' and 'sizes' can be specified.
  1414. * @li sizes: A 1-D int64 Tensor, The size of the output tensor. nly one of \n
  1415. 'scales' and 'sizes' can be specified. If 'size' is specified, then set scales \n
  1416. to empty data (zero shape) in this operator's input list.
  1417. * @par Attributes:
  1418. * @li coordinate_transformation_mode: String. Defaults to half_pixel. how to transform \n
  1419. the coordinate in the resized tensor to the coordinate in the original tensor. \n
  1420. other optional: pytorch_half_pixel, align_corners, asymmetric, tf_half_pixel_for_nn, \n
  1421. tf_crop_and_resize.
  1422. * @li cubic_coeff_a: Float. Defaults to -0.75, only used in cubic interpolation. \n
  1423. other optional: -0.5
  1424. * @li exclude_outside: Int. Defaults to 0, If set to 1, the weight of sampling \n
  1425. locations outside the tensor will be set to 0 and the weight will be renormalized \n
  1426. so that their sum is 1.0.
  1427. * @li extrapolation_value: Float. Defaults to 0.0f. When coordinate_transformation_mode \n
  1428. is "tf_crop_and_resize" and x_original is outside the range [0, length_original - 1], \n
  1429. this value is used as the corresponding output value.
  1430. * @li mode: String. Defaults to nearest. Three interpolation modes: nearest (default), \n
  1431. linear and cubic.
  1432. * @li nearest_mode: String. Defaults to round_prefer_floor. Four modes: round_prefer_floor, \n
  1433. round_prefer_ceil, floor, ceil. Only used by nearest interpolation.
  1434. * @par Outputs:
  1435. * y: A Tensor. Has the same type as x.
  1436. * @attention Constraints: \n
  1437. * Input x must be a 4-D tensor.
  1438. * @par Third-party framework compatibility
  1439. * Compatible with tensorflow ResizeNearestNeighborV2 operator.
  1440. */
  1441. REG_OP(Resize)
  1442. .INPUT(x, TensorType({DT_INT8,DT_UINT8,DT_INT16,DT_UINT16,DT_INT32,
  1443. DT_INT64,DT_FLOAT16,DT_FLOAT,DT_DOUBLE}))
  1444. .OPTIONAL_INPUT(roi, TensorType({DT_FLOAT16,DT_FLOAT,DT_DOUBLE}))
  1445. .OPTIONAL_INPUT(scales, TensorType({DT_FLOAT}))
  1446. .OPTIONAL_INPUT(sizes, TensorType({DT_INT64,DT_INT32}))
  1447. .OUTPUT(y, TensorType({DT_INT8,DT_UINT8,DT_INT16,DT_UINT16,DT_INT32,
  1448. DT_INT64,DT_FLOAT16,DT_FLOAT,DT_DOUBLE}))
  1449. .ATTR(coordinate_transformation_mode, String, "half_pixel")
  1450. .ATTR(cubic_coeff_a, Float, -0.75)
  1451. .ATTR(exclude_outside, Int, 0)
  1452. .ATTR(extrapolation_value, Float, 0.0)
  1453. .ATTR(mode, String, "nearest")
  1454. .ATTR(nearest_mode, String, "round_prefer_floor")
  1455. .OP_END_FACTORY_REG(Resize)
  1456. /**
  1457. *@brief Function parse image from string to int. \n
  1458. *@par Inputs:
  1459. * contents: A Tensor of type string. 0-D. The JPEG-encoded image. \n
  1460. *@par Attributes:
  1461. *@li channels: An optional int. Defaults to 0. Number of color channels for the decoded image.
  1462. *@li ratio: An optional int. Defaults to 1. Downscaling ratio.
  1463. *@li fancy_upscaling: An optional bool. Defaults to True. If true use a slower but nicer upscaling of the chroma planes
  1464. *@li try_recover_truncated: An optional bool. Defaults to False. If true try to recover an image from truncated input.
  1465. *@li acceptable_fraction: An optional float. Defaults to 1. The minimum required fraction of lines before a truncated input is accepted.
  1466. *@li dct_method: An optional string. Defaults to "". string specifying a hint about the algorithm used for decompression. \n
  1467. *@par Outputs:
  1468. *image: A Tensor dtype of uint8.
  1469. */
  1470. REG_OP(DecodeJpeg)
  1471. .INPUT(contents, TensorType({DT_STRING}))
  1472. .OUTPUT(image, TensorType({DT_UINT8}))
  1473. .ATTR(channels, Int, 0)
  1474. .ATTR(ratio, Int, 1)
  1475. .ATTR(fancy_upscaling, Bool, true)
  1476. .ATTR(try_recover_truncated, Bool, false)
  1477. .ATTR(acceptable_fraction, Float, 1.0)
  1478. .ATTR(dct_method, String, "")
  1479. .OP_END_FACTORY_REG(DecodeJpeg)
  1480. /**
  1481. *@brief Image warping using per-pixel flow vectors. \n
  1482. *@par Inputs:
  1483. *@li image: 4-D Tensor with shape `[batch, height, width, channels]`.
  1484. *@li flow: 4-D Tensor with shape `[batch, height, width, 2]`. \n
  1485. *@par Outputs:
  1486. *y: Returns 4-D with the same shape and dtype as `image`. \n
  1487. */
  1488. REG_OP(DenseImageWarp)
  1489. .INPUT(image, TensorType({DT_FLOAT, DT_FLOAT16}))
  1490. .INPUT(flow, TensorType({DT_FLOAT, DT_FLOAT16}))
  1491. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16}))
  1492. .OP_END_FACTORY_REG(DenseImageWarp)
  1493. /**
  1494. *@brief Calculate the resize_d function. \n
  1495. *@par Inputs:
  1496. *One inputs, including:
  1497. * x: A tensor. Must be one of the following types:
  1498. * float16, float32. \n
  1499. *@par Attributes:
  1500. *@li sizes: An optional listInt. \n
  1501. *@li scales: An optional listFloat.
  1502. Defaults to none. \n
  1503. *@li roi: An optional listInt.
  1504. Defaults to none. \n
  1505. *@li coordinate_transformation_mode: An optional String.
  1506. Defaults to "half_pixel". \n
  1507. *@li cubic_coeff_a: An optional float.
  1508. Defaults to -0.75. \n
  1509. *@li exclude_outside: An optional int.
  1510. Defaults to 0. \n
  1511. *@li extrapolation_value: An optional float.
  1512. Defaults to 0.0. \n
  1513. *@li mode: An optional String.
  1514. Defaults to "nearest". \n
  1515. *@li nearest_mode: An optional String.
  1516. Defaults to "round_prefer_floor". \n
  1517. *@par Outputs:
  1518. *y: A Tensor with the same type of x's,
  1519. shape depends on x and sizes. \n
  1520. */
  1521. REG_OP(ResizeD)
  1522. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1523. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1524. .REQUIRED_ATTR(sizes, ListInt)
  1525. .ATTR(scales, ListFloat, {})
  1526. .ATTR(roi, ListInt, {})
  1527. .ATTR(coordinate_transformation_mode, String, "half_pixel")
  1528. .ATTR(cubic_coeff_a, Float, -0.75)
  1529. .ATTR(exclude_outside, Int, 0)
  1530. .ATTR(extrapolation_value, Float, 0.0)
  1531. .ATTR(mode, String, "nearest")
  1532. .ATTR(nearest_mode, String, "round_prefer_floor")
  1533. .OP_END_FACTORY_REG(ResizeD)
  1534. /**
  1535. *@brief Calculate the resize_grad_d function. \n
  1536. *@par Inputs:
  1537. *One inputs, including:
  1538. * grads: A tensor. Must be one of the following types:
  1539. * float16, float32. \n
  1540. *@par Attributes:
  1541. *@li original_size: An optional listInt. \n
  1542. *@li roi: An optional listInt.
  1543. Defaults to none. \n
  1544. *@li scales: An optional listFloat.
  1545. Defaults to none. \n
  1546. *@li coordinate_transformation_mode: An optional String.
  1547. Defaults to "half_pixel". \n
  1548. *@li cubic_coeff_a: An optional float.
  1549. Defaults to -0.75. \n
  1550. *@li exclude_outside: An optional int.
  1551. Defaults to 0. \n
  1552. *@li extrapolation_value: An optional float.
  1553. Defaults to 0.0. \n
  1554. *@li mode: An optional String.
  1555. Defaults to "nearest". \n
  1556. *@li nearest_mode: An optional String.
  1557. Defaults to "round_prefer_floor". \n
  1558. *@par Outputs:
  1559. *y: A Tensor with the same type of x's,
  1560. shape depends on x and sizes. \n
  1561. */
  1562. REG_OP(ResizeGradD)
  1563. .INPUT(grads, TensorType({DT_FLOAT16, DT_FLOAT}))
  1564. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1565. .REQUIRED_ATTR(original_size, ListInt)
  1566. .ATTR(roi, ListInt, {})
  1567. .ATTR(scales, ListFloat, {})
  1568. .ATTR(coordinate_transformation_mode, String, "half_pixel")
  1569. .ATTR(cubic_coeff_a, Float, -0.75)
  1570. .ATTR(exclude_outside, Int, 0)
  1571. .ATTR(extrapolation_value, Float, 0.0)
  1572. .ATTR(mode, String, "nearest")
  1573. .ATTR(nearest_mode, String, "round_prefer_floor")
  1574. .OP_END_FACTORY_REG(ResizeGradD)
  1575. /**
  1576. *@brief Computes the gradients of DenseImageWarp with respect to image and flow. \n
  1577. *@par Inputs:
  1578. *@li grad: gradients with respect to DenseImageWarp output.
  1579. *@li image: 4-D Tensor with shape `[batch, height, width, channels]`.
  1580. *@li flow: 4-D Tensor with shape `[batch, height, width, 2]`. \n
  1581. *@par Outputs:
  1582. *@li grad_image: Returns 4-D with the same shape and dtype as `image`.
  1583. *@li grad_flow: Returns 4-D with the same shape and dtype as `flow`. \n
  1584. */
  1585. REG_OP(DenseImageWarpGrad)
  1586. .INPUT(grad, TensorType({DT_FLOAT, DT_FLOAT16}))
  1587. .INPUT(image, TensorType({DT_FLOAT, DT_FLOAT16}))
  1588. .INPUT(flow, TensorType({DT_FLOAT, DT_FLOAT16}))
  1589. .OUTPUT(grad_image, TensorType({DT_FLOAT, DT_FLOAT16}))
  1590. .OUTPUT(grad_flow, TensorType({DT_FLOAT, DT_FLOAT16}))
  1591. .OP_END_FACTORY_REG(DenseImageWarpGrad)
  1592. /**
  1593. *@brief This operation samples input X by using interpolation based on flow field grid,
  1594. which is usually gennerated by affine_grid. The grid of shape [N, H, W, 2] is the concatenation of
  1595. (x, y) coordinates with shape [N, H, W] each, where x is indexing the 4th dimension (in width dimension) of
  1596. input data x and y is indexng the 3rd dimention (in height dimension), finally results is
  1597. the interpolation value of 4 nearest corner points. The output tensor shape will be [N, C, H, W].
  1598. *@par Inputs:
  1599. *@li x: 4-D Tensor with shape `[batch, channels, height, width]`.
  1600. *@li grid: flow field grid, 4-D Tensor with shape `[batch, height, width, 2]`.
  1601. *@par Attributes:
  1602. *@li interpolation_mode: An optional string specifying the interpolation method. Only 'bilinear' is
  1603. supported for now .
  1604. *@li padding_mode: An optional string specifying the pad method. Only 'zeros' is supported for now .
  1605. *@li align_corners: An optional bool. If "true", the centers of the corner
  1606. pixels of the input and output tensors are aligned. Defaults to "false" .
  1607. *@par Outputs:
  1608. *y: Returns 4-D Tensor with the same dtype as `X`.
  1609. *@par Third-party framework compatibility
  1610. *Compatible with pytorch GridSampler2D operator.
  1611. *@par Restrictions:
  1612. *Warning:THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1613. */
  1614. REG_OP(GridSampler2D)
  1615. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1616. .INPUT(grid, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1617. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1618. .ATTR(interpolation_mode, String, "bilinear")
  1619. .ATTR(padding_mode, String, "zeros")
  1620. .ATTR(align_corners, Bool, false)
  1621. .OP_END_FACTORY_REG(GridSampler2D)
  1622. /**
  1623. *@brief Computes the gradients of GridSampler2D.
  1624. *@par Inputs:
  1625. *@li grad: A 4-D Tensor with shape `[batch, channels, height, width]`.
  1626. *@li x: A 4-D Tensor with shape `[batch, channels, height, width]`.
  1627. *@li grid: flow field grid, 4-D Tensor with shape `[batch, height, width, 2]`.
  1628. *@par Attributes:
  1629. *@li interpolation_mode: An optional string specifying the interpolation method.
  1630. Defaults to "bilinear".
  1631. *@li padding_mode: An optional string specifying the pad method.
  1632. Defaults to "zeros".
  1633. *@li align_corners: An optional bool. If "true", the centers of the corner
  1634. pixels of the input and output tensors are aligned. Defaults to false.
  1635. *@par Outputs:
  1636. *dx: Returns 4-D Tensor with the same dtype and shape as `x`.
  1637. *dgrid: Returns 4-D Tensor with the same dtype and shape as `grid`.
  1638. *@par Third-party framework compatibility
  1639. *Compatible with pytorch GridSampler2DGrad operator.
  1640. *@par Restrictions:
  1641. *Warning:THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1642. */
  1643. REG_OP(GridSampler2DGrad)
  1644. .INPUT(grad, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1645. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1646. .INPUT(grid, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1647. .OUTPUT(dx, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1648. .OUTPUT(dgrid, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1649. .ATTR(interpolation_mode, String, "bilinear")
  1650. .ATTR(padding_mode, String, "zeros")
  1651. .ATTR(align_corners, Bool, false)
  1652. .OP_END_FACTORY_REG(GridSampler2DGrad)
  1653. /**
  1654. *@brief This operation unnormalize input Grid, which is usually gennerated by affine_grid.
  1655. *@par Inputs:
  1656. *@li grid: flow field grid, 4-D Tensor with shape `[batch, height, width, 2]`.
  1657. *@li assist: Assist matrix, a 4-D tensor of type float16.
  1658. *@par Attributes:
  1659. *align_corners: An optional bool. If "true", the centers of the corner
  1660. pixels of the input and output tensors are aligned. Defaults to "false" .
  1661. *@par Outputs:
  1662. *@li diff: Returns 4-D Tensor with the same shape and dtype as `grid`.
  1663. *@li position: Returns 4-D Tensor with the same shape as `grid`.
  1664. */
  1665. REG_OP(GridUnnormal)
  1666. .INPUT(grid, TensorType({DT_FLOAT16, DT_FLOAT}))
  1667. .INPUT(assist, TensorType({DT_FLOAT16, DT_FLOAT}))
  1668. .OUTPUT(diff, TensorType({DT_FLOAT16, DT_FLOAT}))
  1669. .OUTPUT(position, TensorType({DT_INT32}))
  1670. .ATTR(align_corners, Bool, false)
  1671. .OP_END_FACTORY_REG(GridUnnormal)
  1672. /**
  1673. *@brief This operation unfold input X based on unnormalized grid, which is gennerated by GridUnnormal.
  1674. *@par Inputs:
  1675. *@li x: 4-D Tensor with shape `[batch, channels, height, width]`.
  1676. *@li position: 4-D Tensor with shape `[batch, output_height, output_width, 2]`.
  1677. *@par Attributes:
  1678. *padding_mode: An optional string specifying the pad method. Only 'zeros' is supported for now .
  1679. *@par Outputs:
  1680. *y: Returns 4-D Tensor with the same dtype as `x`.
  1681. *@par Restrictions:
  1682. *Warning:THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1683. */
  1684. REG_OP(ImageUnfold)
  1685. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  1686. .INPUT(position, TensorType({DT_INT32}))
  1687. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
  1688. .ATTR(padding_mode, String, "zeros")
  1689. .OP_END_FACTORY_REG(ImageUnfold)
  1690. /**
  1691. *@brief This operation select images to warp_images according to offsets.
  1692. *@par Inputs:
  1693. *@li images: 4-D Tensor with shape `[batch, height, width, 3]`.
  1694. *@li offsets: 4-D Tensor with shape `[batch, 4, new_height, new_width]`.
  1695. *@par Outputs:
  1696. *warp_images: Returns 5-D Tensor with shape
  1697. `[batch, 4, new_height, new_width, 3]` and the same dtype as `images`.
  1698. */
  1699. REG_OP(IMGWarpOffsets)
  1700. .INPUT(images, TensorType({DT_UINT8, DT_FLOAT16, DT_FLOAT}))
  1701. .INPUT(offsets, TensorType({DT_FLOAT, DT_INT32}))
  1702. .OUTPUT(warp_images, TensorType({DT_UINT8, DT_FLOAT16, DT_FLOAT}))
  1703. .OP_END_FACTORY_REG(IMGWarpOffsets)
  1704. /**
  1705. *@brief This operation samples 3d input x by using interpolation based on flow field grid,
  1706. which is usually gennerated by affine_grid.
  1707. *@par Inputs:
  1708. *@li x: 5-D Tensor with shape `[batch, channels, depth, height, width]`.
  1709. *@li grid: flow field grid, 5-D Tensor with shape `[batch, depth, height, width, 2]`.
  1710. *@par Attributes:
  1711. *@li interpolation_mode: An optional string specifying the interpolation method.
  1712. *@li padding_mode: An optional string specifying the pad method.
  1713. *@li align_corners: An optional bool. If "true", the centers of the corner
  1714. pixels of the input and output tensors are aligned. Defaults to "false" .
  1715. *@par Outputs:
  1716. *y: Returns 5-D Tensor with the same dtype as `x`.
  1717. *@par Third-party framework compatibility
  1718. *Compatible with pytorch GridSampler3D operator.
  1719. *@par Restrictions:
  1720. *Warning:THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1721. */
  1722. REG_OP(GridSampler3D)
  1723. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1724. .INPUT(grid, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1725. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1726. .ATTR(interpolation_mode, String, "bilinear")
  1727. .ATTR(padding_mode, String, "zeros")
  1728. .ATTR(align_corners, Bool, false)
  1729. .OP_END_FACTORY_REG(GridSampler3D)
  1730. /**
  1731. *@brief Computes the gradients of GridSampler3D.
  1732. *@par Inputs:
  1733. *@li grad: 5-D Tensor with shape `[batch, channels, depth, height, width]`.
  1734. *@li x: 5-D Tensor with shape `[batch, channels, depth, height, width]`.
  1735. *@li grid: flow field grid, 5-D Tensor with shape `[batch, depth, height, width, 2]`.
  1736. *@par Attributes:
  1737. *@li interpolation_mode: An optional string specifying the interpolation method.
  1738. *@li padding_mode: An optional string specifying the pad method.
  1739. *@li align_corners: An optional bool. If "true", the centers of the corner
  1740. pixels of the input and output tensors are aligned. Defaults to "false" .
  1741. *@par Outputs:
  1742. *dx: Returns 5-D Tensor with the same dtype and shape as `x`.
  1743. *dgrid: Returns 5-D Tensor with the same dtype and shape as `grid`.
  1744. *@par Third-party framework compatibility
  1745. *Compatible with pytorch GridSampler3DGrad operator.
  1746. *@par Restrictions:
  1747. *Warning:THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1748. */
  1749. REG_OP(GridSampler3DGrad)
  1750. .INPUT(grad, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1751. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1752. .INPUT(grid, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1753. .OUTPUT(dx, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1754. .OUTPUT(dgrid, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1755. .ATTR(interpolation_mode, String, "bilinear")
  1756. .ATTR(padding_mode, String, "zeros")
  1757. .ATTR(align_corners, Bool, false)
  1758. .OP_END_FACTORY_REG(GridSampler3DGrad)
  1759. /**
  1760. *@brief Upsample the 3-D data with the nearest neighbor ​interpolation algorithm. \n
  1761. *@par Inputs:
  1762. *One inputs, including:
  1763. *x: A 5-D input tensor [N, C, D, H, W]. Must be one of the following types:
  1764. * float16, float32, float64. \n
  1765. *@par Attributes:
  1766. *@li output_size: An optional listInt. Defaults to none.
  1767. contain 3 elements: output_depth, output_height, output_width. The number of elements of 'output_size'
  1768. should be the same as the rank of input 'x'. Only one of 'scales' and 'output_size' can be specified. \n
  1769. *@li scales: An optional listFloat. Defaults to none.
  1770. The scale array along each dimension, contain 3 elements: scale_depth, scale_height, scale_width.
  1771. The number of elements of 'scales' should be the same as the rank of input 'x'. One of 'scales' and
  1772. 'output_size' MUST be specified and it is an error if both are specified. \n
  1773. *@par Outputs:
  1774. *y: A 5-D tensor. Has the same type as input x, shape depends on x and output_size/scales. \n
  1775. *@par Restrictions:
  1776. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. \n
  1777. */
  1778. REG_OP(UpsampleNearest3d)
  1779. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1780. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1781. .ATTR(output_size, ListInt, {})
  1782. .ATTR(scales, ListFloat, {})
  1783. .OP_END_FACTORY_REG(UpsampleNearest3d)
  1784. /**
  1785. *@brief Upsample the 3-D data with the trilinear ​interpolation algorithm. \n
  1786. *@par Inputs:
  1787. *One inputs, including:
  1788. *x: A 5-D input tensor [N, C, D, H, W]. Must be one of the following types:
  1789. * float16, float32, float64. \n
  1790. *@par Attributes:
  1791. *@li output_size: An optional listInt. Defaults to none.
  1792. contain 3 elements: output_depth, output_height, output_width. The number of elements of 'output_size' should
  1793. be the same as the rank of input 'x'. Only one of 'scales' and 'output_size' can be specified. \n
  1794. *@li scales: An optional listFloat. Defaults to none.
  1795. The scale array along each dimension, contain 3 elements: scale_depth, scale_height, scale_width.
  1796. The number of elements of 'scales' should be the same as the rank of input 'x'.
  1797. One of 'scales' and 'output_size' MUST be specified and it is an error if both are specified. \n
  1798. *@li align_corners: An optional bool. Defaults to false.
  1799. If true, the input and output tensors are aligned by the center points of their corner pixels, preserving the
  1800. values at the corner pixels. If false, the input and output tensors are aligned by the corner points of their
  1801. corner pixels, and the interpolation use edge value padding for out of boundary values. \n
  1802. *@par Outputs:
  1803. *y: A 5-D tensor. Has the same type as input x, shape depends on x and output_size/scales. \n
  1804. *@par Restrictions:
  1805. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. \n
  1806. */
  1807. REG_OP(UpsampleTrilinear3d)
  1808. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1809. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1810. .ATTR(output_size, ListInt, {})
  1811. .ATTR(scales, ListFloat, {})
  1812. .ATTR(align_corners, Bool, false)
  1813. .OP_END_FACTORY_REG(UpsampleTrilinear3d)
  1814. /**
  1815. *@brief Upsample the 3-D gradient data with the nearest neighbor ​interpolation algorithm. \n
  1816. *@par Inputs:
  1817. *One inputs, including:
  1818. *grad_output: A 5-D input tensor [N, C, D, H, W]. Must be one of the following types:
  1819. * float16, float32, float64. \n
  1820. *@par Attributes:
  1821. *@li input_size: An required listInt.
  1822. contain 5 elements: [min_batch, channels, depth, height, width]. Must:
  1823. input_size[0] == grad_output_tensor_size[0]
  1824. input_size[1] == grad_output_tensor_size[1]. \n
  1825. *@li output_size: An optional listInt. Defaults to none.
  1826. contain 3 elements: depth, height, width. The number of elements of 'output_size' should
  1827. be the same as the rank of input 'grad_output'. Only one of 'scales' and 'output_size' can be specified. Must:
  1828. grad_output_tensor_size[2] == floor(input_size[2] * scales[0]) == output_size[0]
  1829. grad_output_tensor_size[3] == floor(input_size[3] * scales[1]) == output_size[1]
  1830. grad_output_tensor_size[4] == floor(input_size[4] * scales[2]) == output_size[2]. \n
  1831. *@li scales: An optional listFloat. Defaults to none.
  1832. The scale array along each dimension, contain 3 elements: scale_depth, scale_height, scale_width.
  1833. The number of elements of 'scales' should be the same as the rank of input 'grad_output'.
  1834. One of 'scales' and 'output_size' MUST be specified and it is an error if both are specified. \n
  1835. *@par Outputs:
  1836. *y: A 5-D tensor. Has the same type as input grad_output, shape depends on Attributes:input_size. \n
  1837. *@par Restrictions:
  1838. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1839. */
  1840. REG_OP(UpsampleNearest3dGrad)
  1841. .INPUT(grad_output, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1842. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1843. .REQUIRED_ATTR(input_size, ListInt)
  1844. .ATTR(output_size, ListInt, {})
  1845. .ATTR(scales, ListFloat, {})
  1846. .OP_END_FACTORY_REG(UpsampleNearest3dGrad)
  1847. /**
  1848. *@brief Upsample the 3-D gradient data trilinear ​interpolation algorithm. \n
  1849. *@par Inputs:
  1850. *One inputs, including:
  1851. *grad_output: A 5-D input tensor [N, C, D, H, W]. Must be one of the following types:
  1852. * float16, float32, float64. \n
  1853. *@par Attributes:
  1854. *@li input_size: An required listInt.
  1855. contain 5 elements: [min_batch, channels, depth, height, width]. Must:
  1856. input_size[0] == grad_output_tensor_size[0]
  1857. input_size[1] == grad_output_tensor_size[1]. \n
  1858. *@li output_size: An optional listInt. Defaults to none.
  1859. contain 3 elements: depth, height, width. The number of elements of 'output_size' should
  1860. be the same as the rank of input 'grad_output'. Only one of 'scales' and 'output_size' can be specified. Must:
  1861. grad_output_tensor_size[2] == floor(input_size[2] * scales[0]) == output_size[0]
  1862. grad_output_tensor_size[3] == floor(input_size[3] * scales[1]) == output_size[1]
  1863. grad_output_tensor_size[4] == floor(input_size[4] * scales[2]) == output_size[2]. \n
  1864. *@li scales: An optional listFloat. Defaults to none.
  1865. The scale array along each dimension, contain 3 elements: scale_depth, scale_height, scale_width.
  1866. The number of elements of 'scales' should be the same as the rank of input 'grad_output'.
  1867. One of 'scales' and 'output_size' MUST be specified and it is an error if both are specified. \n
  1868. *@par Outputs:
  1869. *y: A Tensor with shape depends on intput_size and output_size/scales. Must be one of the following
  1870. types: float16, float32, float64. \n
  1871. *@par Restrictions:
  1872. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1873. */
  1874. REG_OP(UpsampleTrilinear3dGrad)
  1875. .INPUT(grad_output, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1876. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1877. .REQUIRED_ATTR(input_size, ListInt)
  1878. .ATTR(output_size, ListInt, {})
  1879. .ATTR(scales, ListFloat, {})
  1880. .ATTR(align_corners, Bool, false)
  1881. .OP_END_FACTORY_REG(UpsampleTrilinear3dGrad)
  1882. /**
  1883. *@brief Upsample the 1-D data with the nearest neighbor ​interpolation algorithm. \n
  1884. *@par Inputs:
  1885. *x: A 1-D input tensor [N, C, W]. Must be one of the following types:
  1886. * float16, float32, float64. \n
  1887. *@par Attributes:
  1888. *@li output_size: An required listInt contains output_width.
  1889. *@li scales: An optional listFloat contains scale_width. Defaults to be zero. \n
  1890. *@par Outputs:
  1891. *y: A 3-D tensor. Has the same type as input x, shape depends on x and output_size/scales. \n
  1892. *@par Restrictions:
  1893. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. \n
  1894. */
  1895. REG_OP(UpsampleNearest1d)
  1896. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1897. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1898. .REQUIRED_ATTR(output_size, ListInt)
  1899. .ATTR(scales, ListFloat, {})
  1900. .OP_END_FACTORY_REG(UpsampleNearest1d)
  1901. /**
  1902. *@brief Upsample the 1-D gradient data with the nearest neighbor ​interpolation algorithm. \n
  1903. *@par Inputs:
  1904. *grad_output: A 3-D input tensor [N, C, W]. Must be one of the following types:
  1905. * float16, float32, float64. \n
  1906. *@par Attributes:
  1907. *@li output_size: An required listInt contains output_width.
  1908. *@li scales: An optional listFloat contains scale_width. Defaults to be zero.
  1909. *@li input_size: An required listInt contains output_width. \n
  1910. *@par Outputs:
  1911. *y: A 3-D tensor. Has the same type as input grad_output, shape depends on Attributes:input_size. \n
  1912. *@par Restrictions:
  1913. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. \n
  1914. */
  1915. REG_OP(UpsampleNearest1dGrad)
  1916. .INPUT(grad_output, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1917. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1918. .REQUIRED_ATTR(input_size, ListInt)
  1919. .REQUIRED_ATTR(output_size, ListInt)
  1920. .ATTR(scales, ListFloat, {})
  1921. .OP_END_FACTORY_REG(UpsampleNearest1dGrad)
  1922. /**
  1923. * @brief Function parse image from string to int. \n
  1924. * @par Inputs:
  1925. * contents: A Tensor of type string. 0-D. The JPEG, GIF, PNG, BMP-encoded image. \n
  1926. * @par Attributes:
  1927. * @li channels: An optional int. Defaults to 0. Number of color channels for the decoded image.
  1928. * @li dtype: type of image
  1929. * @li expand_animations: Controls the shape of the returned op's output. If 'true', the returned op will
  1930. produce a 4-D tensor for GIF files. If 'false', the returned op will produce a 3-D tensor for GIF files.
  1931. * @par Outputs:
  1932. * image: A Tensor dtype of uint8, uint16 or float.
  1933. * @par Restrictions:
  1934. * Warning:THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  1935. */
  1936. REG_OP(DecodeImage)
  1937. .INPUT(contents, TensorType({DT_STRING}))
  1938. .OUTPUT(image, TensorType({DT_UINT8, DT_UINT16, DT_FLOAT}))
  1939. .ATTR(channels, Int, 0)
  1940. .ATTR(dtype, Type, DT_UINT8)
  1941. .ATTR(expand_animations, Bool, true)
  1942. .OP_END_FACTORY_REG(DecodeImage)
  1943. /**
  1944. * @brief JPEG encode input image with provided compression quality. \n
  1945. * @par Inputs:
  1946. * @li images: image is a 3-D uint8 tensor of shape [height, width, channels].
  1947. * @li quality: int32 jpeg compression quality value between 0 and 100, 0-D tensor.
  1948. * @par Outputs: JPEG-encoded image
  1949. * contents: an output string. \n
  1950. * @par Third-party framework compatibility.
  1951. * Compatible with tensorflow EncodeJpegVariableQuality operator.
  1952. */
  1953. REG_OP(EncodeJpegVariableQuality)
  1954. .INPUT(images, TensorType({DT_UINT8}))
  1955. .INPUT(quality, TensorType({DT_INT32}))
  1956. .OUTPUT(contents, TensorType({DT_STRING}))
  1957. .OP_END_FACTORY_REG(EncodeJpegVariableQuality)
  1958. /**
  1959. * @brief image to transforms. \n
  1960. * @par Inputs:
  1961. * @li images: [batch, height, width, channels], 4-D tensor.
  1962. * @li transforms: [batch, 8] or [1, 8] matrix, 2-D tensor.
  1963. * @li outout_shape: [new_height, new_width], 1-D tensor.
  1964. * @par Attributes:
  1965. * @li interpolation: Interpolation method, "NEAREST" or "BILINEAR", 0-D tensor.
  1966. * @li fill_mode: Defaults to "CONSTANT". Fill mode, "REFLECT", "WRAP", or "CONSTANT", 0-D tensor.
  1967. * @par Outputs
  1968. * transformed_images: has the same type as iamges, 4-D tensor with shape[batch, new_height, new_width, channels]. \n
  1969. * @par Third-party framework compatibility.
  1970. * Compatible with tensorflow ImageProjectiveTransform operator.
  1971. */
  1972. REG_OP(ImageProjectiveTransform)
  1973. .INPUT(images, TensorType({DT_UINT8, DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1974. .INPUT(transforms, TensorType({DT_FLOAT}))
  1975. .INPUT(output_shape, TensorType({DT_INT32}))
  1976. .REQUIRED_ATTR(interpolation, String)
  1977. .ATTR(fill_mode, String, "CONSTANT")
  1978. .OUTPUT(transformed_images, TensorType({DT_UINT8, DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1979. .OP_END_FACTORY_REG(ImageProjectiveTransform)
  1980. } // namespace ge
  1981. #endif // OPS_BUILT_IN_OP_PROTO_INC_IMAGE_OPS_H_

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