objc2_ml_compute/generated/MLCDevice.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6#[cfg(feature = "objc2-metal")]
7use objc2_metal::*;
8
9use crate::*;
10
11extern_class!(
12 /// A device that will be used to execute a neural network.
13 /// If a MLCdevice is created with multiple devices using the [devicesWithType:selectMultipleDvices], on configurations
14 /// where multiple GPUs are available such as on the Mac Pro, the framework may transparently schedule the execution
15 /// across multiple GPUs. There are some requirements for a MLCDevice with multiple devices such as there can only be
16 /// one training and/or inference graph associated with this device. If multiple graphs are used, they must be compiled using
17 /// MLCGraphCompilationOptionsLinkGraphs specified in compileOptions and the multiple graphs should be linked together
18 /// with linkWithGraphs.
19 ///
20 /// See also [Apple's documentation](https://developer.apple.com/documentation/mlcompute/mlcdevice?language=objc)
21 #[unsafe(super(NSObject))]
22 #[derive(Debug, PartialEq, Eq, Hash)]
23 #[deprecated]
24 pub struct MLCDevice;
25);
26
27extern_conformance!(
28 unsafe impl NSCopying for MLCDevice {}
29);
30
31unsafe impl CopyingHelper for MLCDevice {
32 type Result = Self;
33}
34
35extern_conformance!(
36 unsafe impl NSObjectProtocol for MLCDevice {}
37);
38
39impl MLCDevice {
40 extern_methods!(
41 #[cfg(feature = "MLCTypes")]
42 /// The type specified when the device is created
43 ///
44 /// Recommend that developers use MLCDeviceTypeAny as the device type.
45 /// This will ensure that MLCompute will select the best device to execute the neural network.
46 /// If developers want to be able to control device selection, they can select CPU or GPU and
47 /// for the GPU, they can also select a specific Metal device.
48 #[deprecated]
49 #[unsafe(method(type))]
50 #[unsafe(method_family = none)]
51 pub unsafe fn r#type(&self) -> MLCDeviceType;
52
53 #[cfg(feature = "MLCTypes")]
54 /// The specific device selected.
55 ///
56 /// This can be CPU, GPU or ANE. If type is MLCDeviceTypeAny, this property
57 /// can be used to find out the specific device type that is selected.
58 #[unsafe(method(actualDeviceType))]
59 #[unsafe(method_family = none)]
60 pub unsafe fn actualDeviceType(&self) -> MLCDeviceType;
61
62 #[cfg(feature = "objc2-metal")]
63 #[deprecated]
64 #[unsafe(method(gpuDevices))]
65 #[unsafe(method_family = none)]
66 pub unsafe fn gpuDevices(&self) -> Retained<NSArray<ProtocolObject<dyn MTLDevice>>>;
67
68 /// Creates a device which uses the CPU.
69 ///
70 /// Returns: A new device.
71 #[deprecated]
72 #[unsafe(method(cpuDevice))]
73 #[unsafe(method_family = none)]
74 pub unsafe fn cpuDevice() -> Retained<Self>;
75
76 /// Creates a device which uses a GPU, if any.
77 ///
78 /// Returns: A new device, or `nil` if no GPU exists.
79 #[deprecated]
80 #[unsafe(method(gpuDevice))]
81 #[unsafe(method_family = none)]
82 pub unsafe fn gpuDevice() -> Option<Retained<Self>>;
83
84 /// Creates a device which uses the Apple Neural Engine, if any.
85 ///
86 /// Returns: A new device, or `nil` if no ANE exists.
87 #[unsafe(method(aneDevice))]
88 #[unsafe(method_family = none)]
89 pub unsafe fn aneDevice() -> Option<Retained<Self>>;
90
91 #[cfg(feature = "MLCTypes")]
92 /// Create a MLCDevice object
93 ///
94 /// Parameter `type`: A device type
95 ///
96 /// Returns: A new device object
97 #[deprecated]
98 #[unsafe(method(deviceWithType:))]
99 #[unsafe(method_family = none)]
100 pub unsafe fn deviceWithType(r#type: MLCDeviceType) -> Option<Retained<Self>>;
101
102 #[cfg(feature = "MLCTypes")]
103 /// Create a MLCDevice object that uses multiple devices if available
104 ///
105 /// Parameter `type`: A device type
106 ///
107 /// Parameter `selectsMultipleComputeDevices`: A boolean to indicate whether to select multiple compute devices
108 ///
109 /// Returns: A new device object
110 #[unsafe(method(deviceWithType:selectsMultipleComputeDevices:))]
111 #[unsafe(method_family = none)]
112 pub unsafe fn deviceWithType_selectsMultipleComputeDevices(
113 r#type: MLCDeviceType,
114 selects_multiple_compute_devices: bool,
115 ) -> Option<Retained<Self>>;
116
117 #[cfg(feature = "objc2-metal")]
118 /// Create a MLCDevice object
119 ///
120 /// This method can be used by developers to select specific GPUs
121 ///
122 /// Parameter `gpus`: List of Metal devices
123 ///
124 /// Returns: A new device object
125 #[deprecated]
126 #[unsafe(method(deviceWithGPUDevices:))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn deviceWithGPUDevices(
129 gpus: &NSArray<ProtocolObject<dyn MTLDevice>>,
130 ) -> Option<Retained<Self>>;
131 );
132}
133
134/// Methods declared on superclass `NSObject`.
135impl MLCDevice {
136 extern_methods!(
137 #[unsafe(method(init))]
138 #[unsafe(method_family = init)]
139 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
140
141 #[unsafe(method(new))]
142 #[unsafe(method_family = new)]
143 pub unsafe fn new() -> Retained<Self>;
144 );
145}