objc2-ml-compute 0.3.2

Bindings to the MLCompute framework
Documentation
//! 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>;
    );
}