objc2_metal_performance_shaders_graph/generated/MPSGraphResizeOps.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6#[cfg(feature = "objc2-metal-performance-shaders")]
7use objc2_metal_performance_shaders::*;
8
9use crate::*;
10
11/// The resize mode to use for resizing.
12///
13/// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshadersgraph/mpsgraphresizemode?language=objc)
14// NS_ENUM
15#[repr(transparent)]
16#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
17pub struct MPSGraphResizeMode(pub NSUInteger);
18impl MPSGraphResizeMode {
19 /// Samples the nearest neighbor to the pixel coordinate.
20 #[doc(alias = "MPSGraphResizeNearest")]
21 pub const Nearest: Self = Self(0);
22 /// Samples the 4 neighbors to the pixel coordinate and uses bilinear interpolation.
23 #[doc(alias = "MPSGraphResizeBilinear")]
24 pub const Bilinear: Self = Self(1);
25}
26
27unsafe impl Encode for MPSGraphResizeMode {
28 const ENCODING: Encoding = NSUInteger::ENCODING;
29}
30
31unsafe impl RefEncode for MPSGraphResizeMode {
32 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35/// The rounding mode to use when using nearest resize mode.
36///
37/// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshadersgraph/mpsgraphresizenearestroundingmode?language=objc)
38// NS_ENUM
39#[repr(transparent)]
40#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
41pub struct MPSGraphResizeNearestRoundingMode(pub NSUInteger);
42impl MPSGraphResizeNearestRoundingMode {
43 /// Rounds values to the nearest integer value, with 0.5f offset rounding toward +inf.
44 #[doc(alias = "MPSGraphResizeNearestRoundingModeRoundPreferCeil")]
45 pub const RoundPreferCeil: Self = Self(0);
46 /// Rounds values to the nearest integer value, with 0.5f rounding toward -inf.
47 #[doc(alias = "MPSGraphResizeNearestRoundingModeRoundPreferFloor")]
48 pub const RoundPreferFloor: Self = Self(1);
49 /// Rounds values toward +inf.
50 #[doc(alias = "MPSGraphResizeNearestRoundingModeCeil")]
51 pub const Ceil: Self = Self(2);
52 /// Rounds values toward -inf.
53 #[doc(alias = "MPSGraphResizeNearestRoundingModeFloor")]
54 pub const Floor: Self = Self(3);
55 /// Rounds values to the nearest integer value, with 0.5f rounding toward the closest even value.
56 #[doc(alias = "MPSGraphResizeNearestRoundingModeRoundToEven")]
57 pub const RoundToEven: Self = Self(4);
58 /// Rounds values to the nearest integer value, with 0.5f rounding toward the closest odd value.
59 #[doc(alias = "MPSGraphResizeNearestRoundingModeRoundToOdd")]
60 pub const RoundToOdd: Self = Self(5);
61}
62
63unsafe impl Encode for MPSGraphResizeNearestRoundingMode {
64 const ENCODING: Encoding = NSUInteger::ENCODING;
65}
66
67unsafe impl RefEncode for MPSGraphResizeNearestRoundingMode {
68 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
69}
70
71/// MPSGraphResizeOps.
72#[cfg(all(feature = "MPSGraph", feature = "MPSGraphCore"))]
73impl MPSGraph {
74 extern_methods!(
75 #[cfg(all(
76 feature = "MPSGraphTensor",
77 feature = "objc2-metal-performance-shaders"
78 ))]
79 /// Creates a Resize operation and returns the result tensor.
80 ///
81 /// Resamples input images to given size. Result images will be distorted if size is of different aspect ratio.
82 /// Resize supports the following modes:
83 /// Nearest Neighbor - values are interpolated using the closest neighbor pixel
84 /// Bilinear - values are computed using bilinear interpolation of 4 neighboring pixels
85 /// Destination indices are computed using direct index scaling by default, with no offset added.
86 /// If the centerResult parameter is true, the destination indices will be scaled and shifted to be centered
87 /// on the input image.
88 /// If the alignCorners parameter is true, the corners of the result images will match the input images.
89 /// Scaling will be modified to a factor of (size - 1) / (inputSize - 1). When alignCorners is true, the
90 /// centerResult parameter does nothing.
91 /// In order to achieve the same behavior as OpenCV's resize and TensorFlowV2's resize,
92 /// ```md
93 /// centerResult = YES;
94 /// alginCorners = NO;
95 /// ```
96 /// To achieve the same behavior as TensorFlowV1 resize
97 /// ```md
98 /// centerResult = NO;
99 /// ```
100 ///
101 /// - Parameters:
102 /// - imagesTensor: Tensor containing input images.
103 /// - size: A 2-element shape as [newHeight, newWidth]
104 /// - mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
105 /// - centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
106 /// - alignCorners: When YES, the result image will have the same value as the input image in the corners
107 /// - layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
108 /// - name: The name for the operation.
109 /// - Returns: A valid MPSGraphTensor object
110 #[unsafe(method(resizeTensor:size:mode:centerResult:alignCorners:layout:name:))]
111 #[unsafe(method_family = none)]
112 pub unsafe fn resizeTensor_size_mode_centerResult_alignCorners_layout_name(
113 &self,
114 images_tensor: &MPSGraphTensor,
115 size: &MPSShape,
116 mode: MPSGraphResizeMode,
117 center_result: bool,
118 align_corners: bool,
119 layout: MPSGraphTensorNamedDataLayout,
120 name: Option<&NSString>,
121 ) -> Retained<MPSGraphTensor>;
122
123 #[cfg(feature = "MPSGraphTensor")]
124 /// Creates a Resize operation and returns the result tensor.
125 ///
126 /// Resamples input images to given size. Result images will be distorted if size is of different aspect ratio.
127 /// Resize supports the following modes:
128 /// Nearest Neighbor - values are interpolated using the closest neighbor pixel
129 /// Bilinear - values are computed using bilinear interpolation of 4 neighboring pixels
130 /// Destination indices are computed using direct index scaling by default, with no offset added.
131 /// If the centerResult parameter is true, the destination indices will be scaled and shifted to be centered
132 /// on the input image.
133 /// If the alignCorners parameter is true, the corners of the result images will match the input images.
134 /// Scaling will be modified to a factor of (size - 1) / (inputSize - 1). When alignCorners is true, the
135 /// centerResult parameter does nothing.
136 /// In order to achieve the same behavior as OpenCV's resize and TensorFlowV2's resize,
137 /// ```md
138 /// centerResult = YES;
139 /// alginCorners = NO;
140 /// ```
141 /// To achieve the same behavior as TensorFlowV1 resize
142 /// ```md
143 /// centerResult = NO;
144 /// ```
145 ///
146 /// - Parameters:
147 /// - imagesTensor: Tensor containing input images.
148 /// - size: 1D Int32 or Int64 tensor. A 2-element shape as [newHeight, newWidth]
149 /// - mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
150 /// - centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
151 /// - alignCorners: When YES, the result image will have the same value as the input image in the corners
152 /// - layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
153 /// - name: The name for the operation.
154 /// - Returns: A valid MPSGraphTensor object
155 #[unsafe(method(resizeTensor:sizeTensor:mode:centerResult:alignCorners:layout:name:))]
156 #[unsafe(method_family = none)]
157 pub unsafe fn resizeTensor_sizeTensor_mode_centerResult_alignCorners_layout_name(
158 &self,
159 images_tensor: &MPSGraphTensor,
160 size: &MPSGraphTensor,
161 mode: MPSGraphResizeMode,
162 center_result: bool,
163 align_corners: bool,
164 layout: MPSGraphTensorNamedDataLayout,
165 name: Option<&NSString>,
166 ) -> Retained<MPSGraphTensor>;
167
168 #[cfg(feature = "MPSGraphTensor")]
169 /// Creates a Resize operation and returns the result tensor.
170 ///
171 /// Resamples input images to given size. Result images will be distorted if size is of different aspect ratio.
172 /// Resize supports the following modes:
173 /// Nearest Neighbor - values are interpolated using the closest neighbor pixel
174 /// Bilinear - values are computed using bilinear interpolation of 4 neighboring pixels
175 /// Destination indices are computed using direct index scaling by default, with no offset added.
176 /// If the centerResult parameter is true, the destination indices will be scaled and shifted to be centered
177 /// on the input image.
178 /// If the alignCorners parameter is true, the corners of the result images will match the input images.
179 /// Scaling will be modified to a factor of (size - 1) / (inputSize - 1). When alignCorners is true, the
180 /// centerResult parameter does nothing.
181 /// In order to achieve the same behavior as OpenCV's resize and TensorFlowV2's resize,
182 /// ```md
183 /// centerResult = YES;
184 /// alginCorners = NO;
185 /// ```
186 /// To achieve the same behavior as TensorFlowV1 resize
187 /// ```md
188 /// centerResult = NO;
189 /// ```
190 ///
191 /// - Parameters:
192 /// - imagesTensor: Tensor containing input images.
193 /// - size: The target size of the result tensor. 1D Int32 or Int64 tensor of size equal to rank of input.
194 /// - mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
195 /// - centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
196 /// - alignCorners: When YES, the result image will have the same value as the input image in the corners
197 /// - name: The name for the operation.
198 /// - Returns: A valid MPSGraphTensor object
199 #[unsafe(method(resizeTensor:sizeTensor:mode:centerResult:alignCorners:name:))]
200 #[unsafe(method_family = none)]
201 pub unsafe fn resizeTensor_sizeTensor_mode_centerResult_alignCorners_name(
202 &self,
203 images_tensor: &MPSGraphTensor,
204 size: &MPSGraphTensor,
205 mode: MPSGraphResizeMode,
206 center_result: bool,
207 align_corners: bool,
208 name: Option<&NSString>,
209 ) -> Retained<MPSGraphTensor>;
210
211 #[cfg(feature = "MPSGraphTensor")]
212 /// Resamples input images to given size using nearest neighbor sampling.
213 ///
214 /// This API allows for the rounding mode to be specified.
215 /// Resamples input images to given size. Result images will be distorted if size is of different aspect ratio.
216 /// Resize supports the following modes:
217 /// Nearest Neighbor - values are interpolated using the closest neighbor pixel
218 /// Bilinear - values are computed using bilinear interpolation of 4 neighboring pixels
219 /// Destination indices are computed using direct index scaling by default, with no offset added.
220 /// If the centerResult parameter is true, the destination indices will be scaled and shifted to be centered
221 /// on the input image.
222 /// If the alignCorners parameter is true, the corners of the result images will match the input images.
223 /// Scaling will be modified to a factor of (size - 1) / (inputSize - 1). When alignCorners is true, the
224 /// centerResult parameter does nothing.
225 /// In order to achieve the same behavior as OpenCV's resize and TensorFlowV2's resize,
226 /// ```md
227 /// centerResult = YES;
228 /// alginCorners = NO;
229 /// ```
230 /// To achieve the same behavior as TensorFlowV1 resize
231 /// ```md
232 /// centerResult = NO;
233 /// ```
234 ///
235 /// - Parameters:
236 /// - imagesTensor: Tensor containing input images.
237 /// - size: 1D Int32 or Int64 tensor. A 2-element shape as [newHeight, newWidth]
238 /// - nearestRoundingMode: The rounding mode to use when using nearest resampling. Default is roundPreferCeil.
239 /// - centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
240 /// - alignCorners: When YES, the result image will have the same value as the input image in the corners
241 /// - layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
242 /// - name: The name for the operation.
243 /// - Returns: A valid MPSGraphTensor object
244 #[unsafe(method(resizeNearestWithTensor:sizeTensor:nearestRoundingMode:centerResult:alignCorners:layout:name:))]
245 #[unsafe(method_family = none)]
246 pub unsafe fn resizeNearestWithTensor_sizeTensor_nearestRoundingMode_centerResult_alignCorners_layout_name(
247 &self,
248 images_tensor: &MPSGraphTensor,
249 size: &MPSGraphTensor,
250 nearest_rounding_mode: MPSGraphResizeNearestRoundingMode,
251 center_result: bool,
252 align_corners: bool,
253 layout: MPSGraphTensorNamedDataLayout,
254 name: Option<&NSString>,
255 ) -> Retained<MPSGraphTensor>;
256
257 #[cfg(feature = "MPSGraphTensor")]
258 /// Creates a Resize operation and returns the result tensor.
259 ///
260 /// Resamples input images to given size using nearest neighbor sampling. Result images will be distorted if
261 /// size is of different aspect ratio.
262 /// Destination indices are computed using direct index scaling by default, with no offset added.
263 /// If the centerResult parameter is true, the destination indices will be scaled and shifted to be centered
264 /// on the input image.
265 /// If the alignCorners parameter is true, the corners of the result images will match the input images.
266 /// Scaling will be modified to a factor of (size - 1) / (inputSize - 1). When alignCorners is true, the
267 /// centerResult parameter does nothing.
268 /// In order to achieve the same behavior as OpenCV's resize and TensorFlowV2's resize,
269 /// ```md
270 /// centerResult = YES;
271 /// alginCorners = NO;
272 /// ```
273 /// To achieve the same behavior as TensorFlowV1 resize
274 /// ```md
275 /// centerResult = NO;
276 /// ```
277 ///
278 /// - Parameters:
279 /// - imagesTensor: Tensor containing input images.
280 /// - size: The target size of the result tensor. 1D Int32 or Int64 tensor of size equal to rank of input.
281 /// - nearestRoundingMode: The rounding mode to use when using nearest resampling. Default is roundPreferCeil.
282 /// - centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
283 /// - alignCorners: When YES, the result image will have the same value as the input image in the corners
284 /// - name: The name for the operation.
285 /// - Returns: A valid MPSGraphTensor object
286 #[unsafe(method(resizeNearestWithTensor:sizeTensor:nearestRoundingMode:centerResult:alignCorners:name:))]
287 #[unsafe(method_family = none)]
288 pub unsafe fn resizeNearestWithTensor_sizeTensor_nearestRoundingMode_centerResult_alignCorners_name(
289 &self,
290 images_tensor: &MPSGraphTensor,
291 size: &MPSGraphTensor,
292 nearest_rounding_mode: MPSGraphResizeNearestRoundingMode,
293 center_result: bool,
294 align_corners: bool,
295 name: Option<&NSString>,
296 ) -> Retained<MPSGraphTensor>;
297
298 #[cfg(feature = "MPSGraphTensor")]
299 /// Resamples input images to given size using bilinear sampling.
300 ///
301 /// Resamples input images to given size using nearest neighbor sampling. Result images will be distorted if
302 /// size is of different aspect ratio.
303 /// Destination indices are computed using direct index scaling by default, with no offset added.
304 /// If the centerResult parameter is true, the destination indices will be scaled and shifted to be centered
305 /// on the input image.
306 /// If the alignCorners parameter is true, the corners of the result images will match the input images.
307 /// Scaling will be modified to a factor of (size - 1) / (inputSize - 1). When alignCorners is true, the
308 /// centerResult parameter does nothing.
309 /// In order to achieve the same behavior as OpenCV's resize and TensorFlowV2's resize,
310 /// ```md
311 /// centerResult = YES;
312 /// alginCorners = NO;
313 /// ```
314 /// To achieve the same behavior as TensorFlowV1 resize
315 /// ```md
316 /// centerResult = NO;
317 /// ```
318 ///
319 /// - Parameters:
320 /// - imagesTensor: Tensor containing input images.
321 /// - size: 1D Int32 or Int64 tensor. A 2-element shape as [newHeight, newWidth]
322 /// - centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
323 /// - alignCorners: When YES, the result image will have the same value as the input image in the corners
324 /// - layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
325 /// - name: The name for the operation.
326 /// - Returns: A valid MPSGraphTensor object
327 #[unsafe(method(resizeBilinearWithTensor:sizeTensor:centerResult:alignCorners:layout:name:))]
328 #[unsafe(method_family = none)]
329 pub unsafe fn resizeBilinearWithTensor_sizeTensor_centerResult_alignCorners_layout_name(
330 &self,
331 images_tensor: &MPSGraphTensor,
332 size: &MPSGraphTensor,
333 center_result: bool,
334 align_corners: bool,
335 layout: MPSGraphTensorNamedDataLayout,
336 name: Option<&NSString>,
337 ) -> Retained<MPSGraphTensor>;
338
339 #[cfg(feature = "MPSGraphTensor")]
340 /// Creates a Resize operation and returns the result tensor.
341 ///
342 /// Resamples input images to given size using bilinear sampling. Result images will be distorted if
343 /// size is of different aspect ratio.
344 /// Destination indices are computed using direct index scaling by default, with no offset added.
345 /// If the centerResult parameter is true, the destination indices will be scaled and shifted to be centered
346 /// on the input image.
347 /// If the alignCorners parameter is true, the corners of the result images will match the input images.
348 /// Scaling will be modified to a factor of (size - 1) / (inputSize - 1). When alignCorners is true, the
349 /// centerResult parameter does nothing.
350 /// In order to achieve the same behavior as OpenCV's resize and TensorFlowV2's resize,
351 /// ```md
352 /// centerResult = YES;
353 /// alginCorners = NO;
354 /// ```
355 /// To achieve the same behavior as TensorFlowV1 resize
356 /// ```md
357 /// centerResult = NO;
358 /// ```
359 ///
360 /// - Parameters:
361 /// - imagesTensor: Tensor containing input images.
362 /// - size: The target size of the result tensor. 1D Int32 or Int64 tensor of size equal to rank of input.
363 /// - centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
364 /// - alignCorners: When YES, the result image will have the same value as the input image in the corners
365 /// - name: The name for the operation.
366 /// - Returns: A valid MPSGraphTensor object
367 #[unsafe(method(resizeBilinearWithTensor:sizeTensor:centerResult:alignCorners:name:))]
368 #[unsafe(method_family = none)]
369 pub unsafe fn resizeBilinearWithTensor_sizeTensor_centerResult_alignCorners_name(
370 &self,
371 images_tensor: &MPSGraphTensor,
372 size: &MPSGraphTensor,
373 center_result: bool,
374 align_corners: bool,
375 name: Option<&NSString>,
376 ) -> Retained<MPSGraphTensor>;
377
378 #[cfg(feature = "MPSGraphTensor")]
379 /// Resamples input images to given size using the provided scale and offset.
380 /// Destination indices are computed using
381 /// ```md
382 /// dst_indices = (src_indicesscale) + offset
383 /// ```
384 /// For most use cases passing the scale and offset directly is unnecessary, and it is
385 /// preferable to use the API specifying centerResult and alignCorners.
386 ///
387 /// - Parameters:
388 /// - imagesTensor: Tensor containing input images.
389 /// - size: 1D Int32 or Int64 tensor. A 2-element shape as [newHeight, newWidth]
390 /// - scaleOffset: 1D float tensor. A 4-element shape as [scaleY, scaleX, offsetY, offsetX]
391 /// - mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
392 /// - layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
393 /// - name: The name for the operation.
394 /// - Returns: A valid MPSGraphTensor object
395 #[unsafe(method(resizeTensor:sizeTensor:scaleOffsetTensor:mode:layout:name:))]
396 #[unsafe(method_family = none)]
397 pub unsafe fn resizeTensor_sizeTensor_scaleOffsetTensor_mode_layout_name(
398 &self,
399 images_tensor: &MPSGraphTensor,
400 size: &MPSGraphTensor,
401 scale_offset: &MPSGraphTensor,
402 mode: MPSGraphResizeMode,
403 layout: MPSGraphTensorNamedDataLayout,
404 name: Option<&NSString>,
405 ) -> Retained<MPSGraphTensor>;
406
407 #[cfg(feature = "MPSGraphTensor")]
408 /// Creates a Resize operation and returns the result tensor.
409 ///
410 /// Resamples input images to given size using the provided scale and offset.
411 /// Destination indices are computed using
412 /// ```md
413 /// dst_indices = (src_indices * scale) + offset
414 /// ```
415 /// For most use cases passing the scale and offset directly is unnecessary, and it is
416 /// preferable to use the API specifying centerResult and alignCorners.
417 ///
418 /// - Parameters:
419 /// - imagesTensor: Tensor containing input images.
420 /// - size: The target size of the result tensor. 1D Int32 or Int64 tensor of size equal to rank of input.
421 /// - scale: 1D float tensor of size equal to rank of input.
422 /// - offset: 1D float tensor of size equal to rank of input.
423 /// - mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
424 /// - name: The name for the operation.
425 /// - Returns: A valid MPSGraphTensor object
426 #[unsafe(method(resizeTensor:sizeTensor:scaleTensor:offsetTensor:mode:name:))]
427 #[unsafe(method_family = none)]
428 pub unsafe fn resizeTensor_sizeTensor_scaleTensor_offsetTensor_mode_name(
429 &self,
430 images_tensor: &MPSGraphTensor,
431 size: &MPSGraphTensor,
432 scale: &MPSGraphTensor,
433 offset: &MPSGraphTensor,
434 mode: MPSGraphResizeMode,
435 name: Option<&NSString>,
436 ) -> Retained<MPSGraphTensor>;
437
438 #[cfg(feature = "MPSGraphTensor")]
439 /// Resamples input images to given size using the provided scale and offset and nearest neighbor sampling
440 /// See above discussion for more details.
441 ///
442 /// - Parameters:
443 /// - imagesTensor: Tensor containing input images.
444 /// - size: 1D Int32 or Int64 tensor. A 2-element shape as [newHeight, newWidth]
445 /// - scaleOffset: 1D float tensor. A 4-element shape as [scaleY, scaleX, offsetY, offsetX]
446 /// - nearestRoundingMode: The rounding mode to use when using nearest resampling.
447 /// - layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
448 /// - name: The name for the operation.
449 /// - Returns: A valid MPSGraphTensor object
450 #[unsafe(method(resizeNearestWithTensor:sizeTensor:scaleOffsetTensor:nearestRoundingMode:layout:name:))]
451 #[unsafe(method_family = none)]
452 pub unsafe fn resizeNearestWithTensor_sizeTensor_scaleOffsetTensor_nearestRoundingMode_layout_name(
453 &self,
454 images_tensor: &MPSGraphTensor,
455 size: &MPSGraphTensor,
456 scale_offset: &MPSGraphTensor,
457 nearest_rounding_mode: MPSGraphResizeNearestRoundingMode,
458 layout: MPSGraphTensorNamedDataLayout,
459 name: Option<&NSString>,
460 ) -> Retained<MPSGraphTensor>;
461
462 #[cfg(feature = "MPSGraphTensor")]
463 /// Creates a Resize operation and returns the result tensor.
464 ///
465 /// Resamples input images to given size using the provided scale and offset and nearest neighbor sampling.
466 /// Destination indices are computed using
467 /// ```md
468 /// dst_indices = (src_indices * scale) + offset
469 /// ```
470 /// For most use cases passing the scale and offset directly is unnecessary, and it is
471 /// preferable to use the API specifying centerResult and alignCorners.
472 ///
473 /// - Parameters:
474 /// - imagesTensor: Tensor containing input images.
475 /// - size: The target size of the result tensor. 1D Int32 or Int64 tensor of size equal to rank of input.
476 /// - scale: 1D float tensor of size equal to rank of input.
477 /// - offset: 1D float tensor of size equal to rank of input.
478 /// - nearestRoundingMode: The rounding mode to use when using nearest resampling. Default is roundPreferCeil.
479 /// - name: The name for the operation.
480 /// - Returns: A valid MPSGraphTensor object
481 #[unsafe(method(resizeNearestWithTensor:sizeTensor:scaleTensor:offsetTensor:nearestRoundingMode:name:))]
482 #[unsafe(method_family = none)]
483 pub unsafe fn resizeNearestWithTensor_sizeTensor_scaleTensor_offsetTensor_nearestRoundingMode_name(
484 &self,
485 images_tensor: &MPSGraphTensor,
486 size: &MPSGraphTensor,
487 scale: &MPSGraphTensor,
488 offset: &MPSGraphTensor,
489 nearest_rounding_mode: MPSGraphResizeNearestRoundingMode,
490 name: Option<&NSString>,
491 ) -> Retained<MPSGraphTensor>;
492
493 #[cfg(feature = "MPSGraphTensor")]
494 /// Resamples input images to given size using the provided scale and offset and bilinear sampling
495 /// See above discussion for more details.
496 ///
497 /// - Parameters:
498 /// - imagesTensor: Tensor containing input images.
499 /// - size: 1D Int32 or Int64 tensor. A 2-element shape as [newHeight, newWidth]
500 /// - scaleOffset: 1D float tensor. A 4-element shape as [scaleY, scaleX, offsetY, offsetX]
501 /// - nearestRoundingMode: The rounding mode to use when using nearest resampling.
502 /// - layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
503 /// - name: The name for the operation.
504 /// - Returns: A valid MPSGraphTensor object
505 #[unsafe(method(resizeBilinearWithTensor:sizeTensor:scaleOffsetTensor:layout:name:))]
506 #[unsafe(method_family = none)]
507 pub unsafe fn resizeBilinearWithTensor_sizeTensor_scaleOffsetTensor_layout_name(
508 &self,
509 images_tensor: &MPSGraphTensor,
510 size: &MPSGraphTensor,
511 scale_offset: &MPSGraphTensor,
512 layout: MPSGraphTensorNamedDataLayout,
513 name: Option<&NSString>,
514 ) -> Retained<MPSGraphTensor>;
515
516 #[cfg(feature = "MPSGraphTensor")]
517 /// Creates a Resize operation and returns the result tensor.
518 ///
519 /// Resamples input images to given size using the provided scale and offset and bilinear sampling.
520 /// Destination indices are computed using
521 /// ```md
522 /// dst_indices = (src_indices * scale) + offset
523 /// ```
524 /// For most use cases passing the scale and offset directly is unnecessary, and it is
525 /// preferable to use the API specifying centerResult and alignCorners.
526 ///
527 /// - Parameters:
528 /// - imagesTensor: Tensor containing input images.
529 /// - size: The target size of the result tensor. 1D Int32 or Int64 tensor of size equal to rank of input.
530 /// - scale: 1D float tensor of size equal to rank of input.
531 /// - offset: 1D float tensor of size equal to rank of input.
532 /// - name: The name for the operation.
533 /// - Returns: A valid MPSGraphTensor object
534 #[unsafe(method(resizeBilinearWithTensor:sizeTensor:scaleTensor:offsetTensor:name:))]
535 #[unsafe(method_family = none)]
536 pub unsafe fn resizeBilinearWithTensor_sizeTensor_scaleTensor_offsetTensor_name(
537 &self,
538 images_tensor: &MPSGraphTensor,
539 size: &MPSGraphTensor,
540 scale: &MPSGraphTensor,
541 offset: &MPSGraphTensor,
542 name: Option<&NSString>,
543 ) -> Retained<MPSGraphTensor>;
544
545 #[cfg(feature = "MPSGraphTensor")]
546 /// Creates a Resize gradient operation and returns the result tensor.
547 ///
548 /// Computes the gradient for the forward pass Resize op with identical parameters.
549 /// See discussion of resizeTensor for more in depth description of resize paramters.
550 ///
551 /// - Parameters:
552 /// - gradient: Incoming gradient tensor
553 /// - input: Forward pass input tensor
554 /// - mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
555 /// - centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
556 /// - alignCorners: When YES, the result image will have the same value as the input image in the corners
557 /// - layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
558 /// - name: The name for the operation.
559 /// - Returns: A valid MPSGraphTensor object
560 #[unsafe(method(resizeWithGradientTensor:input:mode:centerResult:alignCorners:layout:name:))]
561 #[unsafe(method_family = none)]
562 pub unsafe fn resizeWithGradientTensor_input_mode_centerResult_alignCorners_layout_name(
563 &self,
564 gradient: &MPSGraphTensor,
565 input: &MPSGraphTensor,
566 mode: MPSGraphResizeMode,
567 center_result: bool,
568 align_corners: bool,
569 layout: MPSGraphTensorNamedDataLayout,
570 name: Option<&NSString>,
571 ) -> Retained<MPSGraphTensor>;
572
573 #[cfg(feature = "MPSGraphTensor")]
574 /// Creates a Resize gradient operation and returns the result tensor.
575 ///
576 /// Computes the gradient for the forward pass Resize op with identical parameters.
577 /// See discussion of resizeTensor for more in depth description of resize paramters.
578 ///
579 /// - Parameters:
580 /// - gradient: Incoming gradient tensor
581 /// - input: Forward pass input tensor
582 /// - nearestRoundingMode: The rounding mode to use when using nearest resampling.
583 /// - centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
584 /// - alignCorners: When YES, the result image will have the same value as the input image in the corners
585 /// - layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
586 /// - name: The name for the operation.
587 /// - Returns: A valid MPSGraphTensor object
588 #[unsafe(method(resizeNearestWithGradientTensor:input:nearestRoundingMode:centerResult:alignCorners:layout:name:))]
589 #[unsafe(method_family = none)]
590 pub unsafe fn resizeNearestWithGradientTensor_input_nearestRoundingMode_centerResult_alignCorners_layout_name(
591 &self,
592 gradient: &MPSGraphTensor,
593 input: &MPSGraphTensor,
594 nearest_rounding_mode: MPSGraphResizeNearestRoundingMode,
595 center_result: bool,
596 align_corners: bool,
597 layout: MPSGraphTensorNamedDataLayout,
598 name: Option<&NSString>,
599 ) -> Retained<MPSGraphTensor>;
600
601 #[cfg(feature = "MPSGraphTensor")]
602 /// Creates a Resize gradient operation and returns the result tensor.
603 ///
604 /// Computes the gradient for the forward pass Resize op with identical parameters.
605 /// See discussion of resizeTensor for more in depth description of resize paramters.
606 ///
607 /// - Parameters:
608 /// - gradient: Incoming gradient tensor
609 /// - input: Forward pass input tensor
610 /// - centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
611 /// - alignCorners: When YES, the result image will have the same value as the input image in the corners
612 /// - layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
613 /// - name: The name for the operation.
614 /// - Returns: A valid MPSGraphTensor object
615 #[unsafe(method(resizeBilinearWithGradientTensor:input:centerResult:alignCorners:layout:name:))]
616 #[unsafe(method_family = none)]
617 pub unsafe fn resizeBilinearWithGradientTensor_input_centerResult_alignCorners_layout_name(
618 &self,
619 gradient: &MPSGraphTensor,
620 input: &MPSGraphTensor,
621 center_result: bool,
622 align_corners: bool,
623 layout: MPSGraphTensorNamedDataLayout,
624 name: Option<&NSString>,
625 ) -> Retained<MPSGraphTensor>;
626
627 #[cfg(feature = "MPSGraphTensor")]
628 /// Creates a Resize gradient operation and returns the result tensor.
629 ///
630 /// Computes the gradient for the forward pass Resize op with identical parameters.
631 /// See discussion of resizeTensor for more in depth description of resize paramters.
632 ///
633 /// - Parameters:
634 /// - gradient: Incoming gradient tensor
635 /// - input: Forward pass input tensor
636 /// - scaleOffset: 1D float tensor. A 4-element shape as [scaleY, scaleX, offsetY, offsetX]
637 /// - mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
638 /// - layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
639 /// - name: The name for the operation.
640 /// - Returns: A valid MPSGraphTensor object
641 #[unsafe(method(resizeWithGradientTensor:input:scaleOffsetTensor:mode:layout:name:))]
642 #[unsafe(method_family = none)]
643 pub unsafe fn resizeWithGradientTensor_input_scaleOffsetTensor_mode_layout_name(
644 &self,
645 gradient: &MPSGraphTensor,
646 input: &MPSGraphTensor,
647 scale_offset: &MPSGraphTensor,
648 mode: MPSGraphResizeMode,
649 layout: MPSGraphTensorNamedDataLayout,
650 name: Option<&NSString>,
651 ) -> Retained<MPSGraphTensor>;
652
653 #[cfg(feature = "MPSGraphTensor")]
654 /// Creates a Resize gradient operation and returns the result tensor.
655 ///
656 /// Computes the gradient for the forward pass Resize op with identical parameters.
657 /// See discussion of resizeTensor for more in depth description of resize paramters.
658 ///
659 /// - Parameters:
660 /// - gradient: Incoming gradient tensor
661 /// - input: Forward pass input tensor
662 /// - scale: 1D float tensor of size equal to rank of input.
663 /// - offset: 1D float tensor of size equal to rank of input.
664 /// - mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
665 /// - name: The name for the operation.
666 /// - Returns: A valid MPSGraphTensor object
667 #[unsafe(method(resizeWithGradientTensor:input:scaleTensor:offsetTensor:mode:name:))]
668 #[unsafe(method_family = none)]
669 pub unsafe fn resizeWithGradientTensor_input_scaleTensor_offsetTensor_mode_name(
670 &self,
671 gradient: &MPSGraphTensor,
672 input: &MPSGraphTensor,
673 scale: &MPSGraphTensor,
674 offset: &MPSGraphTensor,
675 mode: MPSGraphResizeMode,
676 name: Option<&NSString>,
677 ) -> Retained<MPSGraphTensor>;
678
679 #[cfg(feature = "MPSGraphTensor")]
680 /// Creates a Resize gradient operation and returns the result tensor.
681 ///
682 /// Computes the gradient for the forward pass Resize op with identical parameters.
683 /// See discussion of resizeTensor for more in depth description of resize paramters.
684 ///
685 /// - Parameters:
686 /// - gradient: Incoming gradient tensor
687 /// - input: Forward pass input tensor
688 /// - scaleOffset: 1D float tensor. A 4-element shape as [scaleY, scaleX, offsetY, offsetX]
689 /// - nearestRoundingMode: The rounding mode to use when using nearest resampling.
690 /// - layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
691 /// - name: The name for the operation.
692 /// - Returns: A valid MPSGraphTensor object
693 #[unsafe(method(resizeNearestWithGradientTensor:input:scaleOffsetTensor:nearestRoundingMode:layout:name:))]
694 #[unsafe(method_family = none)]
695 pub unsafe fn resizeNearestWithGradientTensor_input_scaleOffsetTensor_nearestRoundingMode_layout_name(
696 &self,
697 gradient: &MPSGraphTensor,
698 input: &MPSGraphTensor,
699 scale_offset: &MPSGraphTensor,
700 nearest_rounding_mode: MPSGraphResizeNearestRoundingMode,
701 layout: MPSGraphTensorNamedDataLayout,
702 name: Option<&NSString>,
703 ) -> Retained<MPSGraphTensor>;
704
705 #[cfg(feature = "MPSGraphTensor")]
706 /// Creates a Resize gradient operation and returns the result tensor.
707 ///
708 /// Computes the gradient for the forward pass Resize op with nearest neighbor sampling and identical parameters.
709 /// See discussion of resizeTensor for more in depth description of resize paramters.
710 ///
711 /// - Parameters:
712 /// - gradient: Incoming gradient tensor
713 /// - input: Forward pass input tensor
714 /// - scale: 1D float tensor of size equal to rank of input.
715 /// - offset: 1D float tensor of size equal to rank of input.
716 /// - nearestRoundingMode: The rounding mode to use when using nearest resampling. Default is roundPreferCeil.
717 /// - name: The name for the operation.
718 /// - Returns: A valid MPSGraphTensor object
719 #[unsafe(method(resizeNearestWithGradientTensor:input:scaleTensor:offsetTensor:nearestRoundingMode:name:))]
720 #[unsafe(method_family = none)]
721 pub unsafe fn resizeNearestWithGradientTensor_input_scaleTensor_offsetTensor_nearestRoundingMode_name(
722 &self,
723 gradient: &MPSGraphTensor,
724 input: &MPSGraphTensor,
725 scale: &MPSGraphTensor,
726 offset: &MPSGraphTensor,
727 nearest_rounding_mode: MPSGraphResizeNearestRoundingMode,
728 name: Option<&NSString>,
729 ) -> Retained<MPSGraphTensor>;
730
731 #[cfg(feature = "MPSGraphTensor")]
732 /// Creates a Resize gradient operation and returns the result tensor.
733 ///
734 /// Computes the gradient for the forward pass Resize op with bilinear sampling and identical parameters.
735 /// See discussion of resizeTensor for more in depth description of resize paramters.
736 ///
737 /// - Parameters:
738 /// - gradient: Incoming gradient tensor
739 /// - input: Forward pass input tensor
740 /// - scaleOffset: 1D float tensor. A 4-element shape as [scaleY, scaleX, offsetY, offsetX]
741 /// - layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
742 /// - name: The name for the operation.
743 /// - Returns: A valid MPSGraphTensor object
744 #[unsafe(method(resizeBilinearWithGradientTensor:input:scaleOffsetTensor:layout:name:))]
745 #[unsafe(method_family = none)]
746 pub unsafe fn resizeBilinearWithGradientTensor_input_scaleOffsetTensor_layout_name(
747 &self,
748 gradient: &MPSGraphTensor,
749 input: &MPSGraphTensor,
750 scale_offset: &MPSGraphTensor,
751 layout: MPSGraphTensorNamedDataLayout,
752 name: Option<&NSString>,
753 ) -> Retained<MPSGraphTensor>;
754
755 #[cfg(feature = "MPSGraphTensor")]
756 /// Creates a Resize gradient operation and returns the result tensor.
757 ///
758 /// Computes the gradient for the forward pass Resize op with bilinear sampling and identical parameters.
759 ///
760 /// - Parameters:
761 /// - gradient: Incoming gradient tensor
762 /// - input: Forward pass input tensor
763 /// - scale: 1D float tensor of size equal to rank of input.
764 /// - offset: 1D float tensor of size equal to rank of input.
765 /// - name: The name for the operation.
766 /// - Returns: A valid MPSGraphTensor object
767 #[unsafe(method(resizeBilinearWithGradientTensor:input:scaleTensor:offsetTensor:name:))]
768 #[unsafe(method_family = none)]
769 pub unsafe fn resizeBilinearWithGradientTensor_input_scaleTensor_offsetTensor_name(
770 &self,
771 gradient: &MPSGraphTensor,
772 input: &MPSGraphTensor,
773 scale: &MPSGraphTensor,
774 offset: &MPSGraphTensor,
775 name: Option<&NSString>,
776 ) -> Retained<MPSGraphTensor>;
777 );
778}