objc2_metal_performance_shaders_graph/generated/MPSGraphFourierTransformOps.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
10/// The scaling modes for Fourier transform operations.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshadersgraph/mpsgraphfftscalingmode?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct MPSGraphFFTScalingMode(pub NSUInteger);
17impl MPSGraphFFTScalingMode {
18 /// Computes the FFT result with no scaling.
19 #[doc(alias = "MPSGraphFFTScalingModeNone")]
20 pub const None: Self = Self(0);
21 /// Scales the FFT result with reciprocal of the total FFT size over all transformed dimensions.
22 #[doc(alias = "MPSGraphFFTScalingModeSize")]
23 pub const Size: Self = Self(1);
24 /// Scales the FFT result with reciprocal square root of the total FFT size over all transformed dimensions, resulting in signal strength conserving transformation.
25 #[doc(alias = "MPSGraphFFTScalingModeUnitary")]
26 pub const Unitary: Self = Self(2);
27}
28
29unsafe impl Encode for MPSGraphFFTScalingMode {
30 const ENCODING: Encoding = NSUInteger::ENCODING;
31}
32
33unsafe impl RefEncode for MPSGraphFFTScalingMode {
34 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
35}
36
37extern_class!(
38 /// The class that defines the parameters for a fast Fourier transform (FFT) operation.
39 ///
40 /// Use this descriptor with ``MPSGraph/fastFourierTransformWithTensor:axes:descriptor:name:``,
41 /// ``MPSGraph/realToHermiteanFFTWithTensor:axesTensor:descriptor:name:``, and
42 /// ``MPSGraph/HermiteanToRealFFTWithTensor:axesTensor:descriptor:name:`` methods.
43 ///
44 /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshadersgraph/mpsgraphfftdescriptor?language=objc)
45 #[unsafe(super(MPSGraphObject, NSObject))]
46 #[derive(Debug, PartialEq, Eq, Hash)]
47 #[cfg(feature = "MPSGraphCore")]
48 pub struct MPSGraphFFTDescriptor;
49);
50
51#[cfg(feature = "MPSGraphCore")]
52extern_conformance!(
53 unsafe impl NSCopying for MPSGraphFFTDescriptor {}
54);
55
56#[cfg(feature = "MPSGraphCore")]
57unsafe impl CopyingHelper for MPSGraphFFTDescriptor {
58 type Result = Self;
59}
60
61#[cfg(feature = "MPSGraphCore")]
62extern_conformance!(
63 unsafe impl NSObjectProtocol for MPSGraphFFTDescriptor {}
64);
65
66#[cfg(feature = "MPSGraphCore")]
67impl MPSGraphFFTDescriptor {
68 extern_methods!(
69 /// A Boolean-valued parameter that defines the phase factor sign for Fourier transforms.
70 ///
71 /// When set to `YES` graph uses the positive phase factor: `exp(+i 2Pi mu nu / n)`, when computing the (inverse) Fourier transform.
72 /// Otherwise MPSGraph uses the negative phase factor: `exp(-i 2Pi mu nu / n)`, when computing the Fourier transform.
73 /// Default value: `NO`.
74 #[unsafe(method(inverse))]
75 #[unsafe(method_family = none)]
76 pub unsafe fn inverse(&self) -> bool;
77
78 /// Setter for [`inverse`][Self::inverse].
79 #[unsafe(method(setInverse:))]
80 #[unsafe(method_family = none)]
81 pub unsafe fn setInverse(&self, inverse: bool);
82
83 /// The scaling mode of the fast fourier transform (FFT) operation.
84 ///
85 /// Note that the scaling mode is independent from the phase factor. Default value: `MPSGraphFFTScalingModeNone`.
86 #[unsafe(method(scalingMode))]
87 #[unsafe(method_family = none)]
88 pub unsafe fn scalingMode(&self) -> MPSGraphFFTScalingMode;
89
90 /// Setter for [`scalingMode`][Self::scalingMode].
91 #[unsafe(method(setScalingMode:))]
92 #[unsafe(method_family = none)]
93 pub unsafe fn setScalingMode(&self, scaling_mode: MPSGraphFFTScalingMode);
94
95 /// A parameter which controls how graph rounds the output tensor size for a Hermitean-to-real Fourier transform.
96 ///
97 /// If set to `YES` then MPSGraph rounds the last output dimension of the result tensor in
98 /// ``MPSGraph/HermiteanToRealFFTWithTensor:axesTensor:descriptor:name:`` to an odd value.
99 /// Has no effect in the other Fourier transform operations.
100 /// Default value: `NO`.
101 #[unsafe(method(roundToOddHermitean))]
102 #[unsafe(method_family = none)]
103 pub unsafe fn roundToOddHermitean(&self) -> bool;
104
105 /// Setter for [`roundToOddHermitean`][Self::roundToOddHermitean].
106 #[unsafe(method(setRoundToOddHermitean:))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn setRoundToOddHermitean(&self, round_to_odd_hermitean: bool);
109
110 /// Creates a fast Fourier transform descriptor with default parameter values.
111 #[unsafe(method(descriptor))]
112 #[unsafe(method_family = none)]
113 pub unsafe fn descriptor() -> Option<Retained<Self>>;
114 );
115}
116
117/// Methods declared on superclass `NSObject`.
118#[cfg(feature = "MPSGraphCore")]
119impl MPSGraphFFTDescriptor {
120 extern_methods!(
121 #[unsafe(method(init))]
122 #[unsafe(method_family = init)]
123 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
124
125 #[unsafe(method(new))]
126 #[unsafe(method_family = new)]
127 pub unsafe fn new() -> Retained<Self>;
128 );
129}
130
131/// MPSGraphFourierTransformOps.
132#[cfg(all(feature = "MPSGraph", feature = "MPSGraphCore"))]
133impl MPSGraph {
134 extern_methods!(
135 #[cfg(feature = "MPSGraphTensor")]
136 /// Creates a fast Fourier transform operation and returns the result tensor.
137 ///
138 /// This operation computes the fast Fourier transform of the input tensor according to the following formulae.
139 /// ```md
140 /// output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) input[nu], where
141 /// ```
142 /// `scale = 1` for `scaling_mode = none`,
143 /// `scale = 1/V_f` for `scaling_mode = size`,
144 /// `scale = 1/sqrt(V_f)` for `scaling_mode = unitary`, where
145 /// `V_f` is the volume of the transformation defined by the dimensions included in `axes`
146 /// (`V_f = prod_{i
147 /// \in axes} shape(input)[i]`) (see ``MPSGraphFFTDescriptor/scalingMode``),
148 /// `+` is selected in `+/-` when `inverse` is specified, otherwise `-` is used
149 /// and the sum is done separately over each dimension in `axes` and `n` is the
150 /// dimension length of that axis.
151 ///
152 /// > Tip: Currently MPSGraph supports the transformation only within the last four dimensions of the input tensor. In case
153 /// you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input
154 /// with ``MPSGraph/transposeTensor:permutation:name:`` to be within that last four and then transpose
155 /// the result tensor back with the inverse of the input transpose.
156 ///
157 /// - Parameters:
158 /// - tensor: A complex or real-valued input tensor.
159 /// - axes: An array of numbers that specifies over which axes MPSGraph performs the Fourier transform - all axes must be contained within last four dimensions of the input tensor.
160 /// - descriptor: A descriptor that defines the parameters of the Fourier transform operation - see ``MPSGraphFFTDescriptor``.
161 /// - name: The name for the operation.
162 /// - Returns: A valid complex-valued MPSGraphTensor of the same shape as `tensor`.
163 #[unsafe(method(fastFourierTransformWithTensor:axes:descriptor:name:))]
164 #[unsafe(method_family = none)]
165 pub unsafe fn fastFourierTransformWithTensor_axes_descriptor_name(
166 &self,
167 tensor: &MPSGraphTensor,
168 axes: &NSArray<NSNumber>,
169 descriptor: &MPSGraphFFTDescriptor,
170 name: Option<&NSString>,
171 ) -> Retained<MPSGraphTensor>;
172
173 #[cfg(feature = "MPSGraphTensor")]
174 /// Creates a fast Fourier transform operation and returns the result tensor.
175 ///
176 /// This operation computes the fast Fourier transform of the input tensor according to the following formulae.
177 /// ```md
178 /// output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) input[nu], where
179 /// ```
180 /// `scale = 1` for `scaling_mode = none`,
181 /// `scale = 1/V_f` for `scaling_mode = size`,
182 /// `scale = 1/sqrt(V_f)` for `scaling_mode = unitary`, where
183 /// `V_f` is the volume of the transformation defined by the dimensions included in `axes`
184 /// (`V_f = prod_{i
185 /// \in axes} shape(input)[i]`) (see ``MPSGraphFFTDescriptor/scalingMode``),
186 /// `+` is selected in `+/-` when `inverse` is specified, otherwise `-` is used
187 /// and the sum is done separately over each dimension in `axes` and `n` is the
188 /// dimension length of that axis.
189 ///
190 /// > Tip: Currently MPSGraph supports the transformation only within the last four dimensions of the input tensor. In case
191 /// you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input
192 /// with ``MPSGraph/transposeTensor:permutation:name:`` to be within that last four and then transpose
193 /// the result tensor back with the inverse of the input transpose.
194 ///
195 /// - Parameters:
196 /// - tensor: A complex or real-valued input tensor.
197 /// - axesTensor: A tensor of rank one containing the axes over which MPSGraph performs the transformation. See ``MPSGraph/fastFourierTransformWithTensor:axes:descriptor:name:``.
198 /// - descriptor: A descriptor that defines the parameters of the Fourier transform operation - see ``MPSGraphFFTDescriptor``.
199 /// - name: The name for the operation.
200 /// - Returns: A valid complex-valued MPSGraphTensor of the same shape as `tensor`.
201 #[unsafe(method(fastFourierTransformWithTensor:axesTensor:descriptor:name:))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn fastFourierTransformWithTensor_axesTensor_descriptor_name(
204 &self,
205 tensor: &MPSGraphTensor,
206 axes_tensor: &MPSGraphTensor,
207 descriptor: &MPSGraphFFTDescriptor,
208 name: Option<&NSString>,
209 ) -> Retained<MPSGraphTensor>;
210
211 #[cfg(feature = "MPSGraphTensor")]
212 /// Creates a Real-to-Hermitean fast Fourier transform operation and returns the result tensor.
213 ///
214 /// This operation computes the fast Fourier transform of a real-valued input tensor according to the following formulae.
215 /// ```md
216 /// output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) input[nu], where
217 /// ```
218 /// `scale = 1` for `scaling_mode = none`,
219 /// `scale = 1/V_f` for `scaling_mode = size`,
220 /// `scale = 1/sqrt(V_f)` for `scaling_mode = unitary`, where
221 /// `V_f` is the volume of the transformation defined by the dimensions included in `axes`
222 /// (`V_f = prod_{i
223 /// \in axes} shape(input)[i]`) (see ``MPSGraphFFTDescriptor/scalingMode``),
224 /// `+` is selected in `+/-` when `inverse` is specified, otherwise `-` is used
225 /// and the sum is done separately over each dimension in `axes` and `n` is the
226 /// dimension length of that axis. With this API MPSGraph writes out only the results for the unique
227 /// frequencies, resulting in a tensor which has size `(n/2)+1` in the last dimension defined by `axes`.
228 ///
229 /// > Tip: Currently MPSGraph supports the transformation only within the last four dimensions of the input tensor. In case
230 /// you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input
231 /// with ``MPSGraph/transposeTensor:permutation:name:`` to be within that last four and then transpose
232 /// the result tensor back with the inverse of the input transpose.
233 ///
234 /// - Parameters:
235 /// - tensor: A Real-valued input tensor. Must have datatype `MPSDataTypeFloat32` or `MPSDatatypeFloat16`.
236 /// - axes: An array of numbers that specifies over which axes MPSGraph performs the Fourier transform - all axes must be contained within last four dimensions of the input tensor.
237 /// - descriptor: A descriptor that defines the parameters of the Fourier transform operation - see ``MPSGraphFFTDescriptor``.
238 /// - name: The name for the operation.
239 /// - Returns: A valid MPSGraphTensor of type `MPSDataTypeComplexFloat32` or `MPSDataTypeComplexFloat16` with reduced size (see Discussion).
240 #[unsafe(method(realToHermiteanFFTWithTensor:axes:descriptor:name:))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn realToHermiteanFFTWithTensor_axes_descriptor_name(
243 &self,
244 tensor: &MPSGraphTensor,
245 axes: &NSArray<NSNumber>,
246 descriptor: &MPSGraphFFTDescriptor,
247 name: Option<&NSString>,
248 ) -> Retained<MPSGraphTensor>;
249
250 #[cfg(feature = "MPSGraphTensor")]
251 /// Creates a Real-to-Hermitean fast Fourier transform operation and returns the result tensor.
252 ///
253 /// This operation computes the fast Fourier transform of a real-valued input tensor according to the following formulae.
254 /// ```md
255 /// output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) input[nu], where
256 /// ```
257 /// `scale = 1` for `scaling_mode = none`,
258 /// `scale = 1/V_f` for `scaling_mode = size`,
259 /// `scale = 1/sqrt(V_f)` for `scaling_mode = unitary`, where
260 /// `V_f` is the volume of the transformation defined by the dimensions included in `axes`
261 /// (`V_f = prod_{i
262 /// \in axes} shape(input)[i]`) (see ``MPSGraphFFTDescriptor/scalingMode``),
263 /// `+` is selected in `+/-` when `inverse` is specified, otherwise `-` is used
264 /// and the sum is done separately over each dimension in `axes` and `n` is the
265 /// dimension length of that axis. With this API MPSGraph writes out only the results for the unique
266 /// frequencies, resulting in a tensor which has size `(n/2)+1` in the last dimension defined by `axes`.
267 ///
268 /// > Tip: Currently MPSGraph supports the transformation only within the last four dimensions of the input tensor. In case
269 /// you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input
270 /// with ``MPSGraph/transposeTensor:permutation:name:`` to be within that last four and then transpose
271 /// the result tensor back with the inverse of the input transpose.
272 ///
273 /// - Parameters:
274 /// - tensor: A real-valued input tensor. Must have datatype `MPSDataTypeFloat32` or `MPSDatatypeFloat16`.
275 /// - axesTensor: A tensor of rank one containing the axes over which MPSGraph performs the transformation. See ``MPSGraph/fastFourierTransformWithTensor:axes:descriptor:name:``.
276 /// - descriptor: A descriptor that defines the parameters of the Fourier transform operation - see ``MPSGraphFFTDescriptor``.
277 /// - name: The name for the operation.
278 /// - Returns: A valid MPSGraphTensor of type `MPSDataTypeComplexFloat32` or `MPSDataTypeComplexFloat16` with reduced size (see Discussion).
279 #[unsafe(method(realToHermiteanFFTWithTensor:axesTensor:descriptor:name:))]
280 #[unsafe(method_family = none)]
281 pub unsafe fn realToHermiteanFFTWithTensor_axesTensor_descriptor_name(
282 &self,
283 tensor: &MPSGraphTensor,
284 axes_tensor: &MPSGraphTensor,
285 descriptor: &MPSGraphFFTDescriptor,
286 name: Option<&NSString>,
287 ) -> Retained<MPSGraphTensor>;
288
289 #[cfg(feature = "MPSGraphTensor")]
290 /// Creates a Hermitean-to-real fast Fourier transform operation and returns the result tensor.
291 ///
292 /// This operation computes the fast Fourier transform of a complex-valued input tensor according to the following formulae.
293 /// ```md
294 /// output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) in'[nu], where
295 /// ```
296 /// `in'[nu] = conjugate(in[n - nu])`, for the last dimension defined by `axes` when `nu` is out of range of the input dimension.
297 /// `scale = 1` for `scaling_mode = none`,
298 /// `scale = 1/V_f` for `scaling_mode = size`,
299 /// `scale = 1/sqrt(V_f)` for `scaling_mode = unitary`, where
300 /// `V_f` is the volume of the transformation defined by the dimensions included in `axes`
301 /// (`V_f = prod_{i
302 /// \in axes} shape(input)[i]`) (see ``MPSGraphFFTDescriptor/scalingMode``),
303 /// `+` is selected in `+/-` when `inverse` is specified, otherwise `-` is used
304 /// and the sum is done separately over each dimension in `axes` and `n` is the
305 /// dimension length of that axis. With this API MPSGraph treats the input tensor to have only the unique
306 /// frequencies, which means that the resulting tensor has size `(inSize-1)*2 + x` in the last dimension defined by `axes`,
307 /// where `inSize = shape(input)[axis] ( = (n/2)+1 )` is the size of the input `tensor` in the last transformed dimension and
308 /// `x = 1` when ``MPSGraphFFTDescriptor/roundToOddHermitean`` = `YES` and `x = 0` otherwise.
309 ///
310 /// > Tip: Currently transformation is supported only within the last four dimensions of the input tensor. In case
311 /// you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input
312 /// with ``MPSGraph/transposeTensor:permutation:name:`` to be within that last four and then transpose
313 /// the result tensor back with the inverse of the input transpose.
314 ///
315 /// - Parameters:
316 /// - tensor: A complex-valued input tensor with reduced size (see Discussion). Must have datatype `MPSDataTypeComplexFloat32` or `MPSDataTypeComplexFloat16`.
317 /// - axes: An array of numbers that specifies over which axes MPSGraph performs the Fourier transform - all axes must be contained within last four dimensions of the input tensor.
318 /// - descriptor: A descriptor that defines the parameters of the Fourier transform operation - see ``MPSGraphFFTDescriptor``.
319 /// - name: The name for the operation.
320 /// - Returns: A valid MPSGraphTensor of type `MPSDataTypeFloat32` or `MPSDataTypeFloat16` (full size).
321 #[unsafe(method(HermiteanToRealFFTWithTensor:axes:descriptor:name:))]
322 #[unsafe(method_family = none)]
323 pub unsafe fn HermiteanToRealFFTWithTensor_axes_descriptor_name(
324 &self,
325 tensor: &MPSGraphTensor,
326 axes: &NSArray<NSNumber>,
327 descriptor: &MPSGraphFFTDescriptor,
328 name: Option<&NSString>,
329 ) -> Retained<MPSGraphTensor>;
330
331 #[cfg(feature = "MPSGraphTensor")]
332 /// Creates a Hermitean-to-real fast Fourier transform operation and returns the result tensor.
333 ///
334 /// This operation computes the fast Fourier transform of a complex-valued input tensor according to the following formulae.
335 /// ```md
336 /// output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) in'[nu], where
337 /// ```
338 /// `in'[nu] = conjugate(in[n - nu])`, for the last dimension defined by `axes` when `nu` is out of range of the input dimension.
339 /// `scale = 1` for `scaling_mode = none`,
340 /// `scale = 1/V_f` for `scaling_mode = size`,
341 /// `scale = 1/sqrt(V_f)` for `scaling_mode = unitary`, where
342 /// `V_f` is the volume of the transformation defined by the dimensions included in `axes`
343 /// (`V_f = prod_{i
344 /// \in axes} shape(input)[i]`) (see ``MPSGraphFFTDescriptor/scalingMode``),
345 /// `+` is selected in `+/-` when `inverse` is specified, otherwise `-` is used
346 /// and the sum is done separately over each dimension in `axes` and `n` is the
347 /// dimension length of that axis. With this API MPSGraph treats the input tensor to have only the unique
348 /// frequencies, which means that the resulting tensor has size `(inSize-1)*2 + x` in the last dimension defined by `axes`,
349 /// where `inSize = shape(input)[axis] ( = (n/2)+1 )` is the size of the input `tensor` in the last transformed dimension and
350 /// `x = 1` when ``MPSGraphFFTDescriptor/roundToOddHermitean`` = `YES` and `x = 0` otherwise.
351 ///
352 /// > Tip: Currently MPSGraph supports the transformation only within the last four dimensions of the input tensor. In case
353 /// you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input
354 /// with ``MPSGraph/transposeTensor:permutation:name:`` to be within that last four and then transpose
355 /// the result tensor back with the inverse of the input transpose.
356 ///
357 /// - Parameters:
358 /// - tensor: A complex-valued input tensor with reduced size (see Discussion). Must have datatype `MPSDataTypeComplexFloat32` or `MPSDataTypeComplexFloat16`.
359 /// - axesTensor: A tensor of rank one containing the axes over which MPSGraph performs the transformation. See ``MPSGraph/fastFourierTransformWithTensor:axes:descriptor:name:``.
360 /// - descriptor: A descriptor that defines the parameters of the Fourier transform operation - see ``MPSGraphFFTDescriptor``.
361 /// - name: The name for the operation.
362 /// - Returns: A valid MPSGraphTensor of type `MPSDataTypeFloat32` or `MPSDataTypeFloat16` (full size).
363 #[unsafe(method(HermiteanToRealFFTWithTensor:axesTensor:descriptor:name:))]
364 #[unsafe(method_family = none)]
365 pub unsafe fn HermiteanToRealFFTWithTensor_axesTensor_descriptor_name(
366 &self,
367 tensor: &MPSGraphTensor,
368 axes_tensor: &MPSGraphTensor,
369 descriptor: &MPSGraphFFTDescriptor,
370 name: Option<&NSString>,
371 ) -> Retained<MPSGraphTensor>;
372 );
373}