objc2_metal_performance_shaders/generated/MPSNeuralNetwork/
MPSCNNUpsampling.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    /// The MPSCNNUpsampling filter can be used to resample an existing MPSImage
15    /// using a different sampling frequency for the x and y dimensions with the purpose of
16    /// enlarging the size of an image.
17    ///
18    /// The number of output feature channels remains the same as the number of input feature
19    /// channels.
20    ///
21    /// The scaleFactor must be an integer value >= 1. The default value is 1.
22    /// If scaleFactor == 1, the filter acts as a copy kernel.
23    ///
24    /// Nearest and bilinear variants are supported.
25    ///
26    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnnupsampling?language=objc)
27    #[unsafe(super(MPSCNNKernel, MPSKernel, NSObject))]
28    #[derive(Debug, PartialEq, Eq, Hash)]
29    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
30    pub struct MPSCNNUpsampling;
31);
32
33#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
34extern_conformance!(
35    unsafe impl NSCoding for MPSCNNUpsampling {}
36);
37
38#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
39extern_conformance!(
40    unsafe impl NSCopying for MPSCNNUpsampling {}
41);
42
43#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
44unsafe impl CopyingHelper for MPSCNNUpsampling {
45    type Result = Self;
46}
47
48#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
49extern_conformance!(
50    unsafe impl NSObjectProtocol for MPSCNNUpsampling {}
51);
52
53#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
54extern_conformance!(
55    unsafe impl NSSecureCoding for MPSCNNUpsampling {}
56);
57
58#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
59impl MPSCNNUpsampling {
60    extern_methods!(
61        /// The upsampling scale factor for the x dimension. The default value is 1.
62        #[unsafe(method(scaleFactorX))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn scaleFactorX(&self) -> c_double;
65
66        /// The upsampling scale factor for the y dimension. The default value is 1.
67        #[unsafe(method(scaleFactorY))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn scaleFactorY(&self) -> c_double;
70
71        /// If YES, the centers of the 4 corner pixels of the input and output regions are aligned,
72        /// preserving the values at the corner pixels.
73        /// The default is NO.
74        #[unsafe(method(alignCorners))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn alignCorners(&self) -> bool;
77
78        #[unsafe(method(initWithDevice:))]
79        #[unsafe(method_family = init)]
80        pub unsafe fn initWithDevice(
81            this: Allocated<Self>,
82            device: &ProtocolObject<dyn MTLDevice>,
83        ) -> Retained<Self>;
84    );
85}
86
87/// Methods declared on superclass `MPSCNNKernel`.
88#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
89impl MPSCNNUpsampling {
90    extern_methods!(
91        /// NSSecureCoding compatability
92        ///
93        /// While the standard NSSecureCoding/NSCoding method
94        /// -initWithCoder: should work, since the file can't
95        /// know which device your data is allocated on, we
96        /// have to guess and may guess incorrectly.  To avoid
97        /// that problem, use initWithCoder:device instead.
98        ///
99        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
100        ///
101        /// Parameter `device`: The MTLDevice on which to make the MPSKernel
102        ///
103        /// Returns: A new MPSKernel 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}
117
118/// Methods declared on superclass `MPSKernel`.
119#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
120impl MPSCNNUpsampling {
121    extern_methods!(
122        /// Called by NSCoder to decode MPSKernels
123        ///
124        /// This isn't the right interface to decode a MPSKernel, but
125        /// it is the one that NSCoder uses. To enable your NSCoder
126        /// (e.g. NSKeyedUnarchiver) to set which device to use
127        /// extend the object to adopt the MPSDeviceProvider
128        /// protocol. Otherwise, the Metal system default device
129        /// will be used.
130        ///
131        /// # Safety
132        ///
133        /// `a_decoder` possibly has further requirements.
134        #[unsafe(method(initWithCoder:))]
135        #[unsafe(method_family = init)]
136        pub unsafe fn initWithCoder(
137            this: Allocated<Self>,
138            a_decoder: &NSCoder,
139        ) -> Option<Retained<Self>>;
140    );
141}
142
143/// Methods declared on superclass `NSObject`.
144#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
145impl MPSCNNUpsampling {
146    extern_methods!(
147        #[unsafe(method(init))]
148        #[unsafe(method_family = init)]
149        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
150
151        #[unsafe(method(new))]
152        #[unsafe(method_family = new)]
153        pub unsafe fn new() -> Retained<Self>;
154    );
155}
156
157extern_class!(
158    /// Dependencies: This depends on Metal.framework.
159    ///
160    /// Specifies the nearest spatial upsampling filter.
161    ///
162    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnnupsamplingnearest?language=objc)
163    #[unsafe(super(MPSCNNUpsampling, MPSCNNKernel, MPSKernel, NSObject))]
164    #[derive(Debug, PartialEq, Eq, Hash)]
165    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
166    pub struct MPSCNNUpsamplingNearest;
167);
168
169#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
170extern_conformance!(
171    unsafe impl NSCoding for MPSCNNUpsamplingNearest {}
172);
173
174#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
175extern_conformance!(
176    unsafe impl NSCopying for MPSCNNUpsamplingNearest {}
177);
178
179#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
180unsafe impl CopyingHelper for MPSCNNUpsamplingNearest {
181    type Result = Self;
182}
183
184#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
185extern_conformance!(
186    unsafe impl NSObjectProtocol for MPSCNNUpsamplingNearest {}
187);
188
189#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
190extern_conformance!(
191    unsafe impl NSSecureCoding for MPSCNNUpsamplingNearest {}
192);
193
194#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
195impl MPSCNNUpsamplingNearest {
196    extern_methods!(
197        /// Initialize the nearest spatial upsampling filter.
198        ///
199        /// Parameter `device`: The device the filter will run on.
200        ///
201        /// Parameter `integerScaleFactorX`: The upsampling factor for the x dimension.
202        ///
203        /// Parameter `integerScaleFactorY`: The upsampling factor for the y dimension.
204        ///
205        /// Returns: A valid MPSCNNUpsamplingNearest object or nil, if failure.
206        #[unsafe(method(initWithDevice:integerScaleFactorX:integerScaleFactorY:))]
207        #[unsafe(method_family = init)]
208        pub unsafe fn initWithDevice_integerScaleFactorX_integerScaleFactorY(
209            this: Allocated<Self>,
210            device: &ProtocolObject<dyn MTLDevice>,
211            integer_scale_factor_x: NSUInteger,
212            integer_scale_factor_y: NSUInteger,
213        ) -> Retained<Self>;
214    );
215}
216
217/// Methods declared on superclass `MPSCNNUpsampling`.
218#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
219impl MPSCNNUpsamplingNearest {
220    extern_methods!(
221        #[unsafe(method(initWithDevice:))]
222        #[unsafe(method_family = init)]
223        pub unsafe fn initWithDevice(
224            this: Allocated<Self>,
225            device: &ProtocolObject<dyn MTLDevice>,
226        ) -> Retained<Self>;
227    );
228}
229
230/// Methods declared on superclass `MPSCNNKernel`.
231#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
232impl MPSCNNUpsamplingNearest {
233    extern_methods!(
234        /// NSSecureCoding compatability
235        ///
236        /// While the standard NSSecureCoding/NSCoding method
237        /// -initWithCoder: should work, since the file can't
238        /// know which device your data is allocated on, we
239        /// have to guess and may guess incorrectly.  To avoid
240        /// that problem, use initWithCoder:device instead.
241        ///
242        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
243        ///
244        /// Parameter `device`: The MTLDevice on which to make the MPSKernel
245        ///
246        /// Returns: A new MPSKernel object, or nil if failure.
247        ///
248        /// # Safety
249        ///
250        /// `a_decoder` possibly has further requirements.
251        #[unsafe(method(initWithCoder:device:))]
252        #[unsafe(method_family = init)]
253        pub unsafe fn initWithCoder_device(
254            this: Allocated<Self>,
255            a_decoder: &NSCoder,
256            device: &ProtocolObject<dyn MTLDevice>,
257        ) -> Option<Retained<Self>>;
258    );
259}
260
261/// Methods declared on superclass `MPSKernel`.
262#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
263impl MPSCNNUpsamplingNearest {
264    extern_methods!(
265        /// Called by NSCoder to decode MPSKernels
266        ///
267        /// This isn't the right interface to decode a MPSKernel, but
268        /// it is the one that NSCoder uses. To enable your NSCoder
269        /// (e.g. NSKeyedUnarchiver) to set which device to use
270        /// extend the object to adopt the MPSDeviceProvider
271        /// protocol. Otherwise, the Metal system default device
272        /// will be used.
273        ///
274        /// # Safety
275        ///
276        /// `a_decoder` possibly has further requirements.
277        #[unsafe(method(initWithCoder:))]
278        #[unsafe(method_family = init)]
279        pub unsafe fn initWithCoder(
280            this: Allocated<Self>,
281            a_decoder: &NSCoder,
282        ) -> Option<Retained<Self>>;
283    );
284}
285
286/// Methods declared on superclass `NSObject`.
287#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
288impl MPSCNNUpsamplingNearest {
289    extern_methods!(
290        #[unsafe(method(init))]
291        #[unsafe(method_family = init)]
292        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
293
294        #[unsafe(method(new))]
295        #[unsafe(method_family = new)]
296        pub unsafe fn new() -> Retained<Self>;
297    );
298}
299
300extern_class!(
301    /// Dependencies: This depends on Metal.framework.
302    ///
303    /// Specifies the bilinear spatial upsampling filter.
304    ///
305    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnnupsamplingbilinear?language=objc)
306    #[unsafe(super(MPSCNNUpsampling, MPSCNNKernel, MPSKernel, NSObject))]
307    #[derive(Debug, PartialEq, Eq, Hash)]
308    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
309    pub struct MPSCNNUpsamplingBilinear;
310);
311
312#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
313extern_conformance!(
314    unsafe impl NSCoding for MPSCNNUpsamplingBilinear {}
315);
316
317#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
318extern_conformance!(
319    unsafe impl NSCopying for MPSCNNUpsamplingBilinear {}
320);
321
322#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
323unsafe impl CopyingHelper for MPSCNNUpsamplingBilinear {
324    type Result = Self;
325}
326
327#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
328extern_conformance!(
329    unsafe impl NSObjectProtocol for MPSCNNUpsamplingBilinear {}
330);
331
332#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
333extern_conformance!(
334    unsafe impl NSSecureCoding for MPSCNNUpsamplingBilinear {}
335);
336
337#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
338impl MPSCNNUpsamplingBilinear {
339    extern_methods!(
340        /// Initialize the bilinear spatial upsampling filter.
341        ///
342        /// Parameter `device`: The device the filter will run on.
343        ///
344        /// Parameter `integerScaleFactorX`: The upsampling factor for the x dimension.
345        ///
346        /// Parameter `integerScaleFactorY`: The upsampling factor for the y dimension.
347        ///
348        /// Returns: A valid MPSCNNUpsamplingBilinear object or nil, if failure.
349        #[unsafe(method(initWithDevice:integerScaleFactorX:integerScaleFactorY:))]
350        #[unsafe(method_family = init)]
351        pub unsafe fn initWithDevice_integerScaleFactorX_integerScaleFactorY(
352            this: Allocated<Self>,
353            device: &ProtocolObject<dyn MTLDevice>,
354            integer_scale_factor_x: NSUInteger,
355            integer_scale_factor_y: NSUInteger,
356        ) -> Retained<Self>;
357
358        /// Initialize the bilinear spatial upsampling filter.
359        ///
360        /// Parameter `device`: The device the filter will run on.
361        ///
362        /// Parameter `integerScaleFactorX`: The upsampling factor for the x dimension.
363        ///
364        /// Parameter `integerScaleFactorY`: The upsampling factor for the y dimension.
365        ///
366        /// Parameter `alignCorners`: Specifier whether the centers of the 4 corner pixels of the input and output regions are aligned,
367        /// preserving the values at the corner pixels.
368        ///
369        /// Returns: A valid MPSCNNUpsamplingBilinear object or nil, if failure.
370        #[unsafe(method(initWithDevice:integerScaleFactorX:integerScaleFactorY:alignCorners:))]
371        #[unsafe(method_family = init)]
372        pub unsafe fn initWithDevice_integerScaleFactorX_integerScaleFactorY_alignCorners(
373            this: Allocated<Self>,
374            device: &ProtocolObject<dyn MTLDevice>,
375            integer_scale_factor_x: NSUInteger,
376            integer_scale_factor_y: NSUInteger,
377            align_corners: bool,
378        ) -> Retained<Self>;
379    );
380}
381
382/// Methods declared on superclass `MPSCNNUpsampling`.
383#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
384impl MPSCNNUpsamplingBilinear {
385    extern_methods!(
386        #[unsafe(method(initWithDevice:))]
387        #[unsafe(method_family = init)]
388        pub unsafe fn initWithDevice(
389            this: Allocated<Self>,
390            device: &ProtocolObject<dyn MTLDevice>,
391        ) -> Retained<Self>;
392    );
393}
394
395/// Methods declared on superclass `MPSCNNKernel`.
396#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
397impl MPSCNNUpsamplingBilinear {
398    extern_methods!(
399        /// NSSecureCoding compatability
400        ///
401        /// While the standard NSSecureCoding/NSCoding method
402        /// -initWithCoder: should work, since the file can't
403        /// know which device your data is allocated on, we
404        /// have to guess and may guess incorrectly.  To avoid
405        /// that problem, use initWithCoder:device instead.
406        ///
407        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
408        ///
409        /// Parameter `device`: The MTLDevice on which to make the MPSKernel
410        ///
411        /// Returns: A new MPSKernel object, or nil if failure.
412        ///
413        /// # Safety
414        ///
415        /// `a_decoder` possibly has further requirements.
416        #[unsafe(method(initWithCoder:device:))]
417        #[unsafe(method_family = init)]
418        pub unsafe fn initWithCoder_device(
419            this: Allocated<Self>,
420            a_decoder: &NSCoder,
421            device: &ProtocolObject<dyn MTLDevice>,
422        ) -> Option<Retained<Self>>;
423    );
424}
425
426/// Methods declared on superclass `MPSKernel`.
427#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
428impl MPSCNNUpsamplingBilinear {
429    extern_methods!(
430        /// Called by NSCoder to decode MPSKernels
431        ///
432        /// This isn't the right interface to decode a MPSKernel, but
433        /// it is the one that NSCoder uses. To enable your NSCoder
434        /// (e.g. NSKeyedUnarchiver) to set which device to use
435        /// extend the object to adopt the MPSDeviceProvider
436        /// protocol. Otherwise, the Metal system default device
437        /// will be used.
438        ///
439        /// # Safety
440        ///
441        /// `a_decoder` possibly has further requirements.
442        #[unsafe(method(initWithCoder:))]
443        #[unsafe(method_family = init)]
444        pub unsafe fn initWithCoder(
445            this: Allocated<Self>,
446            a_decoder: &NSCoder,
447        ) -> Option<Retained<Self>>;
448    );
449}
450
451/// Methods declared on superclass `NSObject`.
452#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
453impl MPSCNNUpsamplingBilinear {
454    extern_methods!(
455        #[unsafe(method(init))]
456        #[unsafe(method_family = init)]
457        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
458
459        #[unsafe(method(new))]
460        #[unsafe(method_family = new)]
461        pub unsafe fn new() -> Retained<Self>;
462    );
463}
464
465extern_class!(
466    /// Dependencies: This depends on Metal.framework
467    ///
468    /// The MPSCNNUpsamplingGradient filter is used for training. It is the backward
469    /// filter for the MPSCNNUpsampling filter. It operates on the gradient input,
470    /// specifically, it reduces the size of the gradient input in the x and y dimensions.
471    ///
472    /// The number of output feature channels remains the same as the number of input feature
473    /// channels.
474    ///
475    /// The scaleFactor must be an integer value >= 1. The default value is 1.
476    /// If scaleFactor == 1, the filter acts as a copy kernel.
477    ///
478    /// Nearest and bilinear variants are supported.
479    ///
480    /// For example, for the nearest variant with scaleFactorX = scaleFactorY = 2, the
481    /// forward pass produced the following output:
482    ///
483    /// Input:        Output:
484    /// a a b b
485    /// a b         a a b b
486    /// c d         c c d d
487    /// c c d d
488    ///
489    /// To upsample the image, the input data is replicated.
490    ///
491    /// And, the backward pass for the above froward pass is computed in the following
492    /// way:
493    ///
494    /// Input:            Output:
495    /// a1 a2 b1 b2
496    /// a2 a3 b3 b4        x y
497    /// c1 c2 d1 d2        z w
498    /// c3 c4 d3 d4
499    ///
500    /// where    x = a1 + a2 + a3 + a4
501    /// y = b1 + b2 + b3 + b4
502    /// z = c1 + c2 + c3 + c4
503    /// w = d1 + d2 + d3 + d4
504    ///
505    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnnupsamplinggradient?language=objc)
506    #[unsafe(super(MPSCNNGradientKernel, MPSCNNBinaryKernel, MPSKernel, NSObject))]
507    #[derive(Debug, PartialEq, Eq, Hash)]
508    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
509    pub struct MPSCNNUpsamplingGradient;
510);
511
512#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
513extern_conformance!(
514    unsafe impl NSCoding for MPSCNNUpsamplingGradient {}
515);
516
517#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
518extern_conformance!(
519    unsafe impl NSCopying for MPSCNNUpsamplingGradient {}
520);
521
522#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
523unsafe impl CopyingHelper for MPSCNNUpsamplingGradient {
524    type Result = Self;
525}
526
527#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
528extern_conformance!(
529    unsafe impl NSObjectProtocol for MPSCNNUpsamplingGradient {}
530);
531
532#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
533extern_conformance!(
534    unsafe impl NSSecureCoding for MPSCNNUpsamplingGradient {}
535);
536
537#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
538impl MPSCNNUpsamplingGradient {
539    extern_methods!(
540        /// The downsampling scale factor for the x dimension. The default value is 1.
541        #[unsafe(method(scaleFactorX))]
542        #[unsafe(method_family = none)]
543        pub unsafe fn scaleFactorX(&self) -> c_double;
544
545        /// The downsampling scale factor for the y dimension. The default value is 1.
546        #[unsafe(method(scaleFactorY))]
547        #[unsafe(method_family = none)]
548        pub unsafe fn scaleFactorY(&self) -> c_double;
549
550        #[unsafe(method(initWithDevice:))]
551        #[unsafe(method_family = init)]
552        pub unsafe fn initWithDevice(
553            this: Allocated<Self>,
554            device: &ProtocolObject<dyn MTLDevice>,
555        ) -> Retained<Self>;
556    );
557}
558
559/// Methods declared on superclass `MPSCNNGradientKernel`.
560#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
561impl MPSCNNUpsamplingGradient {
562    extern_methods!(
563        /// NSSecureCoding compatability
564        ///
565        /// While the standard NSSecureCoding/NSCoding method
566        /// -initWithCoder: should work, since the file can't
567        /// know which device your data is allocated on, we
568        /// have to guess and may guess incorrectly.  To avoid
569        /// that problem, use initWithCoder:device instead.
570        ///
571        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
572        ///
573        /// Parameter `device`: The MTLDevice on which to make the MPSKernel
574        ///
575        /// Returns: A new MPSKernel object, or nil if failure.
576        ///
577        /// # Safety
578        ///
579        /// `a_decoder` possibly has further requirements.
580        #[unsafe(method(initWithCoder:device:))]
581        #[unsafe(method_family = init)]
582        pub unsafe fn initWithCoder_device(
583            this: Allocated<Self>,
584            a_decoder: &NSCoder,
585            device: &ProtocolObject<dyn MTLDevice>,
586        ) -> Option<Retained<Self>>;
587    );
588}
589
590/// Methods declared on superclass `MPSKernel`.
591#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
592impl MPSCNNUpsamplingGradient {
593    extern_methods!(
594        /// Called by NSCoder to decode MPSKernels
595        ///
596        /// This isn't the right interface to decode a MPSKernel, but
597        /// it is the one that NSCoder uses. To enable your NSCoder
598        /// (e.g. NSKeyedUnarchiver) to set which device to use
599        /// extend the object to adopt the MPSDeviceProvider
600        /// protocol. Otherwise, the Metal system default device
601        /// will be used.
602        ///
603        /// # Safety
604        ///
605        /// `a_decoder` possibly has further requirements.
606        #[unsafe(method(initWithCoder:))]
607        #[unsafe(method_family = init)]
608        pub unsafe fn initWithCoder(
609            this: Allocated<Self>,
610            a_decoder: &NSCoder,
611        ) -> Option<Retained<Self>>;
612    );
613}
614
615/// Methods declared on superclass `NSObject`.
616#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
617impl MPSCNNUpsamplingGradient {
618    extern_methods!(
619        #[unsafe(method(init))]
620        #[unsafe(method_family = init)]
621        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
622
623        #[unsafe(method(new))]
624        #[unsafe(method_family = new)]
625        pub unsafe fn new() -> Retained<Self>;
626    );
627}
628
629extern_class!(
630    /// Dependencies: This depends on Metal.framework.
631    ///
632    /// Specifies the nearest spatial downsampling filter.
633    ///
634    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnnupsamplingnearestgradient?language=objc)
635    #[unsafe(super(
636        MPSCNNUpsamplingGradient,
637        MPSCNNGradientKernel,
638        MPSCNNBinaryKernel,
639        MPSKernel,
640        NSObject
641    ))]
642    #[derive(Debug, PartialEq, Eq, Hash)]
643    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
644    pub struct MPSCNNUpsamplingNearestGradient;
645);
646
647#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
648extern_conformance!(
649    unsafe impl NSCoding for MPSCNNUpsamplingNearestGradient {}
650);
651
652#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
653extern_conformance!(
654    unsafe impl NSCopying for MPSCNNUpsamplingNearestGradient {}
655);
656
657#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
658unsafe impl CopyingHelper for MPSCNNUpsamplingNearestGradient {
659    type Result = Self;
660}
661
662#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
663extern_conformance!(
664    unsafe impl NSObjectProtocol for MPSCNNUpsamplingNearestGradient {}
665);
666
667#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
668extern_conformance!(
669    unsafe impl NSSecureCoding for MPSCNNUpsamplingNearestGradient {}
670);
671
672#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
673impl MPSCNNUpsamplingNearestGradient {
674    extern_methods!(
675        /// Initialize the nearest spatial upsampling filter.
676        ///
677        /// Parameter `device`: The device the filter will run on.
678        ///
679        /// Parameter `integerScaleFactorX`: The downsampling factor for the x dimension.
680        ///
681        /// Parameter `integerScaleFactorY`: The downsampling factor for the y dimension.
682        ///
683        /// Returns: A valid MPSCNNUpsamplingNearestGradient object or nil, if failure.
684        #[unsafe(method(initWithDevice:integerScaleFactorX:integerScaleFactorY:))]
685        #[unsafe(method_family = init)]
686        pub unsafe fn initWithDevice_integerScaleFactorX_integerScaleFactorY(
687            this: Allocated<Self>,
688            device: &ProtocolObject<dyn MTLDevice>,
689            integer_scale_factor_x: NSUInteger,
690            integer_scale_factor_y: NSUInteger,
691        ) -> Retained<Self>;
692    );
693}
694
695/// Methods declared on superclass `MPSCNNUpsamplingGradient`.
696#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
697impl MPSCNNUpsamplingNearestGradient {
698    extern_methods!(
699        #[unsafe(method(initWithDevice:))]
700        #[unsafe(method_family = init)]
701        pub unsafe fn initWithDevice(
702            this: Allocated<Self>,
703            device: &ProtocolObject<dyn MTLDevice>,
704        ) -> Retained<Self>;
705    );
706}
707
708/// Methods declared on superclass `MPSCNNGradientKernel`.
709#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
710impl MPSCNNUpsamplingNearestGradient {
711    extern_methods!(
712        /// NSSecureCoding compatability
713        ///
714        /// While the standard NSSecureCoding/NSCoding method
715        /// -initWithCoder: should work, since the file can't
716        /// know which device your data is allocated on, we
717        /// have to guess and may guess incorrectly.  To avoid
718        /// that problem, use initWithCoder:device instead.
719        ///
720        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
721        ///
722        /// Parameter `device`: The MTLDevice on which to make the MPSKernel
723        ///
724        /// Returns: A new MPSKernel object, or nil if failure.
725        ///
726        /// # Safety
727        ///
728        /// `a_decoder` possibly has further requirements.
729        #[unsafe(method(initWithCoder:device:))]
730        #[unsafe(method_family = init)]
731        pub unsafe fn initWithCoder_device(
732            this: Allocated<Self>,
733            a_decoder: &NSCoder,
734            device: &ProtocolObject<dyn MTLDevice>,
735        ) -> Option<Retained<Self>>;
736    );
737}
738
739/// Methods declared on superclass `MPSKernel`.
740#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
741impl MPSCNNUpsamplingNearestGradient {
742    extern_methods!(
743        /// Called by NSCoder to decode MPSKernels
744        ///
745        /// This isn't the right interface to decode a MPSKernel, but
746        /// it is the one that NSCoder uses. To enable your NSCoder
747        /// (e.g. NSKeyedUnarchiver) to set which device to use
748        /// extend the object to adopt the MPSDeviceProvider
749        /// protocol. Otherwise, the Metal system default device
750        /// will be used.
751        ///
752        /// # Safety
753        ///
754        /// `a_decoder` possibly has further requirements.
755        #[unsafe(method(initWithCoder:))]
756        #[unsafe(method_family = init)]
757        pub unsafe fn initWithCoder(
758            this: Allocated<Self>,
759            a_decoder: &NSCoder,
760        ) -> Option<Retained<Self>>;
761    );
762}
763
764/// Methods declared on superclass `NSObject`.
765#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
766impl MPSCNNUpsamplingNearestGradient {
767    extern_methods!(
768        #[unsafe(method(init))]
769        #[unsafe(method_family = init)]
770        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
771
772        #[unsafe(method(new))]
773        #[unsafe(method_family = new)]
774        pub unsafe fn new() -> Retained<Self>;
775    );
776}
777
778extern_class!(
779    /// Dependencies: This depends on Metal.framework.
780    ///
781    /// Specifies the bilinear spatial downsampling filter.
782    ///
783    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnnupsamplingbilineargradient?language=objc)
784    #[unsafe(super(
785        MPSCNNUpsamplingGradient,
786        MPSCNNGradientKernel,
787        MPSCNNBinaryKernel,
788        MPSKernel,
789        NSObject
790    ))]
791    #[derive(Debug, PartialEq, Eq, Hash)]
792    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
793    pub struct MPSCNNUpsamplingBilinearGradient;
794);
795
796#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
797extern_conformance!(
798    unsafe impl NSCoding for MPSCNNUpsamplingBilinearGradient {}
799);
800
801#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
802extern_conformance!(
803    unsafe impl NSCopying for MPSCNNUpsamplingBilinearGradient {}
804);
805
806#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
807unsafe impl CopyingHelper for MPSCNNUpsamplingBilinearGradient {
808    type Result = Self;
809}
810
811#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
812extern_conformance!(
813    unsafe impl NSObjectProtocol for MPSCNNUpsamplingBilinearGradient {}
814);
815
816#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
817extern_conformance!(
818    unsafe impl NSSecureCoding for MPSCNNUpsamplingBilinearGradient {}
819);
820
821#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
822impl MPSCNNUpsamplingBilinearGradient {
823    extern_methods!(
824        /// Initialize the bilinear spatial downsampling filter.
825        ///
826        /// Parameter `device`: The device the filter will run on.
827        ///
828        /// Parameter `integerScaleFactorX`: The downsampling factor for the x dimension.
829        ///
830        /// Parameter `integerScaleFactorY`: The downsampling factor for the y dimension.
831        ///
832        /// Returns: A valid MPSCNNUpsamplingBilinearGradient object or nil, if failure.
833        #[unsafe(method(initWithDevice:integerScaleFactorX:integerScaleFactorY:))]
834        #[unsafe(method_family = init)]
835        pub unsafe fn initWithDevice_integerScaleFactorX_integerScaleFactorY(
836            this: Allocated<Self>,
837            device: &ProtocolObject<dyn MTLDevice>,
838            integer_scale_factor_x: NSUInteger,
839            integer_scale_factor_y: NSUInteger,
840        ) -> Retained<Self>;
841    );
842}
843
844/// Methods declared on superclass `MPSCNNUpsamplingGradient`.
845#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
846impl MPSCNNUpsamplingBilinearGradient {
847    extern_methods!(
848        #[unsafe(method(initWithDevice:))]
849        #[unsafe(method_family = init)]
850        pub unsafe fn initWithDevice(
851            this: Allocated<Self>,
852            device: &ProtocolObject<dyn MTLDevice>,
853        ) -> Retained<Self>;
854    );
855}
856
857/// Methods declared on superclass `MPSCNNGradientKernel`.
858#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
859impl MPSCNNUpsamplingBilinearGradient {
860    extern_methods!(
861        /// NSSecureCoding compatability
862        ///
863        /// While the standard NSSecureCoding/NSCoding method
864        /// -initWithCoder: should work, since the file can't
865        /// know which device your data is allocated on, we
866        /// have to guess and may guess incorrectly.  To avoid
867        /// that problem, use initWithCoder:device instead.
868        ///
869        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
870        ///
871        /// Parameter `device`: The MTLDevice on which to make the MPSKernel
872        ///
873        /// Returns: A new MPSKernel object, or nil if failure.
874        ///
875        /// # Safety
876        ///
877        /// `a_decoder` possibly has further requirements.
878        #[unsafe(method(initWithCoder:device:))]
879        #[unsafe(method_family = init)]
880        pub unsafe fn initWithCoder_device(
881            this: Allocated<Self>,
882            a_decoder: &NSCoder,
883            device: &ProtocolObject<dyn MTLDevice>,
884        ) -> Option<Retained<Self>>;
885    );
886}
887
888/// Methods declared on superclass `MPSKernel`.
889#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
890impl MPSCNNUpsamplingBilinearGradient {
891    extern_methods!(
892        /// Called by NSCoder to decode MPSKernels
893        ///
894        /// This isn't the right interface to decode a MPSKernel, but
895        /// it is the one that NSCoder uses. To enable your NSCoder
896        /// (e.g. NSKeyedUnarchiver) to set which device to use
897        /// extend the object to adopt the MPSDeviceProvider
898        /// protocol. Otherwise, the Metal system default device
899        /// will be used.
900        ///
901        /// # Safety
902        ///
903        /// `a_decoder` possibly has further requirements.
904        #[unsafe(method(initWithCoder:))]
905        #[unsafe(method_family = init)]
906        pub unsafe fn initWithCoder(
907            this: Allocated<Self>,
908            a_decoder: &NSCoder,
909        ) -> Option<Retained<Self>>;
910    );
911}
912
913/// Methods declared on superclass `NSObject`.
914#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
915impl MPSCNNUpsamplingBilinearGradient {
916    extern_methods!(
917        #[unsafe(method(init))]
918        #[unsafe(method_family = init)]
919        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
920
921        #[unsafe(method(new))]
922        #[unsafe(method_family = new)]
923        pub unsafe fn new() -> Retained<Self>;
924    );
925}