objc2_metal_performance_shaders/generated/MPSNDArray/
MPSNDArrayKernel.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    /// [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarraymultiarybase?language=objc)
13    #[unsafe(super(MPSKernel, NSObject))]
14    #[derive(Debug, PartialEq, Eq, Hash)]
15    #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
16    pub struct MPSNDArrayMultiaryBase;
17);
18
19#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
20extern_conformance!(
21    unsafe impl NSCoding for MPSNDArrayMultiaryBase {}
22);
23
24#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
25extern_conformance!(
26    unsafe impl NSCopying for MPSNDArrayMultiaryBase {}
27);
28
29#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
30unsafe impl CopyingHelper for MPSNDArrayMultiaryBase {
31    type Result = Self;
32}
33
34#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
35extern_conformance!(
36    unsafe impl NSObjectProtocol for MPSNDArrayMultiaryBase {}
37);
38
39#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
40extern_conformance!(
41    unsafe impl NSSecureCoding for MPSNDArrayMultiaryBase {}
42);
43
44#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
45impl MPSNDArrayMultiaryBase {
46    extern_methods!(
47        #[cfg(feature = "MPSNDArrayTypes")]
48        /// Read offsets to use when addressing a source NDArray
49        ///
50        /// The coordinate of the position read from this source array which is
51        /// used to calculate the result value at [0,0,0,....]
52        /// If the position read is actually a contiguous region (e.g. the area covered by
53        /// a convolution kernel) then this is the center of that region, rounded down, for
54        /// each dimension.
55        ///
56        /// Parameter `sourceIndex`: The index of the source MPSNDArray to which the list of offsets is applied
57        #[deprecated]
58        #[unsafe(method(offsetsAtSourceIndex:))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn offsetsAtSourceIndex(&self, source_index: NSUInteger) -> MPSNDArrayOffsets;
61
62        #[cfg(feature = "MPSCoreTypes")]
63        /// The edge mode used for each source NDArray
64        ///
65        /// Parameter `sourceIndex`: The index of the source image
66        ///
67        /// Returns: The MPSImageEdgeMode for that image
68        #[deprecated]
69        #[unsafe(method(edgeModeAtSourceIndex:))]
70        #[unsafe(method_family = none)]
71        pub unsafe fn edgeModeAtSourceIndex(&self, source_index: NSUInteger) -> MPSImageEdgeMode;
72
73        #[cfg(feature = "MPSNDArrayTypes")]
74        /// Get the diameters of the point spread function (PSF) in each dimension
75        ///
76        /// Parameter `sourceIndex`: The MPSNDArrayMultiaryKernel source NDArray to which the kernel will be applied
77        ///
78        /// Returns: A list of kernel diameters in each dimension
79        #[deprecated]
80        #[unsafe(method(kernelSizesForSourceIndex:))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn kernelSizesForSourceIndex(&self, source_index: NSUInteger)
83            -> MPSNDArraySizes;
84
85        #[cfg(feature = "MPSNDArrayTypes")]
86        /// Return the downsampling ratio for the kernel in each dimension
87        ///
88        /// If the filter is a "backwards" filter such as a gradient filter
89        /// or convolution transpose, then this is the upsampling ratio and
90        /// zeros are inserted in the result.
91        ///
92        /// Parameter `sourceIndex`: The index of the source for which the strides apply
93        ///
94        /// Returns: The strides from one destination sample to the next in each
95        /// dimension of the corresponding source NDArray
96        #[deprecated]
97        #[unsafe(method(stridesForSourceIndex:))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn stridesForSourceIndex(&self, source_index: NSUInteger) -> MPSNDArrayOffsets;
100
101        #[cfg(feature = "MPSNDArrayTypes")]
102        /// Get the kernel dilation rate for each dimension
103        ///
104        /// Parameter `sourceIndex`: The index of the source image for which this applies
105        ///
106        /// Returns: The kernel dilation rate for each dimension.
107        #[deprecated]
108        #[unsafe(method(dilationRatesForSourceIndex:))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn dilationRatesForSourceIndex(
111            &self,
112            source_index: NSUInteger,
113        ) -> MPSNDArraySizes;
114
115        /// Method to allocate the result image for -encodeToCommandBuffer:sourceImage:
116        ///
117        /// Default: MPSTemporaryImage.defaultAllocator
118        #[unsafe(method(destinationArrayAllocator))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn destinationArrayAllocator(
121            &self,
122        ) -> Retained<ProtocolObject<dyn MPSNDArrayAllocator>>;
123
124        /// Setter for [`destinationArrayAllocator`][Self::destinationArrayAllocator].
125        #[unsafe(method(setDestinationArrayAllocator:))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn setDestinationArrayAllocator(
128            &self,
129            destination_array_allocator: &ProtocolObject<dyn MPSNDArrayAllocator>,
130        );
131
132        #[unsafe(method(initWithDevice:))]
133        #[unsafe(method_family = init)]
134        pub unsafe fn initWithDevice(
135            this: Allocated<Self>,
136            device: &ProtocolObject<dyn MTLDevice>,
137        ) -> Retained<Self>;
138
139        /// Initialize a MPSNDArrayMultiaryKernel
140        ///
141        /// Parameter `device`: The device on which the kernel will run
142        ///
143        /// Parameter `count`: The maximum number of NDArrays read by the kernel
144        ///
145        /// Returns: A valid MPSNDArrayMultiaryKernel, or nil if allocation failure.
146        #[unsafe(method(initWithDevice:sourceCount:))]
147        #[unsafe(method_family = init)]
148        pub unsafe fn initWithDevice_sourceCount(
149            this: Allocated<Self>,
150            device: &ProtocolObject<dyn MTLDevice>,
151            count: NSUInteger,
152        ) -> Retained<Self>;
153
154        /// Initialize a MPSNDArrayMultiaryKernel from a NSCoder
155        ///
156        /// Parameter `coder`: The NSCoder that contains the serialized object
157        ///
158        /// Parameter `device`: The device on which the kernel will run
159        ///
160        /// Returns: A valid MPSNDArrayMultiaryKernel, or nil if allocation failure.
161        ///
162        /// # Safety
163        ///
164        /// `coder` possibly has further requirements.
165        #[unsafe(method(initWithCoder:device:))]
166        #[unsafe(method_family = init)]
167        pub unsafe fn initWithCoder_device(
168            this: Allocated<Self>,
169            coder: &NSCoder,
170            device: &ProtocolObject<dyn MTLDevice>,
171        ) -> Retained<Self>;
172
173        /// Initialize a MPSNDArrayMultiaryKernel from a NSCoder
174        ///
175        /// Parameter `coder`: The NSCoder that contains the serialized object
176        ///
177        /// # Safety
178        ///
179        /// `coder` possibly has further requirements.
180        #[unsafe(method(encodeWithCoder:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn encodeWithCoder(&self, coder: &NSCoder);
183
184        /// Create a copy with
185        ///
186        /// Parameter `zone`: The NSZone in which to allocate the MPSNDArrayMultiaryKernel object
187        ///
188        /// Parameter `device`: The device on which the new kernel will run. Pass nil for same device.
189        ///
190        /// Returns: A valid MPSNDArrayMultiaryKernel, or nil if allocation failure.
191        ///
192        /// # Safety
193        ///
194        /// `zone` must be a valid pointer or null.
195        #[unsafe(method(copyWithZone:device:))]
196        #[unsafe(method_family = copy)]
197        pub unsafe fn copyWithZone_device(
198            &self,
199            zone: *mut NSZone,
200            device: Option<&ProtocolObject<dyn MTLDevice>>,
201        ) -> Retained<Self>;
202
203        #[cfg(feature = "MPSState")]
204        #[unsafe(method(resultStateForSourceArrays:sourceStates:destinationArray:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn resultStateForSourceArrays_sourceStates_destinationArray(
207            &self,
208            source_arrays: &NSArray<MPSNDArray>,
209            source_states: Option<&NSArray<MPSState>>,
210            destination_array: &MPSNDArray,
211        ) -> Option<Retained<MPSState>>;
212
213        #[cfg(feature = "MPSState")]
214        /// Return a descriptor suitable for allocating a NSArray to receive the result
215        ///
216        /// The object properties (kernelSize, offsets, edgeMode, etc.) should be properly
217        /// configured as if the -encode call was about to be made, before this method is
218        /// called. Those properties may affect the results.
219        ///
220        /// Parameter `sources`: The list of sources passed into the -encode call
221        ///
222        /// Parameter `state`: The source state object, if any passed to the -encode call
223        ///
224        /// Returns: a valid MPSNDArrayDescriptor that may be used to create a MPSNDArray to used to
225        /// hold the results of this kernel.
226        #[unsafe(method(destinationArrayDescriptorForSourceArrays:sourceState:))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn destinationArrayDescriptorForSourceArrays_sourceState(
229            &self,
230            sources: &NSArray<MPSNDArray>,
231            state: Option<&MPSState>,
232        ) -> Retained<MPSNDArrayDescriptor>;
233    );
234}
235
236/// Methods declared on superclass `MPSKernel`.
237#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
238impl MPSNDArrayMultiaryBase {
239    extern_methods!(
240        /// Called by NSCoder to decode MPSKernels
241        ///
242        /// This isn't the right interface to decode a MPSKernel, but
243        /// it is the one that NSCoder uses. To enable your NSCoder
244        /// (e.g. NSKeyedUnarchiver) to set which device to use
245        /// extend the object to adopt the MPSDeviceProvider
246        /// protocol. Otherwise, the Metal system default device
247        /// will be used.
248        ///
249        /// # Safety
250        ///
251        /// `a_decoder` possibly has further requirements.
252        #[unsafe(method(initWithCoder:))]
253        #[unsafe(method_family = init)]
254        pub unsafe fn initWithCoder(
255            this: Allocated<Self>,
256            a_decoder: &NSCoder,
257        ) -> Option<Retained<Self>>;
258    );
259}
260
261/// Methods declared on superclass `NSObject`.
262#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
263impl MPSNDArrayMultiaryBase {
264    extern_methods!(
265        #[unsafe(method(init))]
266        #[unsafe(method_family = init)]
267        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
268
269        #[unsafe(method(new))]
270        #[unsafe(method_family = new)]
271        pub unsafe fn new() -> Retained<Self>;
272    );
273}
274
275extern_class!(
276    /// [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarraymultiarykernel?language=objc)
277    #[unsafe(super(MPSNDArrayMultiaryBase, MPSKernel, NSObject))]
278    #[derive(Debug, PartialEq, Eq, Hash)]
279    #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
280    pub struct MPSNDArrayMultiaryKernel;
281);
282
283#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
284extern_conformance!(
285    unsafe impl NSCoding for MPSNDArrayMultiaryKernel {}
286);
287
288#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
289extern_conformance!(
290    unsafe impl NSCopying for MPSNDArrayMultiaryKernel {}
291);
292
293#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
294unsafe impl CopyingHelper for MPSNDArrayMultiaryKernel {
295    type Result = Self;
296}
297
298#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
299extern_conformance!(
300    unsafe impl NSObjectProtocol for MPSNDArrayMultiaryKernel {}
301);
302
303#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
304extern_conformance!(
305    unsafe impl NSSecureCoding for MPSNDArrayMultiaryKernel {}
306);
307
308#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
309impl MPSNDArrayMultiaryKernel {
310    extern_methods!(
311        #[unsafe(method(initWithDevice:sourceCount:))]
312        #[unsafe(method_family = init)]
313        pub unsafe fn initWithDevice_sourceCount(
314            this: Allocated<Self>,
315            device: &ProtocolObject<dyn MTLDevice>,
316            count: NSUInteger,
317        ) -> Retained<Self>;
318
319        /// # Safety
320        ///
321        /// `coder` possibly has further requirements.
322        #[unsafe(method(initWithCoder:device:))]
323        #[unsafe(method_family = init)]
324        pub unsafe fn initWithCoder_device(
325            this: Allocated<Self>,
326            coder: &NSCoder,
327            device: &ProtocolObject<dyn MTLDevice>,
328        ) -> Retained<Self>;
329
330        /// Encode a simple inference NDArray kernel and return a NDArray to hold the result
331        ///
332        /// Parameter `cmdBuf`: The command buffer into which to encode the kernel
333        ///
334        /// Parameter `sourceArrays`: The list of sources for the filter in a NSArray.
335        /// Ordering to be defined by subclass
336        ///
337        /// Returns: A newly allocated MPSNDArray that will contain the result of the calculation
338        /// when the command buffer completes successfully.
339        #[unsafe(method(encodeToCommandBuffer:sourceArrays:))]
340        #[unsafe(method_family = none)]
341        pub unsafe fn encodeToCommandBuffer_sourceArrays(
342            &self,
343            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
344            source_arrays: &NSArray<MPSNDArray>,
345        ) -> Retained<MPSNDArray>;
346
347        /// Encode a simple inference NDArray kernel and return a NDArray to hold the result
348        ///
349        /// Parameter `cmdBuf`: The command buffer into which to encode the kernel
350        ///
351        /// Parameter `sourceArrays`: The list of sources for the filter in a NSArray.
352        /// Ordering to be defined by subclass
353        ///
354        /// Parameter `destination`: The NDArray to receive the result
355        #[unsafe(method(encodeToCommandBuffer:sourceArrays:destinationArray:))]
356        #[unsafe(method_family = none)]
357        pub unsafe fn encodeToCommandBuffer_sourceArrays_destinationArray(
358            &self,
359            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
360            source_arrays: &NSArray<MPSNDArray>,
361            destination: &MPSNDArray,
362        );
363
364        #[cfg(feature = "MPSState")]
365        /// Encode a simple inference NDArray kernel and return a NDArray to hold the result
366        ///
367        /// Parameter `cmdBuf`: The command buffer into which to encode the kernel
368        ///
369        /// Parameter `sourceArrays`: The list of sources for the filter in a NSArray.
370        /// Ordering to be defined by subclass
371        ///
372        /// Parameter `outGradientState`: If non-nil, the address output gradient state is written to this address
373        ///
374        /// Parameter `outputStateIsTemporary`: If YES, the state if any will be allocated to contain temporary textures and buffers as needed
375        ///
376        /// Returns: A newly allocated MPSNDArray that will contain the result of the calculation
377        /// when the command buffer completes successfully.
378        #[unsafe(method(encodeToCommandBuffer:sourceArrays:resultState:outputStateIsTemporary:))]
379        #[unsafe(method_family = none)]
380        pub unsafe fn encodeToCommandBuffer_sourceArrays_resultState_outputStateIsTemporary(
381            &self,
382            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
383            source_arrays: &NSArray<MPSNDArray>,
384            out_gradient_state: Option<&mut Option<Retained<MPSState>>>,
385            output_state_is_temporary: bool,
386        ) -> Retained<MPSNDArray>;
387
388        #[cfg(feature = "MPSState")]
389        /// Encode a simple inference NDArray kernel and return a NDArray to hold the result
390        ///
391        /// Parameter `cmdBuf`: The command buffer into which to encode the kernel
392        ///
393        /// Parameter `sourceArrays`: The list of sources for the filter in a NSArray.
394        /// Ordering to be defined by subclass
395        ///
396        /// Parameter `outGradientState`: The output gradient state to record the operation for later use by gradient
397        ///
398        /// Parameter `destination`: A destination array to contain the result of the calculation
399        /// when the command buffer completes successfully.
400        #[unsafe(method(encodeToCommandBuffer:sourceArrays:resultState:destinationArray:))]
401        #[unsafe(method_family = none)]
402        pub unsafe fn encodeToCommandBuffer_sourceArrays_resultState_destinationArray(
403            &self,
404            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
405            source_arrays: &NSArray<MPSNDArray>,
406            out_gradient_state: Option<&MPSState>,
407            destination: &MPSNDArray,
408        );
409
410        /// Encode a simple inference NDArray kernel and return a NDArray to hold the result
411        ///
412        /// Parameter `encoder`: The MTLComputeCommandEncoder that the kernel will be encoded on
413        ///
414        /// Parameter `commandBuffer`: The command buffer into which to encode the kernel
415        ///
416        /// Parameter `sourceArrays`: The list of sources for the filter in a NSArray.
417        /// Ordering to be defined by subclass
418        ///
419        /// Parameter `destination`: A destination array to contain the result of the calculation
420        /// when the command buffer completes successfully.
421        #[unsafe(method(encodeToCommandEncoder:commandBuffer:sourceArrays:destinationArray:))]
422        #[unsafe(method_family = none)]
423        pub unsafe fn encodeToCommandEncoder_commandBuffer_sourceArrays_destinationArray(
424            &self,
425            encoder: Option<&ProtocolObject<dyn MTLComputeCommandEncoder>>,
426            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
427            source_arrays: &NSArray<MPSNDArray>,
428            destination: &MPSNDArray,
429        );
430    );
431}
432
433/// Methods declared on superclass `MPSNDArrayMultiaryBase`.
434#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
435impl MPSNDArrayMultiaryKernel {
436    extern_methods!(
437        #[unsafe(method(initWithDevice:))]
438        #[unsafe(method_family = init)]
439        pub unsafe fn initWithDevice(
440            this: Allocated<Self>,
441            device: &ProtocolObject<dyn MTLDevice>,
442        ) -> Retained<Self>;
443    );
444}
445
446/// Methods declared on superclass `MPSKernel`.
447#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
448impl MPSNDArrayMultiaryKernel {
449    extern_methods!(
450        /// Called by NSCoder to decode MPSKernels
451        ///
452        /// This isn't the right interface to decode a MPSKernel, but
453        /// it is the one that NSCoder uses. To enable your NSCoder
454        /// (e.g. NSKeyedUnarchiver) to set which device to use
455        /// extend the object to adopt the MPSDeviceProvider
456        /// protocol. Otherwise, the Metal system default device
457        /// will be used.
458        ///
459        /// # Safety
460        ///
461        /// `a_decoder` possibly has further requirements.
462        #[unsafe(method(initWithCoder:))]
463        #[unsafe(method_family = init)]
464        pub unsafe fn initWithCoder(
465            this: Allocated<Self>,
466            a_decoder: &NSCoder,
467        ) -> Option<Retained<Self>>;
468    );
469}
470
471/// Methods declared on superclass `NSObject`.
472#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
473impl MPSNDArrayMultiaryKernel {
474    extern_methods!(
475        #[unsafe(method(init))]
476        #[unsafe(method_family = init)]
477        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
478
479        #[unsafe(method(new))]
480        #[unsafe(method_family = new)]
481        pub unsafe fn new() -> Retained<Self>;
482    );
483}
484
485extern_class!(
486    /// [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarraymultiarygradientkernel?language=objc)
487    #[unsafe(super(MPSNDArrayMultiaryBase, MPSKernel, NSObject))]
488    #[derive(Debug, PartialEq, Eq, Hash)]
489    #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
490    pub struct MPSNDArrayMultiaryGradientKernel;
491);
492
493#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
494extern_conformance!(
495    unsafe impl NSCoding for MPSNDArrayMultiaryGradientKernel {}
496);
497
498#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
499extern_conformance!(
500    unsafe impl NSCopying for MPSNDArrayMultiaryGradientKernel {}
501);
502
503#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
504unsafe impl CopyingHelper for MPSNDArrayMultiaryGradientKernel {
505    type Result = Self;
506}
507
508#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
509extern_conformance!(
510    unsafe impl NSObjectProtocol for MPSNDArrayMultiaryGradientKernel {}
511);
512
513#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
514extern_conformance!(
515    unsafe impl NSSecureCoding for MPSNDArrayMultiaryGradientKernel {}
516);
517
518#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
519impl MPSNDArrayMultiaryGradientKernel {
520    extern_methods!(
521        #[unsafe(method(initWithDevice:sourceCount:))]
522        #[unsafe(method_family = init)]
523        pub unsafe fn initWithDevice_sourceCount(
524            this: Allocated<Self>,
525            device: &ProtocolObject<dyn MTLDevice>,
526            count: NSUInteger,
527        ) -> Retained<Self>;
528
529        /// # Safety
530        ///
531        /// `coder` possibly has further requirements.
532        #[unsafe(method(initWithCoder:device:))]
533        #[unsafe(method_family = init)]
534        pub unsafe fn initWithCoder_device(
535            this: Allocated<Self>,
536            coder: &NSCoder,
537            device: &ProtocolObject<dyn MTLDevice>,
538        ) -> Retained<Self>;
539
540        /// Initialize a MPSNDArrayMultiaryKernel
541        ///
542        /// Parameter `device`: The device on which the kernel will run
543        ///
544        /// Parameter `count`: The maximum number of NDArrays read by the kernel
545        ///
546        /// Parameter `sourceGradientIndex`: The source index for which gradient will be calculated
547        ///
548        /// Returns: A valid MPSNDArrayMultiaryKernel, or nil if allocation failure.
549        #[unsafe(method(initWithDevice:sourceCount:sourceGradientIndex:))]
550        #[unsafe(method_family = init)]
551        pub unsafe fn initWithDevice_sourceCount_sourceGradientIndex(
552            this: Allocated<Self>,
553            device: &ProtocolObject<dyn MTLDevice>,
554            count: NSUInteger,
555            source_gradient_index: NSUInteger,
556        ) -> Retained<Self>;
557
558        #[cfg(feature = "MPSState")]
559        #[unsafe(method(encodeToCommandBuffer:sourceArrays:sourceGradient:gradientState:))]
560        #[unsafe(method_family = none)]
561        pub unsafe fn encodeToCommandBuffer_sourceArrays_sourceGradient_gradientState(
562            &self,
563            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
564            sources: &NSArray<MPSNDArray>,
565            gradient: &MPSNDArray,
566            state: &MPSState,
567        ) -> Retained<MPSNDArray>;
568
569        #[cfg(feature = "MPSState")]
570        #[unsafe(method(encodeToCommandBuffer:sourceArrays:sourceGradient:gradientState:destinationArray:))]
571        #[unsafe(method_family = none)]
572        pub unsafe fn encodeToCommandBuffer_sourceArrays_sourceGradient_gradientState_destinationArray(
573            &self,
574            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
575            sources: &NSArray<MPSNDArray>,
576            gradient: &MPSNDArray,
577            state: &MPSState,
578            destination: &MPSNDArray,
579        );
580    );
581}
582
583/// Methods declared on superclass `MPSNDArrayMultiaryBase`.
584#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
585impl MPSNDArrayMultiaryGradientKernel {
586    extern_methods!(
587        #[unsafe(method(initWithDevice:))]
588        #[unsafe(method_family = init)]
589        pub unsafe fn initWithDevice(
590            this: Allocated<Self>,
591            device: &ProtocolObject<dyn MTLDevice>,
592        ) -> Retained<Self>;
593    );
594}
595
596/// Methods declared on superclass `MPSKernel`.
597#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
598impl MPSNDArrayMultiaryGradientKernel {
599    extern_methods!(
600        /// Called by NSCoder to decode MPSKernels
601        ///
602        /// This isn't the right interface to decode a MPSKernel, but
603        /// it is the one that NSCoder uses. To enable your NSCoder
604        /// (e.g. NSKeyedUnarchiver) to set which device to use
605        /// extend the object to adopt the MPSDeviceProvider
606        /// protocol. Otherwise, the Metal system default device
607        /// will be used.
608        ///
609        /// # Safety
610        ///
611        /// `a_decoder` possibly has further requirements.
612        #[unsafe(method(initWithCoder:))]
613        #[unsafe(method_family = init)]
614        pub unsafe fn initWithCoder(
615            this: Allocated<Self>,
616            a_decoder: &NSCoder,
617        ) -> Option<Retained<Self>>;
618    );
619}
620
621/// Methods declared on superclass `NSObject`.
622#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
623impl MPSNDArrayMultiaryGradientKernel {
624    extern_methods!(
625        #[unsafe(method(init))]
626        #[unsafe(method_family = init)]
627        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
628
629        #[unsafe(method(new))]
630        #[unsafe(method_family = new)]
631        pub unsafe fn new() -> Retained<Self>;
632    );
633}
634
635extern_class!(
636    /// [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarrayunarykernel?language=objc)
637    #[unsafe(super(MPSNDArrayMultiaryKernel, MPSNDArrayMultiaryBase, MPSKernel, NSObject))]
638    #[derive(Debug, PartialEq, Eq, Hash)]
639    #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
640    pub struct MPSNDArrayUnaryKernel;
641);
642
643#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
644extern_conformance!(
645    unsafe impl NSCoding for MPSNDArrayUnaryKernel {}
646);
647
648#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
649extern_conformance!(
650    unsafe impl NSCopying for MPSNDArrayUnaryKernel {}
651);
652
653#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
654unsafe impl CopyingHelper for MPSNDArrayUnaryKernel {
655    type Result = Self;
656}
657
658#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
659extern_conformance!(
660    unsafe impl NSObjectProtocol for MPSNDArrayUnaryKernel {}
661);
662
663#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
664extern_conformance!(
665    unsafe impl NSSecureCoding for MPSNDArrayUnaryKernel {}
666);
667
668#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
669impl MPSNDArrayUnaryKernel {
670    extern_methods!(
671        #[cfg(feature = "MPSNDArrayTypes")]
672        /// The coordinate of the position read from this source array which is
673        /// used to calculate the result value at [0,0,0,....]
674        /// If the position read is actually a contiguous region (e.g. the area covered by
675        /// a convolution kernel) then this is the center of that region, rounded down, for
676        /// each dimension.
677        /// Default: 0,0,0...
678        #[deprecated]
679        #[unsafe(method(offsets))]
680        #[unsafe(method_family = none)]
681        pub unsafe fn offsets(&self) -> MPSNDArrayOffsets;
682
683        #[cfg(feature = "MPSCoreTypes")]
684        /// The edge mode used for a source NDArray
685        /// Default: MPSImageEdgeModeZero
686        #[deprecated]
687        #[unsafe(method(edgeMode))]
688        #[unsafe(method_family = none)]
689        pub unsafe fn edgeMode(&self) -> MPSImageEdgeMode;
690
691        #[cfg(feature = "MPSNDArrayTypes")]
692        /// The diameters of the point spread function in each dimension for a source NDArray
693        /// Default: 1
694        #[deprecated]
695        #[unsafe(method(kernelSizes))]
696        #[unsafe(method_family = none)]
697        pub unsafe fn kernelSizes(&self) -> MPSNDArraySizes;
698
699        #[cfg(feature = "MPSNDArrayTypes")]
700        /// If the filter is a "backwards" filter such as a gradient filter
701        /// or convolution transpose, then this is the upsampling ratio and
702        /// zeros are inserted in the result.
703        /// Default: 1
704        #[deprecated]
705        #[unsafe(method(strides))]
706        #[unsafe(method_family = none)]
707        pub unsafe fn strides(&self) -> MPSNDArrayOffsets;
708
709        #[cfg(feature = "MPSNDArrayTypes")]
710        /// The stride in each dimension from one PSF tap to an adjacent
711        /// PSF tap. Default: 1
712        #[deprecated]
713        #[unsafe(method(dilationRates))]
714        #[unsafe(method_family = none)]
715        pub unsafe fn dilationRates(&self) -> MPSNDArraySizes;
716
717        #[unsafe(method(initWithDevice:))]
718        #[unsafe(method_family = init)]
719        pub unsafe fn initWithDevice(
720            this: Allocated<Self>,
721            device: &ProtocolObject<dyn MTLDevice>,
722        ) -> Retained<Self>;
723
724        #[unsafe(method(initWithDevice:sourceCount:))]
725        #[unsafe(method_family = init)]
726        pub unsafe fn initWithDevice_sourceCount(
727            this: Allocated<Self>,
728            device: &ProtocolObject<dyn MTLDevice>,
729            count: NSUInteger,
730        ) -> Retained<Self>;
731
732        /// # Safety
733        ///
734        /// `coder` possibly has further requirements.
735        #[unsafe(method(initWithCoder:device:))]
736        #[unsafe(method_family = init)]
737        pub unsafe fn initWithCoder_device(
738            this: Allocated<Self>,
739            coder: &NSCoder,
740            device: &ProtocolObject<dyn MTLDevice>,
741        ) -> Retained<Self>;
742
743        /// Encode a simple inference NDArray kernel and return a NDArray to hold the result
744        ///
745        /// Parameter `cmdBuf`: The command buffer into which to encode the kernel
746        ///
747        /// Parameter `sourceArray`: The source for the filter in an NSArray.
748        ///
749        /// Returns: A newly allocated MPSNDArray that will contain the result of the calculation
750        /// when the command buffer completes successfully.
751        #[unsafe(method(encodeToCommandBuffer:sourceArray:))]
752        #[unsafe(method_family = none)]
753        pub unsafe fn encodeToCommandBuffer_sourceArray(
754            &self,
755            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
756            source_array: &MPSNDArray,
757        ) -> Retained<MPSNDArray>;
758
759        /// Encode a simple inference NDArray kernel and return a NDArray to hold the result
760        ///
761        /// Parameter `cmdBuf`: The command buffer into which to encode the kernel
762        ///
763        /// Parameter `sourceArray`: The source for the filter in an NSArray.
764        ///
765        /// Parameter `destination`: The NDArray to receive the result
766        #[unsafe(method(encodeToCommandBuffer:sourceArray:destinationArray:))]
767        #[unsafe(method_family = none)]
768        pub unsafe fn encodeToCommandBuffer_sourceArray_destinationArray(
769            &self,
770            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
771            source_array: &MPSNDArray,
772            destination: &MPSNDArray,
773        );
774
775        #[cfg(feature = "MPSState")]
776        /// Encode a simple inference NDArray kernel and return a NDArray to hold the result
777        ///
778        /// Parameter `cmdBuf`: The command buffer into which to encode the kernel
779        ///
780        /// Parameter `sourceArray`: The source for the filter in an NSArray.
781        ///
782        /// Parameter `outGradientState`: If non-nil, the address output gradient state is written to this address
783        ///
784        /// Parameter `outputStateIsTemporary`: If YES, the state if any will be allocated to contain temporary textures and buffers as needed
785        ///
786        /// Returns: A newly allocated MPSNDArray that will contain the result of the calculation
787        /// when the command buffer completes successfully.
788        #[unsafe(method(encodeToCommandBuffer:sourceArray:resultState:outputStateIsTemporary:))]
789        #[unsafe(method_family = none)]
790        pub unsafe fn encodeToCommandBuffer_sourceArray_resultState_outputStateIsTemporary(
791            &self,
792            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
793            source_array: &MPSNDArray,
794            out_gradient_state: Option<&mut Option<Retained<MPSState>>>,
795            output_state_is_temporary: bool,
796        ) -> Retained<MPSNDArray>;
797
798        #[cfg(feature = "MPSState")]
799        /// Encode a simple inference NDArray kernel and return a NDArray to hold the result
800        ///
801        /// Parameter `cmdBuf`: The command buffer into which to encode the kernel
802        ///
803        /// Parameter `sourceArray`: The source for the filter in an NSArray.
804        ///
805        /// Parameter `outGradientState`: The output gradient state to record the operation for later use by gradient
806        ///
807        /// Parameter `destination`: A destination array to contain the result of the calculation
808        /// when the command buffer completes successfully.
809        #[unsafe(method(encodeToCommandBuffer:sourceArray:resultState:destinationArray:))]
810        #[unsafe(method_family = none)]
811        pub unsafe fn encodeToCommandBuffer_sourceArray_resultState_destinationArray(
812            &self,
813            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
814            source_array: &MPSNDArray,
815            out_gradient_state: Option<&MPSState>,
816            destination: &MPSNDArray,
817        );
818    );
819}
820
821/// Methods declared on superclass `MPSKernel`.
822#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
823impl MPSNDArrayUnaryKernel {
824    extern_methods!(
825        /// Called by NSCoder to decode MPSKernels
826        ///
827        /// This isn't the right interface to decode a MPSKernel, but
828        /// it is the one that NSCoder uses. To enable your NSCoder
829        /// (e.g. NSKeyedUnarchiver) to set which device to use
830        /// extend the object to adopt the MPSDeviceProvider
831        /// protocol. Otherwise, the Metal system default device
832        /// will be used.
833        ///
834        /// # Safety
835        ///
836        /// `a_decoder` possibly has further requirements.
837        #[unsafe(method(initWithCoder:))]
838        #[unsafe(method_family = init)]
839        pub unsafe fn initWithCoder(
840            this: Allocated<Self>,
841            a_decoder: &NSCoder,
842        ) -> Option<Retained<Self>>;
843    );
844}
845
846/// Methods declared on superclass `NSObject`.
847#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
848impl MPSNDArrayUnaryKernel {
849    extern_methods!(
850        #[unsafe(method(init))]
851        #[unsafe(method_family = init)]
852        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
853
854        #[unsafe(method(new))]
855        #[unsafe(method_family = new)]
856        pub unsafe fn new() -> Retained<Self>;
857    );
858}
859
860extern_class!(
861    /// [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarrayunarygradientkernel?language=objc)
862    #[unsafe(super(
863        MPSNDArrayMultiaryGradientKernel,
864        MPSNDArrayMultiaryBase,
865        MPSKernel,
866        NSObject
867    ))]
868    #[derive(Debug, PartialEq, Eq, Hash)]
869    #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
870    pub struct MPSNDArrayUnaryGradientKernel;
871);
872
873#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
874extern_conformance!(
875    unsafe impl NSCoding for MPSNDArrayUnaryGradientKernel {}
876);
877
878#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
879extern_conformance!(
880    unsafe impl NSCopying for MPSNDArrayUnaryGradientKernel {}
881);
882
883#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
884unsafe impl CopyingHelper for MPSNDArrayUnaryGradientKernel {
885    type Result = Self;
886}
887
888#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
889extern_conformance!(
890    unsafe impl NSObjectProtocol for MPSNDArrayUnaryGradientKernel {}
891);
892
893#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
894extern_conformance!(
895    unsafe impl NSSecureCoding for MPSNDArrayUnaryGradientKernel {}
896);
897
898#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
899impl MPSNDArrayUnaryGradientKernel {
900    extern_methods!(
901        #[unsafe(method(initWithDevice:))]
902        #[unsafe(method_family = init)]
903        pub unsafe fn initWithDevice(
904            this: Allocated<Self>,
905            device: &ProtocolObject<dyn MTLDevice>,
906        ) -> Retained<Self>;
907
908        #[unsafe(method(initWithDevice:sourceCount:sourceGradientIndex:))]
909        #[unsafe(method_family = init)]
910        pub unsafe fn initWithDevice_sourceCount_sourceGradientIndex(
911            this: Allocated<Self>,
912            device: &ProtocolObject<dyn MTLDevice>,
913            count: NSUInteger,
914            source_gradient_index: NSUInteger,
915        ) -> Retained<Self>;
916
917        /// # Safety
918        ///
919        /// `coder` possibly has further requirements.
920        #[unsafe(method(initWithCoder:device:))]
921        #[unsafe(method_family = init)]
922        pub unsafe fn initWithCoder_device(
923            this: Allocated<Self>,
924            coder: &NSCoder,
925            device: &ProtocolObject<dyn MTLDevice>,
926        ) -> Retained<Self>;
927
928        #[cfg(feature = "MPSState")]
929        #[unsafe(method(encodeToCommandBuffer:sourceArray:sourceGradient:gradientState:))]
930        #[unsafe(method_family = none)]
931        pub unsafe fn encodeToCommandBuffer_sourceArray_sourceGradient_gradientState(
932            &self,
933            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
934            source_array: &MPSNDArray,
935            gradient: &MPSNDArray,
936            state: &MPSState,
937        ) -> Retained<MPSNDArray>;
938
939        #[cfg(feature = "MPSState")]
940        #[unsafe(method(encodeToCommandBuffer:sourceArray:sourceGradient:gradientState:destinationArray:))]
941        #[unsafe(method_family = none)]
942        pub unsafe fn encodeToCommandBuffer_sourceArray_sourceGradient_gradientState_destinationArray(
943            &self,
944            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
945            source_array: &MPSNDArray,
946            gradient: &MPSNDArray,
947            state: &MPSState,
948            destination: &MPSNDArray,
949        );
950    );
951}
952
953/// Methods declared on superclass `MPSNDArrayMultiaryGradientKernel`.
954#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
955impl MPSNDArrayUnaryGradientKernel {
956    extern_methods!(
957        #[unsafe(method(initWithDevice:sourceCount:))]
958        #[unsafe(method_family = init)]
959        pub unsafe fn initWithDevice_sourceCount(
960            this: Allocated<Self>,
961            device: &ProtocolObject<dyn MTLDevice>,
962            count: NSUInteger,
963        ) -> Retained<Self>;
964    );
965}
966
967/// Methods declared on superclass `MPSKernel`.
968#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
969impl MPSNDArrayUnaryGradientKernel {
970    extern_methods!(
971        /// Called by NSCoder to decode MPSKernels
972        ///
973        /// This isn't the right interface to decode a MPSKernel, but
974        /// it is the one that NSCoder uses. To enable your NSCoder
975        /// (e.g. NSKeyedUnarchiver) to set which device to use
976        /// extend the object to adopt the MPSDeviceProvider
977        /// protocol. Otherwise, the Metal system default device
978        /// will be used.
979        ///
980        /// # Safety
981        ///
982        /// `a_decoder` possibly has further requirements.
983        #[unsafe(method(initWithCoder:))]
984        #[unsafe(method_family = init)]
985        pub unsafe fn initWithCoder(
986            this: Allocated<Self>,
987            a_decoder: &NSCoder,
988        ) -> Option<Retained<Self>>;
989    );
990}
991
992/// Methods declared on superclass `NSObject`.
993#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
994impl MPSNDArrayUnaryGradientKernel {
995    extern_methods!(
996        #[unsafe(method(init))]
997        #[unsafe(method_family = init)]
998        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
999
1000        #[unsafe(method(new))]
1001        #[unsafe(method_family = new)]
1002        pub unsafe fn new() -> Retained<Self>;
1003    );
1004}
1005
1006extern_class!(
1007    /// [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarraybinarykernel?language=objc)
1008    #[unsafe(super(MPSNDArrayMultiaryKernel, MPSNDArrayMultiaryBase, MPSKernel, NSObject))]
1009    #[derive(Debug, PartialEq, Eq, Hash)]
1010    #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1011    pub struct MPSNDArrayBinaryKernel;
1012);
1013
1014#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1015extern_conformance!(
1016    unsafe impl NSCoding for MPSNDArrayBinaryKernel {}
1017);
1018
1019#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1020extern_conformance!(
1021    unsafe impl NSCopying for MPSNDArrayBinaryKernel {}
1022);
1023
1024#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1025unsafe impl CopyingHelper for MPSNDArrayBinaryKernel {
1026    type Result = Self;
1027}
1028
1029#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1030extern_conformance!(
1031    unsafe impl NSObjectProtocol for MPSNDArrayBinaryKernel {}
1032);
1033
1034#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1035extern_conformance!(
1036    unsafe impl NSSecureCoding for MPSNDArrayBinaryKernel {}
1037);
1038
1039#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1040impl MPSNDArrayBinaryKernel {
1041    extern_methods!(
1042        #[cfg(feature = "MPSNDArrayTypes")]
1043        /// The coordinate of the position read from this source array which is
1044        /// used to calculate the result value at [0,0,0,....]
1045        /// If the position read is actually a contiguous region (e.g. the area covered by
1046        /// a convolution kernel) then this is the center of that region, rounded down, for
1047        /// each dimension.
1048        /// Default: 0,0,0...
1049        #[deprecated]
1050        #[unsafe(method(primaryOffsets))]
1051        #[unsafe(method_family = none)]
1052        pub unsafe fn primaryOffsets(&self) -> MPSNDArrayOffsets;
1053
1054        #[cfg(feature = "MPSCoreTypes")]
1055        /// The edge mode used for a source NDArray
1056        /// Default: MPSImageEdgeModeZero
1057        #[deprecated]
1058        #[unsafe(method(primaryEdgeMode))]
1059        #[unsafe(method_family = none)]
1060        pub unsafe fn primaryEdgeMode(&self) -> MPSImageEdgeMode;
1061
1062        #[cfg(feature = "MPSNDArrayTypes")]
1063        /// The diameters of the point spread function in each dimension for a source NDArray
1064        /// Default: 1
1065        #[deprecated]
1066        #[unsafe(method(primaryKernelSizes))]
1067        #[unsafe(method_family = none)]
1068        pub unsafe fn primaryKernelSizes(&self) -> MPSNDArraySizes;
1069
1070        #[cfg(feature = "MPSNDArrayTypes")]
1071        /// If the filter is a "backwards" filter such as a gradient filter
1072        /// or convolution transpose, then this is the upsampling ratio and
1073        /// zeros are inserted in the result.
1074        /// Default: 1
1075        #[deprecated]
1076        #[unsafe(method(primaryStrides))]
1077        #[unsafe(method_family = none)]
1078        pub unsafe fn primaryStrides(&self) -> MPSNDArrayOffsets;
1079
1080        #[cfg(feature = "MPSNDArrayTypes")]
1081        /// The stride in each dimension from one PSF tap to an adjacent
1082        /// PSF tap. Default: 1
1083        #[deprecated]
1084        #[unsafe(method(primaryDilationRates))]
1085        #[unsafe(method_family = none)]
1086        pub unsafe fn primaryDilationRates(&self) -> MPSNDArraySizes;
1087
1088        #[cfg(feature = "MPSNDArrayTypes")]
1089        /// The coordinate of the position read from this source array which is
1090        /// used to calculate the result value at [0,0,0,....]
1091        /// If the position read is actually a contiguous region (e.g. the area covered by
1092        /// a convolution kernel) then this is the center of that region, rounded down, for
1093        /// each dimension.
1094        /// Default: 0,0,0...
1095        #[deprecated]
1096        #[unsafe(method(secondaryOffsets))]
1097        #[unsafe(method_family = none)]
1098        pub unsafe fn secondaryOffsets(&self) -> MPSNDArrayOffsets;
1099
1100        #[cfg(feature = "MPSCoreTypes")]
1101        /// The edge mode used for a source NDArray
1102        /// Default: MPSImageEdgeModeZero
1103        #[deprecated]
1104        #[unsafe(method(secondaryEdgeMode))]
1105        #[unsafe(method_family = none)]
1106        pub unsafe fn secondaryEdgeMode(&self) -> MPSImageEdgeMode;
1107
1108        #[cfg(feature = "MPSNDArrayTypes")]
1109        /// The diameters of the point spread function in each dimension for a source NDArray
1110        /// Default: 1
1111        #[deprecated]
1112        #[unsafe(method(secondaryKernelSizes))]
1113        #[unsafe(method_family = none)]
1114        pub unsafe fn secondaryKernelSizes(&self) -> MPSNDArraySizes;
1115
1116        #[cfg(feature = "MPSNDArrayTypes")]
1117        /// If the filter is a "backwards" filter such as a gradient filter
1118        /// or convolution transpose, then this is the upsampling ratio and
1119        /// zeros are inserted in the result.
1120        /// Default: 1
1121        #[deprecated]
1122        #[unsafe(method(secondaryStrides))]
1123        #[unsafe(method_family = none)]
1124        pub unsafe fn secondaryStrides(&self) -> MPSNDArrayOffsets;
1125
1126        #[cfg(feature = "MPSNDArrayTypes")]
1127        /// The stride in each dimension from one PSF tap to an adjacent
1128        /// PSF tap. Default: 1
1129        #[deprecated]
1130        #[unsafe(method(secondaryDilationRates))]
1131        #[unsafe(method_family = none)]
1132        pub unsafe fn secondaryDilationRates(&self) -> MPSNDArraySizes;
1133
1134        #[unsafe(method(initWithDevice:))]
1135        #[unsafe(method_family = init)]
1136        pub unsafe fn initWithDevice(
1137            this: Allocated<Self>,
1138            device: &ProtocolObject<dyn MTLDevice>,
1139        ) -> Retained<Self>;
1140
1141        #[unsafe(method(initWithDevice:sourceCount:))]
1142        #[unsafe(method_family = init)]
1143        pub unsafe fn initWithDevice_sourceCount(
1144            this: Allocated<Self>,
1145            device: &ProtocolObject<dyn MTLDevice>,
1146            count: NSUInteger,
1147        ) -> Retained<Self>;
1148
1149        /// # Safety
1150        ///
1151        /// `coder` possibly has further requirements.
1152        #[unsafe(method(initWithCoder:device:))]
1153        #[unsafe(method_family = init)]
1154        pub unsafe fn initWithCoder_device(
1155            this: Allocated<Self>,
1156            coder: &NSCoder,
1157            device: &ProtocolObject<dyn MTLDevice>,
1158        ) -> Retained<Self>;
1159
1160        /// Encode a simple inference NDArray kernel and return a NDArray to hold the result
1161        ///
1162        /// Parameter `cmdBuf`: The command buffer into which to encode the kernel
1163        ///
1164        /// Parameter `primarySourceArray`: The primary source for the filter in an NSArray.
1165        ///
1166        /// Parameter `secondarySourceArray`: The secondary source for the filter in an NSArray.
1167        ///
1168        /// Returns: A newly allocated MPSNDArray that will contain the result of the calculation
1169        /// when the command buffer completes successfully.
1170        #[unsafe(method(encodeToCommandBuffer:primarySourceArray:secondarySourceArray:))]
1171        #[unsafe(method_family = none)]
1172        pub unsafe fn encodeToCommandBuffer_primarySourceArray_secondarySourceArray(
1173            &self,
1174            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
1175            primary_source_array: &MPSNDArray,
1176            secondary_source_array: &MPSNDArray,
1177        ) -> Retained<MPSNDArray>;
1178
1179        /// Encode a simple inference NDArray kernel and return a NDArray to hold the result
1180        ///
1181        /// Parameter `cmdBuf`: The command buffer into which to encode the kernel
1182        ///
1183        /// Parameter `primarySourceArray`: The primary source for the filter in an NSArray.
1184        ///
1185        /// Parameter `secondarySourceArray`: The secondary source for the filter in an NSArray.
1186        ///
1187        /// Parameter `destination`: The NDArray to receive the result
1188        #[unsafe(method(encodeToCommandBuffer:primarySourceArray:secondarySourceArray:destinationArray:))]
1189        #[unsafe(method_family = none)]
1190        pub unsafe fn encodeToCommandBuffer_primarySourceArray_secondarySourceArray_destinationArray(
1191            &self,
1192            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
1193            primary_source_array: &MPSNDArray,
1194            secondary_source_array: &MPSNDArray,
1195            destination: &MPSNDArray,
1196        );
1197
1198        #[cfg(feature = "MPSState")]
1199        /// Encode a simple inference NDArray kernel and return a NDArray to hold the result
1200        ///
1201        /// Parameter `cmdBuf`: The command buffer into which to encode the kernel
1202        ///
1203        /// Parameter `primarySourceArray`: The primary source for the filter in an NSArray.
1204        ///
1205        /// Parameter `secondarySourceArray`: The secondary source for the filter in an NSArray.
1206        ///
1207        /// Parameter `outGradientState`: If non-nil, the address output gradient state is written to this address
1208        ///
1209        /// Parameter `outputStateIsTemporary`: If YES, the state if any will be allocated to contain temporary textures and buffers as needed
1210        ///
1211        /// Returns: A newly allocated MPSNDArray that will contain the result of the calculation
1212        /// when the command buffer completes successfully.
1213        #[unsafe(method(encodeToCommandBuffer:primarySourceArray:secondarySourceArray:resultState:outputStateIsTemporary:))]
1214        #[unsafe(method_family = none)]
1215        pub unsafe fn encodeToCommandBuffer_primarySourceArray_secondarySourceArray_resultState_outputStateIsTemporary(
1216            &self,
1217            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
1218            primary_source_array: &MPSNDArray,
1219            secondary_source_array: &MPSNDArray,
1220            out_gradient_state: Option<&mut Option<Retained<MPSState>>>,
1221            output_state_is_temporary: bool,
1222        ) -> Retained<MPSNDArray>;
1223
1224        #[cfg(feature = "MPSState")]
1225        /// Encode a simple inference NDArray kernel and return a NDArray to hold the result
1226        ///
1227        /// Parameter `cmdBuf`: The command buffer into which to encode the kernel
1228        ///
1229        /// Parameter `primarySourceArray`: The primary source for the filter in an NSArray.
1230        ///
1231        /// Parameter `secondarySourceArray`: The secondary source for the filter in an NSArray.
1232        ///
1233        /// Parameter `outGradientState`: The output gradient state to record the operation for later use by gradient
1234        ///
1235        /// Parameter `destination`: A destination array to contain the result of the calculation
1236        /// when the command buffer completes successfully.
1237        #[unsafe(method(encodeToCommandBuffer:primarySourceArray:secondarySourceArray:resultState:destinationArray:))]
1238        #[unsafe(method_family = none)]
1239        pub unsafe fn encodeToCommandBuffer_primarySourceArray_secondarySourceArray_resultState_destinationArray(
1240            &self,
1241            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
1242            primary_source_array: &MPSNDArray,
1243            secondary_source_array: &MPSNDArray,
1244            out_gradient_state: Option<&MPSState>,
1245            destination: &MPSNDArray,
1246        );
1247    );
1248}
1249
1250/// Methods declared on superclass `MPSKernel`.
1251#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1252impl MPSNDArrayBinaryKernel {
1253    extern_methods!(
1254        /// Called by NSCoder to decode MPSKernels
1255        ///
1256        /// This isn't the right interface to decode a MPSKernel, but
1257        /// it is the one that NSCoder uses. To enable your NSCoder
1258        /// (e.g. NSKeyedUnarchiver) to set which device to use
1259        /// extend the object to adopt the MPSDeviceProvider
1260        /// protocol. Otherwise, the Metal system default device
1261        /// will be used.
1262        ///
1263        /// # Safety
1264        ///
1265        /// `a_decoder` possibly has further requirements.
1266        #[unsafe(method(initWithCoder:))]
1267        #[unsafe(method_family = init)]
1268        pub unsafe fn initWithCoder(
1269            this: Allocated<Self>,
1270            a_decoder: &NSCoder,
1271        ) -> Option<Retained<Self>>;
1272    );
1273}
1274
1275/// Methods declared on superclass `NSObject`.
1276#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1277impl MPSNDArrayBinaryKernel {
1278    extern_methods!(
1279        #[unsafe(method(init))]
1280        #[unsafe(method_family = init)]
1281        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1282
1283        #[unsafe(method(new))]
1284        #[unsafe(method_family = new)]
1285        pub unsafe fn new() -> Retained<Self>;
1286    );
1287}
1288
1289extern_class!(
1290    /// Dependencies: This depends on Metal.framework.
1291    ///
1292    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarraybinaryprimarygradientkernel?language=objc)
1293    #[unsafe(super(
1294        MPSNDArrayMultiaryGradientKernel,
1295        MPSNDArrayMultiaryBase,
1296        MPSKernel,
1297        NSObject
1298    ))]
1299    #[derive(Debug, PartialEq, Eq, Hash)]
1300    #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1301    pub struct MPSNDArrayBinaryPrimaryGradientKernel;
1302);
1303
1304#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1305extern_conformance!(
1306    unsafe impl NSCoding for MPSNDArrayBinaryPrimaryGradientKernel {}
1307);
1308
1309#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1310extern_conformance!(
1311    unsafe impl NSCopying for MPSNDArrayBinaryPrimaryGradientKernel {}
1312);
1313
1314#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1315unsafe impl CopyingHelper for MPSNDArrayBinaryPrimaryGradientKernel {
1316    type Result = Self;
1317}
1318
1319#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1320extern_conformance!(
1321    unsafe impl NSObjectProtocol for MPSNDArrayBinaryPrimaryGradientKernel {}
1322);
1323
1324#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1325extern_conformance!(
1326    unsafe impl NSSecureCoding for MPSNDArrayBinaryPrimaryGradientKernel {}
1327);
1328
1329#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1330impl MPSNDArrayBinaryPrimaryGradientKernel {
1331    extern_methods!(
1332        #[unsafe(method(initWithDevice:sourceCount:sourceGradientIndex:))]
1333        #[unsafe(method_family = init)]
1334        pub unsafe fn initWithDevice_sourceCount_sourceGradientIndex(
1335            this: Allocated<Self>,
1336            device: &ProtocolObject<dyn MTLDevice>,
1337            count: NSUInteger,
1338            source_gradient_index: NSUInteger,
1339        ) -> Retained<Self>;
1340
1341        #[unsafe(method(initWithDevice:))]
1342        #[unsafe(method_family = init)]
1343        pub unsafe fn initWithDevice(
1344            this: Allocated<Self>,
1345            device: &ProtocolObject<dyn MTLDevice>,
1346        ) -> Retained<Self>;
1347
1348        /// # Safety
1349        ///
1350        /// `coder` possibly has further requirements.
1351        #[unsafe(method(initWithCoder:device:))]
1352        #[unsafe(method_family = init)]
1353        pub unsafe fn initWithCoder_device(
1354            this: Allocated<Self>,
1355            coder: &NSCoder,
1356            device: &ProtocolObject<dyn MTLDevice>,
1357        ) -> Retained<Self>;
1358
1359        #[cfg(feature = "MPSState")]
1360        #[unsafe(method(encodeToCommandBuffer:primarySourceArray:secondarySourceArray:sourceGradient:gradientState:))]
1361        #[unsafe(method_family = none)]
1362        pub unsafe fn encodeToCommandBuffer_primarySourceArray_secondarySourceArray_sourceGradient_gradientState(
1363            &self,
1364            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
1365            primary_source_array: &MPSNDArray,
1366            secondary_source_array: &MPSNDArray,
1367            gradient: &MPSNDArray,
1368            state: &MPSState,
1369        ) -> Retained<MPSNDArray>;
1370
1371        #[cfg(feature = "MPSState")]
1372        #[unsafe(method(encodeToCommandBuffer:primarySourceArray:secondarySourceArray:sourceGradient:gradientState:destinationArray:))]
1373        #[unsafe(method_family = none)]
1374        pub unsafe fn encodeToCommandBuffer_primarySourceArray_secondarySourceArray_sourceGradient_gradientState_destinationArray(
1375            &self,
1376            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
1377            primary_source_array: &MPSNDArray,
1378            secondary_source_array: &MPSNDArray,
1379            gradient: &MPSNDArray,
1380            state: &MPSState,
1381            destination: &MPSNDArray,
1382        );
1383    );
1384}
1385
1386/// Methods declared on superclass `MPSNDArrayMultiaryGradientKernel`.
1387#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1388impl MPSNDArrayBinaryPrimaryGradientKernel {
1389    extern_methods!(
1390        #[unsafe(method(initWithDevice:sourceCount:))]
1391        #[unsafe(method_family = init)]
1392        pub unsafe fn initWithDevice_sourceCount(
1393            this: Allocated<Self>,
1394            device: &ProtocolObject<dyn MTLDevice>,
1395            count: NSUInteger,
1396        ) -> Retained<Self>;
1397    );
1398}
1399
1400/// Methods declared on superclass `MPSKernel`.
1401#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1402impl MPSNDArrayBinaryPrimaryGradientKernel {
1403    extern_methods!(
1404        /// Called by NSCoder to decode MPSKernels
1405        ///
1406        /// This isn't the right interface to decode a MPSKernel, but
1407        /// it is the one that NSCoder uses. To enable your NSCoder
1408        /// (e.g. NSKeyedUnarchiver) to set which device to use
1409        /// extend the object to adopt the MPSDeviceProvider
1410        /// protocol. Otherwise, the Metal system default device
1411        /// will be used.
1412        ///
1413        /// # Safety
1414        ///
1415        /// `a_decoder` possibly has further requirements.
1416        #[unsafe(method(initWithCoder:))]
1417        #[unsafe(method_family = init)]
1418        pub unsafe fn initWithCoder(
1419            this: Allocated<Self>,
1420            a_decoder: &NSCoder,
1421        ) -> Option<Retained<Self>>;
1422    );
1423}
1424
1425/// Methods declared on superclass `NSObject`.
1426#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1427impl MPSNDArrayBinaryPrimaryGradientKernel {
1428    extern_methods!(
1429        #[unsafe(method(init))]
1430        #[unsafe(method_family = init)]
1431        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1432
1433        #[unsafe(method(new))]
1434        #[unsafe(method_family = new)]
1435        pub unsafe fn new() -> Retained<Self>;
1436    );
1437}
1438
1439extern_class!(
1440    /// Dependencies: This depends on Metal.framework.
1441    ///
1442    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarraybinarysecondarygradientkernel?language=objc)
1443    #[unsafe(super(
1444        MPSNDArrayMultiaryGradientKernel,
1445        MPSNDArrayMultiaryBase,
1446        MPSKernel,
1447        NSObject
1448    ))]
1449    #[derive(Debug, PartialEq, Eq, Hash)]
1450    #[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1451    pub struct MPSNDArrayBinarySecondaryGradientKernel;
1452);
1453
1454#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1455extern_conformance!(
1456    unsafe impl NSCoding for MPSNDArrayBinarySecondaryGradientKernel {}
1457);
1458
1459#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1460extern_conformance!(
1461    unsafe impl NSCopying for MPSNDArrayBinarySecondaryGradientKernel {}
1462);
1463
1464#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1465unsafe impl CopyingHelper for MPSNDArrayBinarySecondaryGradientKernel {
1466    type Result = Self;
1467}
1468
1469#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1470extern_conformance!(
1471    unsafe impl NSObjectProtocol for MPSNDArrayBinarySecondaryGradientKernel {}
1472);
1473
1474#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1475extern_conformance!(
1476    unsafe impl NSSecureCoding for MPSNDArrayBinarySecondaryGradientKernel {}
1477);
1478
1479#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1480impl MPSNDArrayBinarySecondaryGradientKernel {
1481    extern_methods!(
1482        #[unsafe(method(initWithDevice:sourceCount:sourceGradientIndex:))]
1483        #[unsafe(method_family = init)]
1484        pub unsafe fn initWithDevice_sourceCount_sourceGradientIndex(
1485            this: Allocated<Self>,
1486            device: &ProtocolObject<dyn MTLDevice>,
1487            count: NSUInteger,
1488            source_gradient_index: NSUInteger,
1489        ) -> Retained<Self>;
1490
1491        #[unsafe(method(initWithDevice:))]
1492        #[unsafe(method_family = init)]
1493        pub unsafe fn initWithDevice(
1494            this: Allocated<Self>,
1495            device: &ProtocolObject<dyn MTLDevice>,
1496        ) -> Retained<Self>;
1497
1498        /// # Safety
1499        ///
1500        /// `coder` possibly has further requirements.
1501        #[unsafe(method(initWithCoder:device:))]
1502        #[unsafe(method_family = init)]
1503        pub unsafe fn initWithCoder_device(
1504            this: Allocated<Self>,
1505            coder: &NSCoder,
1506            device: &ProtocolObject<dyn MTLDevice>,
1507        ) -> Retained<Self>;
1508
1509        #[cfg(feature = "MPSState")]
1510        #[unsafe(method(encodeToCommandBuffer:primarySourceArray:secondarySourceArray:sourceGradient:gradientState:))]
1511        #[unsafe(method_family = none)]
1512        pub unsafe fn encodeToCommandBuffer_primarySourceArray_secondarySourceArray_sourceGradient_gradientState(
1513            &self,
1514            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
1515            primary_source_array: &MPSNDArray,
1516            secondary_source_array: &MPSNDArray,
1517            gradient: &MPSNDArray,
1518            state: &MPSState,
1519        ) -> Retained<MPSNDArray>;
1520
1521        #[cfg(feature = "MPSState")]
1522        #[unsafe(method(encodeToCommandBuffer:primarySourceArray:secondarySourceArray:sourceGradient:gradientState:destinationArray:))]
1523        #[unsafe(method_family = none)]
1524        pub unsafe fn encodeToCommandBuffer_primarySourceArray_secondarySourceArray_sourceGradient_gradientState_destinationArray(
1525            &self,
1526            cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
1527            primary_source_array: &MPSNDArray,
1528            secondary_source_array: &MPSNDArray,
1529            gradient: &MPSNDArray,
1530            state: &MPSState,
1531            destination: &MPSNDArray,
1532        );
1533    );
1534}
1535
1536/// Methods declared on superclass `MPSNDArrayMultiaryGradientKernel`.
1537#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1538impl MPSNDArrayBinarySecondaryGradientKernel {
1539    extern_methods!(
1540        #[unsafe(method(initWithDevice:sourceCount:))]
1541        #[unsafe(method_family = init)]
1542        pub unsafe fn initWithDevice_sourceCount(
1543            this: Allocated<Self>,
1544            device: &ProtocolObject<dyn MTLDevice>,
1545            count: NSUInteger,
1546        ) -> Retained<Self>;
1547    );
1548}
1549
1550/// Methods declared on superclass `MPSKernel`.
1551#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1552impl MPSNDArrayBinarySecondaryGradientKernel {
1553    extern_methods!(
1554        /// Called by NSCoder to decode MPSKernels
1555        ///
1556        /// This isn't the right interface to decode a MPSKernel, but
1557        /// it is the one that NSCoder uses. To enable your NSCoder
1558        /// (e.g. NSKeyedUnarchiver) to set which device to use
1559        /// extend the object to adopt the MPSDeviceProvider
1560        /// protocol. Otherwise, the Metal system default device
1561        /// will be used.
1562        ///
1563        /// # Safety
1564        ///
1565        /// `a_decoder` possibly has further requirements.
1566        #[unsafe(method(initWithCoder:))]
1567        #[unsafe(method_family = init)]
1568        pub unsafe fn initWithCoder(
1569            this: Allocated<Self>,
1570            a_decoder: &NSCoder,
1571        ) -> Option<Retained<Self>>;
1572    );
1573}
1574
1575/// Methods declared on superclass `NSObject`.
1576#[cfg(all(feature = "MPSCore", feature = "MPSKernel"))]
1577impl MPSNDArrayBinarySecondaryGradientKernel {
1578    extern_methods!(
1579        #[unsafe(method(init))]
1580        #[unsafe(method_family = init)]
1581        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1582
1583        #[unsafe(method(new))]
1584        #[unsafe(method_family = new)]
1585        pub unsafe fn new() -> Retained<Self>;
1586    );
1587}