objc2_ml_compute/generated/
MLCOptimizerDescriptor.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
8use crate::*;
9
10extern_class!(
11    /// The MLCOptimizerDescriptor specifies an optimizer descriptor.
12    ///
13    /// See also [Apple's documentation](https://developer.apple.com/documentation/mlcompute/mlcoptimizerdescriptor?language=objc)
14    #[unsafe(super(NSObject))]
15    #[derive(Debug, PartialEq, Eq, Hash)]
16    #[deprecated]
17    pub struct MLCOptimizerDescriptor;
18);
19
20extern_conformance!(
21    unsafe impl NSCopying for MLCOptimizerDescriptor {}
22);
23
24unsafe impl CopyingHelper for MLCOptimizerDescriptor {
25    type Result = Self;
26}
27
28extern_conformance!(
29    unsafe impl NSObjectProtocol for MLCOptimizerDescriptor {}
30);
31
32impl MLCOptimizerDescriptor {
33    extern_methods!(
34        /// The learning rate
35        #[deprecated]
36        #[unsafe(method(learningRate))]
37        #[unsafe(method_family = none)]
38        pub unsafe fn learningRate(&self) -> c_float;
39
40        /// The rescale value applied to gradients during optimizer update
41        #[deprecated]
42        #[unsafe(method(gradientRescale))]
43        #[unsafe(method_family = none)]
44        pub unsafe fn gradientRescale(&self) -> c_float;
45
46        /// Whether gradient clipping should be applied or not.
47        ///
48        /// The default is false
49        #[deprecated]
50        #[unsafe(method(appliesGradientClipping))]
51        #[unsafe(method_family = none)]
52        pub unsafe fn appliesGradientClipping(&self) -> bool;
53
54        /// The maximum gradient value if gradient clipping is enabled before gradient is rescaled.
55        #[deprecated]
56        #[unsafe(method(gradientClipMax))]
57        #[unsafe(method_family = none)]
58        pub unsafe fn gradientClipMax(&self) -> c_float;
59
60        /// The minimum gradient value if gradient clipping is enabled before gradient is rescaled.
61        #[deprecated]
62        #[unsafe(method(gradientClipMin))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn gradientClipMin(&self) -> c_float;
65
66        /// The regularization scale.
67        #[deprecated]
68        #[unsafe(method(regularizationScale))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn regularizationScale(&self) -> c_float;
71
72        #[cfg(feature = "MLCTypes")]
73        /// The regularization type.
74        #[deprecated]
75        #[unsafe(method(regularizationType))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn regularizationType(&self) -> MLCRegularizationType;
78
79        #[cfg(feature = "MLCTypes")]
80        /// The type of clipping applied to gradient
81        #[unsafe(method(gradientClippingType))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn gradientClippingType(&self) -> MLCGradientClippingType;
84
85        /// The maximum clipping value
86        #[unsafe(method(maximumClippingNorm))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn maximumClippingNorm(&self) -> c_float;
89
90        /// Used only with MLCGradientClippingTypeByGlobalNorm. If non zero, this norm will be used in place of global norm.
91        #[unsafe(method(customGlobalNorm))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn customGlobalNorm(&self) -> c_float;
94
95        #[cfg(feature = "MLCTypes")]
96        /// Create a MLCOptimizerDescriptor object
97        ///
98        /// Parameter `learningRate`: The learning rate
99        ///
100        /// Parameter `gradientRescale`: The gradient rescale value
101        ///
102        /// Parameter `regularizationType`: The regularization type
103        ///
104        /// Parameter `regularizationScale`: The regularization scale
105        ///
106        /// Returns: A new MLCOptimizerDescriptor object.
107        #[deprecated]
108        #[unsafe(method(descriptorWithLearningRate:gradientRescale:regularizationType:regularizationScale:))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn descriptorWithLearningRate_gradientRescale_regularizationType_regularizationScale(
111            learning_rate: c_float,
112            gradient_rescale: c_float,
113            regularization_type: MLCRegularizationType,
114            regularization_scale: c_float,
115        ) -> Retained<Self>;
116
117        #[cfg(feature = "MLCTypes")]
118        /// Create a MLCOptimizerDescriptor object
119        ///
120        /// Parameter `learningRate`: The learning rate
121        ///
122        /// Parameter `gradientRescale`: The gradient rescale value
123        ///
124        /// Parameter `appliesGradientClipping`: Whether to apply gradient clipping
125        ///
126        /// Parameter `gradientClipMax`: The maximum gradient value to be used with gradient clipping
127        ///
128        /// Parameter `gradientClipMin`: The minimum gradient value to be used with gradient clipping
129        ///
130        /// Parameter `regularizationType`: The regularization type
131        ///
132        /// Parameter `regularizationScale`: The regularization scale
133        ///
134        /// Returns: A new MLCOptimizerDescriptor object.
135        #[deprecated]
136        #[unsafe(method(descriptorWithLearningRate:gradientRescale:appliesGradientClipping:gradientClipMax:gradientClipMin:regularizationType:regularizationScale:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn descriptorWithLearningRate_gradientRescale_appliesGradientClipping_gradientClipMax_gradientClipMin_regularizationType_regularizationScale(
139            learning_rate: c_float,
140            gradient_rescale: c_float,
141            applies_gradient_clipping: bool,
142            gradient_clip_max: c_float,
143            gradient_clip_min: c_float,
144            regularization_type: MLCRegularizationType,
145            regularization_scale: c_float,
146        ) -> Retained<Self>;
147
148        #[cfg(feature = "MLCTypes")]
149        /// Create an MLCOptimizerDescriptor object
150        ///
151        /// Parameter `learningRate`: The learning rate
152        ///
153        /// Parameter `gradientRescale`: The gradient rescale value
154        ///
155        /// Parameter `appliesGradientClipping`: Whether to apply gradient clipping
156        ///
157        /// Parameter `gradientClippingType`: The type of clipping applied to gradients
158        ///
159        /// Parameter `gradientClipMax`: The maximum gradient value to be used with gradient clipping
160        ///
161        /// Parameter `gradientClipMin`: The minimum gradient value to be used with gradient clipping
162        ///
163        /// Parameter `maximumClippingNorm`: The maximum norm to be used with gradient clipping
164        ///
165        /// Parameter `customGlobalNorm`: If non-zero, the norm to be used instead of calculating the global norm
166        ///
167        /// Parameter `regularizationType`: The regularization type
168        ///
169        /// Parameter `regularizationScale`: The regularization scale
170        ///
171        /// Returns: A new MLCOptimizerDescriptor object.
172        #[unsafe(method(descriptorWithLearningRate:gradientRescale:appliesGradientClipping:gradientClippingType:gradientClipMax:gradientClipMin:maximumClippingNorm:customGlobalNorm:regularizationType:regularizationScale:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn descriptorWithLearningRate_gradientRescale_appliesGradientClipping_gradientClippingType_gradientClipMax_gradientClipMin_maximumClippingNorm_customGlobalNorm_regularizationType_regularizationScale(
175            learning_rate: c_float,
176            gradient_rescale: c_float,
177            applies_gradient_clipping: bool,
178            gradient_clipping_type: MLCGradientClippingType,
179            gradient_clip_max: c_float,
180            gradient_clip_min: c_float,
181            maximum_clipping_norm: c_float,
182            custom_global_norm: c_float,
183            regularization_type: MLCRegularizationType,
184            regularization_scale: c_float,
185        ) -> Retained<Self>;
186    );
187}
188
189/// Methods declared on superclass `NSObject`.
190impl MLCOptimizerDescriptor {
191    extern_methods!(
192        #[unsafe(method(init))]
193        #[unsafe(method_family = init)]
194        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
195
196        #[unsafe(method(new))]
197        #[unsafe(method_family = new)]
198        pub unsafe fn new() -> Retained<Self>;
199    );
200}