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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
extern_class!(
/// An inference graph created from one or more MLCGraph objects
/// plus additional layers added directly to the inference graph.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/mlcompute/mlcinferencegraph?language=objc)
#[unsafe(super(MLCGraph, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "MLCGraph")]
#[deprecated]
pub struct MLCInferenceGraph;
);
#[cfg(feature = "MLCGraph")]
extern_conformance!(
unsafe impl NSObjectProtocol for MLCInferenceGraph {}
);
#[cfg(feature = "MLCGraph")]
impl MLCInferenceGraph {
extern_methods!(
/// Returns the total size in bytes of device memory used by all intermediate tensors in the inference graph
///
/// Returns: A NSUInteger value
#[deprecated]
#[unsafe(method(deviceMemorySize))]
#[unsafe(method_family = none)]
pub unsafe fn deviceMemorySize(&self) -> NSUInteger;
#[deprecated]
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
#[deprecated]
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
/// Create an inference graph
///
/// Parameter `graphObjects`: The layers from these graph objects will be added to the training graph
///
/// Returns: A new inference graph object
#[deprecated]
#[unsafe(method(graphWithGraphObjects:))]
#[unsafe(method_family = none)]
pub unsafe fn graphWithGraphObjects(graph_objects: &NSArray<MLCGraph>) -> Retained<Self>;
#[cfg(feature = "MLCTensor")]
/// Add the list of inputs to the inference graph
///
/// Parameter `inputs`: The inputs
///
/// Returns: A boolean indicating success or failure
#[deprecated]
#[unsafe(method(addInputs:))]
#[unsafe(method_family = none)]
pub unsafe fn addInputs(&self, inputs: &NSDictionary<NSString, MLCTensor>) -> bool;
#[cfg(feature = "MLCTensor")]
/// Add the list of inputs to the inference graph
///
/// Each input, loss label or label weights tensor is identified by a NSString.
/// When the inference graph is executed, this NSString is used to identify which data object
/// should be as input data for each tensor whose device memory needs to be updated
/// before the graph is executed.
///
/// Parameter `inputs`: The inputs
///
/// Parameter `lossLabels`: The loss label inputs
///
/// Parameter `lossLabelWeights`: The loss label weights
///
/// Returns: A boolean indicating success or failure
#[deprecated]
#[unsafe(method(addInputs:lossLabels:lossLabelWeights:))]
#[unsafe(method_family = none)]
pub unsafe fn addInputs_lossLabels_lossLabelWeights(
&self,
inputs: &NSDictionary<NSString, MLCTensor>,
loss_labels: Option<&NSDictionary<NSString, MLCTensor>>,
loss_label_weights: Option<&NSDictionary<NSString, MLCTensor>>,
) -> bool;
#[cfg(feature = "MLCTensor")]
/// Add the list of outputs to the inference graph
///
/// Parameter `outputs`: The outputs
///
/// Returns: A boolean indicating success or failure
#[deprecated]
#[unsafe(method(addOutputs:))]
#[unsafe(method_family = none)]
pub unsafe fn addOutputs(&self, outputs: &NSDictionary<NSString, MLCTensor>) -> bool;
#[cfg(all(feature = "MLCDevice", feature = "MLCTypes"))]
/// Compile the training graph for a device.
///
/// Parameter `options`: The compiler options to use when compiling the training graph
///
/// Parameter `device`: The MLCDevice object
///
/// Returns: A boolean indicating success or failure
#[deprecated]
#[unsafe(method(compileWithOptions:device:))]
#[unsafe(method_family = none)]
pub unsafe fn compileWithOptions_device(
&self,
options: MLCGraphCompilationOptions,
device: &MLCDevice,
) -> bool;
#[cfg(all(
feature = "MLCDevice",
feature = "MLCTensor",
feature = "MLCTensorData",
feature = "MLCTypes"
))]
/// Compile the inference graph for a device.
///
/// Specifying the list of constant tensors when we compile the graph allows MLCompute to perform additional optimizations at compile time.
///
/// Parameter `options`: The compiler options to use when compiling the inference graph
///
/// Parameter `device`: The MLCDevice object
///
/// Parameter `inputTensors`: The list of input tensors that are constants
///
/// Parameter `inputTensorsData`: The tensor data to be used with these constant input tensors
///
/// Returns: A boolean indicating success or failure
#[unsafe(method(compileWithOptions:device:inputTensors:inputTensorsData:))]
#[unsafe(method_family = none)]
pub unsafe fn compileWithOptions_device_inputTensors_inputTensorsData(
&self,
options: MLCGraphCompilationOptions,
device: &MLCDevice,
input_tensors: Option<&NSDictionary<NSString, MLCTensor>>,
input_tensors_data: Option<&NSDictionary<NSString, MLCTensorData>>,
) -> bool;
/// Link mutiple inference graphs
///
/// This is used to link subsequent inference graphs with first inference sub-graph.
/// This method should be used when we have tensors shared by one or more layers in multiple sub-graphs
///
/// Parameter `graphs`: The list of inference graphs to link
///
/// Returns: A boolean indicating success or failure
#[deprecated]
#[unsafe(method(linkWithGraphs:))]
#[unsafe(method_family = none)]
pub unsafe fn linkWithGraphs(&self, graphs: &NSArray<MLCInferenceGraph>) -> bool;
#[cfg(all(
feature = "MLCTensor",
feature = "MLCTensorData",
feature = "MLCTypes",
feature = "block2"
))]
/// Execute the inference graph with given input data
///
/// Execute the inference graph given input data.
/// If MLCExecutionOptionsSynchronous is specified in 'options', this method returns after the graph has been executed.
/// Otherwise, this method returns after the graph has been queued for execution. The completion handler is called after the graph has finished execution.
///
/// Parameter `inputsData`: The data objects to use for inputs
///
/// Parameter `batchSize`: The batch size to use. For a graph where batch size changes between layers this value must be 0.
///
/// Parameter `options`: The execution options
///
/// Parameter `completionHandler`: The completion handler
///
/// Returns: A boolean indicating success or failure
///
/// # Safety
///
/// `completion_handler` must be a valid pointer or null.
#[deprecated]
#[unsafe(method(executeWithInputsData:batchSize:options:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn executeWithInputsData_batchSize_options_completionHandler(
&self,
inputs_data: &NSDictionary<NSString, MLCTensorData>,
batch_size: NSUInteger,
options: MLCExecutionOptions,
completion_handler: MLCGraphCompletionHandler,
) -> bool;
#[cfg(all(
feature = "MLCTensor",
feature = "MLCTensorData",
feature = "MLCTypes",
feature = "block2"
))]
/// Execute the inference graph with given input data
///
/// Execute the inference graph given input data.
/// If MLCExecutionOptionsSynchronous is specified in 'options', this method returns after the graph has been executed.
/// Otherwise, this method returns after the graph has been queued for execution. The completion handler is called after the graph has finished execution.
///
/// Parameter `inputsData`: The data objects to use for inputs
///
/// Parameter `outputsData`: The data objects to use for outputs
///
/// Parameter `batchSize`: The batch size to use. For a graph where batch size changes between layers this value must be 0.
///
/// Parameter `options`: The execution options
///
/// Parameter `completionHandler`: The completion handler
///
/// Returns: A boolean indicating success or failure
///
/// # Safety
///
/// `completion_handler` must be a valid pointer or null.
#[deprecated]
#[unsafe(method(executeWithInputsData:outputsData:batchSize:options:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn executeWithInputsData_outputsData_batchSize_options_completionHandler(
&self,
inputs_data: &NSDictionary<NSString, MLCTensorData>,
outputs_data: Option<&NSDictionary<NSString, MLCTensorData>>,
batch_size: NSUInteger,
options: MLCExecutionOptions,
completion_handler: MLCGraphCompletionHandler,
) -> bool;
#[cfg(all(
feature = "MLCTensor",
feature = "MLCTensorData",
feature = "MLCTypes",
feature = "block2"
))]
/// Execute the inference graph with given input data
///
/// Execute the inference graph given input data.
/// If MLCExecutionOptionsSynchronous is specified in 'options', this method returns after the graph has been executed.
/// Otherwise, this method returns after the graph has been queued for execution. The completion handler is called after the graph has finished execution.
///
/// Parameter `inputsData`: The data objects to use for inputs
///
/// Parameter `lossLabelsData`: The data objects to use for loss labels
///
/// Parameter `lossLabelWeightsData`: The data objects to use for loss label weights
///
/// Parameter `batchSize`: The batch size to use. For a graph where batch size changes between layers this value must be 0.
///
/// Parameter `options`: The execution options
///
/// Parameter `completionHandler`: The completion handler
///
/// Returns: A boolean indicating success or failure
///
/// # Safety
///
/// `completion_handler` must be a valid pointer or null.
#[deprecated]
#[unsafe(method(executeWithInputsData:lossLabelsData:lossLabelWeightsData:batchSize:options:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn executeWithInputsData_lossLabelsData_lossLabelWeightsData_batchSize_options_completionHandler(
&self,
inputs_data: &NSDictionary<NSString, MLCTensorData>,
loss_labels_data: Option<&NSDictionary<NSString, MLCTensorData>>,
loss_label_weights_data: Option<&NSDictionary<NSString, MLCTensorData>>,
batch_size: NSUInteger,
options: MLCExecutionOptions,
completion_handler: MLCGraphCompletionHandler,
) -> bool;
#[cfg(all(
feature = "MLCTensor",
feature = "MLCTensorData",
feature = "MLCTypes",
feature = "block2"
))]
/// Execute the inference graph with given input data
///
/// Execute the inference graph given input data.
/// If MLCExecutionOptionsSynchronous is specified in 'options', this method returns after the graph has been executed.
/// Otherwise, this method returns after the graph has been queued for execution. The completion handler is called after the graph has finished execution.
///
/// Parameter `inputsData`: The data objects to use for inputs
///
/// Parameter `lossLabelsData`: The data objects to use for loss labels
///
/// Parameter `lossLabelWeightsData`: The data objects to use for loss label weights
///
/// Parameter `outputsData`: The data objects to use for outputs
///
/// Parameter `batchSize`: The batch size to use. For a graph where batch size changes between layers this value must be 0.
///
/// Parameter `options`: The execution options
///
/// Parameter `completionHandler`: The completion handler
///
/// Returns: A boolean indicating success or failure
///
/// # Safety
///
/// `completion_handler` must be a valid pointer or null.
#[deprecated]
#[unsafe(method(executeWithInputsData:lossLabelsData:lossLabelWeightsData:outputsData:batchSize:options:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn executeWithInputsData_lossLabelsData_lossLabelWeightsData_outputsData_batchSize_options_completionHandler(
&self,
inputs_data: &NSDictionary<NSString, MLCTensorData>,
loss_labels_data: Option<&NSDictionary<NSString, MLCTensorData>>,
loss_label_weights_data: Option<&NSDictionary<NSString, MLCTensorData>>,
outputs_data: Option<&NSDictionary<NSString, MLCTensorData>>,
batch_size: NSUInteger,
options: MLCExecutionOptions,
completion_handler: MLCGraphCompletionHandler,
) -> bool;
);
}
/// Methods declared on superclass `MLCGraph`.
#[cfg(feature = "MLCGraph")]
impl MLCInferenceGraph {
extern_methods!(
/// Creates a new graph.
///
/// Returns: A new graph.
#[deprecated]
#[unsafe(method(graph))]
#[unsafe(method_family = none)]
pub unsafe fn graph() -> Retained<Self>;
);
}