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