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
//! 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!(
/// A class describing the plan for executing a model.
///
/// The application can use the plan to estimate the necessary cost and
/// resources of the model before running the predictions.
///
/// ```text
/// // Load the compute plan of an ML Program model.
/// [MLComputePlan loadContentsOfURL:modelURL configuration:configuration completionHandler:^(MLComputePlan * _Nullable computePlan, NSError * _Nullable error) {
/// if (!computePlan) {
/// // Handle error.
/// return;
/// }
/// MLModelStructureProgram *program = computePlan.modelStructure.program;
/// if (!program) {
/// [NSException raise:NSInternalInconsistencyException format:
/// "
/// Unexpected model type."];
/// }
///
/// MLModelStructureFunction *mainFunction = program.functions["main"];
/// if (!mainFunction) {
/// [NSException raise:NSInternalInconsistencyException format:
/// "
/// Missing main function."];
/// }
///
/// NSArray
/// <MLModelStructureProgramOperation
/// *> *operations = mainFunction.block.operations;
/// for (MLModelStructureProgramOperation *operation in operations) {
/// // Get the compute device usage for the operation.
/// MLComputeDeviceUsage *computeDeviceUsage = [computePlan computeDeviceUsageForMLProgramOperation:operation];
/// // Get the estimated cost of executing the operation.
/// MLComputePlanCost *estimatedCost = [computePlan estimatedCostOfMLProgramOperation:operation];
///
/// }
/// }];
/// ```
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coreml/mlcomputeplan?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MLComputePlan;
);
extern_conformance!(
unsafe impl NSObjectProtocol for MLComputePlan {}
);
impl MLComputePlan {
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>;
#[cfg(all(feature = "MLModelConfiguration", feature = "block2"))]
/// Construct the compute plan of a model asynchronously given the location of its on-disk representation.
///
///
/// Parameter `url`: The location of its on-disk representation (.mlmodelc directory).
///
/// Parameter `configuration`: The model configuration.
///
/// Parameter `handler`: When the compute plan is constructed successfully or unsuccessfully, the completion handler is invoked with a valid MLComputePlan instance or NSError object.
#[unsafe(method(loadContentsOfURL:configuration:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn loadContentsOfURL_configuration_completionHandler(
url: &NSURL,
configuration: &MLModelConfiguration,
handler: &block2::DynBlock<dyn Fn(*mut MLComputePlan, *mut NSError)>,
);
#[cfg(all(
feature = "MLModelAsset",
feature = "MLModelConfiguration",
feature = "block2"
))]
/// Construct the compute plan of a model asynchronously given the model asset.
///
///
/// Parameter `asset`: The model asset.
///
/// Parameter `configuration`: The model configuration.
///
/// Parameter `handler`: When the compute plan is constructed successfully or unsuccessfully, the completion handler is invoked with a valid MLComputePlan instance or NSError object.
#[unsafe(method(loadModelAsset:configuration:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn loadModelAsset_configuration_completionHandler(
asset: &MLModelAsset,
configuration: &MLModelConfiguration,
handler: &block2::DynBlock<dyn Fn(*mut MLComputePlan, *mut NSError)>,
);
#[cfg(all(
feature = "MLComputePlanCost",
feature = "MLModelStructureProgramOperation"
))]
/// Returns the estimated cost of executing an ML Program operation.
///
///
/// Parameter `operation`: An ML Program operation.
///
/// Returns: The estimated cost of executing the operation or nil if the cost couldn't be estimated.
#[unsafe(method(estimatedCostOfMLProgramOperation:))]
#[unsafe(method_family = none)]
pub unsafe fn estimatedCostOfMLProgramOperation(
&self,
operation: &MLModelStructureProgramOperation,
) -> Option<Retained<MLComputePlanCost>>;
#[cfg(all(
feature = "MLComputePlanDeviceUsage",
feature = "MLModelStructureNeuralNetworkLayer"
))]
/// Returns the anticipated compute devices that would be used for executing a NeuralNetwork layer.
///
///
/// Parameter `layer`: A NeuralNetwork layer.
///
/// Returns: The anticipated compute devices that would be used for executing the layer or `nil` if the usage couldn't be determined.
#[unsafe(method(computeDeviceUsageForNeuralNetworkLayer:))]
#[unsafe(method_family = none)]
pub unsafe fn computeDeviceUsageForNeuralNetworkLayer(
&self,
layer: &MLModelStructureNeuralNetworkLayer,
) -> Option<Retained<MLComputePlanDeviceUsage>>;
#[cfg(all(
feature = "MLComputePlanDeviceUsage",
feature = "MLModelStructureProgramOperation"
))]
/// Returns The anticipated compute devices that would be used for executing an ML Program operation.
///
///
/// Parameter `operation`: An ML Program operation.
///
/// Returns: The anticipated compute devices that would be used for executing the operation or `nil`if the usage couldn't be determined.
#[unsafe(method(computeDeviceUsageForMLProgramOperation:))]
#[unsafe(method_family = none)]
pub unsafe fn computeDeviceUsageForMLProgramOperation(
&self,
operation: &MLModelStructureProgramOperation,
) -> Option<Retained<MLComputePlanDeviceUsage>>;
#[cfg(feature = "MLModelStructure")]
/// The model structure.
#[unsafe(method(modelStructure))]
#[unsafe(method_family = none)]
pub unsafe fn modelStructure(&self) -> Retained<MLModelStructure>;
);
}