MPSMatrixBatchNormalization(3) MetalPerformanceShaders.framework MPSMatrixBatchNormalization(3)

MPSMatrixBatchNormalization

#import <MPSMatrixBatchNormalization.h>

Inherits MPSMatrixUnaryKernel.


(void) - setNeuronType:parameterA:parameterB:parameterC:
(MPSCNNNeuronType) - neuronType
(float) - neuronParameterA
(float) - neuronParameterB
(float) - neuronParameterC
(nonnull instancetype) - initWithDevice:
(void) - encodeToCommandBuffer:inputMatrix:meanVector:varianceVector:gammaVector:betaVector:resultMatrix:
(nullable instancetype) - initWithCoder:device:
(nonnull instancetype) - copyWithZone:device:


NSUInteger sourceNumberOfFeatureVectors
NSUInteger sourceInputFeatureChannels
float epsilon
BOOL computeStatistics

MPSMatrixBatchNormalization.h MetalPerformanceShaders.framework

Copyright:

Copyright (c) 2018 Apple Inc. All rights reserved. Batch normalization of arrays stored as MPSMatrix objects.

This depends on Metal.framework.

Applies a batch normalization to a matrix.

A MPSMatrixBatchNormalization object computes the batch normalization of a collection of feature vectors stored in an MPSMatrix.

Feature vectors are stored in a row of the supplied input matrix and the normalization is performed along columns:

y[i,j] = gamma[j] * (x[i,j] - mean(x[:,j])) / (variance(x[:,j]) + epsilon) + beta[j]

where gamma and beta are supplied weight and bias factors and epsilon is a small value added to the variance.

Optionally a neuron activation function may be applied to the result.

- (nonnull instancetype) copyWithZone: (nullable NSZone *) zone(nullable id< MTLDevice >) device

Make a copy of this kernel for a new device -

See also:

MPSKernel

Parameters:

zone The NSZone in which to allocate the object
device The device for the new MPSKernel. If nil, then use self.device.

Returns:

A pointer to a copy of this MPSKernel. This will fail, returning nil if the device is not supported. Devices must be MTLFeatureSet_iOS_GPUFamily2_v1 or later.

Reimplemented from MPSKernel.

- (void) encodeToCommandBuffer: (nonnull id< MTLCommandBuffer >) commandBuffer(MPSMatrix *__nonnull) inputMatrix(MPSVector *__nonnull) meanVector(MPSVector *__nonnull) varianceVector(MPSVector *__nullable) gammaVector(MPSVector *__nullable) betaVector(MPSMatrix *__nonnull) resultMatrix

Encode a MPSMatrixBatchNormalization object to a command buffer.

Parameters:

commandBuffer A valid MTLCommandBuffer to receive the encoded kernel.
inputMatrix A valid MPSMatrix object which specifies the input array.
meanVector A valid MPSVector object containing batch mean values to be used to normalize the inputs if computeStatistics is NO. If computeStatistics is YES the resulting batch mean values will be returned in this array.
varianceVector A valid MPSVector object containing batch variance values to be used to normalize the inputs if computeStatistics is NO. If computeStatistics is YES the resulting batch variance values will be returned in this array.
gammaVector A valid MPSVector object which specifies the gamma terms, or a null object to indicate that no scaling is to be applied.
betaVector A valid MPSVector object which specifies the beta terms, or a null object to indicate that no values are to be added.
resultMatrix A valid MPSMatrix object which specifies the output array.

Encodes the operation to the specified command buffer. resultMatrix must be large enough to hold a MIN(sourceNumberOfFeatureVectors, inputMatrix.rows - sourceMatrixOrigin.x) x MIN(inputMatrix.columns - sourceMatrixOrigin.y, sourceInputFeatureChannels) array.

Let numChannels = MIN(inputMatrix.columns - sourceMatrixOrigin.y, sourceInputFeatureChannels)

The gamma, beta, mean, and variance vectors must contain at least numChannels elements.

- (nullable instancetype) initWithCoder: (NSCoder *__nonnull) aDecoder(nonnull id< MTLDevice >) device

NSSecureCoding compatability See MPSKernel::initWithCoder.

Parameters:

aDecoder The NSCoder subclass with your serialized MPSMatrixBatchNormalization object.
device The MTLDevice on which to make the MPSMatrixBatchNormalization object.

Returns:

A new MPSMatrixBatchNormalization object, or nil if failure.

Reimplemented from MPSKernel.

- (nonnull instancetype) initWithDevice: (nonnull id< MTLDevice >) device

Standard init with default properties per filter type

Parameters:

device The device that the filter will be used on. May not be NULL.

Returns:

a pointer to the newly initialized object. This will fail, returning nil if the device is not supported. Devices must be MTLFeatureSet_iOS_GPUFamily2_v1 or later.

Reimplemented from MPSKernel.

- (float) neuronParameterA

Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

- (float) neuronParameterB

Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

- (float) neuronParameterC

Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

- (MPSCNNNeuronType) neuronType

Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

- (void) setNeuronType: (MPSCNNNeuronType) neuronType(float) parameterA(float) parameterB(float) parameterC

Specifies a neuron activation function to be used.

This method can be used to add a neuron activation funtion of given type with associated scalar parameters A, B, and C that are shared across all output values. Note that this method can only be used to specify neurons which are specified by three (or fewer) parameters shared across all output values (or channels, in CNN nomenclature). It is an error to call this method for neuron activation functions like MPSCNNNeuronTypePReLU, which require per-channel parameter values. An MPSMatrixNeuron kernel is initialized with a default neuron function of MPSCNNNeuronTypeNone.

Parameters:

neuronType Type of neuron activation function. For full list see MPSCNNNeuronType.h
parameterA parameterA of neuron activation that is shared across all output values.
parameterB parameterB of neuron activation that is shared across all output values.
parameterC parameterC of neuron activation that is shared across all output values.

- computeStatistics [read], [write], [nonatomic], [assign]

If YES the batch statistics will be computed prior to performing the normalization. Otherwise the provided statistics will be used. Defaults to NO at initialization time.

- epsilon [read], [write], [nonatomic], [assign]

A small value to add to the variance when normalizing the inputs. Defaults to FLT_MIN upon initialization.

- sourceInputFeatureChannels [read], [write], [nonatomic], [assign]

The input size to to use in the operation. This is equivalent to the number of columns in the primary (input array) source matrix to consider and the number of channels to produce for the output matrix. This property is modifiable and defaults to NSUIntegerMax. At encode time the larger of this property or the available input size is used. The value of NSUIntegerMax thus indicates that all available columns in the input array (beginning at sourceMatrixOrigin.y) should be considered. Defines also the number of output feature channels. Note: The value used in the operation will be MIN(inputMatrix.columns - sourceMatrixOrigin.y, sourceInputFeatureChannels)

- sourceNumberOfFeatureVectors [read], [write], [nonatomic], [assign]

The number of input vectors which make up the input array. This is equivalent to the number of rows to consider from the primary source matrix. This property is modifiable and defaults to NSUIntegerMax. At encode time the larger of this property or the available number of inputs is used. The value of NSUIntegerMax thus indicates that all available input rows (beginning at sourceMatrixOrigin.x) should be considered.

Generated automatically by Doxygen for MetalPerformanceShaders.framework from the source code.

Mon Jul 9 2018 Version MetalPerformanceShaders-119.3