objc2_metal_performance_shaders_graph/generated/
MPSGraphQuantizationOps.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#[cfg(feature = "objc2-metal-performance-shaders")]
8use objc2_metal_performance_shaders::*;
9
10use crate::*;
11
12/// MPSGraphQuantizationOps.
13#[cfg(all(feature = "MPSGraph", feature = "MPSGraphCore"))]
14impl MPSGraph {
15    extern_methods!(
16        #[cfg(all(
17            feature = "MPSGraphTensor",
18            feature = "objc2-metal-performance-shaders"
19        ))]
20        /// Creates a Quantize operation and returns the result tensor.
21        ///
22        /// Convert the float `tensor` to an i8 or u8 tensor by applying a scale + bias transform:
23        /// result = (tensor / scale) + zeroPoint
24        ///
25        /// - Parameters:
26        /// - tensor: Input tensor to be quantized
27        /// - scale: Scale scalar parameter
28        /// - zeroPoint: Bias scalar parameter (converted to dataType of resultTensor)
29        /// - dataType: Integer data type of the result tensor.
30        /// - name: The name for the operation.
31        /// - Returns: A valid MPSGraphTensor array of datatype dataType
32        #[unsafe(method(quantizeTensor:scale:zeroPoint:dataType:name:))]
33        #[unsafe(method_family = none)]
34        pub unsafe fn quantizeTensor_scale_zeroPoint_dataType_name(
35            &self,
36            tensor: &MPSGraphTensor,
37            scale: c_double,
38            zero_point: c_double,
39            data_type: MPSDataType,
40            name: Option<&NSString>,
41        ) -> Retained<MPSGraphTensor>;
42
43        #[cfg(all(
44            feature = "MPSGraphTensor",
45            feature = "objc2-metal-performance-shaders"
46        ))]
47        /// Creates Dequantize operation and returns the result tensor.
48        ///
49        /// Convert the i8 or u8 `tensor` to a float tensor by applying a scale + bias transform:
50        /// result = scale(tensor - zeroPoint)
51        ///
52        /// - Parameters:
53        /// - tensor: Input tensor to be dequantized
54        /// - scale: Scale scalar parameter
55        /// - zeroPoint: Bias scalar parameter (converted to dataType of tensor)
56        /// - dataType: Float data type of the result tensor.
57        /// - name: The name for the operation.
58        /// - Returns: A valid MPSGraphTensor array of datatype dataType
59        #[unsafe(method(dequantizeTensor:scale:zeroPoint:dataType:name:))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn dequantizeTensor_scale_zeroPoint_dataType_name(
62            &self,
63            tensor: &MPSGraphTensor,
64            scale: c_double,
65            zero_point: c_double,
66            data_type: MPSDataType,
67            name: Option<&NSString>,
68        ) -> Retained<MPSGraphTensor>;
69
70        #[cfg(all(
71            feature = "MPSGraphTensor",
72            feature = "objc2-metal-performance-shaders"
73        ))]
74        /// Creates a Quantize operation and returns the result tensor.
75        ///
76        /// Convert the float `tensor` to an i8 or u8 tensor by applying a scale + bias transform:
77        /// result = (tensor / scaleTensor) + zeroPoint
78        ///
79        /// - Parameters:
80        /// - tensor: Input tensor to be quantized
81        /// - scaleTensor: Scale 1D Tensor parameter with size == tensor.shape[axis]
82        /// - zeroPoint: Bias scalar parameter (converted to dataType of resultTensor)
83        /// - dataType: Integer data type of the result tensor.
84        /// - axis: Axis on which the scale 1D value is being broadcasted
85        /// - name: The name for the operation.
86        /// - Returns: A valid MPSGraphTensor array of datatype dataType
87        #[unsafe(method(quantizeTensor:scaleTensor:zeroPoint:dataType:axis:name:))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn quantizeTensor_scaleTensor_zeroPoint_dataType_axis_name(
90            &self,
91            tensor: &MPSGraphTensor,
92            scale_tensor: &MPSGraphTensor,
93            zero_point: c_double,
94            data_type: MPSDataType,
95            axis: NSInteger,
96            name: Option<&NSString>,
97        ) -> Retained<MPSGraphTensor>;
98
99        #[cfg(all(
100            feature = "MPSGraphTensor",
101            feature = "objc2-metal-performance-shaders"
102        ))]
103        /// Creates Dequantize operation and returns the result tensor.
104        ///
105        /// Convert the i8 or u8 `tensor` to a float tensor by applying a scale + bias transform:
106        /// result = scaleTensor(tensor - zeroPoint)
107        ///
108        /// - Parameters:
109        /// - tensor: Input tensor to be dequantized
110        /// - scaleTensor: Scale scalar or 1D Tensor parameter with size == tensor.shape[axis]
111        /// - zeroPoint: Bias scalar parameter (converted to dataType of tensor)
112        /// - dataType: Float data type of the result tensor.
113        /// - axis: Axis on which the scale 1D value is being broadcasted
114        /// - name: The name for the operation.
115        /// - Returns: A valid MPSGraphTensor array of datatype dataType
116        #[unsafe(method(dequantizeTensor:scaleTensor:zeroPoint:dataType:axis:name:))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn dequantizeTensor_scaleTensor_zeroPoint_dataType_axis_name(
119            &self,
120            tensor: &MPSGraphTensor,
121            scale_tensor: &MPSGraphTensor,
122            zero_point: c_double,
123            data_type: MPSDataType,
124            axis: NSInteger,
125            name: Option<&NSString>,
126        ) -> Retained<MPSGraphTensor>;
127
128        #[cfg(all(
129            feature = "MPSGraphTensor",
130            feature = "objc2-metal-performance-shaders"
131        ))]
132        /// Creates a Quantize operation and returns the result tensor.
133        ///
134        /// Convert the float `tensor` to an i8 or u8 tensor by applying a scale + bias transform:
135        /// result = (tensor / scaleTensor) + zeroPointTensor
136        ///
137        /// - Parameters:
138        /// - tensor: Input tensor to be quantized
139        /// - scaleTensor: Scale scalar or 1D Tensor parameter with size == tensor.shape[axis]
140        /// - zeroPointTensor: Bias scalar or 1D Tensor parameter with size == tensor.shape[axis]
141        /// - dataType: Integer data type of the result tensor.
142        /// - axis: Axis on which the scale 1D value is being broadcasted
143        /// - name: The name for the operation.
144        /// - Returns: A valid MPSGraphTensor array of datatype dataType
145        #[unsafe(method(quantizeTensor:scaleTensor:zeroPointTensor:dataType:axis:name:))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn quantizeTensor_scaleTensor_zeroPointTensor_dataType_axis_name(
148            &self,
149            tensor: &MPSGraphTensor,
150            scale_tensor: &MPSGraphTensor,
151            zero_point_tensor: &MPSGraphTensor,
152            data_type: MPSDataType,
153            axis: NSInteger,
154            name: Option<&NSString>,
155        ) -> Retained<MPSGraphTensor>;
156
157        #[cfg(all(
158            feature = "MPSGraphTensor",
159            feature = "objc2-metal-performance-shaders"
160        ))]
161        /// Creates a dequantize operation and returns the result tensor.
162        ///
163        /// Convert the i8 or u8 `tensor` to a float tensor by applying a scale + bias transform:
164        /// result = scaleTensor(tensor - zeroPointTensor)
165        ///
166        /// - Parameters:
167        /// - tensor: Input tensor to be dequantized
168        /// - scaleTensor: Scale scalar or 1D Tensor parameter with size == tensor.shape[axis]
169        /// - zeroPointTensor: Bias scalar or 1D Tensor parameter with size == tensor.shape[axis]
170        /// - dataType: Float data type of the result tensor.
171        /// - axis: Axis on which the scale 1D value is being broadcasted
172        /// - name: The name for the operation.
173        /// - Returns: A valid MPSGraphTensor array of datatype dataType
174        #[unsafe(method(dequantizeTensor:scaleTensor:zeroPointTensor:dataType:axis:name:))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn dequantizeTensor_scaleTensor_zeroPointTensor_dataType_axis_name(
177            &self,
178            tensor: &MPSGraphTensor,
179            scale_tensor: &MPSGraphTensor,
180            zero_point_tensor: &MPSGraphTensor,
181            data_type: MPSDataType,
182            axis: NSInteger,
183            name: Option<&NSString>,
184        ) -> Retained<MPSGraphTensor>;
185
186        #[cfg(all(
187            feature = "MPSGraphTensor",
188            feature = "objc2-metal-performance-shaders"
189        ))]
190        /// Creates a dequantize operation and returns the result tensor.
191        ///
192        /// Convert the i8, u8, i4 or u4 `tensor` to a float tensor by applying a scale and bias transform:
193        /// ```md
194        /// result = scaleTensor(tensor - zeroPointTensor).
195        /// ```
196        ///
197        /// - Parameters:
198        /// - tensor: Input tensor to be dequantized.
199        /// - scaleTensor: The scale tensor with groups support.
200        /// - zeroPointTensor: The bias tensor with groups support.
201        /// - dataType: Float data type of the result tensor.
202        /// - name: The name for the operation.
203        /// - Returns: A valid ``MPSGraphTensor`` array of datatype `dataType`.
204        #[unsafe(method(dequantizeTensor:scaleTensor:zeroPointTensor:dataType:name:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn dequantizeTensor_scaleTensor_zeroPointTensor_dataType_name(
207            &self,
208            tensor: &MPSGraphTensor,
209            scale_tensor: &MPSGraphTensor,
210            zero_point_tensor: &MPSGraphTensor,
211            data_type: MPSDataType,
212            name: Option<&NSString>,
213        ) -> Retained<MPSGraphTensor>;
214
215        #[cfg(all(
216            feature = "MPSGraphTensor",
217            feature = "objc2-metal-performance-shaders"
218        ))]
219        /// Creates a dequantize operation and returns the result tensor.
220        ///
221        /// Converts the i8, u8, i4 or u4 `tensor` to a float tensor by applying a scale and bias transform:
222        /// ```md
223        /// result = scaleTensor * tensor.
224        /// ```
225        ///
226        /// - Parameters:
227        /// - tensor: Input tensor to be dequantized.
228        /// - scaleTensor: Scale Tensor parameter with groups support.
229        /// - dataType: Float data type of the result tensor.
230        /// - name: The name for the operation.
231        /// - Returns: A valid ``MPSGraphTensor`` array of datatype `dataType`.
232        #[unsafe(method(dequantizeTensor:scaleTensor:dataType:name:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn dequantizeTensor_scaleTensor_dataType_name(
235            &self,
236            tensor: &MPSGraphTensor,
237            scale_tensor: &MPSGraphTensor,
238            data_type: MPSDataType,
239            name: Option<&NSString>,
240        ) -> Retained<MPSGraphTensor>;
241
242        #[cfg(feature = "MPSGraphTensor")]
243        /// Creates a lookup-table based quantization operation and returns the result tensor.
244        ///
245        /// Converts a u8 or u4 `tensor` to a float tensor by applying a lookup operation:
246        /// ```md
247        /// result[i1,...,in] = LUTTensor[i1',...,in',tensor[i1,...,in]].
248        /// ```
249        /// Note: The operation supports LUT groups up to the last 3 dimensions for `tensor`.
250        ///
251        /// - Parameters:
252        /// - tensor: Input tensor to be dequantized.
253        /// - LUTTensor: The lookup table to use - for u4 the last dimension should have 16 elements, and for u8 256 elements.
254        /// - name: The name for the operation.
255        /// - Returns: A valid ``MPSGraphTensor`` object.
256        #[unsafe(method(dequantizeTensor:LUTTensor:name:))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn dequantizeTensor_LUTTensor_name(
259            &self,
260            tensor: &MPSGraphTensor,
261            lut_tensor: &MPSGraphTensor,
262            name: Option<&NSString>,
263        ) -> Retained<MPSGraphTensor>;
264
265        #[cfg(feature = "MPSGraphTensor")]
266        /// Creates a vector lookup-table based quantization operation and returns the result tensor.
267        ///
268        /// Converts a u8 or u4 `tensor` to a float tensor by applying a lookup operation, where each
269        /// input index defines a vector of values. The operation reads the vector values from the last dimension of the lookup table
270        /// tensor and stores them into the dimension defined by `axis` on the result tensor.
271        /// ```md
272        /// result[i1, ... , i_axis, ..., in] = LUTTensor[i1', ..., in', tensor[i1, ..., in], i_axis]
273        /// ```
274        /// Note: The operation supports LUT groups up to the last 2 dimensions for `tensor`.
275        ///
276        /// - Parameters:
277        /// - tensor: Input tensor to be dequantized.
278        /// - LUTTensor: The lookup table to use - for u4 the second to last dimension should have 16 elements, and for u8 256 elements.
279        /// - axis: Axis on which the scale 1D value is being broadcasted.
280        /// - name: The name for the operation.
281        /// - Returns: A valid ``MPSGraphTensor`` object.
282        #[unsafe(method(dequantizeTensor:LUTTensor:axis:name:))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn dequantizeTensor_LUTTensor_axis_name(
285            &self,
286            tensor: &MPSGraphTensor,
287            lut_tensor: &MPSGraphTensor,
288            axis: NSInteger,
289            name: Option<&NSString>,
290        ) -> Retained<MPSGraphTensor>;
291    );
292}