MPSCNNInstanceNormalizationDataSource

Trait MPSCNNInstanceNormalizationDataSource 

Source
pub unsafe trait MPSCNNInstanceNormalizationDataSource: NSObjectProtocol + NSCopying {
Show 13 methods // Provided methods unsafe fn gamma(&self) -> *mut c_float where Self: Sized + Message { ... } unsafe fn beta(&self) -> *mut c_float where Self: Sized + Message { ... } unsafe fn numberOfFeatureChannels(&self) -> NSUInteger where Self: Sized + Message { ... } unsafe fn label(&self) -> Option<Retained<NSString>> where Self: Sized + Message { ... } unsafe fn updateGammaAndBetaWithCommandBuffer_instanceNormalizationStateBatch( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, instance_normalization_state_batch: &MPSCNNInstanceNormalizationGradientStateBatch, ) -> Option<Retained<MPSCNNNormalizationGammaAndBetaState>> where Self: Sized + Message { ... } unsafe fn updateGammaAndBetaWithInstanceNormalizationStateBatch( &self, instance_normalization_state_batch: &MPSCNNInstanceNormalizationGradientStateBatch, ) -> 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 { ... } unsafe fn load(&self) -> bool where Self: Sized + Message { ... } unsafe fn purge(&self) where Self: Sized + Message { ... }
}
Available on crate feature MPSCNNInstanceNormalization only.
Expand description

The MPSCNNInstanceNormalizationDataSource protocol declares the methods that an instance of MPSCNNInstanceNormalization uses to initialize the scale factors (gamma) and bias terms (beta).

See also Apple’s documentation

Provided Methods§

Source

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

Return a pointer to an array containing the gamma terms.

Source

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

Return a pointer to an array containing the beta terms.

Source

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

Source

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

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

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

Source

unsafe fn updateGammaAndBetaWithCommandBuffer_instanceNormalizationStateBatch( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, instance_normalization_state_batch: &MPSCNNInstanceNormalizationGradientStateBatch, ) -> 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 MPSCNNInstanceNormalizationStateBatch.

This is for use in the context of training a network within a MPSNNGraph. If you are writing your own graph using the low level interface or aren’t training instance normalization it isn’t needed.

In this mathod, you should perform the update on a GPU, because at the time it is called the data isn’t in the state objects yet and the CPU can’t do the work. You should not attempt to update the MPSCNNInstanceNormalization kernel directly with the results. The state object returned from the function will be used for that. A batch of states will be passed in. You should accumulate the gradients and then update the weights.

This operation is expected to also decrement the read count of instanceNormalizationStateBatch by 1, if the states are temporary.

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

Parameter instanceNormalizationStateBatch: A batch of MPSCNNInstanceNormalizationGradientState objects containing current weights and gradients.

Returns: A MPSCNNNormalizationGammaAndBetaState object containing updated gamma and beta values. If NULL no update was performed.

Source

unsafe fn updateGammaAndBetaWithInstanceNormalizationStateBatch( &self, instance_normalization_state_batch: &MPSCNNInstanceNormalizationGradientStateBatch, ) -> 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 batch MPSCNNInstanceNormalizationState objects. Perform the update on the CPU.

Parameter instanceNormalizationStateBatch: A batch of MPSCNNInstanceNormalizationGradientState objects containing current gamma and beta values and gradients.

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,

Optional 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,

§Safety

a_decoder possibly has further requirements.

Source

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

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.

Source

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

Alerts the data source that the data will be needed soon

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

Trait Implementations§

Source§

impl ProtocolType for dyn MPSCNNInstanceNormalizationDataSource

Available on crate feature MPSNeuralNetwork only.
Source§

const NAME: &'static str = "MPSCNNInstanceNormalizationDataSource"

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 MPSCNNInstanceNormalizationDataSource

Available on crate feature MPSNeuralNetwork only.

Implementations on Foreign Types§

Source§

impl<T> MPSCNNInstanceNormalizationDataSource for ProtocolObject<T>

Available on crate feature MPSNeuralNetwork only.

Implementors§