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 { ... }
}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§
Sourceunsafe fn numberOfFeatureChannels(&self) -> NSUInteger
unsafe fn numberOfFeatureChannels(&self) -> NSUInteger
Returns the number of feature channels within images to be normalized using the supplied parameters.
Sourceunsafe fn gamma(&self) -> *mut c_float
unsafe fn gamma(&self) -> *mut c_float
Returns a pointer to the scale factors for the batch normalization.
Sourceunsafe fn beta(&self) -> *mut c_float
unsafe fn beta(&self) -> *mut c_float
Returns a pointer to the bias terms for the batch normalization. If NULL then no bias is to be applied.
Sourceunsafe fn mean(&self) -> *mut c_float
unsafe fn mean(&self) -> *mut c_float
Returns a pointer to batch mean values with which to initialize the state for a subsequent batch normalization.
Sourceunsafe fn variance(&self) -> *mut c_float
unsafe fn variance(&self) -> *mut c_float
Returns a pointer to batch variance values with which to initialize the state for a subsequent batch normalization.
Sourceunsafe fn load(&self) -> bool
unsafe fn load(&self) -> bool
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.
Sourceunsafe fn purge(&self)
unsafe fn purge(&self)
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.
Sourceunsafe fn label(&self) -> Option<Retained<NSString>>
unsafe fn label(&self) -> Option<Retained<NSString>>
A label that is transferred to the batch normalization filter at init time
Overridden by a MPSCNNBatchNormalizationNode.label if it is non-nil.
Sourceunsafe fn updateGammaAndBetaWithCommandBuffer_batchNormalizationState(
&self,
command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
batch_normalization_state: &MPSCNNBatchNormalizationState,
) -> Option<Retained<MPSCNNNormalizationGammaAndBetaState>>
Available on crate features MPSCNNNormalizationWeights and MPSCore and MPSNNGradientState and MPSState only.
unsafe fn updateGammaAndBetaWithCommandBuffer_batchNormalizationState( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, batch_normalization_state: &MPSCNNBatchNormalizationState, ) -> Option<Retained<MPSCNNNormalizationGammaAndBetaState>>
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.
Sourceunsafe fn updateMeanAndVarianceWithCommandBuffer_batchNormalizationState(
&self,
command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
batch_normalization_state: &MPSCNNBatchNormalizationState,
) -> Option<Retained<MPSCNNNormalizationMeanAndVarianceState>>
Available on crate features MPSCore and MPSNNGradientState and MPSState only.
unsafe fn updateMeanAndVarianceWithCommandBuffer_batchNormalizationState( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, batch_normalization_state: &MPSCNNBatchNormalizationState, ) -> Option<Retained<MPSCNNNormalizationMeanAndVarianceState>>
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.
Sourceunsafe fn updateGammaAndBetaWithBatchNormalizationState(
&self,
batch_normalization_state: &MPSCNNBatchNormalizationState,
) -> bool
Available on crate features MPSCore and MPSNNGradientState and MPSState only.
unsafe fn updateGammaAndBetaWithBatchNormalizationState( &self, batch_normalization_state: &MPSCNNBatchNormalizationState, ) -> bool
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.
Sourceunsafe fn updateMeanAndVarianceWithBatchNormalizationState(
&self,
batch_normalization_state: &MPSCNNBatchNormalizationState,
) -> bool
Available on crate features MPSCore and MPSNNGradientState and MPSState only.
unsafe fn updateMeanAndVarianceWithBatchNormalizationState( &self, batch_normalization_state: &MPSCNNBatchNormalizationState, ) -> bool
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.
Sourceunsafe fn epsilon(&self) -> c_float
unsafe fn epsilon(&self) -> c_float
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
Sourceunsafe fn encodeWithCoder(&self, a_coder: &NSCoder)
unsafe fn encodeWithCoder(&self, a_coder: &NSCoder)
Sourceunsafe fn initWithCoder(
this: Allocated<Self>,
a_decoder: &NSCoder,
) -> Option<Retained<Self>>
unsafe fn initWithCoder( this: Allocated<Self>, a_decoder: &NSCoder, ) -> Option<Retained<Self>>
Sourceunsafe fn supportsSecureCoding() -> bool
unsafe fn supportsSecureCoding() -> bool
NSSecureCoding compatibility.
Sourceunsafe fn copyWithZone_device(
&self,
zone: *mut NSZone,
device: Option<&ProtocolObject<dyn MTLDevice>>,
) -> Retained<Self>
unsafe fn copyWithZone_device( &self, zone: *mut NSZone, device: Option<&ProtocolObject<dyn MTLDevice>>, ) -> Retained<Self>
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.
impl ProtocolType for dyn MPSCNNBatchNormalizationDataSource
MPSNeuralNetwork only.impl<T> ImplementedBy<T> for dyn MPSCNNBatchNormalizationDataSource
MPSNeuralNetwork only.Implementations on Foreign Types§
impl<T> MPSCNNBatchNormalizationDataSource for ProtocolObject<T>where
T: ?Sized + MPSCNNBatchNormalizationDataSource,
MPSNeuralNetwork only.