objc2_metal_performance_shaders/generated/MPSNeuralNetwork/MPSMatrixFullyConnected.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 fully connected neural network layer by performing a
16 /// a matrix multiplication, adding a bias vector, scaling, and applying a
17 /// neuron activation function.
18 ///
19 ///
20 /// A MPSMatrixFullyConnected object computes:
21 ///
22 /// y = neuron(alpha * x * W + bias)
23 ///
24 /// y is the output matrix, x and W are input matrices corresponding
25 /// to a collection of input vectors and weights respectively, and bias
26 /// is a vector which is broadcast and accumulated to each row
27 /// of the product. alpha is a scale factor applied to the product.
28 ///
29 /// neuron() is a pointwise function applied to the intermediate result.
30 ///
31 /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsmatrixfullyconnected?language=objc)
32 #[unsafe(super(MPSMatrixBinaryKernel, 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 MPSMatrixFullyConnected;
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 MPSMatrixFullyConnected {}
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 MPSMatrixFullyConnected {}
61);
62
63#[cfg(all(
64 feature = "MPSCore",
65 feature = "MPSKernel",
66 feature = "MPSMatrix",
67 feature = "MPSMatrixTypes"
68))]
69unsafe impl CopyingHelper for MPSMatrixFullyConnected {
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 MPSMatrixFullyConnected {}
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 MPSMatrixFullyConnected {}
91);
92
93#[cfg(all(
94 feature = "MPSCore",
95 feature = "MPSKernel",
96 feature = "MPSMatrix",
97 feature = "MPSMatrixTypes"
98))]
99impl MPSMatrixFullyConnected {
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 primarySourceMatrixOrigin.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 and the number of rows in the primary (input array) and
122 /// secondary (weight array) source matrices respectively.
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
126 /// columns in the input array (beginning at primarySourceMatrixOrigin.y) and all
127 /// available rows in the weight array (beginning at secondarySourceMatrixOrigin.x)
128 /// should be considered.
129 /// Note: The value used in the operation will be
130 /// MIN(MIN(inputMatrix.columns - primarySourceMatrixOrigin.y,
131 /// weightMatrix.rows - secondarySourceMatrixOrigin.x),
132 /// sourceInputFeatureChannels)
133 #[unsafe(method(sourceInputFeatureChannels))]
134 #[unsafe(method_family = none)]
135 pub unsafe fn sourceInputFeatureChannels(&self) -> NSUInteger;
136
137 /// Setter for [`sourceInputFeatureChannels`][Self::sourceInputFeatureChannels].
138 #[unsafe(method(setSourceInputFeatureChannels:))]
139 #[unsafe(method_family = none)]
140 pub unsafe fn setSourceInputFeatureChannels(
141 &self,
142 source_input_feature_channels: NSUInteger,
143 );
144
145 /// The output size to to use in the operation. This is equivalent to the
146 /// number of columns to consider in the weight array, or the secondary source matrix.
147 /// This property is modifiable and defaults to NSUIntegerMax. At encode
148 /// time the larger of this property or the available output size is used.
149 /// The value of NSUIntegerMax thus indicates that all available
150 /// columns in the weight array (beginning at secondarySourceMatrixOrigin.y)
151 /// should be considered.
152 #[unsafe(method(sourceOutputFeatureChannels))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn sourceOutputFeatureChannels(&self) -> NSUInteger;
155
156 /// Setter for [`sourceOutputFeatureChannels`][Self::sourceOutputFeatureChannels].
157 #[unsafe(method(setSourceOutputFeatureChannels:))]
158 #[unsafe(method_family = none)]
159 pub unsafe fn setSourceOutputFeatureChannels(
160 &self,
161 source_output_feature_channels: NSUInteger,
162 );
163
164 /// The scale factor to apply to the product. Specified in double
165 /// precision. Will be converted to the appropriate precision in the
166 /// implementation subject to rounding and/or clamping as necessary.
167 /// Defaults to 1.0 at initialization time.
168 #[unsafe(method(alpha))]
169 #[unsafe(method_family = none)]
170 pub unsafe fn alpha(&self) -> c_double;
171
172 /// Setter for [`alpha`][Self::alpha].
173 #[unsafe(method(setAlpha:))]
174 #[unsafe(method_family = none)]
175 pub unsafe fn setAlpha(&self, alpha: c_double);
176
177 #[cfg(feature = "MPSCNNNeuronType")]
178 /// Specifies a neuron activation function to be used.
179 ///
180 ///
181 /// This method can be used to add a neuron activation funtion of given type with
182 /// associated scalar parameters A, B, and C that are shared across all output values.
183 /// Note that this method can only be used to specify neurons which are specified by three (or fewer)
184 /// parameters shared across all output values (or channels, in CNN nomenclature). It is an error to call
185 /// this method for neuron activation functions like MPSCNNNeuronTypePReLU,
186 /// which require per-channel parameter values. For those kind of neuron activation functions,
187 /// use appropriate setter functions. An MPSMatrixFullyConnected kernel is initialized
188 /// with a default neuron function of MPSCNNNeuronTypeNone.
189 ///
190 ///
191 /// Parameter `neuronType`: Type of neuron activation function. For full list see MPSCNNNeuronType.h
192 ///
193 /// Parameter `parameterA`: parameterA of neuron activation that is shared across all output values.
194 ///
195 /// Parameter `parameterB`: parameterB of neuron activation that is shared across all output values.
196 ///
197 /// Parameter `parameterC`: parameterC of neuron activation that is shared across all output values.
198 #[unsafe(method(setNeuronType:parameterA:parameterB:parameterC:))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn setNeuronType_parameterA_parameterB_parameterC(
201 &self,
202 neuron_type: MPSCNNNeuronType,
203 parameter_a: c_float,
204 parameter_b: c_float,
205 parameter_c: c_float,
206 );
207
208 #[cfg(feature = "MPSCNNNeuronType")]
209 /// Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method
210 #[unsafe(method(neuronType))]
211 #[unsafe(method_family = none)]
212 pub unsafe fn neuronType(&self) -> MPSCNNNeuronType;
213
214 /// Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method
215 #[unsafe(method(neuronParameterA))]
216 #[unsafe(method_family = none)]
217 pub unsafe fn neuronParameterA(&self) -> c_float;
218
219 /// Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method
220 #[unsafe(method(neuronParameterB))]
221 #[unsafe(method_family = none)]
222 pub unsafe fn neuronParameterB(&self) -> c_float;
223
224 /// Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method
225 #[unsafe(method(neuronParameterC))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn neuronParameterC(&self) -> c_float;
228
229 #[unsafe(method(initWithDevice:))]
230 #[unsafe(method_family = init)]
231 pub unsafe fn initWithDevice(
232 this: Allocated<Self>,
233 device: &ProtocolObject<dyn MTLDevice>,
234 ) -> Retained<Self>;
235
236 /// Encode a MPSMatrixFullyConnected object to a command buffer.
237 ///
238 ///
239 /// Parameter `commandBuffer`: A valid MTLCommandBuffer to receive the encoded kernel.
240 ///
241 ///
242 /// Parameter `inputMatrix`: A valid MPSMatrix object which specifies the input array.
243 ///
244 ///
245 /// Parameter `weightMatrix`: A valid MPSMatrix object which specifies the weight array.
246 ///
247 ///
248 /// Parameter `biasVector`: A valid MPSVector object which specifies the bias values, or
249 /// a null object to indicate that no bias is to be applied.
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(sourceNumberOfInputs,
258 /// inputMatrix.rows - primarySourceMatrixOrigin.x)
259 /// x
260 /// MIN(sourceOutputFeatureChannels,
261 /// weightMatrix.columns - secondarySourceMatrixOrigin.y) array.
262 ///
263 /// The bias vector must contain at least
264 /// MIN(sourceOutputFeatureChannels, weightMatrix.columns - secondarySourceMatrixOrigin.y) elements.
265 #[unsafe(method(encodeToCommandBuffer:inputMatrix:weightMatrix:biasVector:resultMatrix:))]
266 #[unsafe(method_family = none)]
267 pub unsafe fn encodeToCommandBuffer_inputMatrix_weightMatrix_biasVector_resultMatrix(
268 &self,
269 command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
270 input_matrix: &MPSMatrix,
271 weight_matrix: &MPSMatrix,
272 bias_vector: Option<&MPSVector>,
273 result_matrix: &MPSMatrix,
274 );
275
276 /// NSSecureCoding compatability
277 ///
278 /// See
279 /// MPSKernel#initWithCoder.
280 /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSMatrixFullyConnected
281 ///
282 /// Parameter `device`: The MTLDevice on which to make the MPSMatrixFullyConnected object.
283 ///
284 /// Returns: A new MPSMatrixFullyConnected object, or nil if failure.
285 ///
286 /// # Safety
287 ///
288 /// `a_decoder` possibly has further requirements.
289 #[unsafe(method(initWithCoder:device:))]
290 #[unsafe(method_family = init)]
291 pub unsafe fn initWithCoder_device(
292 this: Allocated<Self>,
293 a_decoder: &NSCoder,
294 device: &ProtocolObject<dyn MTLDevice>,
295 ) -> Option<Retained<Self>>;
296
297 /// Make a copy of this kernel for a new device -
298 ///
299 /// See: MPSKernel
300 ///
301 /// Parameter `zone`: The NSZone in which to allocate the object
302 ///
303 /// Parameter `device`: The device for the new MPSKernel. If nil, then use
304 /// self.device.
305 ///
306 /// Returns: A pointer to a copy of this MPSKernel. This will fail, returning
307 /// nil if the device is not supported. Devices must be
308 /// MTLFeatureSet_iOS_GPUFamily2_v1 or later.
309 ///
310 /// # Safety
311 ///
312 /// `zone` must be a valid pointer or null.
313 #[unsafe(method(copyWithZone:device:))]
314 #[unsafe(method_family = copy)]
315 pub unsafe fn copyWithZone_device(
316 &self,
317 zone: *mut NSZone,
318 device: Option<&ProtocolObject<dyn MTLDevice>>,
319 ) -> Retained<Self>;
320 );
321}
322
323/// Methods declared on superclass `MPSKernel`.
324#[cfg(all(
325 feature = "MPSCore",
326 feature = "MPSKernel",
327 feature = "MPSMatrix",
328 feature = "MPSMatrixTypes"
329))]
330impl MPSMatrixFullyConnected {
331 extern_methods!(
332 /// Called by NSCoder to decode MPSKernels
333 ///
334 /// This isn't the right interface to decode a MPSKernel, but
335 /// it is the one that NSCoder uses. To enable your NSCoder
336 /// (e.g. NSKeyedUnarchiver) to set which device to use
337 /// extend the object to adopt the MPSDeviceProvider
338 /// protocol. Otherwise, the Metal system default device
339 /// will be used.
340 ///
341 /// # Safety
342 ///
343 /// `a_decoder` possibly has further requirements.
344 #[unsafe(method(initWithCoder:))]
345 #[unsafe(method_family = init)]
346 pub unsafe fn initWithCoder(
347 this: Allocated<Self>,
348 a_decoder: &NSCoder,
349 ) -> Option<Retained<Self>>;
350 );
351}
352
353/// Methods declared on superclass `NSObject`.
354#[cfg(all(
355 feature = "MPSCore",
356 feature = "MPSKernel",
357 feature = "MPSMatrix",
358 feature = "MPSMatrixTypes"
359))]
360impl MPSMatrixFullyConnected {
361 extern_methods!(
362 #[unsafe(method(init))]
363 #[unsafe(method_family = init)]
364 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
365
366 #[unsafe(method(new))]
367 #[unsafe(method_family = new)]
368 pub unsafe fn new() -> Retained<Self>;
369 );
370}
371
372extern_class!(
373 /// Dependencies: This depends on Metal.framework.
374 ///
375 ///
376 /// Computes the gradient of the fully connected layer with respect
377 /// to either the weights and bias terms or the input feature vectors.
378 ///
379 ///
380 /// An MPSMatrixFullyConnectedGradient kernel may be used to compute
381 /// the gradients corresponding to a MPSMatrixFullyConnected kernel.
382 /// The properties, input, and weight data must match those values
383 /// used in the forward computation.
384 /// This kernel does not compute the gradient of any non-identity
385 /// activation function which may have been applied in the forward
386 /// kernel. Such a kernel must be expressed using both MPSMatrixFullyConnected
387 /// and MPSMatrixNeuron if a gradient is to be computed.
388 ///
389 /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsmatrixfullyconnectedgradient?language=objc)
390 #[unsafe(super(MPSMatrixBinaryKernel, MPSKernel, NSObject))]
391 #[derive(Debug, PartialEq, Eq, Hash)]
392 #[cfg(all(
393 feature = "MPSCore",
394 feature = "MPSKernel",
395 feature = "MPSMatrix",
396 feature = "MPSMatrixTypes"
397 ))]
398 pub struct MPSMatrixFullyConnectedGradient;
399);
400
401#[cfg(all(
402 feature = "MPSCore",
403 feature = "MPSKernel",
404 feature = "MPSMatrix",
405 feature = "MPSMatrixTypes"
406))]
407extern_conformance!(
408 unsafe impl NSCoding for MPSMatrixFullyConnectedGradient {}
409);
410
411#[cfg(all(
412 feature = "MPSCore",
413 feature = "MPSKernel",
414 feature = "MPSMatrix",
415 feature = "MPSMatrixTypes"
416))]
417extern_conformance!(
418 unsafe impl NSCopying for MPSMatrixFullyConnectedGradient {}
419);
420
421#[cfg(all(
422 feature = "MPSCore",
423 feature = "MPSKernel",
424 feature = "MPSMatrix",
425 feature = "MPSMatrixTypes"
426))]
427unsafe impl CopyingHelper for MPSMatrixFullyConnectedGradient {
428 type Result = Self;
429}
430
431#[cfg(all(
432 feature = "MPSCore",
433 feature = "MPSKernel",
434 feature = "MPSMatrix",
435 feature = "MPSMatrixTypes"
436))]
437extern_conformance!(
438 unsafe impl NSObjectProtocol for MPSMatrixFullyConnectedGradient {}
439);
440
441#[cfg(all(
442 feature = "MPSCore",
443 feature = "MPSKernel",
444 feature = "MPSMatrix",
445 feature = "MPSMatrixTypes"
446))]
447extern_conformance!(
448 unsafe impl NSSecureCoding for MPSMatrixFullyConnectedGradient {}
449);
450
451#[cfg(all(
452 feature = "MPSCore",
453 feature = "MPSKernel",
454 feature = "MPSMatrix",
455 feature = "MPSMatrixTypes"
456))]
457impl MPSMatrixFullyConnectedGradient {
458 extern_methods!(
459 /// The number of input vectors which make up the input array.
460 /// This is equivalent to the number of rows in both the input
461 /// matrix and the source gradient matrix.
462 ///
463 /// This value should be equal to the corresponding value in the
464 /// forward fully connected kernel.
465 #[unsafe(method(sourceNumberOfFeatureVectors))]
466 #[unsafe(method_family = none)]
467 pub unsafe fn sourceNumberOfFeatureVectors(&self) -> NSUInteger;
468
469 /// Setter for [`sourceNumberOfFeatureVectors`][Self::sourceNumberOfFeatureVectors].
470 #[unsafe(method(setSourceNumberOfFeatureVectors:))]
471 #[unsafe(method_family = none)]
472 pub unsafe fn setSourceNumberOfFeatureVectors(
473 &self,
474 source_number_of_feature_vectors: NSUInteger,
475 );
476
477 /// The number of feature channels in the output of the forward
478 /// fully connected layer.
479 /// This is equivalent to the number of columns in both the weight
480 /// matrix and the source gradient matrix.
481 ///
482 /// This value should be equal to the corresponding value in the
483 /// forward fully connected kernel.
484 #[unsafe(method(sourceOutputFeatureChannels))]
485 #[unsafe(method_family = none)]
486 pub unsafe fn sourceOutputFeatureChannels(&self) -> NSUInteger;
487
488 /// Setter for [`sourceOutputFeatureChannels`][Self::sourceOutputFeatureChannels].
489 #[unsafe(method(setSourceOutputFeatureChannels:))]
490 #[unsafe(method_family = none)]
491 pub unsafe fn setSourceOutputFeatureChannels(
492 &self,
493 source_output_feature_channels: NSUInteger,
494 );
495
496 /// The number of feature channels in the input to the forward
497 /// fully connected layer.
498 /// This is equivalent to the number of columns in the input matrix.
499 ///
500 /// This value should be equal to the corresponding value in the
501 /// forward fully connected kernel.
502 #[unsafe(method(sourceInputFeatureChannels))]
503 #[unsafe(method_family = none)]
504 pub unsafe fn sourceInputFeatureChannels(&self) -> NSUInteger;
505
506 /// Setter for [`sourceInputFeatureChannels`][Self::sourceInputFeatureChannels].
507 #[unsafe(method(setSourceInputFeatureChannels:))]
508 #[unsafe(method_family = none)]
509 pub unsafe fn setSourceInputFeatureChannels(
510 &self,
511 source_input_feature_channels: NSUInteger,
512 );
513
514 /// Scale factor to apply to the product. This value should be equal
515 /// to the corresponding value in the forward fully connected kernel.
516 #[unsafe(method(alpha))]
517 #[unsafe(method_family = none)]
518 pub unsafe fn alpha(&self) -> c_double;
519
520 /// Setter for [`alpha`][Self::alpha].
521 #[unsafe(method(setAlpha:))]
522 #[unsafe(method_family = none)]
523 pub unsafe fn setAlpha(&self, alpha: c_double);
524
525 #[unsafe(method(initWithDevice:))]
526 #[unsafe(method_family = init)]
527 pub unsafe fn initWithDevice(
528 this: Allocated<Self>,
529 device: &ProtocolObject<dyn MTLDevice>,
530 ) -> Retained<Self>;
531
532 /// Encode a MPSMatrixFullyConnectedGradient object to a command buffer and
533 /// produce the gradient of the loss function with respect to the input data.
534 ///
535 ///
536 /// Parameter `commandBuffer`: A valid MTLCommandBuffer to receive the encoded kernel.
537 ///
538 ///
539 /// Parameter `gradientMatrix`: A valid MPSMatrix object which specifies the input gradient.
540 ///
541 ///
542 /// Parameter `weightMatrix`: A valid MPSMatrix object which specifies the weight array.
543 ///
544 ///
545 /// Parameter `resultGradientForDataMatrix`: A valid MPSMatrix object which specifies the result gradient.
546 ///
547 ///
548 /// This operation computes the resulting gradient of the loss function with respect
549 /// to the forward kernel's input data. weightMatrix should contain the same values
550 /// used to compute the result of the forward kernel.
551 #[unsafe(method(encodeGradientForDataToCommandBuffer:gradientMatrix:weightMatrix:resultGradientForDataMatrix:))]
552 #[unsafe(method_family = none)]
553 pub unsafe fn encodeGradientForDataToCommandBuffer_gradientMatrix_weightMatrix_resultGradientForDataMatrix(
554 &self,
555 command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
556 gradient_matrix: &MPSMatrix,
557 weight_matrix: &MPSMatrix,
558 result_gradient_for_data_matrix: &MPSMatrix,
559 );
560
561 /// Encode a MPSMatrixFullyConnectedGradient object to a command buffer and
562 /// produce the gradient of the loss function with respect to the weight matrix
563 /// and bias vector.
564 ///
565 ///
566 /// Parameter `commandBuffer`: A valid MTLCommandBuffer to receive the encoded kernel.
567 ///
568 ///
569 /// Parameter `gradientMatrix`: A valid MPSMatrix object which specifies the input gradient.
570 ///
571 ///
572 /// Parameter `inputMatrix`: A valid MPSMatrix object which specifies the input array.
573 ///
574 ///
575 /// Parameter `resultGradientForWeightMatrix`: A valid MPSMatrix object which specifies the resulting gradients
576 /// with respect to the weights.
577 ///
578 ///
579 /// Parameter `resultGradientForBiasVector`: A valid MPSVector object which specifies the resulting gradients
580 /// with respect to the bias terms. If NULL these values will not be
581 /// returned.
582 ///
583 ///
584 /// This operation computes the resulting gradient of the loss function with respect
585 /// to the forward kernel's weight data. inputMatrix should contain the same values
586 /// used to compute the result of the forward kernel.
587 #[unsafe(method(encodeGradientForWeightsAndBiasToCommandBuffer:gradientMatrix:inputMatrix:resultGradientForWeightMatrix:resultGradientForBiasVector:))]
588 #[unsafe(method_family = none)]
589 pub unsafe fn encodeGradientForWeightsAndBiasToCommandBuffer_gradientMatrix_inputMatrix_resultGradientForWeightMatrix_resultGradientForBiasVector(
590 &self,
591 command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
592 gradient_matrix: &MPSMatrix,
593 input_matrix: &MPSMatrix,
594 result_gradient_for_weight_matrix: &MPSMatrix,
595 result_gradient_for_bias_vector: Option<&MPSVector>,
596 );
597
598 /// NSSecureCoding compatability
599 ///
600 /// See
601 /// MPSKernel#initWithCoder.
602 /// Parameter `aDecoder`: The NSCoder subclass with your serialized MPSMatrixFullyConnectedGradient
603 ///
604 /// Parameter `device`: The MTLDevice on which to make the MPSMatrixFullyConnectedGradient object.
605 ///
606 /// Returns: A new MPSMatrixFullyConnected object, or nil if failure.
607 ///
608 /// # Safety
609 ///
610 /// `a_decoder` possibly has further requirements.
611 #[unsafe(method(initWithCoder:device:))]
612 #[unsafe(method_family = init)]
613 pub unsafe fn initWithCoder_device(
614 this: Allocated<Self>,
615 a_decoder: &NSCoder,
616 device: &ProtocolObject<dyn MTLDevice>,
617 ) -> Option<Retained<Self>>;
618
619 /// Make a copy of this kernel for a new device -
620 ///
621 /// See: MPSKernel
622 ///
623 /// Parameter `zone`: The NSZone in which to allocate the object
624 ///
625 /// Parameter `device`: The device for the new MPSKernel. If nil, then use
626 /// self.device.
627 ///
628 /// Returns: A pointer to a copy of this MPSKernel. This will fail, returning
629 /// nil if the device is not supported. Devices must be
630 /// MTLFeatureSet_iOS_GPUFamily2_v1 or later.
631 ///
632 /// # Safety
633 ///
634 /// `zone` must be a valid pointer or null.
635 #[unsafe(method(copyWithZone:device:))]
636 #[unsafe(method_family = copy)]
637 pub unsafe fn copyWithZone_device(
638 &self,
639 zone: *mut NSZone,
640 device: Option<&ProtocolObject<dyn MTLDevice>>,
641 ) -> Retained<Self>;
642 );
643}
644
645/// Methods declared on superclass `MPSKernel`.
646#[cfg(all(
647 feature = "MPSCore",
648 feature = "MPSKernel",
649 feature = "MPSMatrix",
650 feature = "MPSMatrixTypes"
651))]
652impl MPSMatrixFullyConnectedGradient {
653 extern_methods!(
654 /// Called by NSCoder to decode MPSKernels
655 ///
656 /// This isn't the right interface to decode a MPSKernel, but
657 /// it is the one that NSCoder uses. To enable your NSCoder
658 /// (e.g. NSKeyedUnarchiver) to set which device to use
659 /// extend the object to adopt the MPSDeviceProvider
660 /// protocol. Otherwise, the Metal system default device
661 /// will be used.
662 ///
663 /// # Safety
664 ///
665 /// `a_decoder` possibly has further requirements.
666 #[unsafe(method(initWithCoder:))]
667 #[unsafe(method_family = init)]
668 pub unsafe fn initWithCoder(
669 this: Allocated<Self>,
670 a_decoder: &NSCoder,
671 ) -> Option<Retained<Self>>;
672 );
673}
674
675/// Methods declared on superclass `NSObject`.
676#[cfg(all(
677 feature = "MPSCore",
678 feature = "MPSKernel",
679 feature = "MPSMatrix",
680 feature = "MPSMatrixTypes"
681))]
682impl MPSMatrixFullyConnectedGradient {
683 extern_methods!(
684 #[unsafe(method(init))]
685 #[unsafe(method_family = init)]
686 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
687
688 #[unsafe(method(new))]
689 #[unsafe(method_family = new)]
690 pub unsafe fn new() -> Retained<Self>;
691 );
692}