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