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::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// The MLCAdamWOptimizer specifies the AdamW optimizer.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/mlcompute/mlcadamwoptimizer?language=objc)
    #[unsafe(super(MLCOptimizer, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "MLCOptimizer")]
    #[deprecated]
    pub struct MLCAdamWOptimizer;
);

#[cfg(feature = "MLCOptimizer")]
extern_conformance!(
    unsafe impl NSCopying for MLCAdamWOptimizer {}
);

#[cfg(feature = "MLCOptimizer")]
unsafe impl CopyingHelper for MLCAdamWOptimizer {
    type Result = Self;
}

#[cfg(feature = "MLCOptimizer")]
extern_conformance!(
    unsafe impl NSObjectProtocol for MLCAdamWOptimizer {}
);

#[cfg(feature = "MLCOptimizer")]
impl MLCAdamWOptimizer {
    extern_methods!(
        /// Coefficent used for computing running averages of gradient.
        ///
        /// The default is 0.9.
        #[deprecated]
        #[unsafe(method(beta1))]
        #[unsafe(method_family = none)]
        pub unsafe fn beta1(&self) -> c_float;

        /// Coefficent used for computing running averages of square of gradient.
        ///
        /// The default is 0.999.
        #[deprecated]
        #[unsafe(method(beta2))]
        #[unsafe(method_family = none)]
        pub unsafe fn beta2(&self) -> c_float;

        /// A term added to improve numerical stability.
        ///
        /// The default is 1e-8.
        #[deprecated]
        #[unsafe(method(epsilon))]
        #[unsafe(method_family = none)]
        pub unsafe fn epsilon(&self) -> c_float;

        /// Whether to use the AMSGrad variant of this algorithm
        ///
        /// The default is false
        #[deprecated]
        #[unsafe(method(usesAMSGrad))]
        #[unsafe(method_family = none)]
        pub unsafe fn usesAMSGrad(&self) -> bool;

        /// The current timestep used for the update.
        ///
        /// The default is 1.
        #[deprecated]
        #[unsafe(method(timeStep))]
        #[unsafe(method_family = none)]
        pub unsafe fn timeStep(&self) -> NSUInteger;

        #[cfg(feature = "MLCOptimizerDescriptor")]
        /// Create an MLCAdamWOptimizer object with defaults
        ///
        /// Returns: A new MLCAdamWOptimizer object.
        #[deprecated]
        #[unsafe(method(optimizerWithDescriptor:))]
        #[unsafe(method_family = none)]
        pub unsafe fn optimizerWithDescriptor(
            optimizer_descriptor: &MLCOptimizerDescriptor,
        ) -> Retained<Self>;

        #[cfg(feature = "MLCOptimizerDescriptor")]
        /// Create an MLCAdamWOptimizer object
        ///
        /// Parameter `optimizerDescriptor`: The optimizer descriptor object
        ///
        /// Parameter `beta1`: The beta1 value
        ///
        /// Parameter `beta2`: The beta2 value
        ///
        /// Parameter `epsilon`: The epsilon value to use to improve numerical stability
        ///
        /// Parameter `usesAMSGrad`: Whether to use the AMSGrad variant of this algorithm from the paper (https://arxiv.org/abs/1904.09237)
        ///
        /// Parameter `timeStep`: The initial timestep to use for the update
        ///
        /// Returns: A new MLCAdamWOptimizer object.
        #[deprecated]
        #[unsafe(method(optimizerWithDescriptor:beta1:beta2:epsilon:usesAMSGrad:timeStep:))]
        #[unsafe(method_family = none)]
        pub unsafe fn optimizerWithDescriptor_beta1_beta2_epsilon_usesAMSGrad_timeStep(
            optimizer_descriptor: &MLCOptimizerDescriptor,
            beta1: c_float,
            beta2: c_float,
            epsilon: c_float,
            uses_ams_grad: bool,
            time_step: NSUInteger,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `MLCOptimizer`.
#[cfg(feature = "MLCOptimizer")]
impl MLCAdamWOptimizer {
    extern_methods!(
        #[deprecated]
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[deprecated]
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}