MPSCNNBatchNormalization(3) MetalPerformanceShaders.framework MPSCNNBatchNormalization(3)
NAME
MPSCNNBatchNormalization
SYNOPSIS
#import <MPSCNNBatchNormalization.h>
Inherits MPSCNNKernel.
Instance Methods
(nonnull instancetype) - initWithDevice:dataSource:
(nonnull instancetype) - initWithDevice:
(nullable instancetype) - initWithCoder:device:
(void) - encodeToCommandBuffer:sourceImage:batchNormalizationState:destinationImage:
(void) - encodeBatchToCommandBuffer:sourceImages:batchNormalizationState:destinationImages:
(MPSImage *__nonnull) - encodeToCommandBuffer:sourceImage:batchNormalizationState:
(MPSImageBatch *__nonnull) - encodeBatchToCommandBuffer:sourceImages:batchNormalizationState:
(MPSCNNBatchNormalizationState *__nullable) - resultStateForSourceImages:
(MPSCNNBatchNormalizationState *__nullable) - temporaryResultStateForCommandBuffer:sourceImages:
(void) - reloadDataSource:
(void) - reloadGammaAndBetaWithCommandBuffer:gammaAndBetaState:
Properties
NSUInteger numberOfFeatureChannels
float epsilon
id< MPSCNNBatchNormalizationDataSource > dataSource
Additional Inherited Members
Detailed Description
This depends on Metal.framework MPSCNNBatchNormalization normalizes input images using per-channel means and variances.
for (c = 0; c < numberOfFeatureChannels; ++c) { input_image = in(:,:,c,:); output_image = (input_image - mean[c]) * gamma[c] /
sqrt(variance[c] + epsilon) + beta[c]; out(:,:,c,:) = output_image; }
Method Documentation
- (MPSImageBatch * __nonnull) encodeBatchToCommandBuffer: (nonnull id< MTLCommandBuffer >) commandBuffer(MPSImageBatch *__nonnull)
sourceImages(MPSCNNBatchNormalizationState *__nonnull) batchNormalizationState
Encode this kernel to a command buffer for a batch of images using a batch normalization state. Create a batch of MPSImages to hold the
result and return it.
Parameters:
commandBuffer A valid command buffer to receive the kernel.
sourceImages The batch of source images.
batchNormalizationState A MPSCNNBatchNormalizationState containing weights and/or statistics to use for the batch normalization.
Returns:
An MPSImageBatch containing the output of the graph.
- (void) encodeBatchToCommandBuffer: (nonnull id< MTLCommandBuffer >) commandBuffer(MPSImageBatch *__nonnull)
sourceImages(MPSCNNBatchNormalizationState *__nonnull) batchNormalizationState(MPSImageBatch *__nonnull) destinationImages
Encode this kernel to a command buffer for a batch of images using a batch normalization state.
Parameters:
commandBuffer A valid command buffer to receive the kernel.
sourceImages The batch of source images.
batchNormalizationState A MPSCNNBatchNormalizationState containing weights and/or statistics to use for the batch normalization.
destinationImages The batch of images to contain the normalized and scaled result images.
- (MPSImage * __nonnull) encodeToCommandBuffer: (nonnull id< MTLCommandBuffer >) commandBuffer(MPSImage *__nonnull)
sourceImage(MPSCNNBatchNormalizationState *__nonnull) batchNormalizationState
Encode this kernel to a command buffer for a single image using a batch normalization state. Create a MPSImage to hold the result and
return it.
Parameters:
commandBuffer A valid command buffer to receive the kernel.
sourceImage The source MPSImage.
batchNormalizationState A MPSCNNBatchNormalizationState containing weights and/or statistics to use for the batch normalization.
Returns:
An MPSImage containing the output of the graph.
- (void) encodeToCommandBuffer: (nonnull id< MTLCommandBuffer >) commandBuffer(MPSImage *__nonnull) sourceImage(MPSCNNBatchNormalizationState
*__nonnull) batchNormalizationState(MPSImage *__nonnull) destinationImage
Encode this kernel to a command buffer for a single image using a batch normalization state.
Parameters:
commandBuffer A valid command buffer to receive the kernel.
sourceImage The source MPSImage.
batchNormalizationState A MPSCNNBatchNormalizationState containing weights and/or statistics to use for the batch normalization.
destinationImage An MPSImage to contain the resulting normalized and scaled image.
- (nullable instancetype) initWithCoder: (NSCoder *__nonnull) aDecoder(nonnull id< MTLDevice >) device
NSSecureCoding compatability While the standard NSSecureCoding/NSCoding method -initWithCoder: should work, since the file can't know
which device your data is allocated on, we have to guess and may guess incorrectly. To avoid that problem, use a subclass of NSCoder that
implements the <MPSDeviceProvider> protocol to tell MPS the MTLDevice to use.
Parameters:
aDecoder The NSCoder subclass with your serialized MPSKernel
device The MTLDevice on which to make the MPSKernel
Returns:
A new MPSCNNBatchNormalization object, or nil if failure.
Reimplemented from MPSCNNKernel.
- (nonnull instancetype) initWithDevice: (nonnull id< MTLDevice >) device
Use initWithDevice:dataSource instead
Reimplemented from MPSCNNKernel.
- (nonnull instancetype) initWithDevice: (nonnull id< MTLDevice >) device(nonnull id< MPSCNNBatchNormalizationDataSource >) dataSource
Initializes a batch normalization kernel using a data source.
Parameters:
device The MTLDevice on which this filter will be used
dataSource A pointer to a object that conforms to the MPSCNNBatchNormalizationDataSource protocol. The data source provides filter
weights and bias terms and, optionally, image statistics which may be used to perform the normalization.
Returns:
A valid MPSCNNBatchNormalization object or nil, if failure.
- (void) reloadDataSource: (__nonnull id< MPSCNNBatchNormalizationDataSource >) dataSource
Reinitialize the filter using a data source.
Parameters:
dataSource The data source which will provide the weights and, optionally, the image batch statistics with which to normalize.
- (void) reloadGammaAndBetaWithCommandBuffer: (__nonnull id< MTLCommandBuffer >) commandBuffer(MPSCNNNormalizationGammaAndBetaState *__nonnull)
gammaAndBetaState
Reload data using new gamma and beta terms contained within an MPSCNNInstanceNormalizationGradientState object.
Parameters:
commandBuffer The command buffer on which to encode the reload.
gammaAndBetaState The state containing the updated weights which are to be reloaded.
- (MPSCNNBatchNormalizationState * __nullable) resultStateForSourceImages: (MPSImageBatch *__nonnull) sourceImages
Return an MPSCNNBatchNormalizationState object which may be used with a MPSCNNBatchNormalization filter.
- (MPSCNNBatchNormalizationState * __nullable) temporaryResultStateForCommandBuffer: (nonnull id< MTLCommandBuffer >)
commandBuffer(MPSImageBatch *__nonnull) sourceImages
Return a temporary MPSCNNBatchNormalizationState object which may be used with a MPSCNNBatchNormalization filter.
Property Documentation
- (id<MPSCNNBatchNormalizationDataSource>) dataSource [read], [nonatomic], [retain]
The data source the batch normalization was initialized with
- epsilon [read], [write], [nonatomic], [assign]
The epsilon value used in the batch normalization formula to bias the variance when normalizing.
- numberOfFeatureChannels [read], [nonatomic], [assign]
The number of feature channels in an image to be normalized.
Author
Generated automatically by Doxygen for MetalPerformanceShaders.framework from the source code.
Version MetalPerformanceShaders-100 Thu Feb 8 2018 MPSCNNBatchNormalization(3)