objc2_metal_performance_shaders_graph/generated/
MPSGraphNormalizationOps.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/// MPSGraphNormalizationOps.
11#[cfg(all(feature = "MPSGraph", feature = "MPSGraphCore"))]
12impl MPSGraph {
13    extern_methods!(
14        #[cfg(feature = "MPSGraphTensor")]
15        /// Returns the mean of the first input along the specified axes.
16        ///
17        /// - Parameters:
18        /// - axes: A list of axes over which to perform the reduction. The order of dimensions goes from the slowest moving at axis=0 to the fastest moving dimension.
19        /// - name: An optional name for the operation.
20        /// - Returns: A valid `MPSGraphTensor` object.
21        #[unsafe(method(meanOfTensor:axes:name:))]
22        #[unsafe(method_family = none)]
23        pub unsafe fn meanOfTensor_axes_name(
24            &self,
25            tensor: &MPSGraphTensor,
26            axes: &NSArray<NSNumber>,
27            name: Option<&NSString>,
28        ) -> Retained<MPSGraphTensor>;
29
30        #[cfg(feature = "MPSGraphTensor")]
31        /// Returns the variance of the first input along the specified axes when the mean has been precomputed.
32        ///
33        /// - Parameters:
34        /// - axes: A list of axes over which to perform the reduction such that the order of dimensions goes from the slowest moving at axis=0 to the fastest moving dimension.
35        /// - name: An optional name for the operation.
36        /// - Returns: A valid `MPSGraphTensor` object.
37        #[unsafe(method(varianceOfTensor:meanTensor:axes:name:))]
38        #[unsafe(method_family = none)]
39        pub unsafe fn varianceOfTensor_meanTensor_axes_name(
40            &self,
41            tensor: &MPSGraphTensor,
42            mean_tensor: &MPSGraphTensor,
43            axes: &NSArray<NSNumber>,
44            name: Option<&NSString>,
45        ) -> Retained<MPSGraphTensor>;
46
47        #[cfg(feature = "MPSGraphTensor")]
48        /// Returns the variance of the first input along the specified axes.
49        ///
50        /// - Parameters:
51        /// - axes: A list of axes over which to perform the reduction. Tthe order of dimensions goes from the slowest moving at axis=0 to the fastest moving dimension.
52        /// - name: An optional name for the operation.
53        /// - Returns: A valid `MPSGraphTensor` object.
54        #[unsafe(method(varianceOfTensor:axes:name:))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn varianceOfTensor_axes_name(
57            &self,
58            tensor: &MPSGraphTensor,
59            axes: &NSArray<NSNumber>,
60            name: Option<&NSString>,
61        ) -> Retained<MPSGraphTensor>;
62
63        #[cfg(feature = "MPSGraphTensor")]
64        /// Creates a batch normalization operation and returns the result tensor.
65        ///
66        /// The mean and variance tensors should be outputs of `meanWithTensor:axes:name` and `varianceWithTensor:meanTensor:axes:name`.
67        /// Use the axes parameter to achieve different types of normalizations.
68        /// For example (assuming your data is in NxHxWxC format)
69        /// Batch normalization: axes = [0, 1, 2]
70        /// Instance normalization: axes = [1, 2]
71        /// Shapes for gamma and beta must match the input data along at least one dimension and will be broadcast along the rest.
72        /// For batch normalization, gamma and beta would typically be 1x1x1xC i.e. one value per channel.
73        ///
74        /// - Parameters:
75        /// - tensor: The input tensor.
76        /// - mean: The mean tensor.
77        /// - variance: The variance tensor.
78        /// - gamma: The tensor used to scale the normalized result.
79        /// - beta: The tensor used to bias the normalized result.
80        /// - epsilon: A small value to add to the variance when normalizing the inputs.
81        /// - name: An optional name for the operation.
82        /// - Returns: A valid `MPSGraphTensor` object.
83        #[unsafe(method(normalizationWithTensor:meanTensor:varianceTensor:gammaTensor:betaTensor:epsilon:name:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn normalizationWithTensor_meanTensor_varianceTensor_gammaTensor_betaTensor_epsilon_name(
86            &self,
87            tensor: &MPSGraphTensor,
88            mean: &MPSGraphTensor,
89            variance: &MPSGraphTensor,
90            gamma: Option<&MPSGraphTensor>,
91            beta: Option<&MPSGraphTensor>,
92            epsilon: c_float,
93            name: Option<&NSString>,
94        ) -> Retained<MPSGraphTensor>;
95
96        #[cfg(feature = "MPSGraphTensor")]
97        /// Creates a normalization gamma-gradient operation and returns the result tensor.
98        ///
99        /// The mean and variance tensors should be outputs of ``meanWithTensor:axes:name`` and ``varianceWithTensor:meanTensor:axes:name``.
100        /// Use the axes parameter to achieve different types of normalizations.
101        /// For example (assuming your data is in `NxHxWxC` format)
102        /// Batch normalization: axes = [0, 1, 2]
103        /// Instance normalization: axes = [1, 2]
104        ///
105        /// - Parameters:
106        /// - incomingGradientTensor: The incoming original `resultTensor` gradient.
107        /// - sourceTensor: The original input source in forward direction.
108        /// - meanTensor: The mean tensor.
109        /// - varianceTensor: The variance tensor.
110        /// - axes: The axes of normalization.
111        /// - epsilon: A small value to add to the variance when normalizing the inputs.
112        /// - name: An optional name for the operation.
113        /// - Returns: A valid `MPSGraphTensor` object.
114        #[unsafe(method(normalizationGammaGradientWithIncomingGradientTensor:sourceTensor:meanTensor:varianceTensor:reductionAxes:epsilon:name:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn normalizationGammaGradientWithIncomingGradientTensor_sourceTensor_meanTensor_varianceTensor_reductionAxes_epsilon_name(
117            &self,
118            incoming_gradient_tensor: &MPSGraphTensor,
119            source_tensor: &MPSGraphTensor,
120            mean_tensor: &MPSGraphTensor,
121            variance_tensor: &MPSGraphTensor,
122            axes: &NSArray<NSNumber>,
123            epsilon: c_float,
124            name: Option<&NSString>,
125        ) -> Retained<MPSGraphTensor>;
126
127        #[cfg(feature = "MPSGraphTensor")]
128        /// Creates a normalization beta-gradient operation and returns the result tensor.
129        ///
130        /// The mean and variance tensors should be outputs of ``meanWithTensor:axes:name`` and ``varianceWithTensor:meanTensor:axes:name``.
131        /// Use the axes parameter to achieve different types of normalizations.
132        /// For example (assuming your data is in `NxHxWxC` format)
133        /// Batch normalization: axes = [0, 1, 2]
134        /// Instance normalization: axes = [1, 2]
135        ///
136        /// - Parameters:
137        /// - incomingGradientTensor: The incoming original `resultTensor` gradient.
138        /// - sourceTensor: The original input source in forward direction.
139        /// - axes: The axes of normalization.
140        /// - name: An optional name for the operation.
141        /// - Returns: A valid `MPSGraphTensor` object.
142        #[unsafe(method(normalizationBetaGradientWithIncomingGradientTensor:sourceTensor:reductionAxes:name:))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn normalizationBetaGradientWithIncomingGradientTensor_sourceTensor_reductionAxes_name(
145            &self,
146            incoming_gradient_tensor: &MPSGraphTensor,
147            source_tensor: &MPSGraphTensor,
148            axes: &NSArray<NSNumber>,
149            name: Option<&NSString>,
150        ) -> Retained<MPSGraphTensor>;
151
152        #[cfg(feature = "MPSGraphTensor")]
153        /// Creates a normalization input gradient operation and returns the result tensor.
154        ///
155        /// The mean and variance tensors should be outputs of ``meanWithTensor:axes:name`` and ``varianceWithTensor:meanTensor:axes:name``.
156        /// Use the axes parameter to achieve different types of normalizations.
157        /// For example (assuming your data is in `NxHxWxC` format)
158        /// Batch normalization: axes = [0, 1, 2]
159        /// Instance normalization: axes = [1, 2]
160        ///
161        /// - Parameters:
162        /// - incomingGradientTensor: The incoming original `resultTensor` gradient.
163        /// - sourceTensor: The original input source in forward direction.
164        /// - meanTensor: The mean tensor.
165        /// - varianceTensor: The variance tensor.
166        /// - gamma: The gamma tensor.
167        /// - gammaGradient: The `gammaGradient` tensor.
168        /// - betaGradient: The `betaGradient` tensor
169        /// - axes: The axes of normalization.
170        /// - epsilon: A small value to add to the variance when normalizing the inputs.
171        /// - name: An optional name for the operation.
172        #[unsafe(method(normalizationGradientWithIncomingGradientTensor:sourceTensor:meanTensor:varianceTensor:gammaTensor:gammaGradientTensor:betaGradientTensor:reductionAxes:epsilon:name:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn normalizationGradientWithIncomingGradientTensor_sourceTensor_meanTensor_varianceTensor_gammaTensor_gammaGradientTensor_betaGradientTensor_reductionAxes_epsilon_name(
175            &self,
176            incoming_gradient_tensor: &MPSGraphTensor,
177            source_tensor: &MPSGraphTensor,
178            mean_tensor: &MPSGraphTensor,
179            variance_tensor: &MPSGraphTensor,
180            gamma: Option<&MPSGraphTensor>,
181            gamma_gradient: Option<&MPSGraphTensor>,
182            beta_gradient: Option<&MPSGraphTensor>,
183            axes: &NSArray<NSNumber>,
184            epsilon: c_float,
185            name: Option<&NSString>,
186        ) -> Retained<MPSGraphTensor>;
187    );
188}