MPSCNNBatchNormalizationDataSource

Trait MPSCNNBatchNormalizationDataSource 

Source
pub unsafe trait MPSCNNBatchNormalizationDataSource: NSObjectProtocol + NSCopying {
Show 17 methods // Provided methods unsafe fn numberOfFeatureChannels(&self) -> NSUInteger where Self: Sized + Message { ... } unsafe fn gamma(&self) -> *mut c_float where Self: Sized + Message { ... } unsafe fn beta(&self) -> *mut c_float where Self: Sized + Message { ... } unsafe fn mean(&self) -> *mut c_float where Self: Sized + Message { ... } unsafe fn variance(&self) -> *mut c_float where Self: Sized + Message { ... } unsafe fn load(&self) -> bool where Self: Sized + Message { ... } unsafe fn purge(&self) where Self: Sized + Message { ... } unsafe fn label(&self) -> Option<Retained<NSString>> where Self: Sized + Message { ... } unsafe fn updateGammaAndBetaWithCommandBuffer_batchNormalizationState( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, batch_normalization_state: &MPSCNNBatchNormalizationState, ) -> Option<Retained<MPSCNNNormalizationGammaAndBetaState>> where Self: Sized + Message { ... } unsafe fn updateMeanAndVarianceWithCommandBuffer_batchNormalizationState( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, batch_normalization_state: &MPSCNNBatchNormalizationState, ) -> Option<Retained<MPSCNNNormalizationMeanAndVarianceState>> where Self: Sized + Message { ... } unsafe fn updateGammaAndBetaWithBatchNormalizationState( &self, batch_normalization_state: &MPSCNNBatchNormalizationState, ) -> bool where Self: Sized + Message { ... } unsafe fn updateMeanAndVarianceWithBatchNormalizationState( &self, batch_normalization_state: &MPSCNNBatchNormalizationState, ) -> bool where Self: Sized + Message { ... } unsafe fn epsilon(&self) -> c_float where Self: Sized + Message { ... } unsafe fn encodeWithCoder(&self, a_coder: &NSCoder) where Self: Sized + Message { ... } unsafe fn initWithCoder( this: Allocated<Self>, a_decoder: &NSCoder, ) -> Option<Retained<Self>> where Self: Sized + Message { ... } unsafe fn supportsSecureCoding() -> bool where Self: Sized + ClassType { ... } unsafe fn copyWithZone_device( &self, zone: *mut NSZone, device: Option<&ProtocolObject<dyn MTLDevice>>, ) -> Retained<Self> where Self: Sized + Message { ... }
}
Available on crate feature MPSCNNBatchNormalization only.
Expand description

The MPSCNNBatchNormalizationDataSource protocol declares the methods that an instance of MPSCNNBatchNormalizationState uses to initialize the scale factors, bias terms, and batch statistics.

See also Apple’s documentation

Provided Methods§

Source

unsafe fn numberOfFeatureChannels(&self) -> NSUInteger
where Self: Sized + Message,

Returns the number of feature channels within images to be normalized using the supplied parameters.

Source

unsafe fn gamma(&self) -> *mut c_float
where Self: Sized + Message,

Returns a pointer to the scale factors for the batch normalization.

Source

unsafe fn beta(&self) -> *mut c_float
where Self: Sized + Message,

Returns a pointer to the bias terms for the batch normalization. If NULL then no bias is to be applied.

Source

unsafe fn mean(&self) -> *mut c_float
where Self: Sized + Message,

Returns a pointer to batch mean values with which to initialize the state for a subsequent batch normalization.

Source

unsafe fn variance(&self) -> *mut c_float
where Self: Sized + Message,

Returns a pointer to batch variance values with which to initialize the state for a subsequent batch normalization.

Source

unsafe fn load(&self) -> bool
where Self: Sized + Message,

Alerts the data source that the data will be needed soon

Each load alert will be balanced by a purge later, when MPS no longer needs the data from this object. Load will always be called atleast once after initial construction or each purge of the object before anything else is called.

Returns: Returns YES on success. If NO is returned, expect MPS object construction to fail.

Source

unsafe fn purge(&self)
where Self: Sized + Message,

Alerts the data source that the data is no longer needed

Each load alert will be balanced by a purge later, when MPS no longer needs the data from this object.

Source

unsafe fn label(&self) -> Option<Retained<NSString>>
where Self: Sized + Message,

A label that is transferred to the batch normalization filter at init time

Overridden by a MPSCNNBatchNormalizationNode.label if it is non-nil.

Source

unsafe fn updateGammaAndBetaWithCommandBuffer_batchNormalizationState( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, batch_normalization_state: &MPSCNNBatchNormalizationState, ) -> Option<Retained<MPSCNNNormalizationGammaAndBetaState>>
where Self: Sized + Message,

Available on crate features MPSCNNNormalizationWeights and MPSCore and MPSNNGradientState and MPSState only.

Compute new gamma and beta values using current values and gradients contained within a MPSCNNBatchNormalizationState. Perform the update using a GPU.

This operation is expected to also decrement the read count of batchNormalizationState by 1.

Parameter commandBuffer: The command buffer on which to encode the update.

Parameter batchNormalizationState: The MPSCNNBatchNormalizationState object containing the current gamma and beta values and the gradient values.

Returns: A MPSCNNNormalizationMeanAndVarianceState object containing updated mean and variance values. If NULL, the MPSNNGraph batch normalization filter gamma and beta values will remain unmodified.

Source

unsafe fn updateMeanAndVarianceWithCommandBuffer_batchNormalizationState( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, batch_normalization_state: &MPSCNNBatchNormalizationState, ) -> Option<Retained<MPSCNNNormalizationMeanAndVarianceState>>
where Self: Sized + Message,

Available on crate features MPSCore and MPSNNGradientState and MPSState only.

Compute new mean and variance values using current batch statistics contained within a MPSCNNBatchNormalizationState. Perform the update using a GPU.

This operation is expected to also decrement the read count of batchNormalizationState by 1.

Parameter commandBuffer: The command buffer on which to encode the update.

Parameter batchNormalizationState: The MPSCNNBatchNormalizationState object containing the current batch statistics.

Returns: A MPSCNNNormalizationMeanAndVarianceState object containing updated mean and variance values. If NULL, the MPSNNGraph batch normalization filter mean and variance values will remain unmodified.

Source

unsafe fn updateGammaAndBetaWithBatchNormalizationState( &self, batch_normalization_state: &MPSCNNBatchNormalizationState, ) -> bool
where Self: Sized + Message,

Available on crate features MPSCore and MPSNNGradientState and MPSState only.

Compute new gamma and beta values using current values and gradients contained within a MPSCNNBatchNormalizationState. Perform the update using the CPU.

Parameter batchNormalizationState: The MPSCNNBatchNormalizationState object containing the current gamma and beta values and the gradient values.

Returns: A boolean value indicating if the update was performed.

Source

unsafe fn updateMeanAndVarianceWithBatchNormalizationState( &self, batch_normalization_state: &MPSCNNBatchNormalizationState, ) -> bool
where Self: Sized + Message,

Available on crate features MPSCore and MPSNNGradientState and MPSState only.

Compute new mean and variance values using current batch statistics contained within a MPSCNNBatchNormalizationState. Perform the update using the CPU.

Parameter batchNormalizationState: The MPSCNNBatchNormalizationState object containing the current batch statistics.

Returns: A boolean value indicating if the update was performed.

Source

unsafe fn epsilon(&self) -> c_float
where Self: Sized + Message,

An optional tiny number to use to maintain numerical stability.

output_image = (input_image - mean[c]) * gamma[c] / sqrt(variance[c] + epsilon) + beta[c]; Defalt value if method unavailable: FLT_MIN

Source

unsafe fn encodeWithCoder(&self, a_coder: &NSCoder)
where Self: Sized + Message,

NSSecureCoding compatibility.

§Safety

a_coder possibly has further requirements.

Source

unsafe fn initWithCoder( this: Allocated<Self>, a_decoder: &NSCoder, ) -> Option<Retained<Self>>
where Self: Sized + Message,

NSSecureCoding compatibility.

§Safety

a_decoder possibly has further requirements.

Source

unsafe fn supportsSecureCoding() -> bool
where Self: Sized + ClassType,

NSSecureCoding compatibility.

Source

unsafe fn copyWithZone_device( &self, zone: *mut NSZone, device: Option<&ProtocolObject<dyn MTLDevice>>, ) -> Retained<Self>
where Self: Sized + Message,

Optional copy method to create a copy of the data source for use with a new device.

Parameter zone: The NSZone on which to allocate.

Parameter device: The device where the kernel which uses this data source will be used.

Returns: A pointer to a copy of this data source.

§Safety

zone must be a valid pointer or null.

Trait Implementations§

Source§

impl ProtocolType for dyn MPSCNNBatchNormalizationDataSource

Available on crate feature MPSNeuralNetwork only.
Source§

const NAME: &'static str = "MPSCNNBatchNormalizationDataSource"

The name of the Objective-C protocol that this type represents. Read more
Source§

fn protocol() -> Option<&'static AnyProtocol>

Get a reference to the Objective-C protocol object that this type represents. Read more
Source§

impl<T> ImplementedBy<T> for dyn MPSCNNBatchNormalizationDataSource

Available on crate feature MPSNeuralNetwork only.

Implementations on Foreign Types§

Source§

impl<T> MPSCNNBatchNormalizationDataSource for ProtocolObject<T>

Available on crate feature MPSNeuralNetwork only.

Implementors§