objc2_metal_performance_shaders/generated/MPSNeuralNetwork/
MPSCNNPooling.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7use objc2_metal::*;
8
9use crate::*;
10
11extern_class!(
12    /// Dependencies: This depends on Metal.framework
13    ///
14    /// Pooling is a form of non-linear sub-sampling. Pooling partitions the input image into a set of
15    /// rectangles (overlapping or non-overlapping) and, for each such sub-region, outputs a value.
16    /// The pooling operation is used in computer vision to reduce the dimensionality of intermediate representations.
17    ///
18    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnnpooling?language=objc)
19    #[unsafe(super(MPSCNNKernel, MPSKernel, NSObject))]
20    #[derive(Debug, PartialEq, Eq, Hash)]
21    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
22    pub struct MPSCNNPooling;
23);
24
25#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
26extern_conformance!(
27    unsafe impl NSCoding for MPSCNNPooling {}
28);
29
30#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
31extern_conformance!(
32    unsafe impl NSCopying for MPSCNNPooling {}
33);
34
35#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
36unsafe impl CopyingHelper for MPSCNNPooling {
37    type Result = Self;
38}
39
40#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
41extern_conformance!(
42    unsafe impl NSObjectProtocol for MPSCNNPooling {}
43);
44
45#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
46extern_conformance!(
47    unsafe impl NSSecureCoding for MPSCNNPooling {}
48);
49
50#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
51impl MPSCNNPooling {
52    extern_methods!(
53        /// Initialize a pooling filter
54        ///
55        /// Parameter `device`: The device the filter will run on
56        ///
57        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
58        ///
59        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
60        ///
61        /// Returns: A valid MPSCNNPooling object or nil, if failure.
62        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:))]
63        #[unsafe(method_family = init)]
64        pub unsafe fn initWithDevice_kernelWidth_kernelHeight(
65            this: Allocated<Self>,
66            device: &ProtocolObject<dyn MTLDevice>,
67            kernel_width: NSUInteger,
68            kernel_height: NSUInteger,
69        ) -> Retained<Self>;
70
71        /// Initialize a pooling filter
72        ///
73        /// Parameter `device`: The device the filter will run on
74        ///
75        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
76        ///
77        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
78        ///
79        /// Parameter `strideInPixelsX`: The output stride (downsampling factor) in the x dimension.
80        ///
81        /// Parameter `strideInPixelsY`: The output stride (downsampling factor) in the y dimension.
82        ///
83        /// Returns: A valid MPSCNNPooling object or nil, if failure.
84        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:strideInPixelsX:strideInPixelsY:))]
85        #[unsafe(method_family = init)]
86        pub unsafe fn initWithDevice_kernelWidth_kernelHeight_strideInPixelsX_strideInPixelsY(
87            this: Allocated<Self>,
88            device: &ProtocolObject<dyn MTLDevice>,
89            kernel_width: NSUInteger,
90            kernel_height: NSUInteger,
91            stride_in_pixels_x: NSUInteger,
92            stride_in_pixels_y: NSUInteger,
93        ) -> Retained<Self>;
94
95        /// NSSecureCoding compatability
96        ///
97        /// See
98        /// MPSKernel#initWithCoder.
99        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSCNNPooling
100        ///
101        /// Parameter `device`: The MTLDevice on which to make the MPSCNNPooling
102        ///
103        /// Returns: A new MPSCNNPooling object, or nil if failure.
104        ///
105        /// # Safety
106        ///
107        /// `a_decoder` possibly has further requirements.
108        #[unsafe(method(initWithCoder:device:))]
109        #[unsafe(method_family = init)]
110        pub unsafe fn initWithCoder_device(
111            this: Allocated<Self>,
112            a_decoder: &NSCoder,
113            device: &ProtocolObject<dyn MTLDevice>,
114        ) -> Option<Retained<Self>>;
115
116        #[unsafe(method(initWithDevice:))]
117        #[unsafe(method_family = init)]
118        pub unsafe fn initWithDevice(
119            this: Allocated<Self>,
120            device: &ProtocolObject<dyn MTLDevice>,
121        ) -> Retained<Self>;
122    );
123}
124
125/// Methods declared on superclass `MPSKernel`.
126#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
127impl MPSCNNPooling {
128    extern_methods!(
129        /// Called by NSCoder to decode MPSKernels
130        ///
131        /// This isn't the right interface to decode a MPSKernel, but
132        /// it is the one that NSCoder uses. To enable your NSCoder
133        /// (e.g. NSKeyedUnarchiver) to set which device to use
134        /// extend the object to adopt the MPSDeviceProvider
135        /// protocol. Otherwise, the Metal system default device
136        /// will be used.
137        ///
138        /// # Safety
139        ///
140        /// `a_decoder` possibly has further requirements.
141        #[unsafe(method(initWithCoder:))]
142        #[unsafe(method_family = init)]
143        pub unsafe fn initWithCoder(
144            this: Allocated<Self>,
145            a_decoder: &NSCoder,
146        ) -> Option<Retained<Self>>;
147    );
148}
149
150/// Methods declared on superclass `NSObject`.
151#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
152impl MPSCNNPooling {
153    extern_methods!(
154        #[unsafe(method(init))]
155        #[unsafe(method_family = init)]
156        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
157
158        #[unsafe(method(new))]
159        #[unsafe(method_family = new)]
160        pub unsafe fn new() -> Retained<Self>;
161    );
162}
163
164extern_class!(
165    /// Dependencies: This depends on Metal.framework
166    ///
167    /// Specifies the max pooling filter.  For each pixel, returns the maximum value of pixels
168    /// in the kernelWidth x kernelHeight filter region.
169    ///
170    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnnpoolingmax?language=objc)
171    #[unsafe(super(MPSCNNPooling, MPSCNNKernel, MPSKernel, NSObject))]
172    #[derive(Debug, PartialEq, Eq, Hash)]
173    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
174    pub struct MPSCNNPoolingMax;
175);
176
177#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
178extern_conformance!(
179    unsafe impl NSCoding for MPSCNNPoolingMax {}
180);
181
182#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
183extern_conformance!(
184    unsafe impl NSCopying for MPSCNNPoolingMax {}
185);
186
187#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
188unsafe impl CopyingHelper for MPSCNNPoolingMax {
189    type Result = Self;
190}
191
192#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
193extern_conformance!(
194    unsafe impl NSObjectProtocol for MPSCNNPoolingMax {}
195);
196
197#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
198extern_conformance!(
199    unsafe impl NSSecureCoding for MPSCNNPoolingMax {}
200);
201
202#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
203impl MPSCNNPoolingMax {
204    extern_methods!(
205        /// Initialize a MPSCNNPoolingMax pooling filter
206        ///
207        /// Parameter `device`: The device the filter will run on
208        ///
209        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
210        ///
211        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
212        ///
213        /// Parameter `strideInPixelsX`: The output stride (downsampling factor) in the x dimension.
214        ///
215        /// Parameter `strideInPixelsY`: The output stride (downsampling factor) in the y dimension.
216        ///
217        /// Returns: A valid MPSCNNPooling object or nil, if failure.
218        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:strideInPixelsX:strideInPixelsY:))]
219        #[unsafe(method_family = init)]
220        pub unsafe fn initWithDevice_kernelWidth_kernelHeight_strideInPixelsX_strideInPixelsY(
221            this: Allocated<Self>,
222            device: &ProtocolObject<dyn MTLDevice>,
223            kernel_width: NSUInteger,
224            kernel_height: NSUInteger,
225            stride_in_pixels_x: NSUInteger,
226            stride_in_pixels_y: NSUInteger,
227        ) -> Retained<Self>;
228
229        /// NSSecureCoding compatability
230        ///
231        /// See
232        /// MPSKernel#initWithCoder.
233        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSCNNPooling
234        ///
235        /// Parameter `device`: The MTLDevice on which to make the MPSCNNPooling
236        ///
237        /// Returns: A new MPSCNNPooling object, or nil if failure.
238        ///
239        /// # Safety
240        ///
241        /// `a_decoder` possibly has further requirements.
242        #[unsafe(method(initWithCoder:device:))]
243        #[unsafe(method_family = init)]
244        pub unsafe fn initWithCoder_device(
245            this: Allocated<Self>,
246            a_decoder: &NSCoder,
247            device: &ProtocolObject<dyn MTLDevice>,
248        ) -> Option<Retained<Self>>;
249    );
250}
251
252/// Methods declared on superclass `MPSCNNPooling`.
253#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
254impl MPSCNNPoolingMax {
255    extern_methods!(
256        /// Initialize a pooling filter
257        ///
258        /// Parameter `device`: The device the filter will run on
259        ///
260        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
261        ///
262        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
263        ///
264        /// Returns: A valid MPSCNNPooling object or nil, if failure.
265        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:))]
266        #[unsafe(method_family = init)]
267        pub unsafe fn initWithDevice_kernelWidth_kernelHeight(
268            this: Allocated<Self>,
269            device: &ProtocolObject<dyn MTLDevice>,
270            kernel_width: NSUInteger,
271            kernel_height: NSUInteger,
272        ) -> Retained<Self>;
273
274        #[unsafe(method(initWithDevice:))]
275        #[unsafe(method_family = init)]
276        pub unsafe fn initWithDevice(
277            this: Allocated<Self>,
278            device: &ProtocolObject<dyn MTLDevice>,
279        ) -> Retained<Self>;
280    );
281}
282
283/// Methods declared on superclass `MPSKernel`.
284#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
285impl MPSCNNPoolingMax {
286    extern_methods!(
287        /// Called by NSCoder to decode MPSKernels
288        ///
289        /// This isn't the right interface to decode a MPSKernel, but
290        /// it is the one that NSCoder uses. To enable your NSCoder
291        /// (e.g. NSKeyedUnarchiver) to set which device to use
292        /// extend the object to adopt the MPSDeviceProvider
293        /// protocol. Otherwise, the Metal system default device
294        /// will be used.
295        ///
296        /// # Safety
297        ///
298        /// `a_decoder` possibly has further requirements.
299        #[unsafe(method(initWithCoder:))]
300        #[unsafe(method_family = init)]
301        pub unsafe fn initWithCoder(
302            this: Allocated<Self>,
303            a_decoder: &NSCoder,
304        ) -> Option<Retained<Self>>;
305    );
306}
307
308/// Methods declared on superclass `NSObject`.
309#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
310impl MPSCNNPoolingMax {
311    extern_methods!(
312        #[unsafe(method(init))]
313        #[unsafe(method_family = init)]
314        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
315
316        #[unsafe(method(new))]
317        #[unsafe(method_family = new)]
318        pub unsafe fn new() -> Retained<Self>;
319    );
320}
321
322extern_class!(
323    /// Dependencies: This depends on Metal.framework
324    ///
325    /// Specifies the average pooling filter.  For each pixel, returns the mean value of pixels
326    /// in the kernelWidth x kernelHeight filter region.
327    /// When
328    /// edgeModeis
329    /// MPSImageEdgeModeClampthe filtering window is shrunk to remain
330    /// within the source image borders. What this means is that close to image borders the filtering window
331    /// will be smaller in order to fit inside the source image and less values will be used to compute the
332    /// average. In case the filtering window is entirely outside the source image border the
333    /// outputted value will be zero.
334    ///
335    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnnpoolingaverage?language=objc)
336    #[unsafe(super(MPSCNNPooling, MPSCNNKernel, MPSKernel, NSObject))]
337    #[derive(Debug, PartialEq, Eq, Hash)]
338    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
339    pub struct MPSCNNPoolingAverage;
340);
341
342#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
343extern_conformance!(
344    unsafe impl NSCoding for MPSCNNPoolingAverage {}
345);
346
347#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
348extern_conformance!(
349    unsafe impl NSCopying for MPSCNNPoolingAverage {}
350);
351
352#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
353unsafe impl CopyingHelper for MPSCNNPoolingAverage {
354    type Result = Self;
355}
356
357#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
358extern_conformance!(
359    unsafe impl NSObjectProtocol for MPSCNNPoolingAverage {}
360);
361
362#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
363extern_conformance!(
364    unsafe impl NSSecureCoding for MPSCNNPoolingAverage {}
365);
366
367#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
368impl MPSCNNPoolingAverage {
369    extern_methods!(
370        /// How much zero padding to apply to both left and right borders of the input image for average pooling,
371        /// when using
372        ///
373        /// See: edgeMode MPSImageEdgeModeClamp. For
374        ///
375        /// See: edgeMode MPSImageEdgeModeZero this property is
376        /// ignored and the area outside the image is interpreted to contain zeros.
377        /// The zero padding size is used to shrink the pooling window to fit inside the area bound by the source image
378        /// and its padding region, but the effect is that the normalization factor of the average computation is computed
379        /// also for the zeros in the padding region.
380        #[unsafe(method(zeroPadSizeX))]
381        #[unsafe(method_family = none)]
382        pub unsafe fn zeroPadSizeX(&self) -> NSUInteger;
383
384        /// Setter for [`zeroPadSizeX`][Self::zeroPadSizeX].
385        #[unsafe(method(setZeroPadSizeX:))]
386        #[unsafe(method_family = none)]
387        pub unsafe fn setZeroPadSizeX(&self, zero_pad_size_x: NSUInteger);
388
389        /// How much zero padding to apply to both top and bottom borders of the input image for average pooling,
390        /// when using
391        ///
392        /// See: edgeMode MPSImageEdgeModeClamp. For
393        ///
394        /// See: edgeMode MPSImageEdgeModeZero this property is
395        /// ignored and the area outside the image is interpreted to contain zeros.
396        /// The zero padding size is used to shrink the pooling window to fit inside the area bound by the source image
397        /// and its padding region, but the effect is that the normalization factor of the average computation is computed
398        /// also for the zeros in the padding region.
399        #[unsafe(method(zeroPadSizeY))]
400        #[unsafe(method_family = none)]
401        pub unsafe fn zeroPadSizeY(&self) -> NSUInteger;
402
403        /// Setter for [`zeroPadSizeY`][Self::zeroPadSizeY].
404        #[unsafe(method(setZeroPadSizeY:))]
405        #[unsafe(method_family = none)]
406        pub unsafe fn setZeroPadSizeY(&self, zero_pad_size_y: NSUInteger);
407
408        /// Initialize a MPSCNNPoolingAverage pooling filter
409        ///
410        /// Parameter `device`: The device the filter will run on
411        ///
412        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
413        ///
414        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
415        ///
416        /// Parameter `strideInPixelsX`: The output stride (downsampling factor) in the x dimension.
417        ///
418        /// Parameter `strideInPixelsY`: The output stride (downsampling factor) in the y dimension.
419        ///
420        /// Returns: A valid MPSCNNPooling object or nil, if failure.
421        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:strideInPixelsX:strideInPixelsY:))]
422        #[unsafe(method_family = init)]
423        pub unsafe fn initWithDevice_kernelWidth_kernelHeight_strideInPixelsX_strideInPixelsY(
424            this: Allocated<Self>,
425            device: &ProtocolObject<dyn MTLDevice>,
426            kernel_width: NSUInteger,
427            kernel_height: NSUInteger,
428            stride_in_pixels_x: NSUInteger,
429            stride_in_pixels_y: NSUInteger,
430        ) -> Retained<Self>;
431
432        /// NSSecureCoding compatability
433        ///
434        /// See
435        /// MPSKernel#initWithCoder.
436        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSCNNPooling
437        ///
438        /// Parameter `device`: The MTLDevice on which to make the MPSCNNPooling
439        ///
440        /// Returns: A new MPSCNNPooling object, or nil if failure.
441        ///
442        /// # Safety
443        ///
444        /// `a_decoder` possibly has further requirements.
445        #[unsafe(method(initWithCoder:device:))]
446        #[unsafe(method_family = init)]
447        pub unsafe fn initWithCoder_device(
448            this: Allocated<Self>,
449            a_decoder: &NSCoder,
450            device: &ProtocolObject<dyn MTLDevice>,
451        ) -> Option<Retained<Self>>;
452    );
453}
454
455/// Methods declared on superclass `MPSCNNPooling`.
456#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
457impl MPSCNNPoolingAverage {
458    extern_methods!(
459        /// Initialize a pooling filter
460        ///
461        /// Parameter `device`: The device the filter will run on
462        ///
463        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
464        ///
465        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
466        ///
467        /// Returns: A valid MPSCNNPooling object or nil, if failure.
468        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:))]
469        #[unsafe(method_family = init)]
470        pub unsafe fn initWithDevice_kernelWidth_kernelHeight(
471            this: Allocated<Self>,
472            device: &ProtocolObject<dyn MTLDevice>,
473            kernel_width: NSUInteger,
474            kernel_height: NSUInteger,
475        ) -> Retained<Self>;
476
477        #[unsafe(method(initWithDevice:))]
478        #[unsafe(method_family = init)]
479        pub unsafe fn initWithDevice(
480            this: Allocated<Self>,
481            device: &ProtocolObject<dyn MTLDevice>,
482        ) -> Retained<Self>;
483    );
484}
485
486/// Methods declared on superclass `MPSKernel`.
487#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
488impl MPSCNNPoolingAverage {
489    extern_methods!(
490        /// Called by NSCoder to decode MPSKernels
491        ///
492        /// This isn't the right interface to decode a MPSKernel, but
493        /// it is the one that NSCoder uses. To enable your NSCoder
494        /// (e.g. NSKeyedUnarchiver) to set which device to use
495        /// extend the object to adopt the MPSDeviceProvider
496        /// protocol. Otherwise, the Metal system default device
497        /// will be used.
498        ///
499        /// # Safety
500        ///
501        /// `a_decoder` possibly has further requirements.
502        #[unsafe(method(initWithCoder:))]
503        #[unsafe(method_family = init)]
504        pub unsafe fn initWithCoder(
505            this: Allocated<Self>,
506            a_decoder: &NSCoder,
507        ) -> Option<Retained<Self>>;
508    );
509}
510
511/// Methods declared on superclass `NSObject`.
512#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
513impl MPSCNNPoolingAverage {
514    extern_methods!(
515        #[unsafe(method(init))]
516        #[unsafe(method_family = init)]
517        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
518
519        #[unsafe(method(new))]
520        #[unsafe(method_family = new)]
521        pub unsafe fn new() -> Retained<Self>;
522    );
523}
524
525extern_class!(
526    /// Dependencies: This depends on Metal.framework
527    ///
528    /// Specifies the L2-norm pooling filter.  For each pixel, returns L2-Norm of pixels
529    /// in the kernelWidth x kernelHeight filter region.
530    /// out[c,x,y] = sqrt ( sum_{dx,dy} in[c,x+dx,y+dy] * in[c,x+dx,y+dy] ).
531    ///
532    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnnpoolingl2norm?language=objc)
533    #[unsafe(super(MPSCNNPooling, MPSCNNKernel, MPSKernel, NSObject))]
534    #[derive(Debug, PartialEq, Eq, Hash)]
535    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
536    pub struct MPSCNNPoolingL2Norm;
537);
538
539#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
540extern_conformance!(
541    unsafe impl NSCoding for MPSCNNPoolingL2Norm {}
542);
543
544#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
545extern_conformance!(
546    unsafe impl NSCopying for MPSCNNPoolingL2Norm {}
547);
548
549#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
550unsafe impl CopyingHelper for MPSCNNPoolingL2Norm {
551    type Result = Self;
552}
553
554#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
555extern_conformance!(
556    unsafe impl NSObjectProtocol for MPSCNNPoolingL2Norm {}
557);
558
559#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
560extern_conformance!(
561    unsafe impl NSSecureCoding for MPSCNNPoolingL2Norm {}
562);
563
564#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
565impl MPSCNNPoolingL2Norm {
566    extern_methods!(
567        /// Initialize a MPSCNNPoolingL2Norm pooling filter
568        ///
569        /// Parameter `device`: The device the filter will run on
570        ///
571        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
572        ///
573        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
574        ///
575        /// Parameter `strideInPixelsX`: The output stride (downsampling factor) in the x dimension.
576        ///
577        /// Parameter `strideInPixelsY`: The output stride (downsampling factor) in the y dimension.
578        ///
579        /// Returns: A valid MPSCNNPooling object or nil, if failure.
580        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:strideInPixelsX:strideInPixelsY:))]
581        #[unsafe(method_family = init)]
582        pub unsafe fn initWithDevice_kernelWidth_kernelHeight_strideInPixelsX_strideInPixelsY(
583            this: Allocated<Self>,
584            device: &ProtocolObject<dyn MTLDevice>,
585            kernel_width: NSUInteger,
586            kernel_height: NSUInteger,
587            stride_in_pixels_x: NSUInteger,
588            stride_in_pixels_y: NSUInteger,
589        ) -> Retained<Self>;
590
591        /// NSSecureCoding compatability
592        ///
593        /// See
594        /// MPSKernel#initWithCoder.
595        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSCNNPooling
596        ///
597        /// Parameter `device`: The MTLDevice on which to make the MPSCNNPooling
598        ///
599        /// Returns: A new MPSCNNPooling object, or nil if failure.
600        ///
601        /// # Safety
602        ///
603        /// `a_decoder` possibly has further requirements.
604        #[unsafe(method(initWithCoder:device:))]
605        #[unsafe(method_family = init)]
606        pub unsafe fn initWithCoder_device(
607            this: Allocated<Self>,
608            a_decoder: &NSCoder,
609            device: &ProtocolObject<dyn MTLDevice>,
610        ) -> Option<Retained<Self>>;
611    );
612}
613
614/// Methods declared on superclass `MPSCNNPooling`.
615#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
616impl MPSCNNPoolingL2Norm {
617    extern_methods!(
618        /// Initialize a pooling filter
619        ///
620        /// Parameter `device`: The device the filter will run on
621        ///
622        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
623        ///
624        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
625        ///
626        /// Returns: A valid MPSCNNPooling object or nil, if failure.
627        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:))]
628        #[unsafe(method_family = init)]
629        pub unsafe fn initWithDevice_kernelWidth_kernelHeight(
630            this: Allocated<Self>,
631            device: &ProtocolObject<dyn MTLDevice>,
632            kernel_width: NSUInteger,
633            kernel_height: NSUInteger,
634        ) -> Retained<Self>;
635
636        #[unsafe(method(initWithDevice:))]
637        #[unsafe(method_family = init)]
638        pub unsafe fn initWithDevice(
639            this: Allocated<Self>,
640            device: &ProtocolObject<dyn MTLDevice>,
641        ) -> Retained<Self>;
642    );
643}
644
645/// Methods declared on superclass `MPSKernel`.
646#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
647impl MPSCNNPoolingL2Norm {
648    extern_methods!(
649        /// Called by NSCoder to decode MPSKernels
650        ///
651        /// This isn't the right interface to decode a MPSKernel, but
652        /// it is the one that NSCoder uses. To enable your NSCoder
653        /// (e.g. NSKeyedUnarchiver) to set which device to use
654        /// extend the object to adopt the MPSDeviceProvider
655        /// protocol. Otherwise, the Metal system default device
656        /// will be used.
657        ///
658        /// # Safety
659        ///
660        /// `a_decoder` possibly has further requirements.
661        #[unsafe(method(initWithCoder:))]
662        #[unsafe(method_family = init)]
663        pub unsafe fn initWithCoder(
664            this: Allocated<Self>,
665            a_decoder: &NSCoder,
666        ) -> Option<Retained<Self>>;
667    );
668}
669
670/// Methods declared on superclass `NSObject`.
671#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
672impl MPSCNNPoolingL2Norm {
673    extern_methods!(
674        #[unsafe(method(init))]
675        #[unsafe(method_family = init)]
676        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
677
678        #[unsafe(method(new))]
679        #[unsafe(method_family = new)]
680        pub unsafe fn new() -> Retained<Self>;
681    );
682}
683
684extern_class!(
685    /// Dependencies: This depends on Metal.framework
686    ///
687    /// Specifies the dilated max pooling filter.  For each pixel, returns the maximum value of pixels
688    /// in the kernelWidth x kernelHeight filter region by step size dilationRateX x dilationRateY.
689    ///
690    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnndilatedpoolingmax?language=objc)
691    #[unsafe(super(MPSCNNPooling, MPSCNNKernel, MPSKernel, NSObject))]
692    #[derive(Debug, PartialEq, Eq, Hash)]
693    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
694    pub struct MPSCNNDilatedPoolingMax;
695);
696
697#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
698extern_conformance!(
699    unsafe impl NSCoding for MPSCNNDilatedPoolingMax {}
700);
701
702#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
703extern_conformance!(
704    unsafe impl NSCopying for MPSCNNDilatedPoolingMax {}
705);
706
707#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
708unsafe impl CopyingHelper for MPSCNNDilatedPoolingMax {
709    type Result = Self;
710}
711
712#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
713extern_conformance!(
714    unsafe impl NSObjectProtocol for MPSCNNDilatedPoolingMax {}
715);
716
717#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
718extern_conformance!(
719    unsafe impl NSSecureCoding for MPSCNNDilatedPoolingMax {}
720);
721
722#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
723impl MPSCNNDilatedPoolingMax {
724    extern_methods!(
725        /// dilationRateX for accessing the image passed in as source
726        #[unsafe(method(dilationRateX))]
727        #[unsafe(method_family = none)]
728        pub unsafe fn dilationRateX(&self) -> NSUInteger;
729
730        /// dilationRateY for accessing the image passed in as source
731        #[unsafe(method(dilationRateY))]
732        #[unsafe(method_family = none)]
733        pub unsafe fn dilationRateY(&self) -> NSUInteger;
734
735        /// Initialize a MPSCNNDilatedPoolingMax pooling filter
736        ///
737        /// Parameter `device`: The device the filter will run on
738        ///
739        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
740        ///
741        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
742        ///
743        /// Parameter `dilationRateX`: The dilation rate in the x dimension.
744        ///
745        /// Parameter `dilationRateY`: The dilation rate in the y dimension.
746        ///
747        /// Parameter `strideInPixelsX`: The output stride (downsampling factor) in the x dimension.
748        ///
749        /// Parameter `strideInPixelsY`: The output stride (downsampling factor) in the y dimension.
750        ///
751        /// Returns: A valid MPSCNNDilatedPoolingMax object or nil, if failure.
752        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:dilationRateX:dilationRateY:strideInPixelsX:strideInPixelsY:))]
753        #[unsafe(method_family = init)]
754        pub unsafe fn initWithDevice_kernelWidth_kernelHeight_dilationRateX_dilationRateY_strideInPixelsX_strideInPixelsY(
755            this: Allocated<Self>,
756            device: &ProtocolObject<dyn MTLDevice>,
757            kernel_width: NSUInteger,
758            kernel_height: NSUInteger,
759            dilation_rate_x: NSUInteger,
760            dilation_rate_y: NSUInteger,
761            stride_in_pixels_x: NSUInteger,
762            stride_in_pixels_y: NSUInteger,
763        ) -> Retained<Self>;
764
765        /// NSSecureCoding compatability
766        ///
767        /// See
768        /// MPSKernel.hinitWithCoder.
769        ///
770        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSCNNDilatedPoolingMax
771        ///
772        /// Parameter `device`: The MTLDevice on which to make the MPSCNNDilatedPoolingMax
773        ///
774        /// Returns: A new MPSCNNDilatedPoolingMax object, or nil if failure.
775        ///
776        /// # Safety
777        ///
778        /// `a_decoder` possibly has further requirements.
779        #[unsafe(method(initWithCoder:device:))]
780        #[unsafe(method_family = init)]
781        pub unsafe fn initWithCoder_device(
782            this: Allocated<Self>,
783            a_decoder: &NSCoder,
784            device: &ProtocolObject<dyn MTLDevice>,
785        ) -> Option<Retained<Self>>;
786    );
787}
788
789/// Methods declared on superclass `MPSCNNPooling`.
790#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
791impl MPSCNNDilatedPoolingMax {
792    extern_methods!(
793        /// Initialize a pooling filter
794        ///
795        /// Parameter `device`: The device the filter will run on
796        ///
797        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
798        ///
799        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
800        ///
801        /// Returns: A valid MPSCNNPooling object or nil, if failure.
802        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:))]
803        #[unsafe(method_family = init)]
804        pub unsafe fn initWithDevice_kernelWidth_kernelHeight(
805            this: Allocated<Self>,
806            device: &ProtocolObject<dyn MTLDevice>,
807            kernel_width: NSUInteger,
808            kernel_height: NSUInteger,
809        ) -> Retained<Self>;
810
811        /// Initialize a pooling filter
812        ///
813        /// Parameter `device`: The device the filter will run on
814        ///
815        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
816        ///
817        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
818        ///
819        /// Parameter `strideInPixelsX`: The output stride (downsampling factor) in the x dimension.
820        ///
821        /// Parameter `strideInPixelsY`: The output stride (downsampling factor) in the y dimension.
822        ///
823        /// Returns: A valid MPSCNNPooling object or nil, if failure.
824        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:strideInPixelsX:strideInPixelsY:))]
825        #[unsafe(method_family = init)]
826        pub unsafe fn initWithDevice_kernelWidth_kernelHeight_strideInPixelsX_strideInPixelsY(
827            this: Allocated<Self>,
828            device: &ProtocolObject<dyn MTLDevice>,
829            kernel_width: NSUInteger,
830            kernel_height: NSUInteger,
831            stride_in_pixels_x: NSUInteger,
832            stride_in_pixels_y: NSUInteger,
833        ) -> Retained<Self>;
834
835        #[unsafe(method(initWithDevice:))]
836        #[unsafe(method_family = init)]
837        pub unsafe fn initWithDevice(
838            this: Allocated<Self>,
839            device: &ProtocolObject<dyn MTLDevice>,
840        ) -> Retained<Self>;
841    );
842}
843
844/// Methods declared on superclass `MPSKernel`.
845#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
846impl MPSCNNDilatedPoolingMax {
847    extern_methods!(
848        /// Called by NSCoder to decode MPSKernels
849        ///
850        /// This isn't the right interface to decode a MPSKernel, but
851        /// it is the one that NSCoder uses. To enable your NSCoder
852        /// (e.g. NSKeyedUnarchiver) to set which device to use
853        /// extend the object to adopt the MPSDeviceProvider
854        /// protocol. Otherwise, the Metal system default device
855        /// will be used.
856        ///
857        /// # Safety
858        ///
859        /// `a_decoder` possibly has further requirements.
860        #[unsafe(method(initWithCoder:))]
861        #[unsafe(method_family = init)]
862        pub unsafe fn initWithCoder(
863            this: Allocated<Self>,
864            a_decoder: &NSCoder,
865        ) -> Option<Retained<Self>>;
866    );
867}
868
869/// Methods declared on superclass `NSObject`.
870#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
871impl MPSCNNDilatedPoolingMax {
872    extern_methods!(
873        #[unsafe(method(init))]
874        #[unsafe(method_family = init)]
875        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
876
877        #[unsafe(method(new))]
878        #[unsafe(method_family = new)]
879        pub unsafe fn new() -> Retained<Self>;
880    );
881}
882
883extern_class!(
884    /// Dependencies: This depends on Metal.framework
885    ///
886    /// Specifies the base class for computing the gradient of the pooling filters.
887    /// The operation backpropagates a gradient vector using the chain rule.
888    ///
889    /// Given the input gradient vector dL(x) = dL/d out(x), which is the derivative of the
890    /// loss-function wrt. (original) pooling filter output the output gradient at position y
891    /// (dL/d in(y)) is computed as follows:
892    ///
893    /// dL/d in(y) = sum_x (dL/d out(x)) * (d out(x)/d in(y)), where
894    ///
895    /// the sum runs over the input gradient pixels starting from primaryOffset
896    /// extending to primaryOffset + sourceSize. Note here that we need a separate
897    /// variable 'sourceSize' to specify which input gradients are included in the output
898    /// gradient computation as this information cannot be deduced directly from the cliprect
899    /// size due to fractional striding or simply because the user wants to examine a subset
900    /// of the contributions to the gradients. In normal operation the sourceSize is specified
901    /// as the cliprect.size of the forward pooling filter in order to compute the gradients for
902    /// all outputs the forward direction produced and the primaryOffset is set to
903    /// cliprect.origin of the original forward pooling operation for the same reason.
904    ///
905    /// The cliprect property of the filter allows the user to send the gradients to a new location,
906    /// which may not match the original forward pooling filter window locations:
907    /// The index 'y' in the formula above refers to the pixel location in the secondary source,
908    /// which is the source image of the original forward pooling filter and secondaryOffset specifies
909    /// the center of the first pooling window as specified in MPSCNNPooling filter specification.
910    /// The first (top leftmost) pixel written into the cliprect computes the derivative of the first pixel
911    /// within the first pooling window that is contained within the secondary source image and
912    /// subsequent values are defined by normal striding rules from secondary source to primary source.
913    /// This means that typically the cliprect is set to fill the effective source area of the original forward
914    /// operation, clamped to edges of the original source image, which in the normal case is the same size
915    /// as the size of the gradient destination image.
916    ///
917    /// If there are any values in the destination cliprect that do not contribute to the forward
918    /// pooling result in the area specified by primaryOffset and sourceSize,
919    /// due to large strides or dilation factors or simply because all forward pass induced values would be
920    /// outside the source area, then those result values are set to zero.
921    ///
922    /// The actual value of d out(x) / d in(y) depends on the pooling operation and these are defined in the
923    /// subclasses of MPSCNNPoolingGradient.
924    ///
925    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnnpoolinggradient?language=objc)
926    #[unsafe(super(MPSCNNGradientKernel, MPSCNNBinaryKernel, MPSKernel, NSObject))]
927    #[derive(Debug, PartialEq, Eq, Hash)]
928    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
929    pub struct MPSCNNPoolingGradient;
930);
931
932#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
933extern_conformance!(
934    unsafe impl NSCoding for MPSCNNPoolingGradient {}
935);
936
937#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
938extern_conformance!(
939    unsafe impl NSCopying for MPSCNNPoolingGradient {}
940);
941
942#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
943unsafe impl CopyingHelper for MPSCNNPoolingGradient {
944    type Result = Self;
945}
946
947#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
948extern_conformance!(
949    unsafe impl NSObjectProtocol for MPSCNNPoolingGradient {}
950);
951
952#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
953extern_conformance!(
954    unsafe impl NSSecureCoding for MPSCNNPoolingGradient {}
955);
956
957#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
958impl MPSCNNPoolingGradient {
959    extern_methods!(
960        /// An optional source size which defines together with primaryOffset, the set of input gradient
961        /// pixels to take into account in the gradient computations.
962        ///
963        /// A MTLSize that together with primaryOffset indicates which part of the source gradient to consider.
964        /// If the area does not lie completely within the primary source image, the intersection between
965        /// source area rectangle and primary source bounds is used.
966        /// Default: A size where every component is NSUIntegerMax indicating the entire rest of the image,
967        /// starting from an offset (see primaryOffset).
968        #[unsafe(method(sourceSize))]
969        #[unsafe(method_family = none)]
970        pub unsafe fn sourceSize(&self) -> MTLSize;
971
972        /// Setter for [`sourceSize`][Self::sourceSize].
973        #[unsafe(method(setSourceSize:))]
974        #[unsafe(method_family = none)]
975        pub unsafe fn setSourceSize(&self, source_size: MTLSize);
976
977        /// Initialize a gradient pooling filter
978        ///
979        /// Parameter `device`: The device the filter will run on
980        ///
981        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
982        ///
983        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
984        ///
985        /// Returns: A valid MPSCNNPoolingGradient object or nil, if failure.
986        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:))]
987        #[unsafe(method_family = init)]
988        pub unsafe fn initWithDevice_kernelWidth_kernelHeight(
989            this: Allocated<Self>,
990            device: &ProtocolObject<dyn MTLDevice>,
991            kernel_width: NSUInteger,
992            kernel_height: NSUInteger,
993        ) -> Retained<Self>;
994
995        /// Initialize a gradient pooling filter
996        ///
997        /// Parameter `device`: The device the filter will run on
998        ///
999        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
1000        ///
1001        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
1002        ///
1003        /// Parameter `strideInPixelsX`: The input stride (upsampling factor) in the x dimension.
1004        ///
1005        /// Parameter `strideInPixelsY`: The input stride (upsampling factor) in the y dimension.
1006        ///
1007        /// Returns: A valid MPSCNNPoolingGradient object or nil, if failure.
1008        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:strideInPixelsX:strideInPixelsY:))]
1009        #[unsafe(method_family = init)]
1010        pub unsafe fn initWithDevice_kernelWidth_kernelHeight_strideInPixelsX_strideInPixelsY(
1011            this: Allocated<Self>,
1012            device: &ProtocolObject<dyn MTLDevice>,
1013            kernel_width: NSUInteger,
1014            kernel_height: NSUInteger,
1015            stride_in_pixels_x: NSUInteger,
1016            stride_in_pixels_y: NSUInteger,
1017        ) -> Retained<Self>;
1018
1019        #[unsafe(method(initWithDevice:))]
1020        #[unsafe(method_family = init)]
1021        pub unsafe fn initWithDevice(
1022            this: Allocated<Self>,
1023            device: &ProtocolObject<dyn MTLDevice>,
1024        ) -> Retained<Self>;
1025
1026        /// NSSecureCoding compatability
1027        ///
1028        /// See
1029        /// MPSKernel#initWithCoder.
1030        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSCNNPoolingGradient
1031        ///
1032        /// Parameter `device`: The MTLDevice on which to make the MPSCNNPoolingGradient
1033        ///
1034        /// Returns: A new MPSCNNPooling object, or nil if failure.
1035        ///
1036        /// # Safety
1037        ///
1038        /// `a_decoder` possibly has further requirements.
1039        #[unsafe(method(initWithCoder:device:))]
1040        #[unsafe(method_family = init)]
1041        pub unsafe fn initWithCoder_device(
1042            this: Allocated<Self>,
1043            a_decoder: &NSCoder,
1044            device: &ProtocolObject<dyn MTLDevice>,
1045        ) -> Option<Retained<Self>>;
1046    );
1047}
1048
1049/// Methods declared on superclass `MPSKernel`.
1050#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1051impl MPSCNNPoolingGradient {
1052    extern_methods!(
1053        /// Called by NSCoder to decode MPSKernels
1054        ///
1055        /// This isn't the right interface to decode a MPSKernel, but
1056        /// it is the one that NSCoder uses. To enable your NSCoder
1057        /// (e.g. NSKeyedUnarchiver) to set which device to use
1058        /// extend the object to adopt the MPSDeviceProvider
1059        /// protocol. Otherwise, the Metal system default device
1060        /// will be used.
1061        ///
1062        /// # Safety
1063        ///
1064        /// `a_decoder` possibly has further requirements.
1065        #[unsafe(method(initWithCoder:))]
1066        #[unsafe(method_family = init)]
1067        pub unsafe fn initWithCoder(
1068            this: Allocated<Self>,
1069            a_decoder: &NSCoder,
1070        ) -> Option<Retained<Self>>;
1071    );
1072}
1073
1074/// Methods declared on superclass `NSObject`.
1075#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1076impl MPSCNNPoolingGradient {
1077    extern_methods!(
1078        #[unsafe(method(init))]
1079        #[unsafe(method_family = init)]
1080        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1081
1082        #[unsafe(method(new))]
1083        #[unsafe(method_family = new)]
1084        pub unsafe fn new() -> Retained<Self>;
1085    );
1086}
1087
1088extern_class!(
1089    /// Dependencies: This depends on Metal.framework
1090    ///
1091    /// Specifies the filter for computing the gradient of the average pooling filter.
1092    /// The operation backpropagates a gradient vector using chain rule.
1093    ///
1094    /// Average pooling forward pass is defined as:
1095    ///
1096    /// out(x) = sum_{dx
1097    /// \in Window(x)} in(s*x+dx) / N(x), where
1098    ///
1099    /// the pooling window definition 'Window(x)' follows MPSCNNPooling specification,
1100    /// 'N(x)' is effective pooling window size in pixels as specified in MPSCNNPoolingAverage,
1101    /// 's' is the pixel stride and in() is the source input image.
1102    ///
1103    /// Hence the partial derivative of the output value wrt. to the input value needed in the
1104    /// gradient backpropagation in MPSCNNPoolingGradient is:
1105    ///
1106    /// d out(x)/d in(y) = sum_{dx
1107    /// \in Window(x)} delta_{s*x+dx, y} / N(x), where
1108    ///
1109    /// delta_{x,y} is the Kronecker delta symbol for which
1110    ///
1111    /// delta_{x,y} =  {  1, when x == y
1112    /// {  0, otherwise.
1113    ///
1114    /// In practice this means that the gradient value for the destination image at pixel 'x' is
1115    /// the sum over these contributions coming from all pooling windows that contribute
1116    /// to the average pooling computation in the forward pass, multiplied by the input
1117    /// gradient value in the source area of the corresponding pooling window.
1118    ///
1119    /// Note: As average pooling is a linear operation of its inputs, the gradient does not
1120    /// depend at all on the original input values, but the original input image size is needed
1121    /// so that we know the limits where the input values seize to exist to inhibit accumulation
1122    /// of gradient values for those pixels. Therefore, as secondary input, any correctly sized
1123    /// image will produce correct results for the gradient backpropagation and hence it is
1124    /// recommended to use a temporary image of correct size (see MPSTemporaryImage) for the
1125    /// secondary source image parameter.
1126    ///
1127    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnnpoolingaveragegradient?language=objc)
1128    #[unsafe(super(
1129        MPSCNNPoolingGradient,
1130        MPSCNNGradientKernel,
1131        MPSCNNBinaryKernel,
1132        MPSKernel,
1133        NSObject
1134    ))]
1135    #[derive(Debug, PartialEq, Eq, Hash)]
1136    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1137    pub struct MPSCNNPoolingAverageGradient;
1138);
1139
1140#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1141extern_conformance!(
1142    unsafe impl NSCoding for MPSCNNPoolingAverageGradient {}
1143);
1144
1145#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1146extern_conformance!(
1147    unsafe impl NSCopying for MPSCNNPoolingAverageGradient {}
1148);
1149
1150#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1151unsafe impl CopyingHelper for MPSCNNPoolingAverageGradient {
1152    type Result = Self;
1153}
1154
1155#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1156extern_conformance!(
1157    unsafe impl NSObjectProtocol for MPSCNNPoolingAverageGradient {}
1158);
1159
1160#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1161extern_conformance!(
1162    unsafe impl NSSecureCoding for MPSCNNPoolingAverageGradient {}
1163);
1164
1165#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1166impl MPSCNNPoolingAverageGradient {
1167    extern_methods!(
1168        /// How much zero padding to apply to both left and right borders of the input image for average pooling,
1169        /// when using
1170        ///
1171        /// See: edgeMode MPSImageEdgeModeClamp. For
1172        ///
1173        /// See: edgeMode MPSImageEdgeModeZero this property is
1174        /// ignored and the area outside the image is interpreted to contain zeros.
1175        /// The zero padding size is used to shrink the pooling window to fit inside the area bound by the source image
1176        /// and its padding region, but the effect is that the normalization factor of the average computation is computed
1177        /// also for the zeros in the padding region.
1178        #[unsafe(method(zeroPadSizeX))]
1179        #[unsafe(method_family = none)]
1180        pub unsafe fn zeroPadSizeX(&self) -> NSUInteger;
1181
1182        /// Setter for [`zeroPadSizeX`][Self::zeroPadSizeX].
1183        #[unsafe(method(setZeroPadSizeX:))]
1184        #[unsafe(method_family = none)]
1185        pub unsafe fn setZeroPadSizeX(&self, zero_pad_size_x: NSUInteger);
1186
1187        /// How much zero padding to apply to both top and bottom borders of the input image for average pooling,
1188        /// when using
1189        ///
1190        /// See: edgeMode MPSImageEdgeModeClamp. For
1191        ///
1192        /// See: edgeMode MPSImageEdgeModeZero this property is
1193        /// ignored and the area outside the image is interpreted to contain zeros.
1194        /// The zero padding size is used to shrink the pooling window to fit inside the area bound by the source image
1195        /// and its padding region, but the effect is that the normalization factor of the average computation is computed
1196        /// also for the zeros in the padding region.
1197        #[unsafe(method(zeroPadSizeY))]
1198        #[unsafe(method_family = none)]
1199        pub unsafe fn zeroPadSizeY(&self) -> NSUInteger;
1200
1201        /// Setter for [`zeroPadSizeY`][Self::zeroPadSizeY].
1202        #[unsafe(method(setZeroPadSizeY:))]
1203        #[unsafe(method_family = none)]
1204        pub unsafe fn setZeroPadSizeY(&self, zero_pad_size_y: NSUInteger);
1205
1206        /// Initialize a gradient average pooling filter
1207        ///
1208        /// Parameter `device`: The device the filter will run on
1209        ///
1210        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
1211        ///
1212        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
1213        ///
1214        /// Parameter `strideInPixelsX`: The input stride (upsampling factor) in the x dimension.
1215        ///
1216        /// Parameter `strideInPixelsY`: The input stride (upsampling factor) in the y dimension.
1217        ///
1218        /// Returns: A valid MPSCNNPoolingGradient object or nil, if failure.
1219        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:strideInPixelsX:strideInPixelsY:))]
1220        #[unsafe(method_family = init)]
1221        pub unsafe fn initWithDevice_kernelWidth_kernelHeight_strideInPixelsX_strideInPixelsY(
1222            this: Allocated<Self>,
1223            device: &ProtocolObject<dyn MTLDevice>,
1224            kernel_width: NSUInteger,
1225            kernel_height: NSUInteger,
1226            stride_in_pixels_x: NSUInteger,
1227            stride_in_pixels_y: NSUInteger,
1228        ) -> Retained<Self>;
1229
1230        /// NSSecureCoding compatability
1231        ///
1232        /// See
1233        /// MPSKernel#initWithCoder.
1234        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSCNNPoolingAverageGradient
1235        ///
1236        /// Parameter `device`: The MTLDevice on which to make the MPSCNNPoolingAverageGradient
1237        ///
1238        /// Returns: A new MPSCNNPoolingAverageGradient object, or nil if failure.
1239        ///
1240        /// # Safety
1241        ///
1242        /// `a_decoder` possibly has further requirements.
1243        #[unsafe(method(initWithCoder:device:))]
1244        #[unsafe(method_family = init)]
1245        pub unsafe fn initWithCoder_device(
1246            this: Allocated<Self>,
1247            a_decoder: &NSCoder,
1248            device: &ProtocolObject<dyn MTLDevice>,
1249        ) -> Option<Retained<Self>>;
1250    );
1251}
1252
1253/// Methods declared on superclass `MPSCNNPoolingGradient`.
1254#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1255impl MPSCNNPoolingAverageGradient {
1256    extern_methods!(
1257        /// Initialize a gradient pooling filter
1258        ///
1259        /// Parameter `device`: The device the filter will run on
1260        ///
1261        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
1262        ///
1263        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
1264        ///
1265        /// Returns: A valid MPSCNNPoolingGradient object or nil, if failure.
1266        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:))]
1267        #[unsafe(method_family = init)]
1268        pub unsafe fn initWithDevice_kernelWidth_kernelHeight(
1269            this: Allocated<Self>,
1270            device: &ProtocolObject<dyn MTLDevice>,
1271            kernel_width: NSUInteger,
1272            kernel_height: NSUInteger,
1273        ) -> Retained<Self>;
1274
1275        #[unsafe(method(initWithDevice:))]
1276        #[unsafe(method_family = init)]
1277        pub unsafe fn initWithDevice(
1278            this: Allocated<Self>,
1279            device: &ProtocolObject<dyn MTLDevice>,
1280        ) -> Retained<Self>;
1281    );
1282}
1283
1284/// Methods declared on superclass `MPSKernel`.
1285#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1286impl MPSCNNPoolingAverageGradient {
1287    extern_methods!(
1288        /// Called by NSCoder to decode MPSKernels
1289        ///
1290        /// This isn't the right interface to decode a MPSKernel, but
1291        /// it is the one that NSCoder uses. To enable your NSCoder
1292        /// (e.g. NSKeyedUnarchiver) to set which device to use
1293        /// extend the object to adopt the MPSDeviceProvider
1294        /// protocol. Otherwise, the Metal system default device
1295        /// will be used.
1296        ///
1297        /// # Safety
1298        ///
1299        /// `a_decoder` possibly has further requirements.
1300        #[unsafe(method(initWithCoder:))]
1301        #[unsafe(method_family = init)]
1302        pub unsafe fn initWithCoder(
1303            this: Allocated<Self>,
1304            a_decoder: &NSCoder,
1305        ) -> Option<Retained<Self>>;
1306    );
1307}
1308
1309/// Methods declared on superclass `NSObject`.
1310#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1311impl MPSCNNPoolingAverageGradient {
1312    extern_methods!(
1313        #[unsafe(method(init))]
1314        #[unsafe(method_family = init)]
1315        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1316
1317        #[unsafe(method(new))]
1318        #[unsafe(method_family = new)]
1319        pub unsafe fn new() -> Retained<Self>;
1320    );
1321}
1322
1323extern_class!(
1324    /// Dependencies: This depends on Metal.framework
1325    ///
1326    /// Specifies the filter for computing the gradient of the max pooling filter.
1327    /// The operation backpropagates a gradient vector using chain rule.
1328    ///
1329    /// Dilated Max pooling forward pass is defined as:
1330    ///
1331    /// out(x) = max_{dx
1332    /// \in Window(x)} in(s*x+D*dx), where
1333    ///
1334    /// the pooling window definition 'Window(x)' follows MPSCNNPooling specification,
1335    /// 's' is the pixel stride and in() is the source input image and D is the dilation factor.
1336    /// For MPSCNNPoolingMaxGradient the dilationRate 'D' is one. NOTE: For even-sized pooling
1337    /// windows with dilation rate greater than one the effective pooling window is centered
1338    /// around s*x with non-even windows leaning towards top-left corner. For example if
1339    /// kernel width = 2, dilation rate = 3, then the pooling considers positions '-2' and '+1'
1340    /// relative to the pooling window center 's*x'.
1341    ///
1342    /// Hence the partial derivative of the output value wrt. to the input value needed in the
1343    /// gradient backpropagation in MPSCNNPoolingGradient is:
1344    ///
1345    /// d out(x)/d in(y) = delta_{x_m, y}, where
1346    ///
1347    /// delta_{x,y} is the Kronecker delta symbol (see MPSCNNPoolingAverageGradient) and x_m
1348    /// is the index of the maximum value in the corresponding pooling window.
1349    ///
1350    /// In practice this means that the gradient value for the destination image at pixel 'x' is
1351    /// the sum over these contributions coming from all pooling windows that contribute
1352    /// to the max pooling computation in the forward pass, multiplied by the input
1353    /// gradient value in the source area of the corresponding pooling window. If there are
1354    /// multiple maximal values within a single pooling window one of them is picked for the
1355    /// gradient and this decision is implementation specific, which means that it can vary
1356    /// between different architectures and even between different filter parameters.
1357    ///
1358    /// Note: The gradient max pooling needs the secondary input image in order to compute
1359    /// the indices of maximal values for each pooling window, but this means redundant computations.
1360    /// Later we may add encode calls to MPSCNNPoolingMax that produce a state that contains the
1361    /// coordinates of the maximal values to be consumed by the gradient filters.
1362    ///
1363    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnnpoolingmaxgradient?language=objc)
1364    #[unsafe(super(
1365        MPSCNNPoolingGradient,
1366        MPSCNNGradientKernel,
1367        MPSCNNBinaryKernel,
1368        MPSKernel,
1369        NSObject
1370    ))]
1371    #[derive(Debug, PartialEq, Eq, Hash)]
1372    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1373    pub struct MPSCNNPoolingMaxGradient;
1374);
1375
1376#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1377extern_conformance!(
1378    unsafe impl NSCoding for MPSCNNPoolingMaxGradient {}
1379);
1380
1381#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1382extern_conformance!(
1383    unsafe impl NSCopying for MPSCNNPoolingMaxGradient {}
1384);
1385
1386#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1387unsafe impl CopyingHelper for MPSCNNPoolingMaxGradient {
1388    type Result = Self;
1389}
1390
1391#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1392extern_conformance!(
1393    unsafe impl NSObjectProtocol for MPSCNNPoolingMaxGradient {}
1394);
1395
1396#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1397extern_conformance!(
1398    unsafe impl NSSecureCoding for MPSCNNPoolingMaxGradient {}
1399);
1400
1401#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1402impl MPSCNNPoolingMaxGradient {
1403    extern_methods!(
1404        /// Initialize a gradient max pooling filter
1405        ///
1406        /// Parameter `device`: The device the filter will run on
1407        ///
1408        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
1409        ///
1410        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
1411        ///
1412        /// Parameter `strideInPixelsX`: The input stride (upsampling factor) in the x dimension.
1413        ///
1414        /// Parameter `strideInPixelsY`: The input stride (upsampling factor) in the y dimension.
1415        ///
1416        /// Returns: A valid MPSCNNPoolingGradient object or nil, if failure.
1417        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:strideInPixelsX:strideInPixelsY:))]
1418        #[unsafe(method_family = init)]
1419        pub unsafe fn initWithDevice_kernelWidth_kernelHeight_strideInPixelsX_strideInPixelsY(
1420            this: Allocated<Self>,
1421            device: &ProtocolObject<dyn MTLDevice>,
1422            kernel_width: NSUInteger,
1423            kernel_height: NSUInteger,
1424            stride_in_pixels_x: NSUInteger,
1425            stride_in_pixels_y: NSUInteger,
1426        ) -> Retained<Self>;
1427
1428        /// NSSecureCoding compatability
1429        ///
1430        /// See
1431        /// MPSKernel#initWithCoder.
1432        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSCNNPoolingMaxGradient
1433        ///
1434        /// Parameter `device`: The MTLDevice on which to make the MPSCNNPoolingMaxGradient
1435        ///
1436        /// Returns: A new MPSCNNPoolingMaxGradient object, or nil if failure.
1437        ///
1438        /// # Safety
1439        ///
1440        /// `a_decoder` possibly has further requirements.
1441        #[unsafe(method(initWithCoder:device:))]
1442        #[unsafe(method_family = init)]
1443        pub unsafe fn initWithCoder_device(
1444            this: Allocated<Self>,
1445            a_decoder: &NSCoder,
1446            device: &ProtocolObject<dyn MTLDevice>,
1447        ) -> Option<Retained<Self>>;
1448    );
1449}
1450
1451/// Methods declared on superclass `MPSCNNPoolingGradient`.
1452#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1453impl MPSCNNPoolingMaxGradient {
1454    extern_methods!(
1455        /// Initialize a gradient pooling filter
1456        ///
1457        /// Parameter `device`: The device the filter will run on
1458        ///
1459        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
1460        ///
1461        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
1462        ///
1463        /// Returns: A valid MPSCNNPoolingGradient object or nil, if failure.
1464        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:))]
1465        #[unsafe(method_family = init)]
1466        pub unsafe fn initWithDevice_kernelWidth_kernelHeight(
1467            this: Allocated<Self>,
1468            device: &ProtocolObject<dyn MTLDevice>,
1469            kernel_width: NSUInteger,
1470            kernel_height: NSUInteger,
1471        ) -> Retained<Self>;
1472
1473        #[unsafe(method(initWithDevice:))]
1474        #[unsafe(method_family = init)]
1475        pub unsafe fn initWithDevice(
1476            this: Allocated<Self>,
1477            device: &ProtocolObject<dyn MTLDevice>,
1478        ) -> Retained<Self>;
1479    );
1480}
1481
1482/// Methods declared on superclass `MPSKernel`.
1483#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1484impl MPSCNNPoolingMaxGradient {
1485    extern_methods!(
1486        /// Called by NSCoder to decode MPSKernels
1487        ///
1488        /// This isn't the right interface to decode a MPSKernel, but
1489        /// it is the one that NSCoder uses. To enable your NSCoder
1490        /// (e.g. NSKeyedUnarchiver) to set which device to use
1491        /// extend the object to adopt the MPSDeviceProvider
1492        /// protocol. Otherwise, the Metal system default device
1493        /// will be used.
1494        ///
1495        /// # Safety
1496        ///
1497        /// `a_decoder` possibly has further requirements.
1498        #[unsafe(method(initWithCoder:))]
1499        #[unsafe(method_family = init)]
1500        pub unsafe fn initWithCoder(
1501            this: Allocated<Self>,
1502            a_decoder: &NSCoder,
1503        ) -> Option<Retained<Self>>;
1504    );
1505}
1506
1507/// Methods declared on superclass `NSObject`.
1508#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1509impl MPSCNNPoolingMaxGradient {
1510    extern_methods!(
1511        #[unsafe(method(init))]
1512        #[unsafe(method_family = init)]
1513        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1514
1515        #[unsafe(method(new))]
1516        #[unsafe(method_family = new)]
1517        pub unsafe fn new() -> Retained<Self>;
1518    );
1519}
1520
1521extern_class!(
1522    /// Dependencies: This depends on Metal.framework
1523    ///
1524    /// Specifies the filter for computing the gradient of the L2-Norm pooling filter.
1525    /// The operation backpropagates a gradient vector using chain rule.
1526    ///
1527    /// L2-Norm pooling forward pass is defined as:
1528    ///
1529    /// out(x) = sqrt( sum_{dx
1530    /// \in Window(x)} in(s*x+dx) * in(s*x+dx) ), where
1531    ///
1532    /// the pooling window definition 'Window(x)' follows MPSCNNPooling specification and
1533    /// 's' is the pixel stride and in() is the source input image.
1534    ///
1535    /// Hence the partial derivative of the output value wrt. to the input value needed in the
1536    /// gradient backpropagation in MPSCNNPoolingGradient is:
1537    ///
1538    /// d out(x)/d in(y) = sum_{dx
1539    /// \in Window(x)} delta_{s*x+dx, y} in(s*x+dx) / out(x), where
1540    ///
1541    /// delta_{x,y} is the Kronecker delta symbol for which
1542    ///
1543    /// delta_{x,y} =  {  1, when x == y
1544    /// {  0, otherwise,
1545    /// and out(x) is the L2-norm pooling value at point 'x' defined above.
1546    ///
1547    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnnpoolingl2normgradient?language=objc)
1548    #[unsafe(super(
1549        MPSCNNPoolingGradient,
1550        MPSCNNGradientKernel,
1551        MPSCNNBinaryKernel,
1552        MPSKernel,
1553        NSObject
1554    ))]
1555    #[derive(Debug, PartialEq, Eq, Hash)]
1556    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1557    pub struct MPSCNNPoolingL2NormGradient;
1558);
1559
1560#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1561extern_conformance!(
1562    unsafe impl NSCoding for MPSCNNPoolingL2NormGradient {}
1563);
1564
1565#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1566extern_conformance!(
1567    unsafe impl NSCopying for MPSCNNPoolingL2NormGradient {}
1568);
1569
1570#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1571unsafe impl CopyingHelper for MPSCNNPoolingL2NormGradient {
1572    type Result = Self;
1573}
1574
1575#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1576extern_conformance!(
1577    unsafe impl NSObjectProtocol for MPSCNNPoolingL2NormGradient {}
1578);
1579
1580#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1581extern_conformance!(
1582    unsafe impl NSSecureCoding for MPSCNNPoolingL2NormGradient {}
1583);
1584
1585#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1586impl MPSCNNPoolingL2NormGradient {
1587    extern_methods!(
1588        /// Initialize a gradient L2-norm pooling filter
1589        ///
1590        /// Parameter `device`: The device the filter will run on
1591        ///
1592        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
1593        ///
1594        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
1595        ///
1596        /// Parameter `strideInPixelsX`: The input stride (upsampling factor) in the x dimension.
1597        ///
1598        /// Parameter `strideInPixelsY`: The input stride (upsampling factor) in the y dimension.
1599        ///
1600        /// Returns: A valid MPSCNNPoolingL2NormGradient object or nil, if failure.
1601        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:strideInPixelsX:strideInPixelsY:))]
1602        #[unsafe(method_family = init)]
1603        pub unsafe fn initWithDevice_kernelWidth_kernelHeight_strideInPixelsX_strideInPixelsY(
1604            this: Allocated<Self>,
1605            device: &ProtocolObject<dyn MTLDevice>,
1606            kernel_width: NSUInteger,
1607            kernel_height: NSUInteger,
1608            stride_in_pixels_x: NSUInteger,
1609            stride_in_pixels_y: NSUInteger,
1610        ) -> Retained<Self>;
1611
1612        /// NSSecureCoding compatability
1613        ///
1614        /// See
1615        /// MPSKernel#initWithCoder.
1616        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSCNNPoolingL2NormGradient
1617        ///
1618        /// Parameter `device`: The MTLDevice on which to make the MPSCNNPoolingL2NormGradient
1619        ///
1620        /// Returns: A new MPSCNNPoolingL2NormGradient object, or nil if failure.
1621        ///
1622        /// # Safety
1623        ///
1624        /// `a_decoder` possibly has further requirements.
1625        #[unsafe(method(initWithCoder:device:))]
1626        #[unsafe(method_family = init)]
1627        pub unsafe fn initWithCoder_device(
1628            this: Allocated<Self>,
1629            a_decoder: &NSCoder,
1630            device: &ProtocolObject<dyn MTLDevice>,
1631        ) -> Option<Retained<Self>>;
1632    );
1633}
1634
1635/// Methods declared on superclass `MPSCNNPoolingGradient`.
1636#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1637impl MPSCNNPoolingL2NormGradient {
1638    extern_methods!(
1639        /// Initialize a gradient pooling filter
1640        ///
1641        /// Parameter `device`: The device the filter will run on
1642        ///
1643        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
1644        ///
1645        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
1646        ///
1647        /// Returns: A valid MPSCNNPoolingGradient object or nil, if failure.
1648        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:))]
1649        #[unsafe(method_family = init)]
1650        pub unsafe fn initWithDevice_kernelWidth_kernelHeight(
1651            this: Allocated<Self>,
1652            device: &ProtocolObject<dyn MTLDevice>,
1653            kernel_width: NSUInteger,
1654            kernel_height: NSUInteger,
1655        ) -> Retained<Self>;
1656
1657        #[unsafe(method(initWithDevice:))]
1658        #[unsafe(method_family = init)]
1659        pub unsafe fn initWithDevice(
1660            this: Allocated<Self>,
1661            device: &ProtocolObject<dyn MTLDevice>,
1662        ) -> Retained<Self>;
1663    );
1664}
1665
1666/// Methods declared on superclass `MPSKernel`.
1667#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1668impl MPSCNNPoolingL2NormGradient {
1669    extern_methods!(
1670        /// Called by NSCoder to decode MPSKernels
1671        ///
1672        /// This isn't the right interface to decode a MPSKernel, but
1673        /// it is the one that NSCoder uses. To enable your NSCoder
1674        /// (e.g. NSKeyedUnarchiver) to set which device to use
1675        /// extend the object to adopt the MPSDeviceProvider
1676        /// protocol. Otherwise, the Metal system default device
1677        /// will be used.
1678        ///
1679        /// # Safety
1680        ///
1681        /// `a_decoder` possibly has further requirements.
1682        #[unsafe(method(initWithCoder:))]
1683        #[unsafe(method_family = init)]
1684        pub unsafe fn initWithCoder(
1685            this: Allocated<Self>,
1686            a_decoder: &NSCoder,
1687        ) -> Option<Retained<Self>>;
1688    );
1689}
1690
1691/// Methods declared on superclass `NSObject`.
1692#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1693impl MPSCNNPoolingL2NormGradient {
1694    extern_methods!(
1695        #[unsafe(method(init))]
1696        #[unsafe(method_family = init)]
1697        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1698
1699        #[unsafe(method(new))]
1700        #[unsafe(method_family = new)]
1701        pub unsafe fn new() -> Retained<Self>;
1702    );
1703}
1704
1705extern_class!(
1706    /// Dependencies: This depends on Metal.framework
1707    ///
1708    /// Specifies the filter for computing the gradient of the dilated max pooling filter.
1709    /// For details see comments on MPSCNNPoolingMaxGradient.
1710    ///
1711    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnndilatedpoolingmaxgradient?language=objc)
1712    #[unsafe(super(
1713        MPSCNNPoolingGradient,
1714        MPSCNNGradientKernel,
1715        MPSCNNBinaryKernel,
1716        MPSKernel,
1717        NSObject
1718    ))]
1719    #[derive(Debug, PartialEq, Eq, Hash)]
1720    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1721    pub struct MPSCNNDilatedPoolingMaxGradient;
1722);
1723
1724#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1725extern_conformance!(
1726    unsafe impl NSCoding for MPSCNNDilatedPoolingMaxGradient {}
1727);
1728
1729#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1730extern_conformance!(
1731    unsafe impl NSCopying for MPSCNNDilatedPoolingMaxGradient {}
1732);
1733
1734#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1735unsafe impl CopyingHelper for MPSCNNDilatedPoolingMaxGradient {
1736    type Result = Self;
1737}
1738
1739#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1740extern_conformance!(
1741    unsafe impl NSObjectProtocol for MPSCNNDilatedPoolingMaxGradient {}
1742);
1743
1744#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1745extern_conformance!(
1746    unsafe impl NSSecureCoding for MPSCNNDilatedPoolingMaxGradient {}
1747);
1748
1749#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1750impl MPSCNNDilatedPoolingMaxGradient {
1751    extern_methods!(
1752        /// Initialize a MPSCNNDilatedPoolingMaxGradient pooling filter
1753        ///
1754        /// Parameter `device`: The device the filter will run on
1755        ///
1756        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
1757        ///
1758        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
1759        ///
1760        /// Parameter `dilationRateX`: The dilation rate in the x dimension.
1761        ///
1762        /// Parameter `dilationRateY`: The dilation rate in the y dimension.
1763        ///
1764        /// Parameter `strideInPixelsX`: The output stride (downsampling factor) in the x dimension.
1765        ///
1766        /// Parameter `strideInPixelsY`: The output stride (downsampling factor) in the y dimension.
1767        ///
1768        /// Returns: A valid MPSCNNDilatedPoolingMax object or nil, if failure.
1769        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:dilationRateX:dilationRateY:strideInPixelsX:strideInPixelsY:))]
1770        #[unsafe(method_family = init)]
1771        pub unsafe fn initWithDevice_kernelWidth_kernelHeight_dilationRateX_dilationRateY_strideInPixelsX_strideInPixelsY(
1772            this: Allocated<Self>,
1773            device: &ProtocolObject<dyn MTLDevice>,
1774            kernel_width: NSUInteger,
1775            kernel_height: NSUInteger,
1776            dilation_rate_x: NSUInteger,
1777            dilation_rate_y: NSUInteger,
1778            stride_in_pixels_x: NSUInteger,
1779            stride_in_pixels_y: NSUInteger,
1780        ) -> Retained<Self>;
1781
1782        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:strideInPixelsX:strideInPixelsY:))]
1783        #[unsafe(method_family = init)]
1784        pub unsafe fn initWithDevice_kernelWidth_kernelHeight_strideInPixelsX_strideInPixelsY(
1785            this: Allocated<Self>,
1786            device: &ProtocolObject<dyn MTLDevice>,
1787            kernel_width: NSUInteger,
1788            kernel_height: NSUInteger,
1789            stride_in_pixels_x: NSUInteger,
1790            stride_in_pixels_y: NSUInteger,
1791        ) -> Retained<Self>;
1792
1793        /// NSSecureCoding compatability
1794        ///
1795        /// See
1796        /// MPSKernel#initWithCoder.
1797        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSCNNPoolingMaxGradient
1798        ///
1799        /// Parameter `device`: The MTLDevice on which to make the MPSCNNPoolingMaxGradient
1800        ///
1801        /// Returns: A new MPSCNNPoolingMaxGradient object, or nil if failure.
1802        ///
1803        /// # Safety
1804        ///
1805        /// `a_decoder` possibly has further requirements.
1806        #[unsafe(method(initWithCoder:device:))]
1807        #[unsafe(method_family = init)]
1808        pub unsafe fn initWithCoder_device(
1809            this: Allocated<Self>,
1810            a_decoder: &NSCoder,
1811            device: &ProtocolObject<dyn MTLDevice>,
1812        ) -> Option<Retained<Self>>;
1813    );
1814}
1815
1816/// Methods declared on superclass `MPSCNNPoolingGradient`.
1817#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1818impl MPSCNNDilatedPoolingMaxGradient {
1819    extern_methods!(
1820        /// Initialize a gradient pooling filter
1821        ///
1822        /// Parameter `device`: The device the filter will run on
1823        ///
1824        /// Parameter `kernelWidth`: The width of the kernel.  Can be an odd or even value.
1825        ///
1826        /// Parameter `kernelHeight`: The height of the kernel.  Can be an odd or even value.
1827        ///
1828        /// Returns: A valid MPSCNNPoolingGradient object or nil, if failure.
1829        #[unsafe(method(initWithDevice:kernelWidth:kernelHeight:))]
1830        #[unsafe(method_family = init)]
1831        pub unsafe fn initWithDevice_kernelWidth_kernelHeight(
1832            this: Allocated<Self>,
1833            device: &ProtocolObject<dyn MTLDevice>,
1834            kernel_width: NSUInteger,
1835            kernel_height: NSUInteger,
1836        ) -> Retained<Self>;
1837
1838        #[unsafe(method(initWithDevice:))]
1839        #[unsafe(method_family = init)]
1840        pub unsafe fn initWithDevice(
1841            this: Allocated<Self>,
1842            device: &ProtocolObject<dyn MTLDevice>,
1843        ) -> Retained<Self>;
1844    );
1845}
1846
1847/// Methods declared on superclass `MPSKernel`.
1848#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1849impl MPSCNNDilatedPoolingMaxGradient {
1850    extern_methods!(
1851        /// Called by NSCoder to decode MPSKernels
1852        ///
1853        /// This isn't the right interface to decode a MPSKernel, but
1854        /// it is the one that NSCoder uses. To enable your NSCoder
1855        /// (e.g. NSKeyedUnarchiver) to set which device to use
1856        /// extend the object to adopt the MPSDeviceProvider
1857        /// protocol. Otherwise, the Metal system default device
1858        /// will be used.
1859        ///
1860        /// # Safety
1861        ///
1862        /// `a_decoder` possibly has further requirements.
1863        #[unsafe(method(initWithCoder:))]
1864        #[unsafe(method_family = init)]
1865        pub unsafe fn initWithCoder(
1866            this: Allocated<Self>,
1867            a_decoder: &NSCoder,
1868        ) -> Option<Retained<Self>>;
1869    );
1870}
1871
1872/// Methods declared on superclass `NSObject`.
1873#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
1874impl MPSCNNDilatedPoolingMaxGradient {
1875    extern_methods!(
1876        #[unsafe(method(init))]
1877        #[unsafe(method_family = init)]
1878        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1879
1880        #[unsafe(method(new))]
1881        #[unsafe(method_family = new)]
1882        pub unsafe fn new() -> Retained<Self>;
1883    );
1884}