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

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348
  1. /**
  2. * Copyright 2019-2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /*!
  17. * \file image_ops.h
  18. * \brief
  19. */
  20. #ifndef GE_OP_MAGE_OPS_H_
  21. #define GE_OP_MAGE_OPS_H_
  22. #include "graph/operator_reg.h"
  23. namespace ge {
  24. /**
  25. *@brief Adjust the hue of one or more images . \n
  26. *@par Inputs:
  27. *Input images is a tensor of at least 3 dimensions. The last dimension is
  28. interpretted as channels, and must be three. Inputs include:
  29. *@li images:A Tensor of type float. Images to adjust. At least 3-D.
  30. *@li delta:A Tensor of type float. A float delta to add to the hue . \n
  31. *@par Outputs:
  32. *y:A Tensor of type float . \n
  33. *@attention Constraints:
  34. *Input images is a tensor of at least 3 dimensions. The last dimension is
  35. interpretted as channels, and must be three . \n
  36. *@par Third-party framework compatibility
  37. *Compatible with tensorflow AdjustHue operator.
  38. */
  39. REG_OP(AdjustHue)
  40. .INPUT(images, TensorType({DT_FLOAT16,DT_FLOAT}))
  41. .INPUT(delta, TensorType({DT_FLOAT}))
  42. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  43. .OP_END_FACTORY_REG(AdjustHue)
  44. /**
  45. *@brief Adjust the saturation of one or more images . \n
  46. *@par Inputs:
  47. *Input images is a tensor of at least 3 dimensions. The last dimension is
  48. interpretted as channels, and must be three. Inputs include:
  49. *@li images:A Tensor of type float. Images to adjust. At least 3-D.
  50. *@li scale:A Tensor of type float. A float scale to add to the saturation . \n
  51. *@par Outputs:
  52. *y:A Tensor of type float . \n
  53. *@attention Constraints:
  54. *Input images is a tensor of at least 3 dimensions. The last dimension is
  55. interpretted as channels, and must be three . \n
  56. *@par Third-party framework compatibility
  57. *Compatible with tensorflow AdjustSaturation operator.
  58. */
  59. REG_OP(AdjustSaturation)
  60. .INPUT(images, TensorType({DT_FLOAT16,DT_FLOAT}))
  61. .INPUT(scale, TensorType({DT_FLOAT}))
  62. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  63. .OP_END_FACTORY_REG(AdjustSaturation)
  64. /**
  65. *@brief Adjust the contrast of one or more images . \n
  66. *@par Inputs:
  67. *Input images is a tensor of at least 3 dimensions. The last 3 dimensions are
  68. interpreted as '[height, width, channels]'. Inputs include:
  69. *@li images:A Tensor of type float. Images to adjust. At least 3-D.
  70. *@li scale:A Tensor of type float. A float multiplier for adjusting contrast . \n
  71. *@par Outputs:
  72. *y:A Tensor of type float . \n
  73. *@attention Constraints:
  74. *Input images is a tensor of at least 3 dimensions. The last dimension is
  75. interpretted as channels, and must be three . \n
  76. *@par Third-party framework compatibility
  77. *Compatible with tensorflow AdjustContrast operator.
  78. */
  79. REG_OP(AdjustContrast)
  80. .INPUT(images, TensorType({DT_FLOAT16,DT_FLOAT}))
  81. .INPUT(contrast_factor, TensorType({DT_FLOAT}))
  82. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT}))
  83. .OP_END_FACTORY_REG(AdjustContrast)
  84. /**
  85. *@brief Extracts crops from the input image tensor and resizes them. Extracts
  86. crops from the input image tensor and resizes them using bilinear sampling or
  87. nearest neighbor sampling to a common output size specified by crop_size . \n
  88. *@par Inputs:
  89. *Input images must be a 4-D tensor. Inputs include:
  90. *@li images:A Tensor. Must be one of the following types:uint8, uint16, int8,
  91. int16, int32, int64, float16, float, double. A 4-D tensor of shape
  92. [batch, image_height, image_width, depth].
  93. *@li boxes: A Tensor of type float. A 2-D tensor of shape [num_boxes, 4].
  94. *@li box_index: A Tensor of type int32. A 1-D tensor of shape [num_boxes] with
  95. int32 values in [0, batch).
  96. *@li crop_size: A Tensor of type int32. A 1-D tensor of 2 elements, crop_size
  97. = [crop_height, crop_width]. All cropped image patches are resized to this size . \n
  98. *@par Attributes:
  99. *@li extrapolation_value: An optional float. Defaults to 0. Value used for
  100. extrapolation, when applicable.
  101. *@li method: An optional string from: '"bilinear", "nearest"'. Defaults to
  102. "bilinear". Currently two sampling methods are supported: Bilinear and
  103. NearestNeighbor . \n
  104. *@par Outputs:
  105. *y:A Tensor of type float . \n
  106. *@attention Constraints:
  107. *Input images must be a 4-D tensor . \n
  108. *@par Third-party framework compatibility
  109. *Compatible with tensorflow CropAndResize operator.
  110. */
  111. REG_OP(CropAndResize)
  112. .INPUT(x, TensorType({DT_UINT8, DT_UINT16, DT_INT8, \
  113. DT_INT16, DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  114. .INPUT(boxes, TensorType({DT_FLOAT}))
  115. .INPUT(box_index, TensorType({DT_INT32}))
  116. .INPUT(crop_size, TensorType({DT_INT32}))
  117. .OUTPUT(y, TensorType({DT_FLOAT}))
  118. .ATTR(extrapolation_value, Float, 0)
  119. .ATTR(method, String, "bilinear")
  120. .OP_END_FACTORY_REG(CropAndResize)
  121. /**
  122. *@brief Extracts crops from the input image tensor and resizes them.
  123. * Extracts crops from the input image tensor and resizes them using bilinear sampling or
  124. * nearest neighbor sampling to a common output size specified by crop_size . \n
  125. *@par Inputs:
  126. *Input images must be a 5HD tensor. Inputs include:
  127. *@li x:A Tensor. Must be one of the following types:float16, float. A 5HD tensor of shape
  128. * [batch, C1, image_height, image_width, C0].
  129. *@li boxes: A Tensor of type float. A 2-D tensor of shape [num_boxes, 4].
  130. *@li box_index: A Tensor of type int32. A 1-D tensor of shape [num_boxes] with int32 values in [0, batch) . \n
  131. *@par Attributes:
  132. *@li crop_size: list int. [crop_height, crop_width]. All cropped image patches
  133. are resized to this size.
  134. *@li extrapolation_value: An optional float. Defaults to 0. Value used for
  135. extrapolation, when applicable.
  136. *@li method: An optional string from: '"bilinear"'. Defaults to "bilinear" . \n
  137. *@par Outputs:
  138. *y:A Tensor of type float . \n
  139. *@attention Constraints:
  140. *Input images must be a 5HD tensor . \n
  141. *@par Third-party framework compatibility
  142. *Compatible with tensorflow CropAndResize operator.
  143. * @par Restrictions:
  144. * Warning: THIS FUNCTION IS DEPRECATED. Please use CropAndResize instead.
  145. */
  146. REG_OP(CropAndResizeD)
  147. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  148. .INPUT(boxes, TensorType({DT_FLOAT}))
  149. .INPUT(box_index, TensorType({DT_INT32}))
  150. .OUTPUT(y, TensorType({DT_FLOAT}))
  151. .REQUIRED_ATTR(crop_size, ListInt)
  152. .ATTR(extrapolation_value, Float, 0)
  153. .ATTR(method, String, "bilinear")
  154. .OP_END_FACTORY_REG(CropAndResizeD)
  155. /**
  156. *@brief Computes the gradient of the crop_and_resize op wrt the input
  157. boxes tensor . \n
  158. *@par Inputs:
  159. *Input images and grads must be a 4-D tensor. Inputs include:
  160. *@li grads: A 4-D tensor of shape [num_boxes, crop_height, crop_width, depth].
  161. *@li images: A 4-D tensor of shape [batch, image_height, image_width, depth].
  162. Both image_height and image_width need to be positive.
  163. *@li boxes: A 2-D tensor of shape [num_boxes, 4]. The i-th row of the tensor
  164. specifies the coordinates of a box in the box_ind[i] image and is specified in
  165. normalized coordinates [y1, x1, y2, x2].
  166. *@li box_index: A 1-D tensor of shape [num_boxes] with int32 values in
  167. [0, batch). The value of box_ind[i] specifies the image that the i-th box
  168. refers to . \n
  169. *@par Attributes:
  170. method: A string specifying the interpolation method. Only 'bilinear' is
  171. supported for now . \n
  172. *@par Outputs:
  173. *y:A 2-D tensor of shape [num_boxes, 4] . \n
  174. *@attention Constraints:
  175. *Input images and grads must be a 4-D tensor . \n
  176. *@par Third-party framework compatibility
  177. *Compatible with tensorflow CropAndResizeGradBoxes operator.
  178. */
  179. REG_OP(CropAndResizeGradBoxes)
  180. .INPUT(grads, TensorType({DT_FLOAT}))
  181. .INPUT(images, TensorType({DT_UINT8, DT_UINT16, DT_INT8, DT_INT16, \
  182. DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  183. .INPUT(boxes, TensorType({DT_FLOAT}))
  184. .INPUT(box_index, TensorType({DT_INT32}))
  185. .OUTPUT(y, TensorType({DT_FLOAT}))
  186. .ATTR(method, String, "bilinear")
  187. .OP_END_FACTORY_REG(CropAndResizeGradBoxes)
  188. /**
  189. *@brief Computes the gradient of the crop_and_resize op wrt the input
  190. images tensor . \n
  191. *@par Inputs:
  192. *Input grads must be a 4-D tensor. Inputs include:
  193. *@li grads: A 4-D tensor of shape [num_boxes, crop_height, crop_width, depth].
  194. *@li boxes: A 2-D tensor of shape [num_boxes, 4]. The i-th row of the tensor
  195. specifies the coordinates of a box in the box_ind[i] image and is specified
  196. in normalized coordinates [y1, x1, y2, x2].
  197. *@li box_index: A 1-D tensor of shape [num_boxes] with int32 values in
  198. [0, batch). The value of box_ind[i] specifies the image that the i-th box
  199. refers to.
  200. *@li image_size: A 1-D tensor with value [batch, image_height, image_width,
  201. depth] containing the original image size. Both image_height and image_width
  202. need to be positive . \n
  203. *@par Attributes:
  204. method: A string specifying the interpolation method. Only 'bilinear' is
  205. supported for now . \n
  206. *@par Outputs:
  207. *y:A 4-D tensor of shape [batch, image_height, image_width, depth] . \n
  208. *@attention Constraints:
  209. *Input grads must be a 4-D tensor . \n
  210. *@par Third-party framework compatibility
  211. *Compatible with tensorflow CropAndResizeGradImage operator.
  212. */
  213. REG_OP(CropAndResizeGradImage)
  214. .INPUT(grads, TensorType({DT_FLOAT}))
  215. .INPUT(boxes, TensorType({DT_FLOAT}))
  216. .INPUT(box_index, TensorType({DT_INT32}))
  217. .INPUT(image_size, TensorType({DT_INT32}))
  218. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  219. .ATTR(method, String, "bilinear")
  220. .REQUIRED_ATTR(T, Type)
  221. .OP_END_FACTORY_REG(CropAndResizeGradImage)
  222. /**
  223. *@brief Extracts a glimpse from the input tensor . \n
  224. *@par Inputs:
  225. *Input x must be a 4-D tensor. Inputs include:
  226. *@li x: A 4-D float tensor of shape [batch_size, height, width, channels].
  227. *@li size: A 1-D tensor of 2 elements containing the size of the glimpses to
  228. extract. The glimpse height must be specified first, following by the glimpse
  229. width.
  230. *@li offsets: A 2-D integer tensor of shape [batch_size, 2] containing the y,
  231. x locations of the center of each window . \n
  232. *@par Attributes:
  233. *@li centered: indicates if the offset coordinates are centered relative to
  234. the image, in which case the (0, 0) offset is relative to the center of the
  235. input images. If false, the (0,0) offset corresponds to the upper left corner
  236. of the input images.
  237. *@li normalized: indicates if the offset coordinates are normalized.
  238. *@li uniform_noise: indicates if the noise should be generated using a
  239. uniform distribution or a Gaussian distribution.
  240. *@li noise: indicates if the noise should uniform, gaussian, or zero.
  241. The default is uniform which means the the noise type will be decided by
  242. uniform_noise . \n
  243. *@par Outputs:
  244. *y:A tensor representing the glimpses [batch_size, glimpse_height,
  245. glimpse_width, channels] . \n
  246. *@attention Constraints:
  247. *Input x must be a 4-D tensor . \n
  248. *@par Third-party framework compatibility
  249. *Compatible with tensorflow CropAndResizeGradImage operator.
  250. */
  251. REG_OP(ExtractGlimpse)
  252. .INPUT(x, TensorType({DT_FLOAT}))
  253. .INPUT(size, TensorType({DT_INT32}))
  254. .INPUT(offsets, TensorType({DT_FLOAT}))
  255. .OUTPUT(y, TensorType({DT_FLOAT}))
  256. .ATTR(centered, Bool, true)
  257. .ATTR(normalized, Bool, true)
  258. .ATTR(uniform_noise, Bool, true)
  259. .ATTR(noise, String, "uniform")
  260. .OP_END_FACTORY_REG(ExtractGlimpse)
  261. /**
  262. *@brief Convert one or more images from HSV to RGB . \n
  263. *@par Inputs:
  264. *Last dimension of input x must be size 3. Inputs include:
  265. *images: 1-D or higher rank. HSV data to convert. Last dimension must be size 3 . \n
  266. *@par Outputs:
  267. *y:images converted to RGB . \n
  268. *@attention Constraints:
  269. *Last dimension of input x must be size 3 . \n
  270. *@par Third-party framework compatibility
  271. *Compatible with tensorflow HSVToRGB operator.
  272. */
  273. REG_OP(HSVToRGB)
  274. .INPUT(images, TensorType({DT_FLOAT16,DT_FLOAT,DT_DOUBLE}))
  275. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT,DT_DOUBLE}))
  276. .OP_END_FACTORY_REG(HSVToRGB)
  277. /**
  278. *@brief Resize quantized images to size using quantized bilinear interpolation . \n
  279. *@par Inputs:
  280. *Input images must be a 4-D tensor. Inputs include:
  281. *@li images: 4-D with shape [batch, height, width, channels].
  282. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width. The new
  283. size for the images.
  284. *@li min: A Tensor of type float.
  285. *@li max: A Tensor of type float . \n
  286. *@par Attributes:
  287. *@li align_corners: An optional bool. Defaults to False. If true, the centers
  288. of the 4 corner pixels of the input and output tensors are aligned, preserving
  289. the values at the corner pixels. Defaults to false.
  290. *@li half_pixel_centers: indicates if the offset coordinates are normalized . \n
  291. *@par Outputs:
  292. *@li resized_images: 4-D with shape [batch, new_height, new_width, channels].
  293. *@li y_min: A Tensor of type float.
  294. *@li y_max: A Tensor of type float . \n
  295. *@attention Constraints:
  296. *Input images and output images must be quantized types . \n
  297. *@par Third-party framework compatibility
  298. *Compatible with tensorflow QuantizedResizeBilinear operator.
  299. */
  300. REG_OP(QuantizedResizeBilinear)
  301. .INPUT(images, TensorType({DT_QUINT8,DT_QINT32,DT_FLOAT}))
  302. .INPUT(size, TensorType({ DT_INT32 }))
  303. .INPUT(min, TensorType({ DT_FLOAT }))
  304. .INPUT(max, TensorType({ DT_FLOAT }))
  305. .OUTPUT(resized_images, TensorType({DT_QUINT8,DT_QINT32,DT_FLOAT }))
  306. .OUTPUT(y_min, TensorType({ DT_FLOAT }))
  307. .OUTPUT(y_max, TensorType({ DT_FLOAT }))
  308. .ATTR(align_corners, Bool, false)
  309. .ATTR(half_pixel_centers, Bool, false)
  310. .OP_END_FACTORY_REG(QuantizedResizeBilinear)
  311. /**
  312. *@brief Resize images to size using area interpolation . \n
  313. *@par Inputs:
  314. *Input images must be a 4-D tensor. Inputs include:
  315. *@li images: 4-D with shape [batch, height, width, channels].
  316. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width.
  317. The new size for the images . \n
  318. *@par Attributes:
  319. *align_corners: If true, the centers of the 4 corner pixels of the input and
  320. output tensors are aligned, preserving the values at the corner pixels.
  321. Defaults to false . \n
  322. *@par Outputs:
  323. *y: 4-D with shape [batch, new_height, new_width, channels] . \n
  324. *@attention Constraints:
  325. *Input images can be of different types but output images are always float . \n
  326. *@par Third-party framework compatibility
  327. *Compatible with tensorflow ResizeArea operator.
  328. */
  329. REG_OP(ResizeArea)
  330. .INPUT(images, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, \
  331. DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  332. .INPUT(size, TensorType({DT_INT32}))
  333. .OUTPUT(y, TensorType({DT_FLOAT}))
  334. .ATTR(align_corners, Bool, false)
  335. .OP_END_FACTORY_REG(ResizeArea)
  336. /**
  337. *@brief Computes the gradient of bicubic interpolation . \n
  338. *@par Inputs:
  339. *Input grads must be a 4-D tensor. Inputs include:
  340. *@li grads: A Tensor of type float. 4-D with shape [batch, height, width,
  341. channels].
  342. *@li original_image: A Tensor. Must be one of the following types: float,
  343. double. 4-D with shape [batch, orig_height, orig_width, channels], The image
  344. tensor that was resized . \n
  345. *@par Attributes:
  346. *@li align_corners: An optional bool. Defaults to False. If true, the centers
  347. of the 4 corner pixels of the input and grad tensors are aligned. Defaults to
  348. false.
  349. *@li half_pixel_centers: An optional bool. Defaults to False . \n
  350. *@par Outputs:
  351. *y: A Tensor. Has the same type as original_image . \n
  352. *@attention Constraints:
  353. *Input images can be of different types but output images are always float . \n
  354. *@par Third-party framework compatibility
  355. *Compatible with tensorflow ResizeBicubicGrad operator.
  356. */
  357. REG_OP(ResizeBicubicGrad)
  358. .INPUT(grads, TensorType({DT_FLOAT}))
  359. .INPUT(original_image, TensorType({DT_FLOAT, DT_DOUBLE}))
  360. .OUTPUT(y, TensorType({DT_FLOAT, DT_DOUBLE}))
  361. .ATTR(align_corners, Bool, false)
  362. .ATTR(half_pixel_centers, Bool, false)
  363. .OP_END_FACTORY_REG(ResizeBicubicGrad)
  364. /**
  365. *@brief Resize images to size using bicubic interpolation . \n
  366. *@par Inputs:
  367. *Input images must be a 4-D tensor. Inputs include:
  368. *@li images: 4-D with shape [batch, height, width, channels].
  369. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width. The new
  370. size for the images . \n
  371. *@par Attributes:
  372. *@li align_corners: If true, the centers of the 4 corner pixels of the input
  373. and output tensors are aligned, preserving the values at the corner pixels.
  374. Defaults to false.
  375. *@li half_pixel_centers: An optional bool. Defaults to False . \n
  376. *@par Outputs:
  377. *y: 4-D with shape [batch, new_height, new_width, channels] . \n
  378. *@attention Constraints:
  379. *Input images can be of different types but output images are always float . \n
  380. *@par Third-party framework compatibility
  381. *Compatible with tensorflow ResizeBicubic operator.
  382. */
  383. REG_OP(ResizeBicubic)
  384. .INPUT(images, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, \
  385. DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  386. .INPUT(size, TensorType({DT_INT32}))
  387. .OUTPUT(y, TensorType({DT_FLOAT}))
  388. .ATTR(align_corners, Bool, false)
  389. .ATTR(half_pixel_centers, Bool, false)
  390. .OP_END_FACTORY_REG(ResizeBicubic)
  391. /**
  392. *@brief Computes the gradient of nearest neighbor interpolation . \n
  393. *@par Inputs:
  394. *Input grads must be a 4-D tensor. Inputs include:
  395. *@li grads: A Tensor. Must be one of the following types: uint8, int8, int32,
  396. float16, float, double. 4-D with shape [batch, height, width, channels].
  397. *@li size: A 1-D int32 Tensor of 2 elements: orig_height, orig_width.
  398. The original input size . \n
  399. *@par Attributes:
  400. *@li align_corners: An optional bool. Defaults to False. If true, the centers
  401. of the 4 corner pixels of the input and grad tensors are aligned. Defaults to
  402. false.
  403. *@li half_pixel_centers: An optional bool. Defaults to False . \n
  404. *@par Outputs:
  405. *y: A Tensor. Has the same type as grads . \n
  406. *@attention Constraints:
  407. *Input grads must be a 4-D tensor . \n
  408. *@par Third-party framework compatibility
  409. *Compatible with tensorflow ResizeNearestNeighborV2Grad operator.
  410. */
  411. REG_OP(ResizeNearestNeighborV2Grad)
  412. .INPUT(grads, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32,
  413. DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  414. .INPUT(size, TensorType({DT_INT32}))
  415. .OUTPUT(y, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32,
  416. DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  417. .ATTR(align_corners, Bool, false)
  418. .ATTR(half_pixel_centers, Bool, false)
  419. .OP_END_FACTORY_REG(ResizeNearestNeighborV2Grad)
  420. /**
  421. *@brief Computes the gradient of nearest neighbor interpolation . \n
  422. *@par Inputs:
  423. *Input grads must be a 4-D tensor. Inputs include:
  424. *grads: A Tensor. 4-D with shape [batch, height, width, channels].
  425. *@par Attributes:
  426. *@li align_corners: An optional bool. Defaults to False. If true, the centers
  427. of the 4 corner pixels of the input and grad tensors are aligned. Defaults to
  428. false.
  429. *@li size: An list type. Specify the images size . \n
  430. *@par Outputs:
  431. *y: A Tensor. Has the same type as grads . \n
  432. *@par Third-party framework compatibility
  433. *Compatible with tensorflow ResizeNearestNeighborV2GradD operator.
  434. *
  435. * @par Restrictions:
  436. * Warning: THIS FUNCTION IS DEPRECATED. Please use ResizeNearestNeighborV2Grad instead.
  437. */
  438. REG_OP(ResizeNearestNeighborV2GradD)
  439. .INPUT(grads, TensorType({DT_FLOAT}))
  440. .OUTPUT(y, TensorType({DT_FLOAT}))
  441. .REQUIRED_ATTR(size, ListInt)
  442. .ATTR(align_corners, Bool, false)
  443. .ATTR(half_pixel_centers, Bool, false)
  444. .OP_END_FACTORY_REG(ResizeNearestNeighborV2GradD)
  445. /**
  446. *@brief Computes the gradient of bilinear interpolation . \n
  447. *@par Inputs:
  448. *Input grads must be a 4-D tensor. Inputs include:
  449. *@li grads: A Tensor of type float32. 4-D with shape [batch, height, width,
  450. channels].
  451. *@li original_image: A Tensor. 4-D with shape [batch, orig_height, orig_width,
  452. channels], The image tensor that was resized . \n
  453. *@par Attributes:
  454. *align_corners: An optional bool. Defaults to False. If true, the centers of
  455. the 4 corner pixels of the input and grad tensors are aligned. Defaults to
  456. false . \n
  457. *@par Outputs:
  458. *y: A Tensor. Has the same type as original_image . \n
  459. *@attention Constraints:
  460. *Input grads must be a 4-D tensor . \n
  461. *@par Third-party framework compatibility
  462. *Compatible with tensorflow ResizeBilinearV2Grad operator.
  463. */
  464. REG_OP(ResizeBilinearV2Grad)
  465. .INPUT(grads, TensorType({DT_FLOAT}))
  466. .INPUT(original_image, TensorType::FloatingDataType())
  467. .OUTPUT(y, TensorType({DT_FLOAT}))
  468. .ATTR(align_corners, Bool, false)
  469. .ATTR(half_pixel_centers, Bool, false)
  470. .OP_END_FACTORY_REG(ResizeBilinearV2Grad)
  471. /**
  472. *@brief Resize images to size using bilinear interpolation . \n
  473. *@par Inputs:
  474. *Input images must be a 4-D tensor. Inputs include:
  475. *@li x: 4-D with shape [batch, height, width, channels].
  476. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width. The new
  477. size for the images . \n
  478. *@par Attributes:
  479. *align_corners: If true, the centers of the 4 corner pixels of the input and
  480. output tensors are aligned, preserving the values at the corner pixels.
  481. Defaults to false . \n
  482. *@par Outputs:
  483. *y: 4-D with shape [batch, new_height, new_width, channels] . \n
  484. *@attention Constraints:
  485. *Input images can be of different types but output images are always float . \n
  486. *@par Third-party framework compatibility
  487. *Compatible with tensorflow ResizeBilinearV2 operator.
  488. */
  489. REG_OP(ResizeBilinearV2)
  490. .INPUT(x, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16,
  491. DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  492. .INPUT(size, TensorType({DT_INT32}))
  493. .OUTPUT(y, TensorType({DT_FLOAT}))
  494. .ATTR(align_corners, Bool, false)
  495. .ATTR(half_pixel_centers, Bool, false)
  496. .OP_END_FACTORY_REG(ResizeBilinearV2)
  497. /**
  498. *@brief Converts one or more images from RGB to HSV . \n
  499. *@par Inputs:
  500. *Last dimension of input images must be size 3. Inputs include:
  501. *images: A Tensor. Must be one of the following types: float, double. 1-D or
  502. higher rank. RGB data to convert. Last dimension must be size 3 . \n
  503. *@par Outputs:
  504. *y: A Tensor. Has the same type as images . \n
  505. *@attention Constraints:
  506. *Outputs a tensor of the same shape as the images tensor, containing the HSV
  507. value of the pixels. The output is only well defined if the value in images
  508. are in [0,1] . \n
  509. *@par Third-party framework compatibility
  510. *Compatible with tensorflow RGBToHSV operator.
  511. */
  512. REG_OP(RGBToHSV)
  513. .INPUT(images, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE }))
  514. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE }))
  515. .OP_END_FACTORY_REG(RGBToHSV)
  516. /**
  517. *@brief Generate a single randomly distorted bounding box for an image . \n
  518. *@par Inputs:
  519. *Input images must be a 4-D tensor. Inputs include:
  520. *@li image_size: 1-D, containing [height, width, channels].
  521. *@li bounding_boxes: 3-D with shape [batch, N, 4] describing the N bounding
  522. boxes associated with the image.
  523. *@li min_object_covered: The cropped area of the image must contain at least
  524. this fraction of any bounding box supplied. The value of this parameter should
  525. be non-negative. In the case of 0, the cropped area does not need to overlap
  526. any of the bounding boxes supplied . \n
  527. *@par Attributes:
  528. *@li seed: If either seed or seed2 are set to non-zero, the random number
  529. generator is seeded by the given seed. Otherwise, it is seeded by a random seed.
  530. *@li seed2: A second seed to avoid seed collision.
  531. *@li aspect_ratio_range: The cropped area of the image must have an aspect
  532. ratio = width / height within this range.
  533. *@li max_attempts: Number of attempts at generating a cropped region of the
  534. image of the specified constraints. After max_attempts failures, return the
  535. entire image.
  536. *@li use_image_if_no_bounding_boxes: Controls behavior if no bounding boxes
  537. supplied. If true, assume an implicit bounding box covering the whole input.
  538. If false, raise an error . \n
  539. *@par Outputs:
  540. *@li begin: 1-D, containing [offset_height, offset_width, 0].
  541. *@li size: 1-D, containing [target_height, target_width, -1].
  542. *@li bboxes: 3-D with shape [1, 1, 4] containing the distorted bounding box . \n
  543. *@attention Constraints:
  544. *Input images can be of different types but output images are always float . \n
  545. *@par Third-party framework compatibility
  546. *Compatible with tensorflow SampleDistortedBoundingBoxExt2 operator.
  547. */
  548. REG_OP(SampleDistortedBoundingBoxExt2)
  549. .INPUT(image_size, TensorType({ DT_UINT8, DT_INT8, DT_INT16, \
  550. DT_INT32, DT_INT64 }))
  551. .INPUT(bounding_boxes, TensorType({ DT_FLOAT }))
  552. .INPUT(min_object_covered, TensorType({ DT_FLOAT }))
  553. .OUTPUT(begin, TensorType({ DT_UINT8, DT_INT8, DT_INT16, \
  554. DT_INT32, DT_INT64 }))
  555. .OUTPUT(size, TensorType({ DT_UINT8, DT_INT8, DT_INT16, \
  556. DT_INT32, DT_INT64 }))
  557. .OUTPUT(bboxes, TensorType({ DT_FLOAT }))
  558. .ATTR(seed, Int, 0)
  559. .ATTR(seed2, Int, 0)
  560. .ATTR(aspect_ratio_range, ListFloat, { 0.75f, 1.33f })
  561. .ATTR(area_range, ListFloat, { 0.05f, 1.0f })
  562. .ATTR(max_attempts, Int, 100)
  563. .ATTR(use_image_if_no_bounding_boxes, Bool, false)
  564. .OP_END_FACTORY_REG(SampleDistortedBoundingBoxExt2)
  565. /**
  566. *@brief Resize images to size using nearest neighbor interpolation . \n
  567. *@par Inputs:
  568. *Input x must be a 4-D tensor. Inputs include:
  569. *@li x: 4-D with shape [batch, height, width, channels].
  570. *@li size: A 1-D int32 Tensor of 2 elements: new_height, new_width.
  571. The new size for the images . \n
  572. *@par Attributes:
  573. *align_corners: If true, the centers of the 4 corner pixels of the input and
  574. output tensors are aligned, preserving the values at the corner pixels.
  575. Defaults to false . \n
  576. *@par Outputs:
  577. *y: 4-D with shape [batch, new_height, new_width, channels] . \n
  578. *@par Third-party framework compatibility
  579. *Compatible with tensorflow ResizeNearestNeighborV2 operator.
  580. */
  581. REG_OP(ResizeNearestNeighborV2)
  582. .INPUT(x, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32,
  583. DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  584. .INPUT(size, TensorType({DT_INT32}))
  585. .OUTPUT(y, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32,
  586. DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  587. .ATTR(align_corners, Bool, false)
  588. .ATTR(half_pixel_centers, Bool, false)
  589. .OP_END_FACTORY_REG(ResizeNearestNeighborV2)
  590. /**
  591. *@brief Draw bounding boxes on a batch of images . \n
  592. *@par Inputs:
  593. *Input images must be a 4-D tensor. Inputs include:
  594. *@li images: A Tensor. Must be one of the following types: float. 4-D with
  595. shape [batch, height, width, depth]. A batch of images.
  596. *@li boxes: A Tensor of type float32. 3-D with shape [batch,
  597. num_bounding_boxes, 4] containing bounding boxes . \n
  598. *@par Outputs:
  599. *A Tensor. Has the same type as images . \n
  600. *@attention Constraints:
  601. *Input images must be a 4-D tensor . \n
  602. *@par Third-party framework compatibility
  603. *Compatible with tensorflow DrawBoundingBoxes operator.
  604. */
  605. REG_OP(DrawBoundingBoxes)
  606. .INPUT(images, TensorType({DT_FLOAT}))
  607. .INPUT(boxes, TensorType({DT_FLOAT}))
  608. .OUTPUT(y, TensorType({DT_FLOAT}))
  609. .OP_END_FACTORY_REG(DrawBoundingBoxes)
  610. /**
  611. *@brief Greedily selects a subset of bounding boxes in descending order of
  612. score . \n
  613. *@par Inputs:
  614. *Input boxes and scores must be float type. Inputs include:
  615. *@li boxes: A 2-D float tensor of shape [num_boxes, 4].
  616. *@li scores: A 1-D float tensor of shape [num_boxes] representing a single
  617. score corresponding to each box (each row of boxes).
  618. *@li max_output_size: A scalar integer tensor representing the maximum number
  619. of boxes to be selected by non max suppression . \n
  620. *@par Attributes:
  621. *iou_threshold: A float representing the threshold for deciding whether boxes
  622. overlap too much with respect to IOU . \n
  623. *@par Outputs:
  624. *selected_indices: A 1-D integer tensor of shape [M] representing the selected
  625. indices from the boxes tensor, where M <= max_output_size . \n
  626. *@attention Constraints:
  627. *Input boxes and scores must be float type . \n
  628. *@par Third-party framework compatibility
  629. *Compatible with tensorflow NonMaxSuppression operator.
  630. */
  631. REG_OP(NonMaxSuppression)
  632. .INPUT(boxes, TensorType({DT_FLOAT}))
  633. .INPUT(scores, TensorType({DT_FLOAT}))
  634. .INPUT(max_output_size, TensorType({DT_INT32}))
  635. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  636. .ATTR(iou_threshold, Float, 0.5f)
  637. .OP_END_FACTORY_REG(NonMaxSuppression)
  638. /**
  639. *@brief Greedily selects a subset of bounding boxes in descending order of
  640. score . \n
  641. *@par Inputs:
  642. *Input boxes and scores must be float type. Inputs include:
  643. *@li boxes: A 2-D float tensor of shape [num_boxes, 4].
  644. *@li scores: A 1-D float tensor of shape [num_boxes] representing a single
  645. score corresponding to each box (each row of boxes).
  646. *@li max_output_size: A scalar integer tensor representing the maximum number
  647. of boxes to be selected by non max suppression.
  648. *@li iou_threshold: A 0-D float tensor representing the threshold for deciding
  649. whether boxes overlap too much with respect to IOU . \n
  650. *@par Outputs:
  651. *selected_indices: A 1-D integer tensor of shape [M] representing the selected
  652. indices from the boxes tensor, where M <= max_output_size . \n
  653. *@attention Constraints:
  654. *Input boxes and scores must be float type . \n
  655. *@par Third-party framework compatibility
  656. *Compatible with tensorflow NonMaxSuppressionV2 operator.
  657. */
  658. REG_OP(NonMaxSuppressionV2)
  659. .INPUT(boxes, TensorType({DT_FLOAT16, DT_FLOAT}))
  660. .INPUT(scores, TensorType({DT_FLOAT16, DT_FLOAT}))
  661. .INPUT(max_output_size, TensorType({DT_INT32}))
  662. .INPUT(iou_threshold, TensorType({DT_FLOAT16,DT_FLOAT}))
  663. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  664. .OP_END_FACTORY_REG(NonMaxSuppressionV2)
  665. /**
  666. *@brief Greedily selects a subset of bounding boxes in descending order of
  667. score . \n
  668. *@par Inputs:
  669. *Input boxes and scores must be float type. Inputs include:
  670. *@li boxes: A 2-D float tensor of shape [num_boxes, 4].
  671. *@li scores: A 1-D float tensor of shape [num_boxes] representing a single
  672. score corresponding to each box (each row of boxes).
  673. *@li max_output_size: A scalar integer tensor representing the maximum number
  674. of boxes to be selected by non max suppression.
  675. *@li iou_threshold: A 0-D float tensor representing the threshold for deciding
  676. whether boxes overlap too much with respect to IOU.
  677. *@li score_threshold: A 0-D float tensor representing the threshold for
  678. deciding when to remove boxes based on score . \n
  679. *@par Outputs:
  680. *selected_indices: A 1-D integer tensor of shape [M] representing the selected
  681. indices from the boxes tensor, where M <= max_output_size . \n
  682. *@attention Constraints:
  683. *Input boxes and scores must be float type . \n
  684. *@par Third-party framework compatibility
  685. *Compatible with tensorflow NonMaxSuppressionV3 operator.
  686. */
  687. REG_OP(NonMaxSuppressionV3)
  688. .INPUT(boxes, TensorType({DT_FLOAT16, DT_FLOAT}))
  689. .INPUT(scores, TensorType({DT_FLOAT16, DT_FLOAT}))
  690. .INPUT(max_output_size, TensorType({DT_INT32}))
  691. .INPUT(iou_threshold, TensorType({DT_FLOAT16,DT_FLOAT}))
  692. .INPUT(score_threshold, TensorType({DT_FLOAT16,DT_FLOAT}))
  693. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  694. .OP_END_FACTORY_REG(NonMaxSuppressionV3)
  695. /**
  696. *@brief Greedily selects a subset of bounding boxes in descending order of
  697. score . \n
  698. *@par Inputs:
  699. *Input boxes and scores must be float type. Inputs include:
  700. *@li boxes: A 2-D float tensor of shape [num_boxes, 4].
  701. *@li scores: A 1-D float tensor of shape [num_boxes] representing a single
  702. score corresponding to each box (each row of boxes).
  703. *@li max_output_size: A scalar integer tensor representing the maximum number
  704. of boxes to be selected by non max suppression.
  705. *@li iou_threshold: A 0-D float tensor representing the threshold for deciding
  706. whether boxes overlap too much with respect to IOU.
  707. *@li score_threshold: A 0-D float tensor representing the threshold for
  708. deciding when to remove boxes based on score . \n
  709. *@par Attributes:
  710. *pad_to_max_output_size: If true, the output selected_indices is padded
  711. to be of length max_output_size. Defaults to false . \n
  712. *@par Outputs:
  713. *@li selected_indices: A 1-D integer tensor of shape [M] representing the
  714. selected indices from the boxes tensor, where M <= max_output_size.
  715. *@li valid_outputs: A 0-D integer tensor representing the number of valid
  716. elements in selected_indices, with the valid elements appearing first . \n
  717. *@attention Constraints:
  718. *Input boxes and scores must be float type . \n
  719. *@par Third-party framework compatibility
  720. *Compatible with tensorflow NonMaxSuppressionV4 operator.
  721. */
  722. REG_OP(NonMaxSuppressionV4)
  723. .INPUT(boxes, TensorType({DT_FLOAT16, DT_FLOAT}))
  724. .INPUT(scores, TensorType({DT_FLOAT16, DT_FLOAT}))
  725. .INPUT(max_output_size, TensorType({DT_INT32}))
  726. .INPUT(iou_threshold, TensorType({DT_FLOAT16,DT_FLOAT}))
  727. .INPUT(score_threshold, TensorType({DT_FLOAT16,DT_FLOAT}))
  728. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  729. .OUTPUT(valid_outputs, TensorType({DT_INT32}))
  730. .ATTR(pad_to_max_output_size, Bool, false)
  731. .OP_END_FACTORY_REG(NonMaxSuppressionV4)
  732. /**
  733. *@brief Greedily selects a subset of bounding boxes in descending order of
  734. score . \n
  735. *@par Inputs:
  736. *Input overlaps and scores must be float type. Inputs include:
  737. *@li overlaps: A 2-D float tensor of shape [num_boxes, num_boxes]
  738. representing the n-by-n box overlap values.
  739. *@li scores: A 1-D float tensor of shape [num_boxes] representing a single
  740. score corresponding to each box (each row of boxes).
  741. *@li max_output_size: A scalar integer tensor representing the maximum number
  742. of boxes to be selected by non max suppression.
  743. *@li overlap_threshold: A 0-D float tensor representing the threshold for
  744. deciding whether boxes overlap too.
  745. *@li score_threshold: A 0-D float tensor representing the threshold for
  746. deciding when to remove boxes based on score . \n
  747. *@par Attributes:
  748. *pad_to_max_output_size: If true, the output selected_indices is padded
  749. to be of length max_output_size. Defaults to false . \n
  750. *@par Outputs:
  751. *selected_indices: A 1-D integer tensor of shape [M] representing the
  752. selected indices from the boxes tensor, where M <= max_output_size . \n
  753. *@par Third-party framework compatibility
  754. *Compatible with tensorflow NonMaxSuppressionWithOverlaps operator.
  755. */
  756. REG_OP(NonMaxSuppressionWithOverlaps)
  757. .INPUT(overlaps, TensorType({DT_FLOAT}))
  758. .INPUT(scores, TensorType({DT_FLOAT}))
  759. .INPUT(max_output_size, TensorType({DT_INT32}))
  760. .INPUT(overlap_threshold, TensorType({DT_FLOAT}))
  761. .INPUT(score_threshold, TensorType({DT_FLOAT}))
  762. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  763. .OP_END_FACTORY_REG(NonMaxSuppressionWithOverlaps)
  764. /**
  765. *@brief JPEG-encode an image . \n
  766. *@par Inputs:
  767. *Input image must be unit8 type. Inputs include:
  768. *image: A 3-D uint8 Tensor of shape [height, width, channels] . \n
  769. *@par Attributes:
  770. *@li format: Per pixel image format.
  771. *@li quality: Quality of the compression from 0 to 100 (higher is better
  772. and slower).
  773. *@li progressive: If True, create a JPEG that loads progressively (coarse
  774. to fine).
  775. *@li optimize_size: If True, spend CPU/RAM to reduce size with no quality
  776. change.
  777. *@li chroma_downsampling: A boolean, default is true.
  778. *@li density_unit: Unit used to specify x_density and y_density: pixels per
  779. inch ('in') or centimeter ('cm').
  780. *@li x_density: Horizontal pixels per density unit.
  781. *@li y_density: Vertical pixels per density unit.
  782. *@li xmp_metadata: If not empty, embed this XMP metadata in the image header . \n
  783. *@par Outputs:
  784. *contents: 0-D. JPEG-encoded image . \n
  785. *@par Third-party framework compatibility
  786. *Compatible with tensorflow EncodeJpeg operator.
  787. */
  788. REG_OP(EncodeJpeg)
  789. .INPUT(image, TensorType({DT_UINT8}))
  790. .OUTPUT(contents, TensorType({DT_STRING}))
  791. .ATTR(format, String, "")
  792. .ATTR(quality, Int, 95)
  793. .ATTR(progressive, Bool, false)
  794. .ATTR(optimize_size, Bool, false)
  795. .ATTR(chroma_downsampling, Bool, true)
  796. .ATTR(density_unit, String, "in")
  797. .ATTR(x_density, Int, 300)
  798. .ATTR(y_density, Int, 300)
  799. .ATTR(xmp_metadata, String, "")
  800. .OP_END_FACTORY_REG(EncodeJpeg)
  801. /**
  802. *@brief PNG-encode an image.
  803. *@par Inputs:
  804. *Input image must be unit8 or uint16 type. Inputs include:
  805. *image: is a 3-D uint8 or uint16 Tensor of shape [height, width, channels]
  806. where channels is: 1: for grayscale; 2: for grayscale + alpha; 3: for RGB;
  807. 4: for RGBA . \n
  808. *@par Attributes:
  809. *compression: Compression level . \n
  810. *@par Outputs:
  811. *contents: 0-D. PNG-encoded image . \n
  812. *@par Third-party framework compatibility
  813. *Compatible with tensorflow EncodePng operator.
  814. */
  815. REG_OP(EncodePng)
  816. .INPUT(image, TensorType({DT_UINT8, DT_UINT16}))
  817. .OUTPUT(contents, TensorType({DT_STRING}))
  818. .ATTR(compression, Int, -1)
  819. .OP_END_FACTORY_REG(EncodePng)
  820. /**
  821. *@brief Resizes "images" to "size" using bilinear interpolation . \n
  822. *@par Inputs:
  823. * One input:
  824. *x: An NC1HWC0 Tensor.
  825. * Must be one of the following types: float16, float32 . \n
  826. *@par Attributes:
  827. *@li size: A required int32 Tensor specifying the new size for the images.
  828. No default value.
  829. *@li align_corners: An optional bool. If "true", the centers of the corner
  830. pixels of the input and output tensors are aligned. Defaults to "false" . \n
  831. *@par Outputs:
  832. *y: A Tensor with type float32 and the same format as input "images" . \n
  833. *@attention Constraints:
  834. *@li The input "size" must be a tensor of 2 elements: size[0] <= 2048,
  835. size[1] <= 2048.
  836. *@li The input "images" must be a tensor of 5 elements: images[2] <= 2048,
  837. images[3] <= 2048 . \n
  838. *@par Third-party framework compatibility
  839. * Compatible with TensorFlow operator ResizeBilinearV2D.
  840. *
  841. * @par Restrictions:
  842. * Warning: THIS FUNCTION IS DEPRECATED. Please use ResizeBilinearV2 instead.
  843. */
  844. REG_OP(ResizeBilinearV2D)
  845. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
  846. .OUTPUT(y, TensorType({DT_FLOAT}))
  847. .ATTR(align_corners, Bool, false)
  848. .ATTR(half_pixel_centers, Bool, false)
  849. .REQUIRED_ATTR(size, ListInt)
  850. .OP_END_FACTORY_REG(ResizeBilinearV2D)
  851. /**
  852. *@brief Resizes "images" to "size" using bilinear interpolation and keep ratio at the time. \n
  853. *@par Inputs:
  854. * One input:
  855. *images: An NC1HWC0 Tensor.
  856. * Must be one of the following types: float16, float32 . \n
  857. *@par Attributes:
  858. *@li min_dimension: A required int32 attribute for the min dimension for the images.
  859. * No default value.
  860. *@li max_dimension: A required int32 attribute for the max dimension for the images.
  861. * No default value.
  862. *@li align_corners: An optional bool. If "true", the centers of the corner
  863. * pixels of the input and output tensors are aligned. Defaults to "false".
  864. *@li half_pixel_centers: indicates if the offset coordinates are normalized
  865. * Defaults to "false" . \n
  866. *@par Outputs:
  867. *y: A Tensor with type float32 and the same format as input "images" . \n
  868. *@attention Constraints:
  869. * The input "images" must be a tensor of 5 elements: images[2] <= 2048,
  870. images[3] <= 2048.
  871. */
  872. REG_OP(KeepRatioResizeBilinear)
  873. .INPUT(images, TensorType({DT_FLOAT16, DT_FLOAT}))
  874. .OUTPUT(y, TensorType({DT_FLOAT}))
  875. .REQUIRED_ATTR(min_dimension, Int)
  876. .REQUIRED_ATTR(max_dimension, Int)
  877. .ATTR(align_corners, Bool, false)
  878. .ATTR(half_pixel_centers, Bool, false)
  879. .OP_END_FACTORY_REG(KeepRatioResizeBilinear)
  880. /**
  881. *@brief Resizes "images" to "size" using nearest neighbor interpolation . \n
  882. *@par Inputs:
  883. * One input:
  884. *x: An NC1HWC0 Tensor.
  885. * Must be one of the following types: float16, float32, int32, int8, uint8
  886. *@par Attributes:
  887. *@li size: A required int32 Tensor specifying the new size for the images.
  888. No default value.
  889. *@li align_corners: An optional bool. If "true", the centers of the corner
  890. pixels of the input and output tensors are aligned. Defaults to "false" . \n
  891. *@par Outputs:
  892. *y: A Tensor with the same type and format as input "images" . \n
  893. *@attention Constraints:
  894. * The input "size" must be a tensor of 2 elements: size[0] <= 7680,
  895. size[1] <= 4320
  896. *@par Third-party framework compatibility
  897. * Compatible with TensorFlow operator ResizeNearestNeighborV2.
  898. *
  899. * @par Restrictions:
  900. * Warning: THIS FUNCTION IS DEPRECATED. Please use ResizeNearestNeighborV2 instead.
  901. */
  902. REG_OP(ResizeNearestNeighborV2D)
  903. .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  904. .OUTPUT(y, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
  905. .REQUIRED_ATTR(size, ListInt)
  906. .ATTR(align_corners, Bool, false)
  907. .ATTR(half_pixel_centers, Bool, false)
  908. .OP_END_FACTORY_REG(ResizeNearestNeighborV2D)
  909. /**
  910. *@brief Extract the shape information of a JPEG-encoded image . \n
  911. *@par Inputs:
  912. *Input contents must be 0-D. Inputs include:
  913. *contents: 0-D. The JPEG-encoded image . \n
  914. *@par Attributes:
  915. *output_type: The output type of the operation (int32 or int64). Defaults
  916. to int32 . \n
  917. *@par Outputs:
  918. *image_shape: 1-D. The image shape with format [height, width, channels] . \n
  919. *@par Third-party framework compatibility
  920. *Compatible with tensorflow ExtractJpegShape operator.
  921. */
  922. REG_OP(ExtractJpegShape)
  923. .INPUT(contents, TensorType({DT_STRING}))
  924. .OUTPUT(image_shape, TensorType({DT_INT32, DT_INT64}))
  925. .REQUIRED_ATTR(output_type, Type)
  926. .OP_END_FACTORY_REG(ExtractJpegShape)
  927. /**
  928. *@brief Draw bounding boxes on a batch of images . \n
  929. *@par Inputs:
  930. *@li images: 4-D with shape `[batch, height, width, depth]`.
  931. A batch of images.
  932. *@li boxes: 3-D with shape `[batch, num_bounding_boxes, 4]`
  933. containing bounding boxes.
  934. *@li colors: 2-D. A list of RGBA colors to cycle through for the boxes . \n
  935. *@par Outputs:
  936. *y: Returns 4-D with the same shape as `images`.
  937. The batch of input images with bounding boxes drawn on the images . \n
  938. *@par Third-party framework compatibility
  939. * Compatible with tensorflow DrawBoundingBoxesV2 operator.
  940. */
  941. REG_OP(DrawBoundingBoxesV2)
  942. .INPUT(images, TensorType({DT_FLOAT}))
  943. .INPUT(boxes, TensorType({DT_FLOAT}))
  944. .INPUT(colors, TensorType({DT_FLOAT}))
  945. .OUTPUT(y, TensorType({DT_FLOAT}))
  946. .OP_END_FACTORY_REG(DrawBoundingBoxesV2)
  947. /**
  948. *@brief Greedily selects a subset of bounding boxes in descending order of score,
  949. pruning away boxes that have high intersection-over-union (IOU) overlap
  950. with previously selected boxes . \n
  951. *@par Inputs:
  952. *@li boxes: A 2-D float tensor of shape `[num_boxes, 4]`.
  953. *@li scores: A 1-D float tensor of shape `[num_boxes]` representing a single
  954. score corresponding to each box (each row of boxes).
  955. *@li max_output_size: A scalar integer tensor representing the maximum number of
  956. boxes to be selected by non max suppression.
  957. *@li iou_threshold: A 0-D float tensor representing the threshold for deciding whether
  958. boxes overlap too much with respect to IOU.
  959. *@li score_threshold: A 0-D float tensor representing the threshold for deciding when to
  960. remove boxes based on score.
  961. *@li soft_nms_sigma: A 0-D float tensor representing the sigma parameter for Soft NMS . \n
  962. *@par Attributes:
  963. pad_to_max_output_size: If true, the output `selected_indices` is padded to be of length
  964. `max_output_size`. Defaults to false. If not specified, defaults to false . \n
  965. *@par Outputs:
  966. *@li selected_indices: A 1-D integer tensor of shape [M] representing the
  967. selected indices from the boxes tensor, where M <= max_output_size.
  968. *@li selected_scores: A 1-D float tensor of shape `[M]` representing the corresponding
  969. scores for each selected box, where `M <= max_output_size`.
  970. *@li valid_outputs: A 0-D integer tensor representing the number of valid
  971. elements in selected_indices, with the valid elements appearing first . \n
  972. *@par Third-party framework compatibility
  973. * Compatible with tensorflow NonMaxSuppressionV5 operator.
  974. */
  975. REG_OP(NonMaxSuppressionV5)
  976. .INPUT(boxes, TensorType({DT_FLOAT16, DT_FLOAT}))
  977. .INPUT(scores, TensorType({DT_FLOAT16, DT_FLOAT}))
  978. .INPUT(max_output_size, TensorType({DT_INT32}))
  979. .INPUT(iou_threshold, TensorType({DT_FLOAT16, DT_FLOAT}))
  980. .INPUT(score_threshold, TensorType({DT_FLOAT16, DT_FLOAT}))
  981. .INPUT(soft_nms_sigma, TensorType({DT_FLOAT16, DT_FLOAT}))
  982. .OUTPUT(selected_indices, TensorType({DT_INT32}))
  983. .OUTPUT(selected_scores, TensorType({DT_FLOAT16, DT_FLOAT}))
  984. .OUTPUT(valid_outputs, TensorType({DT_INT32}))
  985. .ATTR(pad_to_max_output_size, Bool, false)
  986. .REQUIRED_ATTR(T, Type)
  987. .OP_END_FACTORY_REG(NonMaxSuppressionV5)
  988. /**
  989. *@brief Resizes "images" to "size" by scale and translate . \n
  990. *@par Inputs:
  991. *@li images: A `Tensor`. Must be one of the following types: `int8`, `uint8`,
  992. `int16`, `uint16`, `int32`, `int64`, `bfloat16`, `float32`, `float64`.
  993. *@li size: A `Tensor` of type `int32`.
  994. *@li scale: A `Tensor` of type `float32`.
  995. *@li translation: A `Tensor` of type `float32` . \n
  996. *@li kernel_type: type is string, default lanczos3
  997. *@li antialias: type is bool, default true \n
  998. *@par Outputs:
  999. *y: A Tensor with type float32 . \n
  1000. *@par Third-party framework compatibility
  1001. * Compatible with TensorFlow ScaleAndTranslate operator.
  1002. */
  1003. REG_OP(ScaleAndTranslate)
  1004. .INPUT(images, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16,
  1005. DT_INT32, DT_INT64, DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  1006. .INPUT(size, TensorType({DT_INT32}))
  1007. .INPUT(scale, TensorType({DT_FLOAT}))
  1008. .INPUT(translation, TensorType({DT_FLOAT}))
  1009. .OUTPUT(y, TensorType({DT_FLOAT}))
  1010. .ATTR(kernel_type, String, "lanczos3")
  1011. .ATTR(antialias, Bool, true)
  1012. .OP_END_FACTORY_REG(ScaleAndTranslate)
  1013. /**
  1014. *@brief Computes the gradient by scale and translate . \n
  1015. *@par Inputs:
  1016. *@li grads: A `Tensor`. Must be one of the following types: `float32`.
  1017. *@li original_image: A `Tensor`. Must have the same type as `grads`.
  1018. *@li scale: A `Tensor` of type `float32`.
  1019. *@li translation: A `Tensor` of type `float32` . \n
  1020. *@li kernel_type: type is string, default lanczos3
  1021. *@li antialias: type is bool, default true
  1022. *@par Outputs:
  1023. *y: A `Tensor`. Has the same type as `grads` . \n
  1024. *@par Third-party framework compatibility
  1025. * Compatible with TensorFlow ScaleAndTranslateGrad operator.
  1026. */
  1027. REG_OP(ScaleAndTranslateGrad)
  1028. .INPUT(grads, TensorType({DT_FLOAT}))
  1029. .INPUT(original_image, TensorType({DT_FLOAT}))
  1030. .INPUT(scale, TensorType({DT_FLOAT}))
  1031. .INPUT(translation, TensorType({DT_FLOAT}))
  1032. .OUTPUT(y, TensorType({DT_FLOAT}))
  1033. .ATTR(kernel_type, String, "lanczos3")
  1034. .ATTR(antialias, Bool, true)
  1035. .OP_END_FACTORY_REG(ScaleAndTranslateGrad)
  1036. /**
  1037. *@brief Greedily selects a subset of bounding boxes in descending order of score,
  1038. This operation performs non_max_suppression on the inputs per batch, across all classes . \n
  1039. *@par Inputs:
  1040. *@li boxes: A 4-D float tensor of shape `[batch_size, num_boxes, q, 4]`. If `q` is 1 then
  1041. same boxes are used for all classes otherwise, if `q` is equal to number of
  1042. classes, class-specific boxes are used.
  1043. *@li scores: A 3-D float tensor of shape `[batch_size, num_boxes, num_classes]`
  1044. representing a single score corresponding to each box (each row of boxes).
  1045. *@li max_output_size_per_class: A scalar integer tensor representing the maximum number of
  1046. boxes to be selected by non max suppression per class.
  1047. *@li max_total_size: A scalar representing maximum number of boxes retained over all classes.
  1048. *@li iou_threshold: A 0-D float tensor representing the threshold for deciding whether
  1049. boxes overlap too much with respect to IOU.
  1050. *@li score_threshold: A 0-D float tensor representing the threshold for deciding when to remove
  1051. boxes based on score . \n
  1052. *@par Attributes:
  1053. *@li pad_per_class: If false, the output nmsed boxes, scores and classes
  1054. are padded/clipped to `max_total_size`. If true, the
  1055. output nmsed boxes, scores and classes are padded to be of length
  1056. `max_size_per_class`*`num_classes`, unless it exceeds `max_total_size` in
  1057. which case it is clipped to `max_total_size`. Defaults to false.
  1058. *@li clip_boxes: If true, assume the box coordinates are between [0, 1] and clip the output boxes
  1059. if they fall beyond [0, 1]. If false, do not do clipping and output the box
  1060. coordinates as it is. If not specified, defaults to true . \n
  1061. *@par Outputs:
  1062. *nmsed_boxes:type is float
  1063. *nmsed_scores:type is float
  1064. *nmsed_classes:type is float \n
  1065. *@par Third-party framework compatibility
  1066. * Compatible with tensorflow CombinedNonMaxSuppression operator.
  1067. */
  1068. REG_OP(CombinedNonMaxSuppression)
  1069. .INPUT(boxes, TensorType({DT_FLOAT}))
  1070. .INPUT(scores, TensorType({DT_FLOAT}))
  1071. .INPUT(max_output_size_per_class, TensorType({DT_INT32}))
  1072. .INPUT(max_total_size, TensorType({DT_INT32}))
  1073. .INPUT(iou_threshold, TensorType({DT_FLOAT}))
  1074. .INPUT(score_threshold, TensorType({DT_FLOAT}))
  1075. .OUTPUT(nmsed_boxes, TensorType({DT_FLOAT}))
  1076. .OUTPUT(nmsed_scores, TensorType({DT_FLOAT}))
  1077. .OUTPUT(nmsed_classes, TensorType({DT_FLOAT}))
  1078. .OUTPUT(valid_detections, TensorType({DT_INT32}))
  1079. .ATTR(pad_per_class, Bool, false)
  1080. .ATTR(clip_boxes, Bool, true)
  1081. .OP_END_FACTORY_REG(CombinedNonMaxSuppression)
  1082. /**
  1083. *@brief Function spatial transformer . \n
  1084. *@par Inputs:
  1085. *@li x: A Tensor dtype of float16, float32.
  1086. *@li theta: A Tensor dtype of float16, float32, auxiliary coefficients . \n
  1087. *@par Attributes:
  1088. *@li output_size: A tuple output size.
  1089. *@li default_theta: A tuple default theta
  1090. *@li use_default_theta: List use default theta
  1091. *@li align_corners: Align corners
  1092. *@par Outputs:
  1093. *y: A Tensor dtype of float16, float32, should be same shape and type as x.
  1094. */
  1095. REG_OP(SpatialTransformerD)
  1096. .INPUT(x, TensorType({DT_FLOAT,DT_FLOAT16}))
  1097. .OPTIONAL_INPUT(theta, TensorType({DT_FLOAT,DT_FLOAT16}))
  1098. .OUTPUT(y, TensorType({DT_FLOAT,DT_FLOAT16}))
  1099. .ATTR(output_size, ListInt, {-1, -1})
  1100. .ATTR(default_theta, ListFloat, {})
  1101. .ATTR(align_corners, Bool, false)
  1102. .ATTR(use_default_theta, ListBool, {})
  1103. .OP_END_FACTORY_REG(SpatialTransformerD)
  1104. } // namespace ge
  1105. #endif // GE_OP_MAGE_OPS_H_

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