objc2_metal_performance_shaders_graph/generated/
MPSGraphSparseOps.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/// The sparse storage options in the Metal Performance Shaders Graph framework.
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshadersgraph/mpsgraphsparsestoragetype?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct MPSGraphSparseStorageType(pub u64);
19impl MPSGraphSparseStorageType {
20    /// COO Storage
21    #[doc(alias = "MPSGraphSparseStorageCOO")]
22    pub const COO: Self = Self(0);
23    /// CSC Storage
24    #[doc(alias = "MPSGraphSparseStorageCSC")]
25    pub const CSC: Self = Self(1);
26    /// CSR Storage
27    #[doc(alias = "MPSGraphSparseStorageCSR")]
28    pub const CSR: Self = Self(2);
29}
30
31unsafe impl Encode for MPSGraphSparseStorageType {
32    const ENCODING: Encoding = u64::ENCODING;
33}
34
35unsafe impl RefEncode for MPSGraphSparseStorageType {
36    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
37}
38
39extern_class!(
40    /// A class that describes the properties of a create sparse operation.
41    ///
42    /// See also [Apple's documentation](https://developer.apple.com/documentation/metalperformanceshadersgraph/mpsgraphcreatesparseopdescriptor?language=objc)
43    #[unsafe(super(MPSGraphObject, NSObject))]
44    #[derive(Debug, PartialEq, Eq, Hash)]
45    #[cfg(feature = "MPSGraphCore")]
46    pub struct MPSGraphCreateSparseOpDescriptor;
47);
48
49#[cfg(feature = "MPSGraphCore")]
50extern_conformance!(
51    unsafe impl NSCopying for MPSGraphCreateSparseOpDescriptor {}
52);
53
54#[cfg(feature = "MPSGraphCore")]
55unsafe impl CopyingHelper for MPSGraphCreateSparseOpDescriptor {
56    type Result = Self;
57}
58
59#[cfg(feature = "MPSGraphCore")]
60extern_conformance!(
61    unsafe impl NSObjectProtocol for MPSGraphCreateSparseOpDescriptor {}
62);
63
64#[cfg(feature = "MPSGraphCore")]
65impl MPSGraphCreateSparseOpDescriptor {
66    extern_methods!(
67        /// Defines the storage format of the sparse tensor.
68        #[unsafe(method(sparseStorageType))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn sparseStorageType(&self) -> MPSGraphSparseStorageType;
71
72        /// Setter for [`sparseStorageType`][Self::sparseStorageType].
73        #[unsafe(method(setSparseStorageType:))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn setSparseStorageType(&self, sparse_storage_type: MPSGraphSparseStorageType);
76
77        #[cfg(feature = "objc2-metal-performance-shaders")]
78        /// Defines the datatype of the sparse tensor.
79        #[unsafe(method(dataType))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn dataType(&self) -> MPSDataType;
82
83        #[cfg(feature = "objc2-metal-performance-shaders")]
84        /// Setter for [`dataType`][Self::dataType].
85        #[unsafe(method(setDataType:))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn setDataType(&self, data_type: MPSDataType);
88
89        #[cfg(feature = "objc2-metal-performance-shaders")]
90        /// Creates a descriptor for a sparse tensor.
91        ///
92        /// - Parameters:
93        /// - sparseStorageType: A sparseStorageType.
94        /// - dataType: A dataType of the sparse tensor.
95        /// - Returns: The descriptor.
96        #[unsafe(method(descriptorWithStorageType:dataType:))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn descriptorWithStorageType_dataType(
99            sparse_storage_type: MPSGraphSparseStorageType,
100            data_type: MPSDataType,
101        ) -> Option<Retained<Self>>;
102    );
103}
104
105/// Methods declared on superclass `NSObject`.
106#[cfg(feature = "MPSGraphCore")]
107impl MPSGraphCreateSparseOpDescriptor {
108    extern_methods!(
109        #[unsafe(method(init))]
110        #[unsafe(method_family = init)]
111        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
112
113        #[unsafe(method(new))]
114        #[unsafe(method_family = new)]
115        pub unsafe fn new() -> Retained<Self>;
116    );
117}
118
119/// MPSGraphSparseOps.
120#[cfg(all(feature = "MPSGraph", feature = "MPSGraphCore"))]
121impl MPSGraph {
122    extern_methods!(
123        #[cfg(all(
124            feature = "MPSGraphTensor",
125            feature = "objc2-metal-performance-shaders"
126        ))]
127        /// Creates a sparse tensor representation.
128        ///
129        /// sparseVals corresponds to non zero values in matrix.
130        /// indexTensor0 and indexTensor1 are indices used for indexing into sparse data structure.
131        /// For COO, indexTensor0 is x index and indexTensor1 is y index.
132        /// For CSC, indexTensor0 and indexTensor1 correspond to rowIndex and colStarts respectively.
133        /// For CSR, indexTensor0 and indexTensor1 correspond to colIndex and rowStarts respectively.
134        /// You must set input tensors appropriately for each sparse storage type.
135        ///
136        /// - Parameters:
137        /// - sparseStorageType: A sparseStorageType.
138        /// - inputTensorArray: An array of input tensors as [sparseVals, indexTensor0, indexTensor1].
139        /// - shape: The shape of the sparse tensor.
140        /// - dataType: The dataType of the sparse tensor.
141        /// - name: A name for the operation.
142        /// - Returns: A valid ``MPSGraphTensor`` object.
143        #[unsafe(method(sparseTensorWithType:tensors:shape:dataType:name:))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn sparseTensorWithType_tensors_shape_dataType_name(
146            &self,
147            sparse_storage_type: MPSGraphSparseStorageType,
148            input_tensor_array: &NSArray<MPSGraphTensor>,
149            shape: &MPSShape,
150            data_type: MPSDataType,
151            name: Option<&NSString>,
152        ) -> Retained<MPSGraphTensor>;
153
154        #[cfg(all(
155            feature = "MPSGraphTensor",
156            feature = "objc2-metal-performance-shaders"
157        ))]
158        /// Creates a sparse tensor representation.
159        ///
160        /// sparseVals corresponds to non zero values in matrix.
161        /// indexTensor0 and indexTensor1 are indices used for indexing into sparse data structure.
162        /// For COO, indexTensor0 is x index and indexTensor1 is y index .
163        /// For CSC, indexTensor0 and indexTensor1 correspond to rowIndex and colStarts respectively.
164        /// For CSR, indexTensor0 and indexTensor1 correspond to colIndex and rowStarts respectively.
165        /// You must set input tensors appropriately for each sparse storage type.
166        ///
167        /// - Parameters:
168        /// - sparseDescriptor: A sparseDescriptor.
169        /// - inputTensorArray: An array of input tensors as [sparseVals, indexTensor0, indexTensor1].
170        /// - shape: The shape of the sparse tensor.
171        /// - name: A name for the operation.
172        /// - Returns: A valid ``MPSGraphTensor`` object
173        #[unsafe(method(sparseTensorWithDescriptor:tensors:shape:name:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn sparseTensorWithDescriptor_tensors_shape_name(
176            &self,
177            sparse_descriptor: &MPSGraphCreateSparseOpDescriptor,
178            input_tensor_array: &NSArray<MPSGraphTensor>,
179            shape: &MPSShape,
180            name: Option<&NSString>,
181        ) -> Retained<MPSGraphTensor>;
182    );
183}