objc2_metal_performance_shaders/generated/MPSNeuralNetwork/
MPSCNNInstanceNormalization.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    /// A state to hold information necessary to execute a gradient
15    /// pass for MPSCNNInstanceNormalization.  Gradient states should
16    /// be created by using the forward kernel's methods.  This will
17    /// ensure that the state captures all information necessary to
18    /// execute the corresponding gradient pass.
19    ///
20    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnninstancenormalizationgradientstate?language=objc)
21    #[unsafe(super(MPSNNGradientState, MPSState, NSObject))]
22    #[derive(Debug, PartialEq, Eq, Hash)]
23    #[cfg(all(
24        feature = "MPSCore",
25        feature = "MPSNNGradientState",
26        feature = "MPSState"
27    ))]
28    pub struct MPSCNNInstanceNormalizationGradientState;
29);
30
31#[cfg(all(
32    feature = "MPSCore",
33    feature = "MPSNNGradientState",
34    feature = "MPSState"
35))]
36extern_conformance!(
37    unsafe impl NSObjectProtocol for MPSCNNInstanceNormalizationGradientState {}
38);
39
40#[cfg(all(
41    feature = "MPSCore",
42    feature = "MPSNNGradientState",
43    feature = "MPSState"
44))]
45impl MPSCNNInstanceNormalizationGradientState {
46    extern_methods!(
47        #[cfg(all(feature = "MPSCNNKernel", feature = "MPSKernel"))]
48        /// The MPSCNNInstanceNormalization object that created this state object.
49        #[unsafe(method(instanceNormalization))]
50        #[unsafe(method_family = none)]
51        pub unsafe fn instanceNormalization(&self) -> Retained<MPSCNNInstanceNormalization>;
52
53        /// Return an MTLBuffer object with the state's current gamma values.
54        #[unsafe(method(gamma))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn gamma(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>;
57
58        /// Return an MTLBuffer object with the state's current beta values..
59        #[unsafe(method(beta))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn beta(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>;
62
63        #[unsafe(method(gradientForGamma))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn gradientForGamma(&self) -> Retained<ProtocolObject<dyn MTLBuffer>>;
66
67        #[unsafe(method(gradientForBeta))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn gradientForBeta(&self) -> Retained<ProtocolObject<dyn MTLBuffer>>;
70
71        /// Unavailable.  Use MPSCNNInstanceNormalization state creation methods.
72        #[unsafe(method(temporaryStateWithCommandBuffer:textureDescriptor:))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn temporaryStateWithCommandBuffer_textureDescriptor(
75            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
76            descriptor: &MTLTextureDescriptor,
77        ) -> Retained<Self>;
78
79        #[unsafe(method(temporaryStateWithCommandBuffer:))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn temporaryStateWithCommandBuffer(
82            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
83        ) -> Retained<Self>;
84
85        #[unsafe(method(temporaryStateWithCommandBuffer:bufferSize:))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn temporaryStateWithCommandBuffer_bufferSize(
88            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
89            buffer_size: usize,
90        ) -> Retained<Self>;
91
92        /// Unavailable.  Use MPSCNNInstanceNormalization state creation methods.
93        #[unsafe(method(initWithDevice:textureDescriptor:))]
94        #[unsafe(method_family = init)]
95        pub unsafe fn initWithDevice_textureDescriptor(
96            this: Allocated<Self>,
97            device: &ProtocolObject<dyn MTLDevice>,
98            descriptor: &MTLTextureDescriptor,
99        ) -> Retained<Self>;
100
101        /// Unavailable.  Use MPSCNNInstanceNormalization state creation methods.
102        ///
103        /// # Safety
104        ///
105        /// - `resource` may need to be synchronized.
106        /// - `resource` may be unretained, you must ensure it is kept alive while in use.
107        #[unsafe(method(initWithResource:))]
108        #[unsafe(method_family = init)]
109        pub unsafe fn initWithResource(
110            this: Allocated<Self>,
111            resource: Option<&ProtocolObject<dyn MTLResource>>,
112        ) -> Retained<Self>;
113
114        #[unsafe(method(initWithDevice:bufferSize:))]
115        #[unsafe(method_family = init)]
116        pub unsafe fn initWithDevice_bufferSize(
117            this: Allocated<Self>,
118            device: &ProtocolObject<dyn MTLDevice>,
119            buffer_size: usize,
120        ) -> Retained<Self>;
121    );
122}
123
124/// Methods declared on superclass `MPSState`.
125#[cfg(all(
126    feature = "MPSCore",
127    feature = "MPSNNGradientState",
128    feature = "MPSState"
129))]
130impl MPSCNNInstanceNormalizationGradientState {
131    extern_methods!(
132        #[unsafe(method(init))]
133        #[unsafe(method_family = init)]
134        pub unsafe fn init(this: Allocated<Self>) -> Option<Retained<Self>>;
135
136        /// Initialize a non-temporary state to hold a number of textures and buffers
137        ///
138        /// The allocation of each resource will be deferred  until it is needed.
139        /// This occurs when -resource or -resourceAtIndex: is called.
140        ///
141        /// Parameter `resourceList`: The list of resources to create.
142        #[unsafe(method(initWithDevice:resourceList:))]
143        #[unsafe(method_family = init)]
144        pub unsafe fn initWithDevice_resourceList(
145            this: Allocated<Self>,
146            device: &ProtocolObject<dyn MTLDevice>,
147            resource_list: &MPSStateResourceList,
148        ) -> Retained<Self>;
149
150        /// Initialize a temporary state to hold a number of textures and buffers
151        ///
152        /// The textures occur first in sequence
153        #[unsafe(method(temporaryStateWithCommandBuffer:resourceList:))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn temporaryStateWithCommandBuffer_resourceList(
156            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
157            resource_list: &MPSStateResourceList,
158        ) -> Retained<Self>;
159
160        /// Create a state object with a list of MTLResources
161        ///
162        /// Because MPS prefers deferred allocation of resources
163        /// your application should use -initWithTextures:bufferSizes:bufferCount:
164        /// whenever possible. This method is useful for cases when the
165        /// MTLResources must be initialized by the CPU.
166        ///
167        /// # Safety
168        ///
169        /// - `resources` generic may need to be synchronized.
170        /// - `resources` generic may be unretained, you must ensure it is kept alive while in use.
171        #[unsafe(method(initWithResources:))]
172        #[unsafe(method_family = init)]
173        pub unsafe fn initWithResources(
174            this: Allocated<Self>,
175            resources: Option<&NSArray<ProtocolObject<dyn MTLResource>>>,
176        ) -> Retained<Self>;
177    );
178}
179
180/// Methods declared on superclass `NSObject`.
181#[cfg(all(
182    feature = "MPSCore",
183    feature = "MPSNNGradientState",
184    feature = "MPSState"
185))]
186impl MPSCNNInstanceNormalizationGradientState {
187    extern_methods!(
188        #[unsafe(method(new))]
189        #[unsafe(method_family = new)]
190        pub unsafe fn new() -> Retained<Self>;
191    );
192}
193
194/// [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnninstancenormalizationgradientstatebatch?language=objc)
195#[cfg(all(
196    feature = "MPSCore",
197    feature = "MPSNNGradientState",
198    feature = "MPSState"
199))]
200pub type MPSCNNInstanceNormalizationGradientStateBatch =
201    NSArray<MPSCNNInstanceNormalizationGradientState>;
202
203extern_protocol!(
204    /// The MPSCNNInstanceNormalizationDataSource protocol declares the methods that an
205    /// instance of MPSCNNInstanceNormalization uses to initialize the
206    /// scale factors (gamma) and bias terms (beta).
207    ///
208    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnninstancenormalizationdatasource?language=objc)
209    pub unsafe trait MPSCNNInstanceNormalizationDataSource:
210        NSObjectProtocol + NSCopying
211    {
212        /// Return a pointer to an array containing the gamma terms.
213        #[unsafe(method(gamma))]
214        #[unsafe(method_family = none)]
215        unsafe fn gamma(&self) -> *mut c_float;
216
217        /// Return a pointer to an array containing the beta terms.
218        #[unsafe(method(beta))]
219        #[unsafe(method_family = none)]
220        unsafe fn beta(&self) -> *mut c_float;
221
222        #[unsafe(method(numberOfFeatureChannels))]
223        #[unsafe(method_family = none)]
224        unsafe fn numberOfFeatureChannels(&self) -> NSUInteger;
225
226        /// A label that is transferred to the instance normalization filter at init time
227        ///
228        /// Overridden by a MPSCNNInstanceNormalizationNode.label if it is non-nil.
229        #[unsafe(method(label))]
230        #[unsafe(method_family = none)]
231        unsafe fn label(&self) -> Option<Retained<NSString>>;
232
233        #[cfg(all(
234            feature = "MPSCNNNormalizationWeights",
235            feature = "MPSCore",
236            feature = "MPSNNGradientState",
237            feature = "MPSState"
238        ))]
239        /// Compute new gamma and beta values using current values and gradients contained within a
240        /// MPSCNNInstanceNormalizationStateBatch.
241        ///
242        /// This is for use in the context of training a network within a MPSNNGraph. If you are
243        /// writing your own graph using the low level interface or aren't training instance normalization
244        /// it isn't needed.
245        ///
246        /// In this mathod, you should perform the update on a GPU, because at the time it is called
247        /// the data isn't in the state objects yet and the CPU can't do the work. You should not attempt
248        /// to update the MPSCNNInstanceNormalization kernel directly with the results. The state object
249        /// returned from the function will be used for that.  A batch of states will be passed in.
250        /// You should accumulate the gradients and then update the weights.
251        ///
252        /// This operation is expected to also decrement the read count of instanceNormalizationStateBatch by 1,
253        /// if the states are temporary.
254        ///
255        ///
256        /// Parameter `commandBuffer`: The command buffer on which to encode the update.
257        ///
258        ///
259        /// Parameter `instanceNormalizationStateBatch`: A batch of MPSCNNInstanceNormalizationGradientState objects containing
260        /// current weights and gradients.
261        ///
262        ///
263        /// Returns: A MPSCNNNormalizationGammaAndBetaState object containing updated gamma and beta values.  If NULL no
264        /// update was performed.
265        #[optional]
266        #[unsafe(method(updateGammaAndBetaWithCommandBuffer:instanceNormalizationStateBatch:))]
267        #[unsafe(method_family = none)]
268        unsafe fn updateGammaAndBetaWithCommandBuffer_instanceNormalizationStateBatch(
269            &self,
270            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
271            instance_normalization_state_batch: &MPSCNNInstanceNormalizationGradientStateBatch,
272        ) -> Option<Retained<MPSCNNNormalizationGammaAndBetaState>>;
273
274        #[cfg(all(
275            feature = "MPSCore",
276            feature = "MPSNNGradientState",
277            feature = "MPSState"
278        ))]
279        /// Compute new gamma and beta values using current values and gradients contained within a
280        /// batch MPSCNNInstanceNormalizationState objects.  Perform the update on the CPU.
281        ///
282        ///
283        /// Parameter `instanceNormalizationStateBatch`: A batch of MPSCNNInstanceNormalizationGradientState objects containing
284        /// current gamma and beta values and gradients.
285        ///
286        ///
287        /// Returns: A boolean value indicating if the update was performed.
288        #[optional]
289        #[unsafe(method(updateGammaAndBetaWithInstanceNormalizationStateBatch:))]
290        #[unsafe(method_family = none)]
291        unsafe fn updateGammaAndBetaWithInstanceNormalizationStateBatch(
292            &self,
293            instance_normalization_state_batch: &MPSCNNInstanceNormalizationGradientStateBatch,
294        ) -> bool;
295
296        /// An optional tiny number to use to maintain numerical stability.
297        ///
298        /// output_image = (input_image - mean[c]) * gamma[c] / sqrt(variance[c] + epsilon) + beta[c];
299        /// Defalt value if method unavailable: FLT_MIN
300        #[optional]
301        #[unsafe(method(epsilon))]
302        #[unsafe(method_family = none)]
303        unsafe fn epsilon(&self) -> c_float;
304
305        /// Optional NSSecureCoding compatibility.
306        ///
307        /// # Safety
308        ///
309        /// `a_coder` possibly has further requirements.
310        #[optional]
311        #[unsafe(method(encodeWithCoder:))]
312        #[unsafe(method_family = none)]
313        unsafe fn encodeWithCoder(&self, a_coder: &NSCoder);
314
315        /// # Safety
316        ///
317        /// `a_decoder` possibly has further requirements.
318        #[optional]
319        #[unsafe(method(initWithCoder:))]
320        #[unsafe(method_family = init)]
321        unsafe fn initWithCoder(
322            this: Allocated<Self>,
323            a_decoder: &NSCoder,
324        ) -> Option<Retained<Self>>;
325
326        #[optional]
327        #[unsafe(method(supportsSecureCoding))]
328        #[unsafe(method_family = none)]
329        unsafe fn supportsSecureCoding() -> bool;
330
331        /// Optional copy method to create a copy of the data source for use with a new device.
332        ///
333        ///
334        /// Parameter `zone`: The NSZone on which to allocate.
335        ///
336        /// Parameter `device`: The device where the kernel which uses this data source will be used.
337        ///
338        ///
339        /// Returns: A pointer to a copy of this data source.
340        ///
341        /// # Safety
342        ///
343        /// `zone` must be a valid pointer or null.
344        #[optional]
345        #[unsafe(method(copyWithZone:device:))]
346        #[unsafe(method_family = copy)]
347        unsafe fn copyWithZone_device(
348            &self,
349            zone: *mut NSZone,
350            device: Option<&ProtocolObject<dyn MTLDevice>>,
351        ) -> Retained<Self>;
352
353        /// Alerts the data source that the data will be needed soon
354        ///
355        /// Returns: Returns YES on success.  If NO is returned, expect MPS
356        /// object construction to fail.
357        #[optional]
358        #[unsafe(method(load))]
359        #[unsafe(method_family = none)]
360        unsafe fn load(&self) -> bool;
361
362        /// Alerts the data source that the data is no longer needed
363        #[optional]
364        #[unsafe(method(purge))]
365        #[unsafe(method_family = none)]
366        unsafe fn purge(&self);
367    }
368);
369
370extern_class!(
371    /// Dependencies: This depends on Metal.framework
372    ///
373    /// This kernel normalizes each image, on a per-channel basis, to
374    /// have zero mean and unit variance:
375    ///
376    /// for each image:
377    /// for each channel:
378    /// y = (x - mean) * gamma / sqrt(variance + epsilon) + beta;
379    ///
380    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnninstancenormalization?language=objc)
381    #[unsafe(super(MPSCNNKernel, MPSKernel, NSObject))]
382    #[derive(Debug, PartialEq, Eq, Hash)]
383    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
384    pub struct MPSCNNInstanceNormalization;
385);
386
387#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
388extern_conformance!(
389    unsafe impl NSCoding for MPSCNNInstanceNormalization {}
390);
391
392#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
393extern_conformance!(
394    unsafe impl NSCopying for MPSCNNInstanceNormalization {}
395);
396
397#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
398unsafe impl CopyingHelper for MPSCNNInstanceNormalization {
399    type Result = Self;
400}
401
402#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
403extern_conformance!(
404    unsafe impl NSObjectProtocol for MPSCNNInstanceNormalization {}
405);
406
407#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
408extern_conformance!(
409    unsafe impl NSSecureCoding for MPSCNNInstanceNormalization {}
410);
411
412#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
413impl MPSCNNInstanceNormalization {
414    extern_methods!(
415        /// The epsilon value used to bias the variance when normalizing.
416        #[unsafe(method(epsilon))]
417        #[unsafe(method_family = none)]
418        pub unsafe fn epsilon(&self) -> c_float;
419
420        /// Setter for [`epsilon`][Self::epsilon].
421        #[unsafe(method(setEpsilon:))]
422        #[unsafe(method_family = none)]
423        pub unsafe fn setEpsilon(&self, epsilon: c_float);
424
425        /// The data source that the object was initialized with
426        #[unsafe(method(dataSource))]
427        #[unsafe(method_family = none)]
428        pub unsafe fn dataSource(
429            &self,
430        ) -> Retained<ProtocolObject<dyn MPSCNNInstanceNormalizationDataSource>>;
431
432        /// Initialize a MPSCNNInstanceNormalization kernel on a device.
433        ///
434        /// Parameter `dataSource`: An object conforming to the MPSCNNInstanceNormalizationDataSource
435        /// protocol which
436        #[unsafe(method(initWithDevice:dataSource:))]
437        #[unsafe(method_family = init)]
438        pub unsafe fn initWithDevice_dataSource(
439            this: Allocated<Self>,
440            device: &ProtocolObject<dyn MTLDevice>,
441            data_source: &ProtocolObject<dyn MPSCNNInstanceNormalizationDataSource>,
442        ) -> Retained<Self>;
443
444        /// Use initWithDevice:dataSource instead
445        #[unsafe(method(initWithDevice:))]
446        #[unsafe(method_family = init)]
447        pub unsafe fn initWithDevice(
448            this: Allocated<Self>,
449            device: &ProtocolObject<dyn MTLDevice>,
450        ) -> Retained<Self>;
451
452        /// NSSecureCoding compatability
453        ///
454        /// While the standard NSSecureCoding/NSCoding method
455        /// -initWithCoder: should work, since the file can't
456        /// know which device your data is allocated on, we
457        /// have to guess and may guess incorrectly.  To avoid
458        /// that problem, use initWithCoder:device instead.
459        ///
460        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
461        ///
462        /// Parameter `device`: The MTLDevice on which to make the MPSKernel
463        ///
464        /// Returns: A new MPSCNNInstanceNormalization object, or nil if failure.
465        ///
466        /// # Safety
467        ///
468        /// `a_decoder` possibly has further requirements.
469        #[unsafe(method(initWithCoder:device:))]
470        #[unsafe(method_family = init)]
471        pub unsafe fn initWithCoder_device(
472            this: Allocated<Self>,
473            a_decoder: &NSCoder,
474            device: &ProtocolObject<dyn MTLDevice>,
475        ) -> Option<Retained<Self>>;
476
477        /// Reload data using a data source.
478        ///
479        ///
480        /// Parameter `dataSource`: The data source which will provide the gamma and beta terms
481        /// to scale and bias the normalized result respectively.
482        #[deprecated]
483        #[unsafe(method(reloadDataSource:))]
484        #[unsafe(method_family = none)]
485        pub unsafe fn reloadDataSource(
486            &self,
487            data_source: &ProtocolObject<dyn MPSCNNInstanceNormalizationDataSource>,
488        );
489
490        /// Reinitialize the filter using the data source provided at kernel initialization.
491        #[unsafe(method(reloadGammaAndBetaFromDataSource))]
492        #[unsafe(method_family = none)]
493        pub unsafe fn reloadGammaAndBetaFromDataSource(&self);
494
495        #[cfg(all(feature = "MPSCNNNormalizationWeights", feature = "MPSState"))]
496        /// Reload data using new gamma and beta terms contained within an
497        /// MPSCNNInstanceNormalizationGradientState object.
498        ///
499        ///
500        /// Parameter `commandBuffer`: The command buffer on which to encode the reload.
501        ///
502        ///
503        /// Parameter `gammaAndBetaState`: The state containing the updated weights which are to
504        /// be reloaded.
505        #[unsafe(method(reloadGammaAndBetaWithCommandBuffer:gammaAndBetaState:))]
506        #[unsafe(method_family = none)]
507        pub unsafe fn reloadGammaAndBetaWithCommandBuffer_gammaAndBetaState(
508            &self,
509            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
510            gamma_and_beta_state: &MPSCNNNormalizationGammaAndBetaState,
511        );
512
513        #[cfg(all(
514            feature = "MPSImage",
515            feature = "MPSNNGradientState",
516            feature = "MPSState"
517        ))]
518        /// Return a MPSCNNInstanceNormalizationGradientState object for the provided
519        /// source image, source states, and destination image.
520        #[unsafe(method(resultStateForSourceImage:sourceStates:destinationImage:))]
521        #[unsafe(method_family = none)]
522        pub unsafe fn resultStateForSourceImage_sourceStates_destinationImage(
523            &self,
524            source_image: &MPSImage,
525            source_states: Option<&NSArray<MPSState>>,
526            destination_image: &MPSImage,
527        ) -> Option<Retained<MPSCNNInstanceNormalizationGradientState>>;
528
529        #[cfg(all(
530            feature = "MPSImage",
531            feature = "MPSNNGradientState",
532            feature = "MPSState"
533        ))]
534        /// Return a temporary MPSCNNInstanceNormalizationGradientState object which may be used with
535        /// a MPSCNNInstanceNormalization filter.
536        #[unsafe(method(temporaryResultStateForCommandBuffer:sourceImage:sourceStates:destinationImage:))]
537        #[unsafe(method_family = none)]
538        pub unsafe fn temporaryResultStateForCommandBuffer_sourceImage_sourceStates_destinationImage(
539            &self,
540            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
541            source_image: &MPSImage,
542            source_states: Option<&NSArray<MPSState>>,
543            destination_image: &MPSImage,
544        ) -> Option<Retained<MPSCNNInstanceNormalizationGradientState>>;
545    );
546}
547
548/// Methods declared on superclass `MPSKernel`.
549#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
550impl MPSCNNInstanceNormalization {
551    extern_methods!(
552        /// Called by NSCoder to decode MPSKernels
553        ///
554        /// This isn't the right interface to decode a MPSKernel, but
555        /// it is the one that NSCoder uses. To enable your NSCoder
556        /// (e.g. NSKeyedUnarchiver) to set which device to use
557        /// extend the object to adopt the MPSDeviceProvider
558        /// protocol. Otherwise, the Metal system default device
559        /// will be used.
560        ///
561        /// # Safety
562        ///
563        /// `a_decoder` possibly has further requirements.
564        #[unsafe(method(initWithCoder:))]
565        #[unsafe(method_family = init)]
566        pub unsafe fn initWithCoder(
567            this: Allocated<Self>,
568            a_decoder: &NSCoder,
569        ) -> Option<Retained<Self>>;
570    );
571}
572
573/// Methods declared on superclass `NSObject`.
574#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
575impl MPSCNNInstanceNormalization {
576    extern_methods!(
577        #[unsafe(method(init))]
578        #[unsafe(method_family = init)]
579        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
580
581        #[unsafe(method(new))]
582        #[unsafe(method_family = new)]
583        pub unsafe fn new() -> Retained<Self>;
584    );
585}
586
587extern_class!(
588    /// Dependencies: This depends on Metal.framework
589    ///
590    /// This kernel executes a gradient pass corresponding to MPSCNNInstanceNormalization.
591    ///
592    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnninstancenormalizationgradient?language=objc)
593    #[unsafe(super(MPSCNNGradientKernel, MPSCNNBinaryKernel, MPSKernel, NSObject))]
594    #[derive(Debug, PartialEq, Eq, Hash)]
595    #[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
596    pub struct MPSCNNInstanceNormalizationGradient;
597);
598
599#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
600extern_conformance!(
601    unsafe impl NSCoding for MPSCNNInstanceNormalizationGradient {}
602);
603
604#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
605extern_conformance!(
606    unsafe impl NSCopying for MPSCNNInstanceNormalizationGradient {}
607);
608
609#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
610unsafe impl CopyingHelper for MPSCNNInstanceNormalizationGradient {
611    type Result = Self;
612}
613
614#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
615extern_conformance!(
616    unsafe impl NSObjectProtocol for MPSCNNInstanceNormalizationGradient {}
617);
618
619#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
620extern_conformance!(
621    unsafe impl NSSecureCoding for MPSCNNInstanceNormalizationGradient {}
622);
623
624#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
625impl MPSCNNInstanceNormalizationGradient {
626    extern_methods!();
627}
628
629/// Methods declared on superclass `MPSCNNGradientKernel`.
630#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
631impl MPSCNNInstanceNormalizationGradient {
632    extern_methods!(
633        /// Standard init with default properties per filter type
634        ///
635        /// Parameter `device`: The device that the filter will be used on. May not be NULL.
636        ///
637        /// Returns: A pointer to the newly initialized object. This will fail, returning
638        /// nil if the device is not supported. Devices must be
639        /// MTLFeatureSet_iOS_GPUFamily2_v1 or later.
640        #[unsafe(method(initWithDevice:))]
641        #[unsafe(method_family = init)]
642        pub unsafe fn initWithDevice(
643            this: Allocated<Self>,
644            device: &ProtocolObject<dyn MTLDevice>,
645        ) -> Retained<Self>;
646
647        /// NSSecureCoding compatability
648        ///
649        /// While the standard NSSecureCoding/NSCoding method
650        /// -initWithCoder: should work, since the file can't
651        /// know which device your data is allocated on, we
652        /// have to guess and may guess incorrectly.  To avoid
653        /// that problem, use initWithCoder:device instead.
654        ///
655        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSKernel
656        ///
657        /// Parameter `device`: The MTLDevice on which to make the MPSKernel
658        ///
659        /// Returns: A new MPSKernel object, or nil if failure.
660        ///
661        /// # Safety
662        ///
663        /// `a_decoder` possibly has further requirements.
664        #[unsafe(method(initWithCoder:device:))]
665        #[unsafe(method_family = init)]
666        pub unsafe fn initWithCoder_device(
667            this: Allocated<Self>,
668            a_decoder: &NSCoder,
669            device: &ProtocolObject<dyn MTLDevice>,
670        ) -> Option<Retained<Self>>;
671    );
672}
673
674/// Methods declared on superclass `MPSKernel`.
675#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
676impl MPSCNNInstanceNormalizationGradient {
677    extern_methods!(
678        /// Called by NSCoder to decode MPSKernels
679        ///
680        /// This isn't the right interface to decode a MPSKernel, but
681        /// it is the one that NSCoder uses. To enable your NSCoder
682        /// (e.g. NSKeyedUnarchiver) to set which device to use
683        /// extend the object to adopt the MPSDeviceProvider
684        /// protocol. Otherwise, the Metal system default device
685        /// will be used.
686        ///
687        /// # Safety
688        ///
689        /// `a_decoder` possibly has further requirements.
690        #[unsafe(method(initWithCoder:))]
691        #[unsafe(method_family = init)]
692        pub unsafe fn initWithCoder(
693            this: Allocated<Self>,
694            a_decoder: &NSCoder,
695        ) -> Option<Retained<Self>>;
696    );
697}
698
699/// Methods declared on superclass `NSObject`.
700#[cfg(all(feature = "MPSCNNKernel", feature = "MPSCore", feature = "MPSKernel"))]
701impl MPSCNNInstanceNormalizationGradient {
702    extern_methods!(
703        #[unsafe(method(init))]
704        #[unsafe(method_family = init)]
705        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
706
707        #[unsafe(method(new))]
708        #[unsafe(method_family = new)]
709        pub unsafe fn new() -> Retained<Self>;
710    );
711}