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 { ... }
}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§
Sourceunsafe fn gamma(&self) -> *mut c_float
unsafe fn gamma(&self) -> *mut c_float
Return a pointer to an array containing the gamma terms.
unsafe fn numberOfFeatureChannels(&self) -> NSUInteger
Sourceunsafe fn label(&self) -> Option<Retained<NSString>>
unsafe fn label(&self) -> Option<Retained<NSString>>
A label that is transferred to the instance normalization filter at init time
Overridden by a MPSCNNInstanceNormalizationNode.label if it is non-nil.
Sourceunsafe fn updateGammaAndBetaWithCommandBuffer_instanceNormalizationStateBatch(
&self,
command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
instance_normalization_state_batch: &MPSCNNInstanceNormalizationGradientStateBatch,
) -> Option<Retained<MPSCNNNormalizationGammaAndBetaState>>
Available on crate features MPSCNNNormalizationWeights and MPSCore and MPSNNGradientState and MPSState only.
unsafe fn updateGammaAndBetaWithCommandBuffer_instanceNormalizationStateBatch( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, instance_normalization_state_batch: &MPSCNNInstanceNormalizationGradientStateBatch, ) -> 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 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.
Sourceunsafe fn updateGammaAndBetaWithInstanceNormalizationStateBatch(
&self,
instance_normalization_state_batch: &MPSCNNInstanceNormalizationGradientStateBatch,
) -> bool
Available on crate features MPSCore and MPSNNGradientState and MPSState only.
unsafe fn updateGammaAndBetaWithInstanceNormalizationStateBatch( &self, instance_normalization_state_batch: &MPSCNNInstanceNormalizationGradientStateBatch, ) -> bool
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.
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 MPSCNNInstanceNormalizationDataSource
Available on crate feature MPSNeuralNetwork only.
impl ProtocolType for dyn MPSCNNInstanceNormalizationDataSource
MPSNeuralNetwork only.impl<T> ImplementedBy<T> for dyn MPSCNNInstanceNormalizationDataSource
MPSNeuralNetwork only.Implementations on Foreign Types§
impl<T> MPSCNNInstanceNormalizationDataSource for ProtocolObject<T>where
T: ?Sized + MPSCNNInstanceNormalizationDataSource,
MPSNeuralNetwork only.