objc2_metal_performance_shaders/generated/MPSNDArray/
MPSNDArrayQuantization.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/// [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarrayquantizationscheme?language=objc)
11// NS_OPTIONS
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct MPSNDArrayQuantizationScheme(pub NSUInteger);
15bitflags::bitflags! {
16    impl MPSNDArrayQuantizationScheme: NSUInteger {
17        #[doc(alias = "MPSNDArrayQuantizationTypeNone")]
18        const TypeNone = 0;
19        #[doc(alias = "MPSNDArrayQuantizationTypeAffine")]
20        const TypeAffine = 1;
21        #[doc(alias = "MPSNDArrayQuantizationTypeLUT")]
22        const TypeLUT = 2;
23    }
24}
25
26unsafe impl Encode for MPSNDArrayQuantizationScheme {
27    const ENCODING: Encoding = NSUInteger::ENCODING;
28}
29
30unsafe impl RefEncode for MPSNDArrayQuantizationScheme {
31    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
32}
33
34extern_class!(
35    /// Dependencies: This depends on Metal.framework.
36    ///
37    /// Common methods for quantization descriptors
38    ///
39    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarrayquantizationdescriptor?language=objc)
40    #[unsafe(super(NSObject))]
41    #[derive(Debug, PartialEq, Eq, Hash)]
42    pub struct MPSNDArrayQuantizationDescriptor;
43);
44
45extern_conformance!(
46    unsafe impl NSCopying for MPSNDArrayQuantizationDescriptor {}
47);
48
49unsafe impl CopyingHelper for MPSNDArrayQuantizationDescriptor {
50    type Result = Self;
51}
52
53extern_conformance!(
54    unsafe impl NSObjectProtocol for MPSNDArrayQuantizationDescriptor {}
55);
56
57impl MPSNDArrayQuantizationDescriptor {
58    extern_methods!(
59        #[cfg(all(feature = "MPSCore", feature = "MPSCoreTypes"))]
60        /// The datatype to use with quantization - the default is MPSDataTypeUint8
61        #[unsafe(method(quantizationDataType))]
62        #[unsafe(method_family = none)]
63        pub unsafe fn quantizationDataType(&self) -> MPSDataType;
64
65        /// The quantization scheme for this descriptor. The default is MPSNDArrayQuantizationTypeNone.
66        #[unsafe(method(quantizationScheme))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn quantizationScheme(&self) -> MPSNDArrayQuantizationScheme;
69    );
70}
71
72/// Methods declared on superclass `NSObject`.
73impl MPSNDArrayQuantizationDescriptor {
74    extern_methods!(
75        #[unsafe(method(init))]
76        #[unsafe(method_family = init)]
77        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
78
79        #[unsafe(method(new))]
80        #[unsafe(method_family = new)]
81        pub unsafe fn new() -> Retained<Self>;
82    );
83}
84
85extern_class!(
86    /// Dependencies: This depends on Metal.framework.
87    ///
88    /// Describes an affine quantization scheme
89    ///
90    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarrayaffinequantizationdescriptor?language=objc)
91    #[unsafe(super(MPSNDArrayQuantizationDescriptor, NSObject))]
92    #[derive(Debug, PartialEq, Eq, Hash)]
93    pub struct MPSNDArrayAffineQuantizationDescriptor;
94);
95
96extern_conformance!(
97    unsafe impl NSCopying for MPSNDArrayAffineQuantizationDescriptor {}
98);
99
100unsafe impl CopyingHelper for MPSNDArrayAffineQuantizationDescriptor {
101    type Result = Self;
102}
103
104extern_conformance!(
105    unsafe impl NSObjectProtocol for MPSNDArrayAffineQuantizationDescriptor {}
106);
107
108impl MPSNDArrayAffineQuantizationDescriptor {
109    extern_methods!(
110        /// If yes then asymmetric quantization is used. See MPSNDArrayQuantizationScheme.
111        #[unsafe(method(hasZeroPoint))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn hasZeroPoint(&self) -> bool;
114
115        /// Setter for [`hasZeroPoint`][Self::hasZeroPoint].
116        #[unsafe(method(setHasZeroPoint:))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn setHasZeroPoint(&self, has_zero_point: bool);
119
120        /// If yes then offset is used. See MPSNDArrayQuantizationScheme.
121        #[unsafe(method(hasMinValue))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn hasMinValue(&self) -> bool;
124
125        /// Setter for [`hasMinValue`][Self::hasMinValue].
126        #[unsafe(method(setHasMinValue:))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn setHasMinValue(&self, has_min_value: bool);
129
130        /// If true and quantized values are signed, these are assumed to be stored with an
131        /// implicit offset or zero-point of 2^(quantizationBitWidth-1) added to bring signed values into unsigned range.
132        /// e.g. Int4 values are in range [-8,7]. If we add 8 to it values are in range
133        /// [0,15] and can be encoded/stored as UInt4.
134        /// Default is false. Its only currently applicable to Int4.
135        /// Implementation will generate error for any other data type;
136        #[unsafe(method(implicitZeroPoint))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn implicitZeroPoint(&self) -> bool;
139
140        /// Setter for [`implicitZeroPoint`][Self::implicitZeroPoint].
141        #[unsafe(method(setImplicitZeroPoint:))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn setImplicitZeroPoint(&self, implicit_zero_point: bool);
144
145        #[unsafe(method(init))]
146        #[unsafe(method_family = init)]
147        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
148
149        #[cfg(all(feature = "MPSCore", feature = "MPSCoreTypes"))]
150        /// Initializes an affine quantization descriptor.
151        ///
152        /// Parameter `quantizationDataType`: Which quantized datatype is used.
153        ///
154        /// Parameter `hasZeroPoint`: A flag indicating that a zero-point input is expected.
155        ///
156        /// Parameter `hasMinValue`: A flag indicating that a minimum value input is expected.
157        ///
158        /// Returns: A new quantization descriptor.
159        #[unsafe(method(initWithDataType:hasZeroPoint:hasMinValue:))]
160        #[unsafe(method_family = init)]
161        pub unsafe fn initWithDataType_hasZeroPoint_hasMinValue(
162            this: Allocated<Self>,
163            quantization_data_type: MPSDataType,
164            has_zero_point: bool,
165            has_min_value: bool,
166        ) -> Retained<Self>;
167    );
168}
169
170/// Methods declared on superclass `NSObject`.
171impl MPSNDArrayAffineQuantizationDescriptor {
172    extern_methods!(
173        #[unsafe(method(new))]
174        #[unsafe(method_family = new)]
175        pub unsafe fn new() -> Retained<Self>;
176    );
177}
178
179extern_class!(
180    /// Dependencies: This depends on Metal.framework.
181    ///
182    /// Describes a lookup-table based quantization scheme
183    ///
184    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshaders/mpsndarraylutquantizationdescriptor?language=objc)
185    #[unsafe(super(MPSNDArrayQuantizationDescriptor, NSObject))]
186    #[derive(Debug, PartialEq, Eq, Hash)]
187    pub struct MPSNDArrayLUTQuantizationDescriptor;
188);
189
190extern_conformance!(
191    unsafe impl NSCopying for MPSNDArrayLUTQuantizationDescriptor {}
192);
193
194unsafe impl CopyingHelper for MPSNDArrayLUTQuantizationDescriptor {
195    type Result = Self;
196}
197
198extern_conformance!(
199    unsafe impl NSObjectProtocol for MPSNDArrayLUTQuantizationDescriptor {}
200);
201
202impl MPSNDArrayLUTQuantizationDescriptor {
203    extern_methods!(
204        #[cfg(all(feature = "MPSCore", feature = "MPSCoreTypes"))]
205        /// Initializes a scalar lookup-table quantization descriptor.
206        ///
207        /// Parameter `quantizationDataType`: Which quantized datatype is used.
208        ///
209        /// Returns: A new quantization descriptor.
210        #[unsafe(method(initWithDataType:))]
211        #[unsafe(method_family = init)]
212        pub unsafe fn initWithDataType(
213            this: Allocated<Self>,
214            quantization_data_type: MPSDataType,
215        ) -> Retained<Self>;
216
217        #[cfg(all(feature = "MPSCore", feature = "MPSCoreTypes"))]
218        /// Initializes a vector lookup-table quantization descriptor.
219        ///
220        /// Parameter `quantizationDataType`: Which quantized datatype is used.
221        ///
222        /// Parameter `vectorAxis`: The quantization vector axis - this axis will receive the vector component in the destination.
223        ///
224        /// Returns: A new quantization descriptor.
225        #[unsafe(method(initWithDataType:vectorAxis:))]
226        #[unsafe(method_family = init)]
227        pub unsafe fn initWithDataType_vectorAxis(
228            this: Allocated<Self>,
229            quantization_data_type: MPSDataType,
230            vector_axis: NSUInteger,
231        ) -> Retained<Self>;
232    );
233}
234
235/// Methods declared on superclass `NSObject`.
236impl MPSNDArrayLUTQuantizationDescriptor {
237    extern_methods!(
238        #[unsafe(method(init))]
239        #[unsafe(method_family = init)]
240        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
241
242        #[unsafe(method(new))]
243        #[unsafe(method_family = new)]
244        pub unsafe fn new() -> Retained<Self>;
245    );
246}