objc2_metal/generated/
MTL4MachineLearningPipeline.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// Description for a machine learning pipeline state.
12    ///
13    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4machinelearningpipelinedescriptor?language=objc)
14    #[unsafe(super(MTL4PipelineDescriptor, NSObject))]
15    #[derive(Debug, PartialEq, Eq, Hash)]
16    #[cfg(feature = "MTL4PipelineState")]
17    pub struct MTL4MachineLearningPipelineDescriptor;
18);
19
20#[cfg(feature = "MTL4PipelineState")]
21extern_conformance!(
22    unsafe impl NSCopying for MTL4MachineLearningPipelineDescriptor {}
23);
24
25#[cfg(feature = "MTL4PipelineState")]
26unsafe impl CopyingHelper for MTL4MachineLearningPipelineDescriptor {
27    type Result = Self;
28}
29
30#[cfg(feature = "MTL4PipelineState")]
31extern_conformance!(
32    unsafe impl NSObjectProtocol for MTL4MachineLearningPipelineDescriptor {}
33);
34
35#[cfg(feature = "MTL4PipelineState")]
36impl MTL4MachineLearningPipelineDescriptor {
37    extern_methods!(
38        /// Assigns an optional string that helps identify pipeline states you create from this descriptor.
39        #[unsafe(method(label))]
40        #[unsafe(method_family = none)]
41        pub fn label(&self) -> Option<Retained<NSString>>;
42
43        /// Setter for [`label`][Self::label].
44        ///
45        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
46        #[unsafe(method(setLabel:))]
47        #[unsafe(method_family = none)]
48        pub fn setLabel(&self, label: Option<&NSString>);
49
50        #[cfg(feature = "MTL4FunctionDescriptor")]
51        /// Assigns the function that the machine learning pipeline you create from this descriptor executes.
52        #[unsafe(method(machineLearningFunctionDescriptor))]
53        #[unsafe(method_family = none)]
54        pub fn machineLearningFunctionDescriptor(&self)
55            -> Option<Retained<MTL4FunctionDescriptor>>;
56
57        #[cfg(feature = "MTL4FunctionDescriptor")]
58        /// Setter for [`machineLearningFunctionDescriptor`][Self::machineLearningFunctionDescriptor].
59        ///
60        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
61        #[unsafe(method(setMachineLearningFunctionDescriptor:))]
62        #[unsafe(method_family = none)]
63        pub fn setMachineLearningFunctionDescriptor(
64            &self,
65            machine_learning_function_descriptor: Option<&MTL4FunctionDescriptor>,
66        );
67
68        #[cfg(feature = "MTLTensor")]
69        /// Sets the dimension of an input tensor at a buffer index.
70        ///
71        /// - Parameters:
72        /// - dimensions: the dimensions of the tensor.
73        /// - bufferIndex: Index of the tensor to modify.
74        ///
75        /// # Safety
76        ///
77        /// `bufferIndex` might not be bounds-checked.
78        #[unsafe(method(setInputDimensions:atBufferIndex:))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn setInputDimensions_atBufferIndex(
81            &self,
82            dimensions: Option<&MTLTensorExtents>,
83            buffer_index: NSInteger,
84        );
85
86        #[cfg(feature = "MTLTensor")]
87        /// Sets the dimensions of multiple input tensors on a range of buffer bindings.
88        ///
89        /// Use this method to specify the dimensions of multiple input tensors at a range of indices in a single call.
90        ///
91        /// You can indicate that any tensors in the range have unspecified dimensions by providing `NSNull` at the their
92        /// corresponding index location in the array.
93        ///
94        /// - Important: The range's length property needs to match the number of dimensions you provide. Specifically,
95        /// `range.length` needs to match `dimensions.count`.
96        ///
97        /// - Parameters:
98        /// - dimensions: An array of tensor extents.
99        /// - range: The range of inputs of the `dimensions` argument.
100        /// The range's `length` needs to match the dimensions' `count` property.
101        ///
102        /// # Safety
103        ///
104        /// `range` might not be bounds-checked.
105        #[unsafe(method(setInputDimensions:withRange:))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn setInputDimensions_withRange(
108            &self,
109            dimensions: &NSArray<MTLTensorExtents>,
110            range: NSRange,
111        );
112
113        #[cfg(feature = "MTLTensor")]
114        /// Obtains the dimensions of the input tensor at `bufferIndex` if set, `nil` otherwise.
115        ///
116        /// # Safety
117        ///
118        /// `bufferIndex` might not be bounds-checked.
119        #[unsafe(method(inputDimensionsAtBufferIndex:))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn inputDimensionsAtBufferIndex(
122            &self,
123            buffer_index: NSInteger,
124        ) -> Option<Retained<MTLTensorExtents>>;
125
126        /// Resets the descriptor to its default values.
127        #[unsafe(method(reset))]
128        #[unsafe(method_family = none)]
129        pub fn reset(&self);
130    );
131}
132
133/// Methods declared on superclass `NSObject`.
134#[cfg(feature = "MTL4PipelineState")]
135impl MTL4MachineLearningPipelineDescriptor {
136    extern_methods!(
137        #[unsafe(method(init))]
138        #[unsafe(method_family = init)]
139        pub fn init(this: Allocated<Self>) -> Retained<Self>;
140
141        #[unsafe(method(new))]
142        #[unsafe(method_family = new)]
143        pub fn new() -> Retained<Self>;
144    );
145}
146
147#[cfg(feature = "MTL4PipelineState")]
148impl DefaultRetained for MTL4MachineLearningPipelineDescriptor {
149    #[inline]
150    fn default_retained() -> Retained<Self> {
151        Self::new()
152    }
153}
154
155extern_class!(
156    /// Represents reflection information for a machine learning pipeline state.
157    ///
158    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4machinelearningpipelinereflection?language=objc)
159    #[unsafe(super(NSObject))]
160    #[derive(Debug, PartialEq, Eq, Hash)]
161    pub struct MTL4MachineLearningPipelineReflection;
162);
163
164unsafe impl Send for MTL4MachineLearningPipelineReflection {}
165
166unsafe impl Sync for MTL4MachineLearningPipelineReflection {}
167
168extern_conformance!(
169    unsafe impl NSObjectProtocol for MTL4MachineLearningPipelineReflection {}
170);
171
172impl MTL4MachineLearningPipelineReflection {
173    extern_methods!(
174        #[cfg(feature = "MTLArgument")]
175        /// Describes every input and output of the pipeline.
176        #[unsafe(method(bindings))]
177        #[unsafe(method_family = none)]
178        pub fn bindings(&self) -> Retained<NSArray<ProtocolObject<dyn MTLBinding>>>;
179    );
180}
181
182/// Methods declared on superclass `NSObject`.
183impl MTL4MachineLearningPipelineReflection {
184    extern_methods!(
185        #[unsafe(method(init))]
186        #[unsafe(method_family = init)]
187        pub fn init(this: Allocated<Self>) -> Retained<Self>;
188
189        #[unsafe(method(new))]
190        #[unsafe(method_family = new)]
191        pub fn new() -> Retained<Self>;
192    );
193}
194
195impl DefaultRetained for MTL4MachineLearningPipelineReflection {
196    #[inline]
197    fn default_retained() -> Retained<Self> {
198        Self::new()
199    }
200}
201
202extern_protocol!(
203    /// A pipeline state that you can use with machine-learning encoder instances.
204    ///
205    /// See ``MTL4MachineLearningCommandEncoder`` for more information.
206    ///
207    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtl4machinelearningpipelinestate?language=objc)
208    #[cfg(feature = "MTLAllocation")]
209    pub unsafe trait MTL4MachineLearningPipelineState:
210        MTLAllocation + NSObjectProtocol + Send + Sync
211    {
212        /// Queries the string that helps identify this object.
213        #[unsafe(method(label))]
214        #[unsafe(method_family = none)]
215        fn label(&self) -> Option<Retained<NSString>>;
216
217        #[cfg(feature = "MTLDevice")]
218        /// Returns the device the pipeline state belongs to.
219        #[unsafe(method(device))]
220        #[unsafe(method_family = none)]
221        fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
222
223        /// Returns reflection information for this machine learning pipeline state.
224        #[unsafe(method(reflection))]
225        #[unsafe(method_family = none)]
226        fn reflection(&self) -> Option<Retained<MTL4MachineLearningPipelineReflection>>;
227
228        /// Obtain the size of the heap, in bytes, this pipeline requires during the execution.
229        ///
230        /// Use this value to allocate a ``MTLHeap`` instance of sufficient size that you can then provide to
231        /// ``MTL4MachineLearningCommandEncoder/dispatchNetworkWithIntermediatesHeap:``.
232        ///
233        /// Metal uses this heap to store intermediate data as it executes the pipeline. It is your responsibility to provide
234        /// a heap at least as large as this property requests.
235        #[unsafe(method(intermediatesHeapSize))]
236        #[unsafe(method_family = none)]
237        fn intermediatesHeapSize(&self) -> NSUInteger;
238    }
239);