#
MetalPerformanceShaders
Namespace

Highly-optimized image and computer shaders.

### In this article

## Classes

MPSBinaryImageKernel |
A image kernel that combines two textures into one texture result. |

MPSCnnBinaryConvolution |
A MPSCnnKernel that has binary weights and convolves its input. |

MPSCnnBinaryConvolutionNode |
A MPSCnnConvolutionNode that represents a binary convolution kernel. |

MPSCnnBinaryFullyConnected |
A MPSCnnBinaryConvolution that is a fully-connected convolution layer that uses binary weights. |

MPSCnnBinaryFullyConnectedNode |
A MPSCnnBinaryConvolutionNode that represents a fully-connected convolution layer that uses binary weights. |

MPSCnnBinaryKernel |
A MPSKernel that has binary weights. |

MPSCnnConvolution |
A MPSCnnKernel that convolves its inputs, producing a feature map for each of its constituent filters. |

MPSCnnConvolutionDataSource |
Base class for classes that provide weights and bias terms to convolution filters. |

MPSCnnConvolutionDataSource_Extensions |
Extension methods to the IMPSCnnConvolutionDataSource interface to support all the methods from the MPSCnnConvolutionDataSource protocol. |

MPSCnnConvolutionDescriptor |
Describes a convolution kernel. |

MPSCnnConvolutionNode |
Subclass of MPSNNFilterNode that is the base class for convolution representation nodes. |

MPSCnnConvolutionState | |

MPSCnnConvolutionStateNode | |

MPSCnnConvolutionTranspose |
A MPSCnnKernel that transposes its input. |

MPSCnnConvolutionTransposeNode |
A MPSCnnConvolutionNode that represents a transpose kernel. |

MPSCnnCrossChannelNormalization |
A MPSCnnKernel that normalizes across feature channels. |

MPSCnnCrossChannelNormalizationNode |
A MPSCnnNormalizationNode that represents a cross-channel normalization kernel. |

MPSCnnDepthWiseConvolutionDescriptor |
A MPSCnnConvolutionDescriptor that describes depthwise convolution. |

MPSCnnDilatedPoolingMax |
A dilated max MPSCnnPooling filter. |

MPSCnnDilatedPoolingMaxNode |
A MPSNNFilterNode that represents a dilated max pooling filter. |

MPSCnnFullyConnected |
A fully connected layer. |

MPSCnnFullyConnectedNode |
A MPSCnnConvolutionNode that represents a fully connected layer. |

MPSCnnKernel |
The base class for layers in a convolutional neural network. |

MPSCnnLocalContrastNormalization |
A local contrast MPSCnnKernel. |

MPSCnnLocalContrastNormalizationNode |
A MPSCnnNormalizationNode representing a local contrast normalization kernel. |

MPSCnnLogSoftMax |
The logarithmic softmax loss function. |

MPSCnnLogSoftMaxNode |
A MPSNNFilterNode that represents the logarithmic softmax loss function. |

MPSCnnNeuron |
The base class for activation functions. |

MPSCnnNeuronAbsolute |
The absolute-value activation function. |

MPSCnnNeuronAbsoluteNode |
A MPSCnnNeuronNode that represents the absolute-value activation function. |

MPSCnnNeuronElu |
The exponential linear unit activation function. |

MPSCnnNeuronEluNode |
A MPSCnnNeuronNode that represents the exponential linear unit activation function. |

MPSCnnNeuronHardSigmoid |
The hard sigmoid activation function. |

MPSCnnNeuronHardSigmoidNode |
A MPSCnnNeuronNode that represents the hard sigmoid activation function. |

MPSCnnNeuronLinear |
The linear activation function. |

MPSCnnNeuronLinearNode |
A MPSCnnNeuronNode that represents the linear activation function. |

MPSCnnNeuronNode |
The base class for representations of activation functions. |

MPSCnnNeuronPReLU |
The parametric rectified linear unit activation function. |

MPSCnnNeuronPReLUNode |
A MPSCnnNeuronNode that represents the parametric rectified linear unit activation function. |

MPSCnnNeuronReLU |
The rectified linear unit activation function. |

MPSCnnNeuronReLun |
The ReLUN activation function. |

MPSCnnNeuronReLunNode |
A MPSCnnNeuronNode that represents the ReLUN activation function. |

MPSCnnNeuronReLUNode |
A MPSCnnNeuronNode that represents the rectified linear unit activation function. |

MPSCnnNeuronSigmoid |
The sigmoid activation function. |

MPSCnnNeuronSigmoidNode |
A MPSCnnNeuronNode that represents the sigmoid activation function. |

MPSCnnNeuronSoftPlus |
The softplus activation function. |

MPSCnnNeuronSoftPlusNode |
A MPSCnnNeuronNode that represents the softplus activation function. |

MPSCnnNeuronSoftSign |
The softsign activation function. |

MPSCnnNeuronSoftSignNode |
A MPSCnnNeuronNode that represents the softsign activation function. |

MPSCnnNeuronTanH |
The hyperbolic tangent activation function. |

MPSCnnNeuronTanHNode |
T:MetalPerformanceShaders.MPSCNNNeuronNode |

MPSCnnNormalizationNode |
Abstract base class for normalization MPSNNFilterNode subclasses. |

MPSCnnPooling |
A subclass of MPSCnnKernel that sub-samples its input. |

MPSCnnPoolingAverage |
An average pooling filter. |

MPSCnnPoolingAverageNode |
A MPSNNFilterNode that returns the average value of its input region. |

MPSCnnPoolingL2Norm |
An L2-norm pooling filter. |

MPSCnnPoolingL2NormNode |
Representation of an L2-norm pooling filter. |

MPSCnnPoolingMax |
A MPSCnnPooling subclass that performs max-pooling. |

MPSCnnPoolingMaxNode |
A MPSCnnPoolingNode that represents a max-pooling kernel in a convolutional neural net. |

MPSCnnPoolingNode |
A MPSNNFilterNode that represents a pooling kernel in a convolutional neural net. |

MPSCnnSoftMax |
A MPSCnnKernel commonly used in categorization tasks. |

MPSCnnSoftMaxNode |
A MPSNNFilterNode that represents a softmax filter. |

MPSCnnSpatialNormalization |
A MPSCnnKernel that performs spatial normalization. |

MPSCnnSpatialNormalizationNode |
A MPSCnnNormalizationNode that represents a spatial normalization kernel. |

MPSCnnSubPixelConvolutionDescriptor |
A MPSCnnConvolutionDescriptor that describes subpixel upsampling and reshaping. |

MPSCnnUpsampling |
A MPSCnnKernel that upsamples an image. |

MPSCnnUpsamplingBilinear |
A MPSCnnUpsampling filter that performs bilinear spatial upsampling. |

MPSCnnUpsamplingBilinearNode |
A MPSNNFilterNode that performs bilinear spatial upsampling. |

MPSCnnUpsamplingNearest |
A MPSCnnUpsampling filter that performs nearest spatial upsampling. |

MPSCnnUpsamplingNearestNode |
A MPSNNFilterNode that performs nearest spatial upsampling. |

MPSGRUDescriptor |
Describes a gated recurrent unit layer in a neural net. |

MPSImage |
An image that may contain more than 4 channels. (For example, an image in a layer of a convolutional neural network.) |

MPSImageAdd |
A MPSImageArithmetic kernel that performs element-wise addition of two images. |

MPSImageAreaMax |
Filter that finds the maximum pixel value in a window around each pixel in the source image.(Individual channels are processed separately.) |

MPSImageAreaMin |
Filter that finds the minimum pixel value in a window around each pixel in the source image.(Individual channels are processed separately.) |

MPSImageArithmetic |
Base class for MPSBinaryImageKernel classes that perform arithmetic on images. |

MPSImageBilinearScale |
A MPSImageScale subclass that uses bilinear sampling to scale the image. |

MPSImageBox |
Filter that blurs by transforming each pixel of the source image to the average of itself and its neighbors. |

MPSImageConversion |
An image that can convert its color space, alpha, or pixel format. |

MPSImageConvolution |
Filter that represents a convolution. |

MPSImageCopyToMatrix | |

MPSImageDescriptor |
Contains the attributes for a new or existing MPSImage. |

MPSImageDilate |
Finds the maximum value in a region, offset by a corresponding value in a mask. |

MPSImageDivide |
A MPSImageArithmetic kernel that performs element-wise division of two images. |

MPSImageErode |
Finds the mininum value in a region, offset by a corresponding value in a mask. |

MPSImageFindKeypoints | |

MPSImageGaussianBlur |
Filter that applies a fast Gaussian blur to an image. |

MPSImageGaussianPyramid |
Represents a Gaussian image pyramid. |

MPSImageHistogram |
Calculates a histogram of image data. |

MPSImageHistogramEqualization |
A MPSUnaryImageKernel that equalizes the histogram of an image. |

MPSImageHistogramSpecification |
Transforms an image so that its histogram matches a desired histogram. |

MPSImageIntegral |
Filter that sums the values of pixels in a region. |

MPSImageIntegralOfSquares |
Filter that sums the squared values of pixels in a region. |

MPSImageLanczosScale |
Filter that performs a scaling operation with Lanczos resampling. |

MPSImageLaplacian |
An optimized Laplacian filter. |

MPSImageMedian |
Filter that finds the median value of each channel for pixels in the region around each source image pixel. |

MPSImageMultiply |
A MPSImageArithmetic kernel that performs element-wise multiplication of two images. |

MPSImagePyramid |
Base class for image pyramids. |

MPSImageScale |
A MPSUnaryImageKernel that can resize and change aspect ratio of an image. |

MPSImageSobel |
Filter that detects edges by using a Sobel filter. |

MPSImageStatisticsMean |
A MPSUnaryImageKernel that calculates the mean of pixel values for a region. |

MPSImageStatisticsMeanAndVariance |
A MPSUnaryImageKernel that calculates the mean and variance of pixel values for a region. |

MPSImageStatisticsMinAndMax |
A MPSUnaryImageKernel that calculates the minimum and maximum pixel values for a region. |

MPSImageSubtract |
A MPSImageArithmetic kernel that performs element-wise subtraction of two images. |

MPSImageTent |
Filter that blurs an image with a tent function. |

MPSImageThresholdBinary |
Filter that changes all pixels above a threshold luminance to a specified maximum single-channel value, and completely darkens the rest. |

MPSImageThresholdBinaryInverse |
Filter that changes all pixels above a threshold luminance to 0, and brightens the rest to a specified maximum single-channel value. |

MPSImageThresholdToZero |
Filter that darkens all pixels dimmer than or equal in brightness to a threshold luminance to 0, and leaves the rest unchanged. |

MPSImageThresholdToZeroInverse |
Filter that leaves all pixels dimmer than or equal in brightness to a threshold luminance unchangedt, and darkens the rest to 0. |

MPSImageThresholdTruncate |
Filter that clamps brightness values to a threshold value. |

MPSImageTranspose |
Filter that transposes an image. |

MPSKernel |
Base class that represents the kernel of a shader. |

MPSLSTMDescriptor |
Describes a Long-Short Term Memory layer in neural net. |

MPSMatrix |
A matrix that represents the kernel of a linear transformation. |

MPSMatrixBinaryKernel |
A kernel that operates on two matrices to create a new matrix. |

MPSMatrixCopy |
Performs multiple matrix copy operations. |

MPSMatrixCopyDescriptor |
Describes multiple matrix copy operations. |

MPSMatrixDecompositionCholesky |
A MPSMatrixUnaryKernel that computes the Cholesky factorization. |

MPSMatrixDecompositionLU |
A MPSMatrixUnaryKernel that computes LU factorization using partial pivoting. |

MPSMatrixDescriptor |
Describes the size, data type, and stride of a row-major matrix. |

MPSMatrixFindTopK | |

MPSMatrixFullyConnected | |

MPSMatrixLogSoftMax | |

MPSMatrixMultiplication |
Represents a weighted matrix multiplication operation, followed by a weighted addition operation. |

MPSMatrixNeuron | |

MPSMatrixSoftMax | |

MPSMatrixSolveCholesky |
A MPSMatrixBinaryKernel that solves a linear system of equations via Cholesky factorization. |

MPSMatrixSolveLU | |

MPSMatrixSolveTriangular |
A MPSMatrixBinaryKernel that solves a linear system of equations via a triangular coefficient matrix. |

MPSMatrixSum | |

MPSMatrixUnaryKernel |
A kernel that performs a mapping from one matrix to another. |

MPSMatrixVectorMultiplication |
Performs matrix multiplication. |

MPSNNAdditionNode |
Adds the results of two kernels. |

MPSNNBilinearScaleNode |
A MPSNNFilterNode that performs bilinear sampling. |

MPSNNBinaryArithmeticNode |
Abstract base class of arithmetic nodes. |

MPSNNConcatenationNode |
Concatenates the results of two kernels. |

MPSNNDefaultPadding |
Predefined common padding policies. |

MPSNNDivisionNode |
Divides the results of two kernels. |

MPSNNFilterNode |
A placeholder node in a neural network graph for an image filtering stage. |

MPSNNGraph |
An optimized neural network graph. |

MPSNNImageNode |
A placeholder node for an image in a neural network graph. |

MPSNNLanczosScaleNode |
A MPSNNFilterNode that performs Lanczos resampling. |

MPSNNMultiplicationNode |
Multiplies the results of two kernels. |

MPSNNPadding_Extensions | |

MPSNNScaleNode |
Abstract neural network graph node for image resampling. |

MPSNNStateNode |
A state object in a neural network graph. |

MPSNNSubtractionNode |
Subtracts the results of two kernels. |

MPSRnnDescriptor |
A structural description of a recurrent neural net layer. |

MPSRnnImageInferenceLayer |
A recurrent neural net layer specifically for image data. |

MPSRnnMatrixInferenceLayer |
A recurrent neural net layer. |

MPSRnnRecurrentImageState |
The image containing the state in an image-baed recurrent neural net as it iterates through its sequence. |

MPSRnnRecurrentMatrixState |
The matrix containing the state as a recurrent neural net iterates through its sequence. |

MPSRnnSingleGateDescriptor |
Describes the internal gate in a recurrent neural net. |

MPSState |
Temporary storage used by convolutional neural nets. |

MPSTemporaryImage |
Discardable image data. |

MPSTemporaryMatrix |
A matrix allocated in GPU private memory. |

MPSTemporaryVector |
A one-dimensional array allocated in GPU private memory. |

MPSUnaryImageKernel |
Represents a shader transformation produces one texture from another. |

MPSVector |
A one-dimensional array. |

MPSVectorDescriptor |
Describes the length and data type of a MPSVector. |

## Structs

MPSImageHistogramInfo |
Specifies the range of histogram data in a histogram, the number of entries, and whether to encode the alpha channel. |

MPSImageKeypointRangeInfo |
Options for the discovery of keypoints in an image. |

MPSImageReadWriteParams |
Options for the reading and writing of feature channels in an image. |

MPSMatrixCopyOffsets |
Describes a copy operation that supports offsets. |

MPSOffset |
A coordinate that represents an offset. |

MPSOrigin |
A coordinate that represents the origin of a coordinate system. |

MPSRegion |
Structure that represents a region as an origin and a size. |

MPSScaleTransform |
A transformation for use with a Lanczos kernel. |

MPSSize |
A structure that represents a width, height, and depth. |

## Interfaces

IMPSCnnConvolutionDataSource |
Interface representing the required methods (if any) of the protocol MPSCnnConvolutionDataSource. |

IMPSDeviceProvider | |

IMPSHandle |
Interface describing a Metal Performance Shaders-specific identifier. |

IMPSImageAllocator |
Interface defining a factory that generates a MPSImage from a |

IMPSImageSizeEncodingState |
Interface defining methods relating to when image size is stored elsewhere in the graph. |

IMPSImageTransformProvider |
Interface defining image resampling methods. |

IMPSNNPadding |
Interface describing how kernels should pad their inputs. |

## Enums

MPSAlphaType |
Enumerates values that indicate if and what kind of color premultiplication will be applied to color values. |

MPSCnnBinaryConvolutionFlags |
Flagging enumeration for options available to binary convolution kernels. |

MPSCnnBinaryConvolutionType |
Enumerates the operation used in a binary convolution. |

MPSCnnConvolutionFlags |
Developers should not use this deprecated class. |

MPSCnnNeuronType |
Enumerates the available activation functions of a neuron. |

MPSDataLayout |
Enumerates whether a data buffer is row- or column-major |

MPSDataType |
Enumerates values that specify floating point data types. |

MPSImageEdgeMode |
Enumerates shader behavior at the edges of regions and images. |

MPSImageFeatureChannelFormat |
Enumerates image channel descriptions. |

MPSKernelOptions |
Enumerates ORable kernel options that improve performance in certain cases. |

MPSMatrixDecompositionStatus |
Enumerates the result forms of a matrix decomposition. |

MPSNNPaddingMethod |
Options for how a neural network graph will pad results. |

MPSPurgeableState |
Enumerates an image's underlying texture's purgeable state. |

MPSRnnBidirectionalCombineMode |
Enumerates how input matrices or images should be combined in a recurrent neural net. |

MPSRnnSequenceDirection |
Enumerates the propagation direction in a layer in a recurrent neural net. |

## Delegates

MPSCopyAllocator |
Commands to copy a source texture to a new location. Used for out-of-place filters. |

## Remarks

The Metal Performance Shaders namespace defines the MPSKernel class and a number of subclasses that provide highly-optimized shaders tuned for available GPU hardware.

## Feedback

Send feedback about:

Loading feedback...