MPSCNNPoolingGradient(3) MetalPerformanceShaders.framework MPSCNNPoolingGradient(3)
NAME
MPSCNNPoolingGradient
SYNOPSIS
#import <MPSCNNPooling.h>
Inherits MPSCNNGradientKernel.
Inherited by MPSCNNDilatedPoolingMaxGradient, MPSCNNPoolingAverageGradient, MPSCNNPoolingL2NormGradient, and MPSCNNPoolingMaxGradient.
Instance Methods
(nonnull instancetype) - initWithDevice:kernelWidth:kernelHeight:
(nonnull instancetype) - initWithDevice:kernelWidth:kernelHeight:strideInPixelsX:strideInPixelsY:
(nonnull instancetype) - initWithDevice:
(nullable instancetype) - initWithCoder:device:
Properties
MTLSize sourceSize
Additional Inherited Members
Detailed Description
This depends on Metal.framework Specifies the base class for computing the gradient of the pooling filters. The operation backpropagates a
gradient vector using the chain rule.
Given the input gradient vector dL(x) = dL/d out(x), which is the derivative of the loss-function wrt. (original) pooling filter output the
output gradient at position y (dL/d in(y)) is computed as follows:
dL/d in(y) = sum_x (dL/d out(x)) * (d out(x)/d in(y)), where
the sum runs over the input gradient pixels starting from primaryOffset extending to primaryOffset + sourceSize. Note here that we need a
separate variable 'sourceSize' to specify which input gradients are included in the output gradient computation as this information cannot
be deduced directly from the cliprect size due to fractional striding or simply because the user wants to examine a subset of the
contributions to the gradients. In normal operation the sourceSize is specified as the cliprect.size of the forward pooling filter in order
to compute the gradients for all outputs the forward direction produced and the primaryOffset is set to cliprect.origin of the original
forward pooling operation for the same reason.
The cliprect property of the filter allows the user to send the gradients to a new location, which may not match the original forward
pooling filter window locations: The index 'y' in the formula above refers to the pixel location in the secondary source, which is the
source image of the original forward pooling filter and secondaryOffset specifies the center of the first pooling window as specified in
MPSCNNPooling filter specification. The first (top leftmost) pixel written into the cliprect computes the derivative of the first pixel
within the first pooling window that is contained within the secondary source image and subsequent values are defined by normal striding
rules from secondary source to primary source. This means that typically the cliprect is set to fill the effective source area of the
original forward operation, clamped to edges of the original source image, which in the normal case is the same size as the size of the
gradient destination image.
If there are any values in the destination cliprect that do not contribute to the forward pooling result in the area specified by
primaryOffset and sourceSize, due to large strides or dilation factors or simply because all forward pass induced values would be outside
the source area, then those result values are set to zero.
The actual value of d out(x) / d in(y) depends on the pooling operation and these are defined in the subclasses of MPSCNNPoolingGradient.
Method Documentation
- (nullable instancetype) initWithCoder: (NSCoder *__nonnull) aDecoder(nonnull id< MTLDevice >) device
NSSecureCoding compatability See MPSKernel::initWithCoder.
Parameters:
aDecoder The NSCoder subclass with your serialized MPSCNNPoolingGradient
device The MTLDevice on which to make the MPSCNNPoolingGradient
Returns:
A new MPSCNNPooling object, or nil if failure.
Reimplemented from MPSCNNGradientKernel.
Reimplemented in MPSCNNPoolingAverageGradient, MPSCNNPoolingMaxGradient, MPSCNNPoolingL2NormGradient, and MPSCNNDilatedPoolingMaxGradient.
- (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 MPSCNNGradientKernel.
- (nonnull instancetype) initWithDevice: (nonnull id< MTLDevice >) device(NSUInteger) kernelWidth(NSUInteger) kernelHeight
Initialize a gradient pooling filter
Parameters:
device The device the filter will run on
kernelWidth The width of the kernel. Can be an odd or even value.
kernelHeight The height of the kernel. Can be an odd or even value.
Returns:
A valid MPSCNNPoolingGradient object or nil, if failure.
- (nonnull instancetype) initWithDevice: (nonnull id< MTLDevice >) device(NSUInteger) kernelWidth(NSUInteger) kernelHeight(NSUInteger)
strideInPixelsX(NSUInteger) strideInPixelsY
Initialize a gradient pooling filter
Parameters:
device The device the filter will run on
kernelWidth The width of the kernel. Can be an odd or even value.
kernelHeight The height of the kernel. Can be an odd or even value.
strideInPixelsX The input stride (upsampling factor) in the x dimension.
strideInPixelsY The input stride (upsampling factor) in the y dimension.
Returns:
A valid MPSCNNPoolingGradient object or nil, if failure.
Reimplemented in MPSCNNPoolingAverageGradient, MPSCNNPoolingMaxGradient, MPSCNNPoolingL2NormGradient, and MPSCNNDilatedPoolingMaxGradient.
Property Documentation
- sourceSize [read], [write], [nonatomic], [assign]
An optional source size which defines together with primaryOffset, the set of input gradient pixels to take into account in the gradient
computations. A MTLSize that together with primaryOffset indicates which part of the source gradient to consider. If the area does not lie
completely within the primary source image, the intersection between source area rectangle and primary source bounds is used. Default: A
size where every component is NSUIntegerMax indicating the entire rest of the image, starting from an offset (see primaryOffset).
Author
Generated automatically by Doxygen for MetalPerformanceShaders.framework from the source code.
Version MetalPerformanceShaders-100 Thu Feb 8 2018 MPSCNNPoolingGradient(3)