MPSNNDefaultPadding(3) MetalPerformanceShaders.framework MPSNNDefaultPadding(3)
NAME
MPSNNDefaultPadding
SYNOPSIS
#import <MPSNeuralNetworkTypes.h>
Inherits NSObject, and <MPSNNPadding>.
Instance Methods
(NSString *__nonnull) - label
Class Methods
(instancetype __nonnull) + paddingWithMethod:
(instancetype __nonnull) + paddingForTensorflowAveragePooling
(instancetype __nonnull) + paddingForTensorflowAveragePoolingValidOnly
Method Documentation
- (NSString * __nonnull) label
Human readable description of what the padding policy does
+ (instancetype __nonnull) paddingForTensorflowAveragePooling
A padding policy that attempts to reproduce TensorFlow behavior for average pooling Most TensorFlow padding is covered by the standard
MPSNNPaddingMethod encodings. You can use +paddingWithMethod to get quick access to MPSNNPadding objects, when default filter behavior
isn't enough. (It often is.) However, the edging for max pooling in TensorFlow is a bit unusual.
This padding method attempts to reproduce TensorFlow padding for average pooling. In addition to setting MPSNNPaddingMethodSizeSame |
MPSNNPaddingMethodAlignCentered | MPSNNPaddingMethodAddRemainderToBottomRight, it also configures the filter to run with
MPSImageEdgeModeClamp, which (as a special case for average pooling only), normalizes the sum of contributing samples to the area of valid
contributing pixels only.
// Sample implementation for the tensorflowPoolingPaddingPolicy returned
-(MPSNNPaddingMethod) paddingMethod{ return MPSNNPaddingMethodCustom | MPSNNPaddingMethodSizeSame; }
-(MPSImageDescriptor * __nonnull) destinationImageDescriptorForSourceImages: (NSArray <MPSImage *> *__nonnull) sourceImages
sourceStates: (NSArray <MPSState *> * __nullable) sourceStates
forKernel: (MPSKernel * __nonnull) kernel
suggestedDescriptor: (MPSImageDescriptor * __nonnull) inDescriptor
{
((MPSCNNKernel *)kernel).edgeMode = MPSImageEdgeModeClamp;
return inDescriptor;
}
+ (instancetype __nonnull) paddingForTensorflowAveragePoolingValidOnly
Typical pooling padding policy for valid only mode
+ (instancetype __nonnull) paddingWithMethod: (MPSNNPaddingMethod) method
Fetch a well known object that implements a non-custom padding method For custom padding methods, you will need to implement an object
that conforms to the full MPSNNPadding protocol, including NSSecureCoding.
Parameters:
method A MPSNNPaddingMethod
Returns:
An object that implements <MPSNNPadding> for use with MPSNNGraphNodes.
Author
Generated automatically by Doxygen for MetalPerformanceShaders.framework from the source code.
Version MetalPerformanceShaders-100 Thu Feb 8 2018 MPSNNDefaultPadding(3)