MPSNNDefaultPadding(3) MetalPerformanceShaders.framework MPSNNDefaultPadding(3)

MPSNNDefaultPadding

#import <MPSNeuralNetworkTypes.h>

Inherits NSObject, and <MPSNNPadding>.


(NSString *__nonnull) - label


(instancetype __nonnull) + paddingWithMethod:
(instancetype __nonnull) + paddingForTensorflowAveragePooling
(instancetype __nonnull) + paddingForTensorflowAveragePoolingValidOnly

- (NSString * __nonnull) label

Human readable description of what the padding policy does

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;
}

Typical pooling padding policy for valid only mode

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.

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

Mon Jul 9 2018 Version MetalPerformanceShaders-119.3