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        ///
185        /// # Safety
186        ///
187        /// `completion_handler` must be a valid pointer or null.
188        #[deprecated]
189        #[unsafe(method(executeWithInputsData:batchSize:options:completionHandler:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn executeWithInputsData_batchSize_options_completionHandler(
192            &self,
193            inputs_data: &NSDictionary<NSString, MLCTensorData>,
194            batch_size: NSUInteger,
195            options: MLCExecutionOptions,
196            completion_handler: MLCGraphCompletionHandler,
197        ) -> bool;
198
199        #[cfg(all(
200            feature = "MLCTensor",
201            feature = "MLCTensorData",
202            feature = "MLCTypes",
203            feature = "block2"
204        ))]
205        /// Execute the inference graph with given input data
206        ///
207        /// Execute the inference graph given input data.
208        /// If MLCExecutionOptionsSynchronous is specified in 'options', this method returns after the graph has been executed.
209        /// Otherwise, this method returns after the graph has been queued for execution.  The completion handler  is called after the graph has finished execution.
210        ///
211        /// Parameter `inputsData`: The data objects to use for inputs
212        ///
213        /// Parameter `outputsData`: The data objects to use for outputs
214        ///
215        /// Parameter `batchSize`: The batch size to use.  For a graph where batch size changes between layers this value must be 0.
216        ///
217        /// Parameter `options`: The execution options
218        ///
219        /// Parameter `completionHandler`: The completion handler
220        ///
221        /// Returns: A boolean indicating success or failure
222        ///
223        /// # Safety
224        ///
225        /// `completion_handler` must be a valid pointer or null.
226        #[deprecated]
227        #[unsafe(method(executeWithInputsData:outputsData:batchSize:options:completionHandler:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn executeWithInputsData_outputsData_batchSize_options_completionHandler(
230            &self,
231            inputs_data: &NSDictionary<NSString, MLCTensorData>,
232            outputs_data: Option<&NSDictionary<NSString, MLCTensorData>>,
233            batch_size: NSUInteger,
234            options: MLCExecutionOptions,
235            completion_handler: MLCGraphCompletionHandler,
236        ) -> bool;
237
238        #[cfg(all(
239            feature = "MLCTensor",
240            feature = "MLCTensorData",
241            feature = "MLCTypes",
242            feature = "block2"
243        ))]
244        /// Execute the inference graph with given input data
245        ///
246        /// Execute the inference graph given input data.
247        /// If MLCExecutionOptionsSynchronous is specified in 'options', this method returns after the graph has been executed.
248        /// Otherwise, this method returns after the graph has been queued for execution.  The completion handler  is called after the graph has finished execution.
249        ///
250        /// Parameter `inputsData`: The data objects to use for inputs
251        ///
252        /// Parameter `lossLabelsData`: The data objects to use for loss labels
253        ///
254        /// Parameter `lossLabelWeightsData`: The data objects to use for loss label weights
255        ///
256        /// Parameter `batchSize`: The batch size to use.  For a graph where batch size changes between layers this value must be 0.
257        ///
258        /// Parameter `options`: The execution options
259        ///
260        /// Parameter `completionHandler`: The completion handler
261        ///
262        /// Returns: A boolean indicating success or failure
263        ///
264        /// # Safety
265        ///
266        /// `completion_handler` must be a valid pointer or null.
267        #[deprecated]
268        #[unsafe(method(executeWithInputsData:lossLabelsData:lossLabelWeightsData:batchSize:options:completionHandler:))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn executeWithInputsData_lossLabelsData_lossLabelWeightsData_batchSize_options_completionHandler(
271            &self,
272            inputs_data: &NSDictionary<NSString, MLCTensorData>,
273            loss_labels_data: Option<&NSDictionary<NSString, MLCTensorData>>,
274            loss_label_weights_data: Option<&NSDictionary<NSString, MLCTensorData>>,
275            batch_size: NSUInteger,
276            options: MLCExecutionOptions,
277            completion_handler: MLCGraphCompletionHandler,
278        ) -> bool;
279
280        #[cfg(all(
281            feature = "MLCTensor",
282            feature = "MLCTensorData",
283            feature = "MLCTypes",
284            feature = "block2"
285        ))]
286        /// Execute the inference graph with given input data
287        ///
288        /// Execute the inference graph given input data.
289        /// If MLCExecutionOptionsSynchronous is specified in 'options', this method returns after the graph has been executed.
290        /// Otherwise, this method returns after the graph has been queued for execution.  The completion handler  is called after the graph has finished execution.
291        ///
292        /// Parameter `inputsData`: The data objects to use for inputs
293        ///
294        /// Parameter `lossLabelsData`: The data objects to use for loss labels
295        ///
296        /// Parameter `lossLabelWeightsData`: The data objects to use for loss label weights
297        ///
298        /// Parameter `outputsData`: The data objects to use for outputs
299        ///
300        /// Parameter `batchSize`: The batch size to use.  For a graph where batch size changes between layers this value must be 0.
301        ///
302        /// Parameter `options`: The execution options
303        ///
304        /// Parameter `completionHandler`: The completion handler
305        ///
306        /// Returns: A boolean indicating success or failure
307        ///
308        /// # Safety
309        ///
310        /// `completion_handler` must be a valid pointer or null.
311        #[deprecated]
312        #[unsafe(method(executeWithInputsData:lossLabelsData:lossLabelWeightsData:outputsData:batchSize:options:completionHandler:))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn executeWithInputsData_lossLabelsData_lossLabelWeightsData_outputsData_batchSize_options_completionHandler(
315            &self,
316            inputs_data: &NSDictionary<NSString, MLCTensorData>,
317            loss_labels_data: Option<&NSDictionary<NSString, MLCTensorData>>,
318            loss_label_weights_data: Option<&NSDictionary<NSString, MLCTensorData>>,
319            outputs_data: Option<&NSDictionary<NSString, MLCTensorData>>,
320            batch_size: NSUInteger,
321            options: MLCExecutionOptions,
322            completion_handler: MLCGraphCompletionHandler,
323        ) -> bool;
324    );
325}
326
327/// Methods declared on superclass `MLCGraph`.
328#[cfg(feature = "MLCGraph")]
329impl MLCInferenceGraph {
330    extern_methods!(
331        /// Creates a new graph.
332        ///
333        /// Returns: A new graph.
334        #[deprecated]
335        #[unsafe(method(graph))]
336        #[unsafe(method_family = none)]
337        pub unsafe fn graph() -> Retained<Self>;
338    );
339}