objc2_metal_performance_shaders/generated/MPSNeuralNetwork/MPSCNNNormalizationWeights.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::*;
6use objc2_metal::*;
7
8use crate::*;
9
10extern_class!(
11 /// A state which contains gamma and beta terms used to apply a scale
12 /// and bias in either an MPSCNNInstanceNormalization or MPSCNNBatchNormalization
13 /// operation.
14 ///
15 /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpscnnnormalizationgammaandbetastate?language=objc)
16 #[unsafe(super(MPSState, NSObject))]
17 #[derive(Debug, PartialEq, Eq, Hash)]
18 #[cfg(all(feature = "MPSCore", feature = "MPSState"))]
19 pub struct MPSCNNNormalizationGammaAndBetaState;
20);
21
22#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
23extern_conformance!(
24 unsafe impl NSObjectProtocol for MPSCNNNormalizationGammaAndBetaState {}
25);
26
27#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
28impl MPSCNNNormalizationGammaAndBetaState {
29 extern_methods!(
30 /// A MTLBuffer containing the gamma terms.
31 #[unsafe(method(gamma))]
32 #[unsafe(method_family = none)]
33 pub unsafe fn gamma(&self) -> Retained<ProtocolObject<dyn MTLBuffer>>;
34
35 /// A MTLBuffer containing the beta terms.
36 #[unsafe(method(beta))]
37 #[unsafe(method_family = none)]
38 pub unsafe fn beta(&self) -> Retained<ProtocolObject<dyn MTLBuffer>>;
39
40 /// Initialize a MPSCNNNormalizationGammaAndBetaState object using values
41 /// contained in MTLBuffers.
42 ///
43 ///
44 /// Parameter `gamma`: The MTLBuffer containing gamma terms.
45 ///
46 ///
47 /// Parameter `beta`: The MTLBuffer containing beta terms.
48 ///
49 /// # Safety
50 ///
51 /// - `gamma` may need to be synchronized.
52 /// - `gamma` may be unretained, you must ensure it is kept alive while in use.
53 /// - `gamma` contents should be of the correct type.
54 /// - `beta` may need to be synchronized.
55 /// - `beta` may be unretained, you must ensure it is kept alive while in use.
56 /// - `beta` contents should be of the correct type.
57 #[unsafe(method(initWithGamma:beta:))]
58 #[unsafe(method_family = init)]
59 pub unsafe fn initWithGamma_beta(
60 this: Allocated<Self>,
61 gamma: &ProtocolObject<dyn MTLBuffer>,
62 beta: &ProtocolObject<dyn MTLBuffer>,
63 ) -> Retained<Self>;
64
65 /// Create a temporary MPSCNNNormalizationGammaAndBetaState suitable
66 /// for a normalization operation on images containing no more than
67 /// the specified number of feature channels.
68 ///
69 ///
70 /// Parameter `commandBuffer`: The command buffer on which the temporary state will
71 /// be used.
72 ///
73 ///
74 /// Parameter `numberOfFeatureChannels`: The number of feature channels used to size the
75 /// state.
76 #[unsafe(method(temporaryStateWithCommandBuffer:numberOfFeatureChannels:))]
77 #[unsafe(method_family = none)]
78 pub unsafe fn temporaryStateWithCommandBuffer_numberOfFeatureChannels(
79 command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
80 number_of_feature_channels: NSUInteger,
81 ) -> Retained<Self>;
82 );
83}
84
85/// Methods declared on superclass `MPSState`.
86#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
87impl MPSCNNNormalizationGammaAndBetaState {
88 extern_methods!(
89 /// Create a MPSState holding a temporary MTLBuffer
90 ///
91 /// Parameter `cmdBuf`: The command buffer against which the temporary resource is allocated
92 ///
93 /// Parameter `bufferSize`: The size of the buffer in bytes
94 #[unsafe(method(temporaryStateWithCommandBuffer:bufferSize:))]
95 #[unsafe(method_family = none)]
96 pub unsafe fn temporaryStateWithCommandBuffer_bufferSize(
97 cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
98 buffer_size: usize,
99 ) -> Retained<Self>;
100
101 /// Create a MPSState holding a temporary MTLTexture
102 ///
103 /// Parameter `cmdBuf`: The command buffer against which the temporary resource is allocated
104 ///
105 /// Parameter `descriptor`: A descriptor for the new temporary texture
106 #[unsafe(method(temporaryStateWithCommandBuffer:textureDescriptor:))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn temporaryStateWithCommandBuffer_textureDescriptor(
109 cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
110 descriptor: &MTLTextureDescriptor,
111 ) -> Retained<Self>;
112
113 /// Create a new autoreleased temporary state object without underlying resource
114 ///
115 /// Parameter `cmdBuf`: The command buffer with which the temporary resource is associated
116 #[unsafe(method(temporaryStateWithCommandBuffer:))]
117 #[unsafe(method_family = none)]
118 pub unsafe fn temporaryStateWithCommandBuffer(
119 cmd_buf: &ProtocolObject<dyn MTLCommandBuffer>,
120 ) -> Retained<Self>;
121
122 #[unsafe(method(initWithDevice:bufferSize:))]
123 #[unsafe(method_family = init)]
124 pub unsafe fn initWithDevice_bufferSize(
125 this: Allocated<Self>,
126 device: &ProtocolObject<dyn MTLDevice>,
127 buffer_size: usize,
128 ) -> Retained<Self>;
129
130 #[unsafe(method(initWithDevice:textureDescriptor:))]
131 #[unsafe(method_family = init)]
132 pub unsafe fn initWithDevice_textureDescriptor(
133 this: Allocated<Self>,
134 device: &ProtocolObject<dyn MTLDevice>,
135 descriptor: &MTLTextureDescriptor,
136 ) -> Retained<Self>;
137
138 /// Create a MPSState with a non-temporary MTLResource
139 ///
140 /// Parameter `resource`: A MTLBuffer or MTLTexture. May be nil.
141 ///
142 /// # Safety
143 ///
144 /// - `resource` may need to be synchronized.
145 /// - `resource` may be unretained, you must ensure it is kept alive while in use.
146 #[unsafe(method(initWithResource:))]
147 #[unsafe(method_family = init)]
148 pub unsafe fn initWithResource(
149 this: Allocated<Self>,
150 resource: Option<&ProtocolObject<dyn MTLResource>>,
151 ) -> Retained<Self>;
152
153 #[unsafe(method(init))]
154 #[unsafe(method_family = init)]
155 pub unsafe fn init(this: Allocated<Self>) -> Option<Retained<Self>>;
156
157 /// Initialize a non-temporary state to hold a number of textures and buffers
158 ///
159 /// The allocation of each resource will be deferred until it is needed.
160 /// This occurs when -resource or -resourceAtIndex: is called.
161 ///
162 /// Parameter `resourceList`: The list of resources to create.
163 #[unsafe(method(initWithDevice:resourceList:))]
164 #[unsafe(method_family = init)]
165 pub unsafe fn initWithDevice_resourceList(
166 this: Allocated<Self>,
167 device: &ProtocolObject<dyn MTLDevice>,
168 resource_list: &MPSStateResourceList,
169 ) -> Retained<Self>;
170
171 /// Initialize a temporary state to hold a number of textures and buffers
172 ///
173 /// The textures occur first in sequence
174 #[unsafe(method(temporaryStateWithCommandBuffer:resourceList:))]
175 #[unsafe(method_family = none)]
176 pub unsafe fn temporaryStateWithCommandBuffer_resourceList(
177 command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
178 resource_list: &MPSStateResourceList,
179 ) -> Retained<Self>;
180
181 /// Create a state object with a list of MTLResources
182 ///
183 /// Because MPS prefers deferred allocation of resources
184 /// your application should use -initWithTextures:bufferSizes:bufferCount:
185 /// whenever possible. This method is useful for cases when the
186 /// MTLResources must be initialized by the CPU.
187 ///
188 /// # Safety
189 ///
190 /// - `resources` generic may need to be synchronized.
191 /// - `resources` generic may be unretained, you must ensure it is kept alive while in use.
192 #[unsafe(method(initWithResources:))]
193 #[unsafe(method_family = init)]
194 pub unsafe fn initWithResources(
195 this: Allocated<Self>,
196 resources: Option<&NSArray<ProtocolObject<dyn MTLResource>>>,
197 ) -> Retained<Self>;
198 );
199}
200
201/// Methods declared on superclass `NSObject`.
202#[cfg(all(feature = "MPSCore", feature = "MPSState"))]
203impl MPSCNNNormalizationGammaAndBetaState {
204 extern_methods!(
205 #[unsafe(method(new))]
206 #[unsafe(method_family = new)]
207 pub unsafe fn new() -> Retained<Self>;
208 );
209}