objc2_ml_compute/generated/MLCInferenceGraph.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9extern_class!(
10 /// An inference graph created from one or more MLCGraph objects
11 /// plus additional layers added directly to the inference graph.
12 ///
13 /// See also [Apple's documentation](https://developer.apple.com/documentation/mlcompute/mlcinferencegraph?language=objc)
14 #[unsafe(super(MLCGraph, NSObject))]
15 #[derive(Debug, PartialEq, Eq, Hash)]
16 #[cfg(feature = "MLCGraph")]
17 #[deprecated]
18 pub struct MLCInferenceGraph;
19);
20
21#[cfg(feature = "MLCGraph")]
22extern_conformance!(
23 unsafe impl NSObjectProtocol for MLCInferenceGraph {}
24);
25
26#[cfg(feature = "MLCGraph")]
27impl MLCInferenceGraph {
28 extern_methods!(
29 /// Returns the total size in bytes of device memory used by all intermediate tensors in the inference graph
30 ///
31 /// Returns: A NSUInteger value
32 #[deprecated]
33 #[unsafe(method(deviceMemorySize))]
34 #[unsafe(method_family = none)]
35 pub unsafe fn deviceMemorySize(&self) -> NSUInteger;
36
37 #[deprecated]
38 #[unsafe(method(new))]
39 #[unsafe(method_family = new)]
40 pub unsafe fn new() -> Retained<Self>;
41
42 #[deprecated]
43 #[unsafe(method(init))]
44 #[unsafe(method_family = init)]
45 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
46
47 /// Create an inference graph
48 ///
49 /// Parameter `graphObjects`: The layers from these graph objects will be added to the training graph
50 ///
51 /// Returns: A new inference graph object
52 #[deprecated]
53 #[unsafe(method(graphWithGraphObjects:))]
54 #[unsafe(method_family = none)]
55 pub unsafe fn graphWithGraphObjects(graph_objects: &NSArray<MLCGraph>) -> Retained<Self>;
56
57 #[cfg(feature = "MLCTensor")]
58 /// Add the list of inputs to the inference graph
59 ///
60 /// Parameter `inputs`: The inputs
61 ///
62 /// Returns: A boolean indicating success or failure
63 #[deprecated]
64 #[unsafe(method(addInputs:))]
65 #[unsafe(method_family = none)]
66 pub unsafe fn addInputs(&self, inputs: &NSDictionary<NSString, MLCTensor>) -> bool;
67
68 #[cfg(feature = "MLCTensor")]
69 /// Add the list of inputs to the inference graph
70 ///
71 /// Each input, loss label or label weights tensor is identified by a NSString.
72 /// When the inference graph is executed, this NSString is used to identify which data object
73 /// should be as input data for each tensor whose device memory needs to be updated
74 /// before the graph is executed.
75 ///
76 /// Parameter `inputs`: The inputs
77 ///
78 /// Parameter `lossLabels`: The loss label inputs
79 ///
80 /// Parameter `lossLabelWeights`: The loss label weights
81 ///
82 /// Returns: A boolean indicating success or failure
83 #[deprecated]
84 #[unsafe(method(addInputs:lossLabels:lossLabelWeights:))]
85 #[unsafe(method_family = none)]
86 pub unsafe fn addInputs_lossLabels_lossLabelWeights(
87 &self,
88 inputs: &NSDictionary<NSString, MLCTensor>,
89 loss_labels: Option<&NSDictionary<NSString, MLCTensor>>,
90 loss_label_weights: Option<&NSDictionary<NSString, MLCTensor>>,
91 ) -> bool;
92
93 #[cfg(feature = "MLCTensor")]
94 /// Add the list of outputs to the inference graph
95 ///
96 /// Parameter `outputs`: The outputs
97 ///
98 /// Returns: A boolean indicating success or failure
99 #[deprecated]
100 #[unsafe(method(addOutputs:))]
101 #[unsafe(method_family = none)]
102 pub unsafe fn addOutputs(&self, outputs: &NSDictionary<NSString, MLCTensor>) -> bool;
103
104 #[cfg(all(feature = "MLCDevice", feature = "MLCTypes"))]
105 /// Compile the training graph for a device.
106 ///
107 /// Parameter `options`: The compiler options to use when compiling the training graph
108 ///
109 /// Parameter `device`: The MLCDevice object
110 ///
111 /// Returns: A boolean indicating success or failure
112 #[deprecated]
113 #[unsafe(method(compileWithOptions:device:))]
114 #[unsafe(method_family = none)]
115 pub unsafe fn compileWithOptions_device(
116 &self,
117 options: MLCGraphCompilationOptions,
118 device: &MLCDevice,
119 ) -> bool;
120
121 #[cfg(all(
122 feature = "MLCDevice",
123 feature = "MLCTensor",
124 feature = "MLCTensorData",
125 feature = "MLCTypes"
126 ))]
127 /// Compile the inference graph for a device.
128 ///
129 /// Specifying the list of constant tensors when we compile the graph allows MLCompute to perform additional optimizations at compile time.
130 ///
131 /// Parameter `options`: The compiler options to use when compiling the inference graph
132 ///
133 /// Parameter `device`: The MLCDevice object
134 ///
135 /// Parameter `inputTensors`: The list of input tensors that are constants
136 ///
137 /// Parameter `inputTensorsData`: The tensor data to be used with these constant input tensors
138 ///
139 /// Returns: A boolean indicating success or failure
140 #[unsafe(method(compileWithOptions:device:inputTensors:inputTensorsData:))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn compileWithOptions_device_inputTensors_inputTensorsData(
143 &self,
144 options: MLCGraphCompilationOptions,
145 device: &MLCDevice,
146 input_tensors: Option<&NSDictionary<NSString, MLCTensor>>,
147 input_tensors_data: Option<&NSDictionary<NSString, MLCTensorData>>,
148 ) -> bool;
149
150 /// Link mutiple inference graphs
151 ///
152 /// This is used to link subsequent inference graphs with first inference sub-graph.
153 /// This method should be used when we have tensors shared by one or more layers in multiple sub-graphs
154 ///
155 /// Parameter `graphs`: The list of inference graphs to link
156 ///
157 /// Returns: A boolean indicating success or failure
158 #[deprecated]
159 #[unsafe(method(linkWithGraphs:))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn linkWithGraphs(&self, graphs: &NSArray<MLCInferenceGraph>) -> bool;
162
163 #[cfg(all(
164 feature = "MLCTensor",
165 feature = "MLCTensorData",
166 feature = "MLCTypes",
167 feature = "block2"
168 ))]
169 /// Execute the inference graph with given input data
170 ///
171 /// Execute the inference graph given input data.
172 /// If MLCExecutionOptionsSynchronous is specified in 'options', this method returns after the graph has been executed.
173 /// Otherwise, this method returns after the graph has been queued for execution. The completion handler is called after the graph has finished execution.
174 ///
175 /// Parameter `inputsData`: The data objects to use for inputs
176 ///
177 /// Parameter `batchSize`: The batch size to use. For a graph where batch size changes between layers this value must be 0.
178 ///
179 /// Parameter `options`: The execution options
180 ///
181 /// Parameter `completionHandler`: The completion handler
182 ///
183 /// Returns: A boolean indicating success or failure
184 #[deprecated]
185 #[unsafe(method(executeWithInputsData:batchSize:options:completionHandler:))]
186 #[unsafe(method_family = none)]
187 pub unsafe fn executeWithInputsData_batchSize_options_completionHandler(
188 &self,
189 inputs_data: &NSDictionary<NSString, MLCTensorData>,
190 batch_size: NSUInteger,
191 options: MLCExecutionOptions,
192 completion_handler: MLCGraphCompletionHandler,
193 ) -> bool;
194
195 #[cfg(all(
196 feature = "MLCTensor",
197 feature = "MLCTensorData",
198 feature = "MLCTypes",
199 feature = "block2"
200 ))]
201 /// Execute the inference graph with given input data
202 ///
203 /// Execute the inference graph given input data.
204 /// If MLCExecutionOptionsSynchronous is specified in 'options', this method returns after the graph has been executed.
205 /// Otherwise, this method returns after the graph has been queued for execution. The completion handler is called after the graph has finished execution.
206 ///
207 /// Parameter `inputsData`: The data objects to use for inputs
208 ///
209 /// Parameter `outputsData`: The data objects to use for outputs
210 ///
211 /// Parameter `batchSize`: The batch size to use. For a graph where batch size changes between layers this value must be 0.
212 ///
213 /// Parameter `options`: The execution options
214 ///
215 /// Parameter `completionHandler`: The completion handler
216 ///
217 /// Returns: A boolean indicating success or failure
218 #[deprecated]
219 #[unsafe(method(executeWithInputsData:outputsData:batchSize:options:completionHandler:))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn executeWithInputsData_outputsData_batchSize_options_completionHandler(
222 &self,
223 inputs_data: &NSDictionary<NSString, MLCTensorData>,
224 outputs_data: Option<&NSDictionary<NSString, MLCTensorData>>,
225 batch_size: NSUInteger,
226 options: MLCExecutionOptions,
227 completion_handler: MLCGraphCompletionHandler,
228 ) -> bool;
229
230 #[cfg(all(
231 feature = "MLCTensor",
232 feature = "MLCTensorData",
233 feature = "MLCTypes",
234 feature = "block2"
235 ))]
236 /// Execute the inference graph with given input data
237 ///
238 /// Execute the inference graph given input data.
239 /// If MLCExecutionOptionsSynchronous is specified in 'options', this method returns after the graph has been executed.
240 /// Otherwise, this method returns after the graph has been queued for execution. The completion handler is called after the graph has finished execution.
241 ///
242 /// Parameter `inputsData`: The data objects to use for inputs
243 ///
244 /// Parameter `lossLabelsData`: The data objects to use for loss labels
245 ///
246 /// Parameter `lossLabelWeightsData`: The data objects to use for loss label weights
247 ///
248 /// Parameter `batchSize`: The batch size to use. For a graph where batch size changes between layers this value must be 0.
249 ///
250 /// Parameter `options`: The execution options
251 ///
252 /// Parameter `completionHandler`: The completion handler
253 ///
254 /// Returns: A boolean indicating success or failure
255 #[deprecated]
256 #[unsafe(method(executeWithInputsData:lossLabelsData:lossLabelWeightsData:batchSize:options:completionHandler:))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn executeWithInputsData_lossLabelsData_lossLabelWeightsData_batchSize_options_completionHandler(
259 &self,
260 inputs_data: &NSDictionary<NSString, MLCTensorData>,
261 loss_labels_data: Option<&NSDictionary<NSString, MLCTensorData>>,
262 loss_label_weights_data: Option<&NSDictionary<NSString, MLCTensorData>>,
263 batch_size: NSUInteger,
264 options: MLCExecutionOptions,
265 completion_handler: MLCGraphCompletionHandler,
266 ) -> bool;
267
268 #[cfg(all(
269 feature = "MLCTensor",
270 feature = "MLCTensorData",
271 feature = "MLCTypes",
272 feature = "block2"
273 ))]
274 /// Execute the inference graph with given input data
275 ///
276 /// Execute the inference graph given input data.
277 /// If MLCExecutionOptionsSynchronous is specified in 'options', this method returns after the graph has been executed.
278 /// Otherwise, this method returns after the graph has been queued for execution. The completion handler is called after the graph has finished execution.
279 ///
280 /// Parameter `inputsData`: The data objects to use for inputs
281 ///
282 /// Parameter `lossLabelsData`: The data objects to use for loss labels
283 ///
284 /// Parameter `lossLabelWeightsData`: The data objects to use for loss label weights
285 ///
286 /// Parameter `outputsData`: The data objects to use for outputs
287 ///
288 /// Parameter `batchSize`: The batch size to use. For a graph where batch size changes between layers this value must be 0.
289 ///
290 /// Parameter `options`: The execution options
291 ///
292 /// Parameter `completionHandler`: The completion handler
293 ///
294 /// Returns: A boolean indicating success or failure
295 #[deprecated]
296 #[unsafe(method(executeWithInputsData:lossLabelsData:lossLabelWeightsData:outputsData:batchSize:options:completionHandler:))]
297 #[unsafe(method_family = none)]
298 pub unsafe fn executeWithInputsData_lossLabelsData_lossLabelWeightsData_outputsData_batchSize_options_completionHandler(
299 &self,
300 inputs_data: &NSDictionary<NSString, MLCTensorData>,
301 loss_labels_data: Option<&NSDictionary<NSString, MLCTensorData>>,
302 loss_label_weights_data: Option<&NSDictionary<NSString, MLCTensorData>>,
303 outputs_data: Option<&NSDictionary<NSString, MLCTensorData>>,
304 batch_size: NSUInteger,
305 options: MLCExecutionOptions,
306 completion_handler: MLCGraphCompletionHandler,
307 ) -> bool;
308 );
309}
310
311/// Methods declared on superclass `MLCGraph`.
312#[cfg(feature = "MLCGraph")]
313impl MLCInferenceGraph {
314 extern_methods!(
315 /// Creates a new graph.
316 ///
317 /// Returns: A new graph.
318 #[deprecated]
319 #[unsafe(method(graph))]
320 #[unsafe(method_family = none)]
321 pub unsafe fn graph() -> Retained<Self>;
322 );
323}