objc2_metal_performance_shaders/generated/MPSNeuralNetwork/
MPSMatrixBatchNormalization.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    ///
15    /// Applies a batch normalization to a matrix.
16    ///
17    ///
18    /// A MPSMatrixBatchNormalization object computes the batch normalization
19    /// of a collection of feature vectors stored in an MPSMatrix.
20    ///
21    /// Feature vectors are stored in a row of the supplied input matrix and the
22    /// normalization is performed along columns:
23    ///
24    /// y[i,j] = gamma[j] * (x[i,j] - mean(x[:,j])) / (variance(x[:,j]) + epsilon) + beta[j]
25    ///
26    /// where gamma and beta are supplied weight and bias factors and epsilon is a small value added
27    /// to the variance.
28    ///
29    /// Optionally a neuron activation function may be applied to the result.
30    ///
31    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsmatrixbatchnormalization?language=objc)
32    #[unsafe(super(MPSMatrixUnaryKernel, MPSKernel, NSObject))]
33    #[derive(Debug, PartialEq, Eq, Hash)]
34    #[cfg(all(
35        feature = "MPSCore",
36        feature = "MPSKernel",
37        feature = "MPSMatrix",
38        feature = "MPSMatrixTypes"
39    ))]
40    pub struct MPSMatrixBatchNormalization;
41);
42
43#[cfg(all(
44    feature = "MPSCore",
45    feature = "MPSKernel",
46    feature = "MPSMatrix",
47    feature = "MPSMatrixTypes"
48))]
49extern_conformance!(
50    unsafe impl NSCoding for MPSMatrixBatchNormalization {}
51);
52
53#[cfg(all(
54    feature = "MPSCore",
55    feature = "MPSKernel",
56    feature = "MPSMatrix",
57    feature = "MPSMatrixTypes"
58))]
59extern_conformance!(
60    unsafe impl NSCopying for MPSMatrixBatchNormalization {}
61);
62
63#[cfg(all(
64    feature = "MPSCore",
65    feature = "MPSKernel",
66    feature = "MPSMatrix",
67    feature = "MPSMatrixTypes"
68))]
69unsafe impl CopyingHelper for MPSMatrixBatchNormalization {
70    type Result = Self;
71}
72
73#[cfg(all(
74    feature = "MPSCore",
75    feature = "MPSKernel",
76    feature = "MPSMatrix",
77    feature = "MPSMatrixTypes"
78))]
79extern_conformance!(
80    unsafe impl NSObjectProtocol for MPSMatrixBatchNormalization {}
81);
82
83#[cfg(all(
84    feature = "MPSCore",
85    feature = "MPSKernel",
86    feature = "MPSMatrix",
87    feature = "MPSMatrixTypes"
88))]
89extern_conformance!(
90    unsafe impl NSSecureCoding for MPSMatrixBatchNormalization {}
91);
92
93#[cfg(all(
94    feature = "MPSCore",
95    feature = "MPSKernel",
96    feature = "MPSMatrix",
97    feature = "MPSMatrixTypes"
98))]
99impl MPSMatrixBatchNormalization {
100    extern_methods!(
101        /// The number of input vectors which make up the input array.  This
102        /// is equivalent to the number of rows to consider from the primary
103        /// source matrix.
104        /// This property is modifiable and defaults to NSUIntegerMax.  At encode
105        /// time the larger of this property or the available number of inputs is
106        /// used.  The value of NSUIntegerMax thus indicates that all available input
107        /// rows (beginning at sourceMatrixOrigin.x) should be considered.
108        #[unsafe(method(sourceNumberOfFeatureVectors))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn sourceNumberOfFeatureVectors(&self) -> NSUInteger;
111
112        /// Setter for [`sourceNumberOfFeatureVectors`][Self::sourceNumberOfFeatureVectors].
113        #[unsafe(method(setSourceNumberOfFeatureVectors:))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn setSourceNumberOfFeatureVectors(
116            &self,
117            source_number_of_feature_vectors: NSUInteger,
118        );
119
120        /// The input size to to use in the operation.  This is equivalent to the
121        /// number of columns in the primary (input array) source matrix to consider
122        /// and the number of channels to produce for the output matrix.
123        /// This property is modifiable and defaults to NSUIntegerMax.  At encode
124        /// time the larger of this property or the available input size is used.
125        /// The value of NSUIntegerMax thus indicates that all available columns in
126        /// the input array (beginning at sourceMatrixOrigin.y) should be considered.
127        /// Defines also the number of output feature channels.
128        /// Note: The value used in the operation will be
129        /// MIN(inputMatrix.columns - sourceMatrixOrigin.y, sourceInputFeatureChannels)
130        #[unsafe(method(sourceInputFeatureChannels))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn sourceInputFeatureChannels(&self) -> NSUInteger;
133
134        /// Setter for [`sourceInputFeatureChannels`][Self::sourceInputFeatureChannels].
135        #[unsafe(method(setSourceInputFeatureChannels:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn setSourceInputFeatureChannels(
138            &self,
139            source_input_feature_channels: NSUInteger,
140        );
141
142        /// A small value to add to the variance when normalizing the inputs.  Defaults
143        /// to FLT_MIN upon initialization.
144        #[unsafe(method(epsilon))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn epsilon(&self) -> c_float;
147
148        /// Setter for [`epsilon`][Self::epsilon].
149        #[unsafe(method(setEpsilon:))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn setEpsilon(&self, epsilon: c_float);
152
153        /// If YES the batch statistics will be computed prior to performing the normalization.
154        /// Otherwise the provided statistics will be used.  Defaults to NO at initialization
155        /// time.
156        #[unsafe(method(computeStatistics))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn computeStatistics(&self) -> bool;
159
160        /// Setter for [`computeStatistics`][Self::computeStatistics].
161        #[unsafe(method(setComputeStatistics:))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn setComputeStatistics(&self, compute_statistics: bool);
164
165        #[cfg(feature = "MPSCNNNeuronType")]
166        /// Specifies a neuron activation function to be used.
167        ///
168        ///
169        /// This method can be used to add a neuron activation funtion of given type with
170        /// associated scalar parameters A, B, and C that are shared across all output values.
171        /// Note that this method can only be used to specify neurons which are specified by three (or fewer)
172        /// parameters shared across all output values (or channels, in CNN nomenclature). It is an error to call
173        /// this method for neuron activation functions like MPSCNNNeuronTypePReLU,
174        /// which require per-channel parameter values.  An MPSMatrixNeuron kernel is initialized
175        /// with a default neuron function of MPSCNNNeuronTypeNone.
176        ///
177        ///
178        /// Parameter `neuronType`: Type of neuron activation function. For full list see MPSCNNNeuronType.h
179        ///
180        /// Parameter `parameterA`: parameterA of neuron activation that is shared across all output values.
181        ///
182        /// Parameter `parameterB`: parameterB of neuron activation that is shared across all output values.
183        ///
184        /// Parameter `parameterC`: parameterC of neuron activation that is shared across all output values.
185        #[unsafe(method(setNeuronType:parameterA:parameterB:parameterC:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn setNeuronType_parameterA_parameterB_parameterC(
188            &self,
189            neuron_type: MPSCNNNeuronType,
190            parameter_a: c_float,
191            parameter_b: c_float,
192            parameter_c: c_float,
193        );
194
195        #[cfg(feature = "MPSCNNNeuronType")]
196        /// Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method
197        #[unsafe(method(neuronType))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn neuronType(&self) -> MPSCNNNeuronType;
200
201        /// Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method
202        #[unsafe(method(neuronParameterA))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn neuronParameterA(&self) -> c_float;
205
206        /// Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method
207        #[unsafe(method(neuronParameterB))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn neuronParameterB(&self) -> c_float;
210
211        /// Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method
212        #[unsafe(method(neuronParameterC))]
213        #[unsafe(method_family = none)]
214        pub unsafe fn neuronParameterC(&self) -> c_float;
215
216        #[unsafe(method(initWithDevice:))]
217        #[unsafe(method_family = init)]
218        pub unsafe fn initWithDevice(
219            this: Allocated<Self>,
220            device: &ProtocolObject<dyn MTLDevice>,
221        ) -> Retained<Self>;
222
223        /// Encode a MPSMatrixBatchNormalization object to a command buffer.
224        ///
225        ///
226        /// Parameter `commandBuffer`: A valid MTLCommandBuffer to receive the encoded kernel.
227        ///
228        ///
229        /// Parameter `inputMatrix`: A valid MPSMatrix object which specifies the input array.
230        ///
231        ///
232        /// Parameter `meanVector`: A valid MPSVector object containing batch mean values to be used
233        /// to normalize the inputs if computeStatistics is NO.  If
234        /// computeStatistics is YES the resulting batch mean values
235        /// will be returned in this array.
236        ///
237        ///
238        /// Parameter `varianceVector`: A valid MPSVector object containing batch variance values to be used
239        /// to normalize the inputs if computeStatistics is NO.  If
240        /// computeStatistics is YES the resulting batch variance values
241        /// will be returned in this array.
242        ///
243        ///
244        /// Parameter `gammaVector`: A valid MPSVector object which specifies the gamma terms, or
245        /// a null object to indicate that no scaling is to be applied.
246        ///
247        ///
248        /// Parameter `betaVector`: A valid MPSVector object which specifies the beta terms, or
249        /// a null object to indicate that no values are to be added.
250        ///
251        ///
252        /// Parameter `resultMatrix`: A valid MPSMatrix object which specifies the output array.
253        ///
254        ///
255        /// Encodes the operation to the specified command buffer.  resultMatrix
256        /// must be large enough to hold a
257        /// MIN(sourceNumberOfFeatureVectors, inputMatrix.rows - sourceMatrixOrigin.x)
258        /// x
259        /// MIN(inputMatrix.columns - sourceMatrixOrigin.y, sourceInputFeatureChannels) array.
260        ///
261        /// Let numChannels = MIN(inputMatrix.columns - sourceMatrixOrigin.y, sourceInputFeatureChannels)
262        ///
263        /// The gamma, beta, mean, and variance vectors must contain at least numChannels elements.
264        #[unsafe(method(encodeToCommandBuffer:inputMatrix:meanVector:varianceVector:gammaVector:betaVector:resultMatrix:))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn encodeToCommandBuffer_inputMatrix_meanVector_varianceVector_gammaVector_betaVector_resultMatrix(
267            &self,
268            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
269            input_matrix: &MPSMatrix,
270            mean_vector: &MPSVector,
271            variance_vector: &MPSVector,
272            gamma_vector: Option<&MPSVector>,
273            beta_vector: Option<&MPSVector>,
274            result_matrix: &MPSMatrix,
275        );
276
277        /// NSSecureCoding compatability
278        ///
279        /// See
280        /// MPSKernel#initWithCoder.
281        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSMatrixBatchNormalization object.
282        ///
283        /// Parameter `device`: The MTLDevice on which to make the MPSMatrixBatchNormalization object.
284        ///
285        /// Returns: A new MPSMatrixBatchNormalization object, or nil if failure.
286        ///
287        /// # Safety
288        ///
289        /// `a_decoder` possibly has further requirements.
290        #[unsafe(method(initWithCoder:device:))]
291        #[unsafe(method_family = init)]
292        pub unsafe fn initWithCoder_device(
293            this: Allocated<Self>,
294            a_decoder: &NSCoder,
295            device: &ProtocolObject<dyn MTLDevice>,
296        ) -> Option<Retained<Self>>;
297
298        /// Make a copy of this kernel for a new device -
299        ///
300        /// See: MPSKernel
301        ///
302        /// Parameter `zone`: The NSZone in which to allocate the object
303        ///
304        /// Parameter `device`: The device for the new MPSKernel. If nil, then use
305        /// self.device.
306        ///
307        /// Returns: A pointer to a copy of this MPSKernel. This will fail, returning
308        /// nil if the device is not supported. Devices must be
309        /// MTLFeatureSet_iOS_GPUFamily2_v1 or later.
310        ///
311        /// # Safety
312        ///
313        /// `zone` must be a valid pointer or null.
314        #[unsafe(method(copyWithZone:device:))]
315        #[unsafe(method_family = copy)]
316        pub unsafe fn copyWithZone_device(
317            &self,
318            zone: *mut NSZone,
319            device: Option<&ProtocolObject<dyn MTLDevice>>,
320        ) -> Retained<Self>;
321    );
322}
323
324/// Methods declared on superclass `MPSKernel`.
325#[cfg(all(
326    feature = "MPSCore",
327    feature = "MPSKernel",
328    feature = "MPSMatrix",
329    feature = "MPSMatrixTypes"
330))]
331impl MPSMatrixBatchNormalization {
332    extern_methods!(
333        /// Called by NSCoder to decode MPSKernels
334        ///
335        /// This isn't the right interface to decode a MPSKernel, but
336        /// it is the one that NSCoder uses. To enable your NSCoder
337        /// (e.g. NSKeyedUnarchiver) to set which device to use
338        /// extend the object to adopt the MPSDeviceProvider
339        /// protocol. Otherwise, the Metal system default device
340        /// will be used.
341        ///
342        /// # Safety
343        ///
344        /// `a_decoder` possibly has further requirements.
345        #[unsafe(method(initWithCoder:))]
346        #[unsafe(method_family = init)]
347        pub unsafe fn initWithCoder(
348            this: Allocated<Self>,
349            a_decoder: &NSCoder,
350        ) -> Option<Retained<Self>>;
351    );
352}
353
354/// Methods declared on superclass `NSObject`.
355#[cfg(all(
356    feature = "MPSCore",
357    feature = "MPSKernel",
358    feature = "MPSMatrix",
359    feature = "MPSMatrixTypes"
360))]
361impl MPSMatrixBatchNormalization {
362    extern_methods!(
363        #[unsafe(method(init))]
364        #[unsafe(method_family = init)]
365        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
366
367        #[unsafe(method(new))]
368        #[unsafe(method_family = new)]
369        pub unsafe fn new() -> Retained<Self>;
370    );
371}
372
373extern_class!(
374    /// Dependencies: This depends on Metal.framework.
375    ///
376    ///
377    /// A kernel to compute the gradient of the batch normalization operation.
378    ///
379    ///
380    /// A MPSMatrixBatchNormalizationGradient object computes the results of backpropagating
381    /// the gradients of a loss function with respect to the outputs of an
382    /// MPSMatrixBatchNormalization object.  The corresponding properties and data used by
383    /// the MPSMatrixBatchNormalizationGradient object should correspond to those used by
384    /// the forward MPSMatrixBatchNormalization object for which the gradient is being computed.
385    ///
386    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsmatrixbatchnormalizationgradient?language=objc)
387    #[unsafe(super(MPSMatrixBinaryKernel, MPSKernel, NSObject))]
388    #[derive(Debug, PartialEq, Eq, Hash)]
389    #[cfg(all(
390        feature = "MPSCore",
391        feature = "MPSKernel",
392        feature = "MPSMatrix",
393        feature = "MPSMatrixTypes"
394    ))]
395    pub struct MPSMatrixBatchNormalizationGradient;
396);
397
398#[cfg(all(
399    feature = "MPSCore",
400    feature = "MPSKernel",
401    feature = "MPSMatrix",
402    feature = "MPSMatrixTypes"
403))]
404extern_conformance!(
405    unsafe impl NSCoding for MPSMatrixBatchNormalizationGradient {}
406);
407
408#[cfg(all(
409    feature = "MPSCore",
410    feature = "MPSKernel",
411    feature = "MPSMatrix",
412    feature = "MPSMatrixTypes"
413))]
414extern_conformance!(
415    unsafe impl NSCopying for MPSMatrixBatchNormalizationGradient {}
416);
417
418#[cfg(all(
419    feature = "MPSCore",
420    feature = "MPSKernel",
421    feature = "MPSMatrix",
422    feature = "MPSMatrixTypes"
423))]
424unsafe impl CopyingHelper for MPSMatrixBatchNormalizationGradient {
425    type Result = Self;
426}
427
428#[cfg(all(
429    feature = "MPSCore",
430    feature = "MPSKernel",
431    feature = "MPSMatrix",
432    feature = "MPSMatrixTypes"
433))]
434extern_conformance!(
435    unsafe impl NSObjectProtocol for MPSMatrixBatchNormalizationGradient {}
436);
437
438#[cfg(all(
439    feature = "MPSCore",
440    feature = "MPSKernel",
441    feature = "MPSMatrix",
442    feature = "MPSMatrixTypes"
443))]
444extern_conformance!(
445    unsafe impl NSSecureCoding for MPSMatrixBatchNormalizationGradient {}
446);
447
448#[cfg(all(
449    feature = "MPSCore",
450    feature = "MPSKernel",
451    feature = "MPSMatrix",
452    feature = "MPSMatrixTypes"
453))]
454impl MPSMatrixBatchNormalizationGradient {
455    extern_methods!(
456        /// The number of input vectors which make up the input array.
457        #[unsafe(method(sourceNumberOfFeatureVectors))]
458        #[unsafe(method_family = none)]
459        pub unsafe fn sourceNumberOfFeatureVectors(&self) -> NSUInteger;
460
461        /// Setter for [`sourceNumberOfFeatureVectors`][Self::sourceNumberOfFeatureVectors].
462        #[unsafe(method(setSourceNumberOfFeatureVectors:))]
463        #[unsafe(method_family = none)]
464        pub unsafe fn setSourceNumberOfFeatureVectors(
465            &self,
466            source_number_of_feature_vectors: NSUInteger,
467        );
468
469        /// The number of feature channels in the input vectors.
470        #[unsafe(method(sourceInputFeatureChannels))]
471        #[unsafe(method_family = none)]
472        pub unsafe fn sourceInputFeatureChannels(&self) -> NSUInteger;
473
474        /// Setter for [`sourceInputFeatureChannels`][Self::sourceInputFeatureChannels].
475        #[unsafe(method(setSourceInputFeatureChannels:))]
476        #[unsafe(method_family = none)]
477        pub unsafe fn setSourceInputFeatureChannels(
478            &self,
479            source_input_feature_channels: NSUInteger,
480        );
481
482        /// A small term added to the variance when normalizing the input.
483        #[unsafe(method(epsilon))]
484        #[unsafe(method_family = none)]
485        pub unsafe fn epsilon(&self) -> c_float;
486
487        /// Setter for [`epsilon`][Self::epsilon].
488        #[unsafe(method(setEpsilon:))]
489        #[unsafe(method_family = none)]
490        pub unsafe fn setEpsilon(&self, epsilon: c_float);
491
492        #[cfg(feature = "MPSCNNNeuronType")]
493        /// Specifies a neuron activation function to be used.
494        ///
495        ///
496        /// This method can be used to add a neuron activation funtion of given type with
497        /// associated scalar parameters A, B, and C that are shared across all output values.
498        /// Note that this method can only be used to specify neurons which are specified by three (or fewer)
499        /// parameters shared across all output values (or channels, in CNN nomenclature). It is an error to call
500        /// this method for neuron activation functions like MPSCNNNeuronTypePReLU,
501        /// which require per-channel parameter values. An MPSMatrixBatchNormalizationGradient kernel is initialized
502        /// with a default neuron function of MPSCNNNeuronTypeNone.
503        ///
504        ///
505        /// Parameter `neuronType`: Type of neuron activation function. For full list see MPSCNNNeuronType.h
506        ///
507        /// Parameter `parameterA`: parameterA of neuron activation that is shared across all output values.
508        ///
509        /// Parameter `parameterB`: parameterB of neuron activation that is shared across all output values.
510        ///
511        /// Parameter `parameterC`: parameterC of neuron activation that is shared across all output values.
512        #[unsafe(method(setNeuronType:parameterA:parameterB:parameterC:))]
513        #[unsafe(method_family = none)]
514        pub unsafe fn setNeuronType_parameterA_parameterB_parameterC(
515            &self,
516            neuron_type: MPSCNNNeuronType,
517            parameter_a: c_float,
518            parameter_b: c_float,
519            parameter_c: c_float,
520        );
521
522        #[cfg(feature = "MPSCNNNeuronType")]
523        /// Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method
524        #[unsafe(method(neuronType))]
525        #[unsafe(method_family = none)]
526        pub unsafe fn neuronType(&self) -> MPSCNNNeuronType;
527
528        /// Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method
529        #[unsafe(method(neuronParameterA))]
530        #[unsafe(method_family = none)]
531        pub unsafe fn neuronParameterA(&self) -> c_float;
532
533        /// Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method
534        #[unsafe(method(neuronParameterB))]
535        #[unsafe(method_family = none)]
536        pub unsafe fn neuronParameterB(&self) -> c_float;
537
538        /// Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method
539        #[unsafe(method(neuronParameterC))]
540        #[unsafe(method_family = none)]
541        pub unsafe fn neuronParameterC(&self) -> c_float;
542
543        #[unsafe(method(initWithDevice:))]
544        #[unsafe(method_family = init)]
545        pub unsafe fn initWithDevice(
546            this: Allocated<Self>,
547            device: &ProtocolObject<dyn MTLDevice>,
548        ) -> Retained<Self>;
549
550        /// Encode a MPSMatrixBatchNormalizationGradient object to a command buffer and compute
551        /// its gradient with respect to its input data.
552        ///
553        ///
554        /// Parameter `commandBuffer`: The commandBuffer on which to encode the operation.
555        ///
556        ///
557        /// Parameter `gradientMatrix`: A matrix whose values represent the gradient of a
558        /// loss function with respect to the results of a forward
559        /// MPSMatrixBatchNormalization operation.
560        ///
561        ///
562        /// Parameter `inputMatrix`: A matrix containing the inputs to a forward MPSMatrixBatchNormalization
563        /// operation for which the gradient values are to be computed.
564        ///
565        ///
566        /// Parameter `meanVector`: A vector containing the batch mean values.  Should contain either the specified
567        /// values used to compute the forward result, or the computed values resulting from
568        /// the forward kernel execution.
569        ///
570        ///
571        /// Parameter `varianceVector`: A vector containing the batch variance values.  Should contain either the specified
572        /// values used to compute the forward result, or the computed values resulting from
573        /// the forward kernel execution.
574        ///
575        ///
576        /// Parameter `gammaVector`: A vector containing the gamma terms.  Should be the same values as used
577        /// when computing the forward result.
578        ///
579        ///
580        /// Parameter `betaVector`: A vector containing the beta terms.  Should be the same values as used when
581        /// computing the forward result.
582        ///
583        ///
584        /// Parameter `resultGradientForDataMatrix`: The matrix containing the resulting gradient values.
585        ///
586        ///
587        /// Parameter `resultGradientForGammaVector`: If non-NULL the vector containing gradients for the gamma
588        /// terms.
589        ///
590        ///
591        /// Parameter `resultGradientForBetaVector`: If non-NULL the vector containing gradients for the beta
592        /// terms.
593        #[unsafe(method(encodeToCommandBuffer:gradientMatrix:inputMatrix:meanVector:varianceVector:gammaVector:betaVector:resultGradientForDataMatrix:resultGradientForGammaVector:resultGradientForBetaVector:))]
594        #[unsafe(method_family = none)]
595        pub unsafe fn encodeToCommandBuffer_gradientMatrix_inputMatrix_meanVector_varianceVector_gammaVector_betaVector_resultGradientForDataMatrix_resultGradientForGammaVector_resultGradientForBetaVector(
596            &self,
597            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
598            gradient_matrix: &MPSMatrix,
599            input_matrix: &MPSMatrix,
600            mean_vector: &MPSVector,
601            variance_vector: &MPSVector,
602            gamma_vector: Option<&MPSVector>,
603            beta_vector: Option<&MPSVector>,
604            result_gradient_for_data_matrix: &MPSMatrix,
605            result_gradient_for_gamma_vector: Option<&MPSVector>,
606            result_gradient_for_beta_vector: Option<&MPSVector>,
607        );
608
609        /// NSSecureCoding compatability
610        ///
611        /// See
612        /// MPSKernel#initWithCoder.
613        /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSMatrixBatchNormalizationGradient
614        ///
615        /// Parameter `device`: The MTLDevice on which to make the MPSMatrixBatchNormalizationGradient object.
616        ///
617        /// Returns: A new MPSMatrixBatchNormalizationGradient object, or nil if failure.
618        ///
619        /// # Safety
620        ///
621        /// `a_decoder` possibly has further requirements.
622        #[unsafe(method(initWithCoder:device:))]
623        #[unsafe(method_family = init)]
624        pub unsafe fn initWithCoder_device(
625            this: Allocated<Self>,
626            a_decoder: &NSCoder,
627            device: &ProtocolObject<dyn MTLDevice>,
628        ) -> Option<Retained<Self>>;
629
630        /// Make a copy of this kernel for a new device -
631        ///
632        /// See: MPSKernel
633        ///
634        /// Parameter `zone`: The NSZone in which to allocate the object
635        ///
636        /// Parameter `device`: The device for the new MPSKernel. If nil, then use
637        /// self.device.
638        ///
639        /// Returns: A pointer to a copy of this MPSKernel. This will fail, returning
640        /// nil if the device is not supported. Devices must be
641        /// MTLFeatureSet_iOS_GPUFamily2_v1 or later.
642        ///
643        /// # Safety
644        ///
645        /// `zone` must be a valid pointer or null.
646        #[unsafe(method(copyWithZone:device:))]
647        #[unsafe(method_family = copy)]
648        pub unsafe fn copyWithZone_device(
649            &self,
650            zone: *mut NSZone,
651            device: Option<&ProtocolObject<dyn MTLDevice>>,
652        ) -> Retained<Self>;
653    );
654}
655
656/// Methods declared on superclass `MPSKernel`.
657#[cfg(all(
658    feature = "MPSCore",
659    feature = "MPSKernel",
660    feature = "MPSMatrix",
661    feature = "MPSMatrixTypes"
662))]
663impl MPSMatrixBatchNormalizationGradient {
664    extern_methods!(
665        /// Called by NSCoder to decode MPSKernels
666        ///
667        /// This isn't the right interface to decode a MPSKernel, but
668        /// it is the one that NSCoder uses. To enable your NSCoder
669        /// (e.g. NSKeyedUnarchiver) to set which device to use
670        /// extend the object to adopt the MPSDeviceProvider
671        /// protocol. Otherwise, the Metal system default device
672        /// will be used.
673        ///
674        /// # Safety
675        ///
676        /// `a_decoder` possibly has further requirements.
677        #[unsafe(method(initWithCoder:))]
678        #[unsafe(method_family = init)]
679        pub unsafe fn initWithCoder(
680            this: Allocated<Self>,
681            a_decoder: &NSCoder,
682        ) -> Option<Retained<Self>>;
683    );
684}
685
686/// Methods declared on superclass `NSObject`.
687#[cfg(all(
688    feature = "MPSCore",
689    feature = "MPSKernel",
690    feature = "MPSMatrix",
691    feature = "MPSMatrixTypes"
692))]
693impl MPSMatrixBatchNormalizationGradient {
694    extern_methods!(
695        #[unsafe(method(init))]
696        #[unsafe(method_family = init)]
697        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
698
699        #[unsafe(method(new))]
700        #[unsafe(method_family = new)]
701        pub unsafe fn new() -> Retained<Self>;
702    );
703}