pub unsafe trait MPSCNNGroupNormalizationDataSource: 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 numberOfGroups(&self) -> NSUInteger
where Self: Sized + Message { ... }
unsafe fn setNumberOfGroups(&self, number_of_groups: NSUInteger)
where Self: Sized + Message { ... }
unsafe fn label(&self) -> Option<Retained<NSString>>
where Self: Sized + Message { ... }
unsafe fn updateGammaAndBetaWithCommandBuffer_groupNormalizationStateBatch(
&self,
command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
group_normalization_state_batch: &MPSCNNGroupNormalizationGradientStateBatch,
) -> Option<Retained<MPSCNNNormalizationGammaAndBetaState>>
where Self: Sized + Message { ... }
unsafe fn updateGammaAndBetaWithGroupNormalizationStateBatch(
&self,
group_normalization_state_batch: &MPSCNNGroupNormalizationGradientStateBatch,
) -> 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 { ... }
}MPSCNNGroupNormalization only.Expand description
The MPSCNNGroupNormalizationDataSource protocol declares the methods that an group of MPSCNNGroupNormalization uses to initialize the scale factors (gamma) and bias terms (beta).
See also Apple’s documentation
Provided Methods§
Sourceunsafe fn gamma(&self) -> *mut c_float
unsafe fn gamma(&self) -> *mut c_float
Return a pointer to an array containing the gamma terms.
Must have numberOfFeatureChannels values since scaling is done per feature channel.
Sourceunsafe fn beta(&self) -> *mut c_float
unsafe fn beta(&self) -> *mut c_float
Return a pointer to an array containing the beta terms.
Must have numberOfFeatureChannels values since scaling is done per feature channel.
unsafe fn numberOfFeatureChannels(&self) -> NSUInteger
Sourceunsafe fn numberOfGroups(&self) -> NSUInteger
unsafe fn numberOfGroups(&self) -> NSUInteger
numberOfFeatureChannels/numberOfGroups channels are normalized together.
Sourceunsafe fn setNumberOfGroups(&self, number_of_groups: NSUInteger)
unsafe fn setNumberOfGroups(&self, number_of_groups: NSUInteger)
Setter for numberOfGroups.
Sourceunsafe fn label(&self) -> Option<Retained<NSString>>
unsafe fn label(&self) -> Option<Retained<NSString>>
A label that is transferred to the group normalization filter at init time
Overridden by a MPSCNNGroupNormalizationNode.label if it is non-nil.
Sourceunsafe fn updateGammaAndBetaWithCommandBuffer_groupNormalizationStateBatch(
&self,
command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
group_normalization_state_batch: &MPSCNNGroupNormalizationGradientStateBatch,
) -> Option<Retained<MPSCNNNormalizationGammaAndBetaState>>
Available on crate features MPSCNNNormalizationWeights and MPSCore and MPSNNGradientState and MPSState only.
unsafe fn updateGammaAndBetaWithCommandBuffer_groupNormalizationStateBatch( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, group_normalization_state_batch: &MPSCNNGroupNormalizationGradientStateBatch, ) -> 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 MPSCNNGroupNormalizationStateBatch.
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 group 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 MPSCNNGroupNormalization 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 groupNormalizationStateBatch by 1, if the states are temporary.
Parameter commandBuffer: The command buffer on which to encode the update.
Parameter groupNormalizationStateBatch: A batch of MPSCNNGroupNormalizationGradientState objects containing
current weights and gradients.
Returns: A MPSCNNNormalizationGammaAndBetaState object containing updated gamma and beta values. If NULL no update was performed.
Sourceunsafe fn updateGammaAndBetaWithGroupNormalizationStateBatch(
&self,
group_normalization_state_batch: &MPSCNNGroupNormalizationGradientStateBatch,
) -> bool
Available on crate features MPSCore and MPSNNGradientState and MPSState only.
unsafe fn updateGammaAndBetaWithGroupNormalizationStateBatch( &self, group_normalization_state_batch: &MPSCNNGroupNormalizationGradientStateBatch, ) -> bool
MPSCore and MPSNNGradientState and MPSState only.Compute new gamma and beta values using current values and gradients contained within a batch MPSCNNGroupNormalizationState objects. Perform the update on the CPU.
Parameter groupNormalizationStateBatch: A batch of MPSCNNGroupNormalizationGradientState objects containing
current gamma and beta values and gradients.
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>>
§Safety
a_decoder possibly has further requirements.
unsafe fn supportsSecureCoding() -> bool
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 MPSCNNGroupNormalizationDataSource
Available on crate feature MPSNeuralNetwork only.
impl ProtocolType for dyn MPSCNNGroupNormalizationDataSource
MPSNeuralNetwork only.impl<T> ImplementedBy<T> for dyn MPSCNNGroupNormalizationDataSource
MPSNeuralNetwork only.Implementations on Foreign Types§
impl<T> MPSCNNGroupNormalizationDataSource for ProtocolObject<T>where
T: ?Sized + MPSCNNGroupNormalizationDataSource,
MPSNeuralNetwork only.