objc2_metal_performance_shaders_graph/generated/
MPSGraphRandomOps.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::*;
7#[cfg(feature = "objc2-metal-performance-shaders")]
8use objc2_metal_performance_shaders::*;
9
10use crate::*;
11
12/// The distributions supported by random operations.
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshadersgraph/mpsgraphrandomdistribution?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct MPSGraphRandomDistribution(pub u64);
19impl MPSGraphRandomDistribution {
20    /// The uniform distribution, with samples drawn uniformly from [min, max) for float types, and [min, max] for integer types.
21    #[doc(alias = "MPSGraphRandomDistributionUniform")]
22    pub const Uniform: Self = Self(0);
23    /// The normal distribution defined by mean and standard deviation.
24    #[doc(alias = "MPSGraphRandomDistributionNormal")]
25    pub const Normal: Self = Self(1);
26    /// The normal distribution defined by mean and standard deviation, truncated to the range [min, max)
27    #[doc(alias = "MPSGraphRandomDistributionTruncatedNormal")]
28    pub const TruncatedNormal: Self = Self(2);
29}
30
31unsafe impl Encode for MPSGraphRandomDistribution {
32    const ENCODING: Encoding = u64::ENCODING;
33}
34
35unsafe impl RefEncode for MPSGraphRandomDistribution {
36    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
37}
38
39/// The sampling method to use when generating values in the normal distribution.
40///
41/// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshadersgraph/mpsgraphrandomnormalsamplingmethod?language=objc)
42// NS_ENUM
43#[repr(transparent)]
44#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
45pub struct MPSGraphRandomNormalSamplingMethod(pub u64);
46impl MPSGraphRandomNormalSamplingMethod {
47    /// Use inverse erf to convert uniform values to values in the normal distribution
48    #[doc(alias = "MPSGraphRandomNormalSamplingInvCDF")]
49    pub const InvCDF: Self = Self(0);
50    /// Use Box Muller transform to convert uniform values to values in the normal distribution. For bounded distributions this is a rejection sampling method.
51    #[doc(alias = "MPSGraphRandomNormalSamplingBoxMuller")]
52    pub const BoxMuller: Self = Self(1);
53}
54
55unsafe impl Encode for MPSGraphRandomNormalSamplingMethod {
56    const ENCODING: Encoding = u64::ENCODING;
57}
58
59unsafe impl RefEncode for MPSGraphRandomNormalSamplingMethod {
60    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
61}
62
63extern_class!(
64    /// A class that describes the random operation.
65    ///
66    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshadersgraph/mpsgraphrandomopdescriptor?language=objc)
67    #[unsafe(super(MPSGraphObject, NSObject))]
68    #[derive(Debug, PartialEq, Eq, Hash)]
69    #[cfg(feature = "MPSGraphCore")]
70    pub struct MPSGraphRandomOpDescriptor;
71);
72
73#[cfg(feature = "MPSGraphCore")]
74extern_conformance!(
75    unsafe impl NSCopying for MPSGraphRandomOpDescriptor {}
76);
77
78#[cfg(feature = "MPSGraphCore")]
79unsafe impl CopyingHelper for MPSGraphRandomOpDescriptor {
80    type Result = Self;
81}
82
83#[cfg(feature = "MPSGraphCore")]
84extern_conformance!(
85    unsafe impl NSObjectProtocol for MPSGraphRandomOpDescriptor {}
86);
87
88#[cfg(feature = "MPSGraphCore")]
89impl MPSGraphRandomOpDescriptor {
90    extern_methods!(
91        /// The type of distribution to draw samples from. See MPSGraphRandomDistribution.
92        #[unsafe(method(distribution))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn distribution(&self) -> MPSGraphRandomDistribution;
95
96        /// Setter for [`distribution`][Self::distribution].
97        #[unsafe(method(setDistribution:))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn setDistribution(&self, distribution: MPSGraphRandomDistribution);
100
101        #[cfg(feature = "objc2-metal-performance-shaders")]
102        /// The data type of the generated result values.
103        ///
104        /// When sampling from the uniform distribution, valid types are MPSDataTypeFloat16,
105        /// MPSDataTypeFloat32, and MPSDataTypeInt32.
106        /// When sampling from the normal or truncated normal distribution, valid types are
107        /// MPSDataTypeFloat16 and MPSDataTypeFloat32.
108        #[unsafe(method(dataType))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn dataType(&self) -> MPSDataType;
111
112        #[cfg(feature = "objc2-metal-performance-shaders")]
113        /// Setter for [`dataType`][Self::dataType].
114        #[unsafe(method(setDataType:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn setDataType(&self, data_type: MPSDataType);
117
118        /// The lower range of the distribution.
119        ///
120        /// This value is used for Uniform distributions with float data types and Truncated Normal disributions.
121        /// Defaults to 0 for uniform distributions and -2 for normal distributions.
122        #[unsafe(method(min))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn min(&self) -> c_float;
125
126        /// Setter for [`min`][Self::min].
127        #[unsafe(method(setMin:))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn setMin(&self, min: c_float);
130
131        /// The upper range of the distribution.
132        ///
133        /// This value is used for Uniform distributions with float data types and Truncated Normal disributions.
134        /// Defaults to 1 for uniform distributions and 2 for normal distributions.
135        #[unsafe(method(max))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn max(&self) -> c_float;
138
139        /// Setter for [`max`][Self::max].
140        #[unsafe(method(setMax:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn setMax(&self, max: c_float);
143
144        /// The lower range of the distribution.
145        ///
146        /// This value is used for Uniform with integer data types
147        /// Defaults to 0.
148        #[unsafe(method(minInteger))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn minInteger(&self) -> NSInteger;
151
152        /// Setter for [`minInteger`][Self::minInteger].
153        #[unsafe(method(setMinInteger:))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn setMinInteger(&self, min_integer: NSInteger);
156
157        /// The upper range of the distribution.
158        ///
159        /// This value is used for Uniform with integer data types
160        /// Defaults to INT32_MAX for uniform distributions and 0 for normal distributions.
161        #[unsafe(method(maxInteger))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn maxInteger(&self) -> NSInteger;
164
165        /// Setter for [`maxInteger`][Self::maxInteger].
166        #[unsafe(method(setMaxInteger:))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn setMaxInteger(&self, max_integer: NSInteger);
169
170        /// The mean of the distribution.
171        ///
172        /// This value is used for Normal and Truncated Normal disributions.
173        /// Defaults to 0.
174        #[unsafe(method(mean))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn mean(&self) -> c_float;
177
178        /// Setter for [`mean`][Self::mean].
179        #[unsafe(method(setMean:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn setMean(&self, mean: c_float);
182
183        /// The standard deviation of the distribution.
184        ///
185        /// This value is used for Normal and Truncated Normal disributions.
186        /// For Truncated Normal distribution this defines the standard deviation parameter of the underlying Normal distribution, that is the width
187        /// of the Gaussian, not the true standard deviation of the truncated distribution which typically differs from the standard deviation of the
188        /// original Normal distribution.
189        /// Defaults to 0 for uniform distributions and 1 for normal distributions.
190        #[unsafe(method(standardDeviation))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn standardDeviation(&self) -> c_float;
193
194        /// Setter for [`standardDeviation`][Self::standardDeviation].
195        #[unsafe(method(setStandardDeviation:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn setStandardDeviation(&self, standard_deviation: c_float);
198
199        /// The sampling method of the distribution.
200        ///
201        /// This value is used for Normal and Truncated Normal disributions. See MPSGraphRandomNormalSamplingMethod.
202        /// Defaults to MPSGraphRandomNormalSamplingInvCDF.
203        #[unsafe(method(samplingMethod))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn samplingMethod(&self) -> MPSGraphRandomNormalSamplingMethod;
206
207        /// Setter for [`samplingMethod`][Self::samplingMethod].
208        #[unsafe(method(setSamplingMethod:))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn setSamplingMethod(&self, sampling_method: MPSGraphRandomNormalSamplingMethod);
211
212        #[cfg(feature = "objc2-metal-performance-shaders")]
213        /// Class method to initialize a distribution descriptor.
214        #[unsafe(method(descriptorWithDistribution:dataType:))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn descriptorWithDistribution_dataType(
217            distribution: MPSGraphRandomDistribution,
218            data_type: MPSDataType,
219        ) -> Option<Retained<Self>>;
220    );
221}
222
223/// Methods declared on superclass `NSObject`.
224#[cfg(feature = "MPSGraphCore")]
225impl MPSGraphRandomOpDescriptor {
226    extern_methods!(
227        #[unsafe(method(init))]
228        #[unsafe(method_family = init)]
229        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
230
231        #[unsafe(method(new))]
232        #[unsafe(method_family = new)]
233        pub unsafe fn new() -> Retained<Self>;
234    );
235}
236
237/// MPSGraphRandomOps.
238#[cfg(all(feature = "MPSGraph", feature = "MPSGraphCore"))]
239impl MPSGraph {
240    extern_methods!(
241        #[cfg(feature = "MPSGraphTensor")]
242        /// Creates a tensor representing state using the Philox algorithm with given counter and key values.
243        ///
244        /// Generates random numbers using the Philox counter-based algorithm, for further details see:
245        /// John K. Salmon, Mark A. Moraes, Ron O. Dror, and David E. Shaw. Parallel Random Numbers: As Easy as 1, 2, 3.
246        /// A stateTensor generated with this API can be used in MPSGraph Random APIs which accept a stateTensor. The
247        /// updated stateTensor is returned alongside the random values, and can be fed to the following random layer. In
248        /// most use cases, a stateTensor should only need to be initialized once at the start of the graph. A stateTensor can
249        /// be set as a target tensor of an MPSGraph execution to obtain a stateTensor serialized as an NDArray. This can be
250        /// used as input to a placeholder in the graph to avoid ever needing to have a state intilization layer in an MPSGraph.
251        /// This can allow for a continued stream through multiple executions of a single MPSGraph by having the final
252        /// stateTensor as a target tensor passed into the following MPSGraph execution as a placeholder input. This may be
253        /// helpful for training graphs in particular.
254        /// ```md
255        /// MPSGraph *graph = [MPSGraph new];
256        /// MPSGraphTensor *stateTensor = [graph randomPhiloxStateTensorWithSeed: seed name: nil];
257        /// NSArray
258        /// <MPSGraphTensor
259        /// *> *resultTensors0 = [graph randomUniformTensorWithShape:
260        ///
261        /// - Parameters:
262        /// - seed: Initial counter and key values will be generated using seed.
263        /// - name: Name for the operation
264        /// - Returns: An MPSGraphTensor representing a random state, to be passed as an input to a random op.
265        #[unsafe(method(randomPhiloxStateTensorWithSeed:name:))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn randomPhiloxStateTensorWithSeed_name(
268            &self,
269            seed: NSUInteger,
270            name: Option<&NSString>,
271        ) -> Retained<MPSGraphTensor>;
272
273        #[cfg(feature = "MPSGraphTensor")]
274        /// Creates a tensor representing state using the Philox algorithm with given counter and key values.
275        ///
276        /// See randomPhiloxStateTensorWithSeed.
277        ///
278        /// - Parameters:
279        /// - counterLow: The value to initilaize lower 64 bits of counter to. Philox utilizes a 128 bit counter
280        /// - counterHigh: The value to initilaize upper 64 bits of counter to. Philox utilizes a 128 bit counter
281        /// - key: The value to initialize the key to in Philox algorithm.
282        /// - name: Name for the operation
283        /// - Returns: An MPSGraphTensor representing a random state, to be passed as an input to a random op.
284        #[unsafe(method(randomPhiloxStateTensorWithCounterLow:counterHigh:key:name:))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn randomPhiloxStateTensorWithCounterLow_counterHigh_key_name(
287            &self,
288            counter_low: NSUInteger,
289            counter_high: NSUInteger,
290            key: NSUInteger,
291            name: Option<&NSString>,
292        ) -> Retained<MPSGraphTensor>;
293
294        #[cfg(all(
295            feature = "MPSGraphTensor",
296            feature = "objc2-metal-performance-shaders"
297        ))]
298        /// Creates a Random op of type matching distribution in descriptor and returns random values.
299        ///
300        /// Returns a tensor of provided shape of random values in the distribution specified. Uses a random seed value
301        /// to initalize state. No state is preserved, and subsequent calls are not guaranteed to result in a unique stream of
302        /// random values.
303        ///
304        /// - Parameters:
305        /// - shape: The shape of the tensor generated
306        /// - descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
307        /// - name: The name for the operation.
308        /// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
309        #[unsafe(method(randomTensorWithShape:descriptor:name:))]
310        #[unsafe(method_family = none)]
311        pub unsafe fn randomTensorWithShape_descriptor_name(
312            &self,
313            shape: &MPSShape,
314            descriptor: &MPSGraphRandomOpDescriptor,
315            name: Option<&NSString>,
316        ) -> Retained<MPSGraphTensor>;
317
318        #[cfg(feature = "MPSGraphTensor")]
319        /// Creates a Random op of type matching distribution in descriptor and returns random values.
320        ///
321        /// Returns a tensor of provided shape of random values in the distribution specified. Uses a random seed value
322        /// to initalize state. No state is preserved, and subsequent calls are not guaranteed to result in a unique stream of
323        /// random values.
324        ///
325        /// - Parameters:
326        /// - shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
327        /// - descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
328        /// - name: The name for the operation.
329        /// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
330        #[unsafe(method(randomTensorWithShapeTensor:descriptor:name:))]
331        #[unsafe(method_family = none)]
332        pub unsafe fn randomTensorWithShapeTensor_descriptor_name(
333            &self,
334            shape_tensor: &MPSGraphTensor,
335            descriptor: &MPSGraphRandomOpDescriptor,
336            name: Option<&NSString>,
337        ) -> Retained<MPSGraphTensor>;
338
339        #[cfg(all(
340            feature = "MPSGraphTensor",
341            feature = "objc2-metal-performance-shaders"
342        ))]
343        /// Creates a Random op of type matching distribution in descriptor and returns random values.
344        ///
345        /// Returns a tensor of provided shape of random values in the distribution specified. Uses the provided seed value
346        /// to initalize state. No state is preserved, and all calls with equal seed yield an identical stream of random values.
347        ///
348        /// - Parameters:
349        /// - shape: The shape of the tensor generated
350        /// - descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
351        /// - seed: The seed to use to initialize state. All calls with equal seed yield an identical stream of random values.
352        /// - name: The name for the operation.
353        /// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
354        #[unsafe(method(randomTensorWithShape:descriptor:seed:name:))]
355        #[unsafe(method_family = none)]
356        pub unsafe fn randomTensorWithShape_descriptor_seed_name(
357            &self,
358            shape: &MPSShape,
359            descriptor: &MPSGraphRandomOpDescriptor,
360            seed: NSUInteger,
361            name: Option<&NSString>,
362        ) -> Retained<MPSGraphTensor>;
363
364        #[cfg(feature = "MPSGraphTensor")]
365        /// Creates a Random op of type matching distribution in descriptor and returns random values.
366        ///
367        /// Returns a tensor of provided shape of random values in the distribution specified. Uses the provided seed value
368        /// to initalize state. No state is preserved, and all calls with equal seed yield an identical stream of random values.
369        ///
370        /// - Parameters:
371        /// - shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
372        /// - descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
373        /// - seed: The seed to use to initialize state. All calls with equal seed yield an identical stream of random values.
374        /// - name: The name for the operation.
375        /// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
376        #[unsafe(method(randomTensorWithShapeTensor:descriptor:seed:name:))]
377        #[unsafe(method_family = none)]
378        pub unsafe fn randomTensorWithShapeTensor_descriptor_seed_name(
379            &self,
380            shape_tensor: &MPSGraphTensor,
381            descriptor: &MPSGraphRandomOpDescriptor,
382            seed: NSUInteger,
383            name: Option<&NSString>,
384        ) -> Retained<MPSGraphTensor>;
385
386        #[cfg(all(
387            feature = "MPSGraphTensor",
388            feature = "objc2-metal-performance-shaders"
389        ))]
390        /// Creates a Random op of type matching distribution in descriptor, and returns random values and updated state.
391        ///
392        /// Returns an array of 2 tensors, where the first is of provided shape of random values in the distribution specified,
393        /// and the second is the updated state tensor.
394        /// Uses the provided state to define a stream of random values. No state is preserved, and all calls with equal state
395        /// yield an identical stream of random values. The initial stateTensor provided should be created using the MPSGraph
396        /// randomPhiloxStateTensor APIs. The resulting stateTensor from this op can be passed as an argument to the following
397        /// random calls to continue sampling from the stream.
398        ///
399        /// - Parameters:
400        /// - shape: The shape of the tensor generated
401        /// - descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
402        /// - state: The state to define a stream of random values. All calls with equal state yield an identical stream of random values.
403        /// - name: The name for the operation.
404        /// - Returns: An array of MPSGraphTensor of size 2. The first MPSGraphTensor is of shape containing random values in the defined range.
405        /// The second MPSGraphTensor is the updated state tensor.
406        #[unsafe(method(randomTensorWithShape:descriptor:stateTensor:name:))]
407        #[unsafe(method_family = none)]
408        pub unsafe fn randomTensorWithShape_descriptor_stateTensor_name(
409            &self,
410            shape: &MPSShape,
411            descriptor: &MPSGraphRandomOpDescriptor,
412            state: &MPSGraphTensor,
413            name: Option<&NSString>,
414        ) -> Retained<NSArray<MPSGraphTensor>>;
415
416        #[cfg(feature = "MPSGraphTensor")]
417        /// Creates a Random op of type matching distribution in descriptor, and returns random values and updated state.
418        ///
419        /// Returns an array of 2 tensors, where the first is of provided shape of random values in the distribution specified,
420        /// and the second is the updated state tensor.
421        /// Uses the provided state to define a stream of random values. No state is preserved, and all calls with equal state
422        /// yield an identical stream of random values. The initial stateTensor provided should be created using the MPSGraph
423        /// randomPhiloxStateTensor APIs. The resulting stateTensor from this op can be passed as an argument to the following
424        /// random calls to continue sampling from the stream.
425        ///
426        /// - Parameters:
427        /// - shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated.
428        /// - descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
429        /// - state: The state to define a stream of random values. All calls with equal state yield an identical stream of random values.
430        /// - name: The name for the operation.
431        /// - Returns: An array of MPSGraphTensor of size 2. The first MPSGraphTensor is of shape containing random values in the defined range.
432        /// The second MPSGraphTensor is the updated state tensor.
433        #[unsafe(method(randomTensorWithShapeTensor:descriptor:stateTensor:name:))]
434        #[unsafe(method_family = none)]
435        pub unsafe fn randomTensorWithShapeTensor_descriptor_stateTensor_name(
436            &self,
437            shape_tensor: &MPSGraphTensor,
438            descriptor: &MPSGraphRandomOpDescriptor,
439            state: &MPSGraphTensor,
440            name: Option<&NSString>,
441        ) -> Retained<NSArray<MPSGraphTensor>>;
442
443        #[cfg(all(
444            feature = "MPSGraphTensor",
445            feature = "objc2-metal-performance-shaders"
446        ))]
447        /// Creates a RandomUniform operation and returns random uniform values
448        ///
449        /// Returns a tensor of provided shape of random uniform values in the range [0.0, 1.0). Uses a random seed value
450        /// to initalize state. No state is preserved, and subsequent calls are not guaranteed to result in a unique stream of
451        /// random values.
452        ///
453        /// - Parameters:
454        /// - shape: The shape of the tensor generated
455        /// - name: The name for the operation.
456        /// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
457        #[unsafe(method(randomUniformTensorWithShape:name:))]
458        #[unsafe(method_family = none)]
459        pub unsafe fn randomUniformTensorWithShape_name(
460            &self,
461            shape: &MPSShape,
462            name: Option<&NSString>,
463        ) -> Retained<MPSGraphTensor>;
464
465        #[cfg(feature = "MPSGraphTensor")]
466        /// Creates a RandomUniform operation and returns random uniform values
467        ///
468        /// Returns a tensor of provided shape of random uniform values in the range [0.0, 1.0). Uses a random seed value
469        /// to initalize state. No state is preserved, and subsequent calls are not guaranteed to result in a unique stream of
470        /// random values.
471        ///
472        /// - Parameters:
473        /// - shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
474        /// - name: The name for the operation.
475        /// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
476        #[unsafe(method(randomUniformTensorWithShapeTensor:name:))]
477        #[unsafe(method_family = none)]
478        pub unsafe fn randomUniformTensorWithShapeTensor_name(
479            &self,
480            shape_tensor: &MPSGraphTensor,
481            name: Option<&NSString>,
482        ) -> Retained<MPSGraphTensor>;
483
484        #[cfg(all(
485            feature = "MPSGraphTensor",
486            feature = "objc2-metal-performance-shaders"
487        ))]
488        /// Creates a RandomUniform operation and returns random uniform values
489        ///
490        /// Returns a tensor of provided shape of random uniform values in the range [0.0, 1.0). Uses the provided seed value
491        /// to initalize state. No state is preserved, and all calls with equal seed yield an identical stream of random values.
492        ///
493        /// - Parameters:
494        /// - shape: The shape of the tensor generated
495        /// - seed: The seed to use to initialize state. All calls with equal seed yield an identical stream of random values.
496        /// - name: The name for the operation.
497        /// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
498        #[unsafe(method(randomUniformTensorWithShape:seed:name:))]
499        #[unsafe(method_family = none)]
500        pub unsafe fn randomUniformTensorWithShape_seed_name(
501            &self,
502            shape: &MPSShape,
503            seed: NSUInteger,
504            name: Option<&NSString>,
505        ) -> Retained<MPSGraphTensor>;
506
507        #[cfg(feature = "MPSGraphTensor")]
508        /// Creates a RandomUniform operation and returns random uniform values
509        ///
510        /// Returns a tensor of provided shape of random uniform values in the range [0.0, 1.0). Uses the provided seed value
511        /// to initalize state. No state is preserved, and all calls with equal seed yield an identical stream of random values.
512        ///
513        /// - Parameters:
514        /// - shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
515        /// - seed: The seed to use to initialize state. All calls with equal seed yield an identical stream of random values.
516        /// - name: The name for the operation.
517        /// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
518        #[unsafe(method(randomUniformTensorWithShapeTensor:seed:name:))]
519        #[unsafe(method_family = none)]
520        pub unsafe fn randomUniformTensorWithShapeTensor_seed_name(
521            &self,
522            shape_tensor: &MPSGraphTensor,
523            seed: NSUInteger,
524            name: Option<&NSString>,
525        ) -> Retained<MPSGraphTensor>;
526
527        #[cfg(all(
528            feature = "MPSGraphTensor",
529            feature = "objc2-metal-performance-shaders"
530        ))]
531        /// Creates a RandomUniform operation and returns random uniform values and updated state
532        ///
533        /// Returns an array of 2 tensors, where the first is a tensor of provided shape of random uniform values in the range
534        /// [0.0, 1.0), and the second is the updated state tensor.
535        /// The provided state is used to define a stream of random values. No state is preserved, and all calls with equal state
536        /// yield an identical stream of random values. The initial stateTensor provided should be created using the MPSGraph
537        /// randomPhiloxStateTensor APIs. The resulting stateTensor from this op can be passed as an argument to the following
538        /// random calls to continue sampling from the stream.
539        ///
540        /// - Parameters:
541        /// - shape: The shape of the tensor generated
542        /// - state: The state to define a stream of random values. All calls with equal state yield an identical stream of random values.
543        /// - name: The name for the operation.
544        /// - Returns: An array of MPSGraphTensor of size 2. The first MPSGraphTensor is of shape containing random values in the defined range.
545        /// The second MPSGraphTensor is the updated state tensor.
546        #[unsafe(method(randomUniformTensorWithShape:stateTensor:name:))]
547        #[unsafe(method_family = none)]
548        pub unsafe fn randomUniformTensorWithShape_stateTensor_name(
549            &self,
550            shape: &MPSShape,
551            state: &MPSGraphTensor,
552            name: Option<&NSString>,
553        ) -> Retained<NSArray<MPSGraphTensor>>;
554
555        #[cfg(feature = "MPSGraphTensor")]
556        /// Creates a RandomUniform operation and returns random uniform values and updated state
557        ///
558        /// Returns an array of 2 tensors, where the first is a tensor of provided shape of random uniform values in the range
559        /// [0.0, 1.0), and the second is the updated state tensor.
560        /// The provided state is used to define a stream of random values. No state is preserved, and all calls with equal state
561        /// yield an identical stream of random values. The initial stateTensor provided should be created using the MPSGraph
562        /// randomPhiloxStateTensor APIs. The resulting stateTensor from this op can be passed as an argument to the following
563        /// random calls to continue sampling from the stream.
564        ///
565        /// - Parameters:
566        /// - shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
567        /// - state: The state to define a stream of random values. All calls with equal state yield an identical stream of random values.
568        /// - name: The name for the operation.
569        /// - Returns: An array of MPSGraphTensor of size 2. The first MPSGraphTensor is of shape containing random values in the defined range.
570        /// The second MPSGraphTensor is the updated state tensor.
571        #[unsafe(method(randomUniformTensorWithShapeTensor:stateTensor:name:))]
572        #[unsafe(method_family = none)]
573        pub unsafe fn randomUniformTensorWithShapeTensor_stateTensor_name(
574            &self,
575            shape_tensor: &MPSGraphTensor,
576            state: &MPSGraphTensor,
577            name: Option<&NSString>,
578        ) -> Retained<NSArray<MPSGraphTensor>>;
579
580        #[cfg(feature = "MPSGraphTensor")]
581        /// Creates a dropout operation and returns the result
582        ///
583        /// Removes values in the `tensor` with a percentage chance equal to `rate`. Removed values are set to 0
584        ///
585        /// - Parameters:
586        /// - tensor: Input tensor
587        /// - rate: The rate of values to be set to 0
588        /// - name: The name for the operation.
589        /// - Returns: A valid MPSGraphTensor object
590        #[unsafe(method(dropoutTensor:rate:name:))]
591        #[unsafe(method_family = none)]
592        pub unsafe fn dropoutTensor_rate_name(
593            &self,
594            tensor: &MPSGraphTensor,
595            rate: c_double,
596            name: Option<&NSString>,
597        ) -> Retained<MPSGraphTensor>;
598
599        #[cfg(feature = "MPSGraphTensor")]
600        /// Creates a dropout operation and returns the result
601        ///
602        /// Removes values in the `tensor` with a percentage chance equal to `rate`. Removed values are set to 0
603        ///
604        /// - Parameters:
605        /// - tensor: Input tensor
606        /// - rate: The rate of values to be set to 0
607        /// - name: The name for the operation.
608        /// - Returns: A valid MPSGraphTensor object
609        #[unsafe(method(dropoutTensor:rateTensor:name:))]
610        #[unsafe(method_family = none)]
611        pub unsafe fn dropoutTensor_rateTensor_name(
612            &self,
613            tensor: &MPSGraphTensor,
614            rate: &MPSGraphTensor,
615            name: Option<&NSString>,
616        ) -> Retained<MPSGraphTensor>;
617    );
618}