MetalPerformanceShadersGraph compiles and runs GPU-accelerated compute and neural-network operations through Metal. You construct an MPSGraph, add operations such as 2D and 3D convolutions, pooling, recurrent layers, FFTs, and scaled dot-product attention using descriptors like MPSGraphConvolution2DOpDescriptor, MPSGraphPooling2DOpDescriptor, MPSGraphLSTMDescriptor, MPSGraphFFTDescriptor, and MPSGraphSDPADescriptor, then compile and execute it on an MPSGraphDevice. Compilation and execution are controlled through MPSGraphCompilationDescriptor and MPSGraphExecutionDescriptor, and a compiled graph can be serialized and rerun as an MPSGraphExecutable. The framework runs on iOS, macOS, tvOS, and visionOS.
Essentials 5
The core graph object and the tensors and operations that make up a compute graph.
- ClMPSGraphiOS 14.0+The optimized representation of a compute graph of operations and tensors.
- ClMPSGraphTensoriOS 14.0+The symbolic representation of a compute data type.
- ClMPSGraphTensorDataiOS 14.0+The representation of a compute data type.
- ClMPSGraphOperationiOS 14.0+A symbolic representation of a compute operation.
- ClMPSGraphVariableOpiOS 14.0+The class that defines the parameters for a variable.
Graph Object Model 3
The base classes and type descriptions shared across graph entities.
- ClMPSGraphObjectiOS 17.0+The common base class for all Metal Performance Shaders Graph objects.
- ClMPSGraphTypeiOS 15.0+The base type class for types on tensors.
- ClMPSGraphShapedTypeiOS 14.0+The shaped type class for types on tensors with a shape and data type.
Compilation and Execution 6
Descriptors and objects that compile, serialize, and run a graph on a Metal device.
- ClMPSGraphCompilationDescriptoriOS 15.0+A class that consists of all the levers for compiling graphs.
- ClMPSGraphExecutionDescriptoriOS 14.0+A class that consists of all the levers to synchronize and schedule graph execution.
- ClMPSGraphExecutableiOS 15.0+The compiled representation of a compute graph executable.
- ClMPSGraphExecutableExecutionDescriptoriOS 15.0+A class that consists of all the levers to synchronize and schedule executable execution.
- ClMPSGraphExecutableSerializationDescriptoriOS 17.0+A class that consists of all the levers to serialize an executable.
- ClMPSGraphDeviceiOS 14.0+A class that describes the compute device.
Convolution Operations 5
Descriptors that configure 2D, 3D, and depthwise convolution operations.
- ClMPSGraphConvolution2DOpDescriptoriOS 14.0+A class that describes the properties of a 2D-convolution operator.
- ClMPSGraphConvolution3DOpDescriptoriOS 16.3+A class that describes the properties of a 3D-convolution operator.
- ClMPSGraphDepthwiseConvolution2DOpDescriptoriOS 14.0+A class that defines the parameters for a 2D-depthwise convolution operation.
- ClMPSGraphDepthwiseConvolution3DOpDescriptoriOS 15.0+The class that defines the parameters for a 3D-depthwise convolution operation.
- ClMPSGraphImToColOpDescriptoriOS 17.0+The class that defines the parameters for an image to column or column to image operation.
Pooling Operations 2
Descriptors that configure 2D and 4D pooling operations.
- ClMPSGraphPooling2DOpDescriptoriOS 14.0+The class that defines the parameters for a 2D pooling operation.
- ClMPSGraphPooling4DOpDescriptoriOS 15.0+The class that defines the parameters for a 4D pooling operation.
Recurrent Operations 3
Descriptors that configure recurrent neural-network layers.
- ClMPSGraphSingleGateRNNDescriptoriOS 15.4+The class that defines the parameters for a single gate RNN operation.
- ClMPSGraphLSTMDescriptoriOS 15.4+The class that defines the parameters for a long short-term memory (LSTM) operation.
- ClMPSGraphGRUDescriptoriOS 16.0+The class that defines the parameters for a gated recurrent unit (GRU) operation.
Signal, Attention, and Specialized Operations 5
Descriptors for FFT, scaled dot-product attention, stencil, random, and sparse operations.
- ClMPSGraphFFTDescriptoriOS 17.0+The class that defines the parameters for a fast Fourier transform (FFT) operation.
- ClMPSGraphSDPADescriptoriOS 26.0+A descriptor that configures a scaled dot product attention (SDPA) operation.
- ClMPSGraphStencilOpDescriptoriOS 15.0+The class that defines the parameters for a stencil operation.
- ClMPSGraphRandomOpDescriptorA class that describes the random operation.
- ClMPSGraphCreateSparseOpDescriptoriOS 15.0+A class that describes the properties of a create sparse operation.
Tensor Layout and Padding 3
Enumerations that describe tensor data layouts and padding behavior.
- EnMPSGraphTensorNamedDataLayoutThe tensor layout.
- EnMPSGraphPaddingStyleThe tensor padding style.
- EnMPSGraphPaddingModeThe tensor padding mode.
Compilation and Device Options 7
Options and enumerations that control graph optimization, deployment, and device selection.
- EnMPSGraphOptionsThe options available to a graph.
- EnMPSGraphOptimizationThe optimization levels to trade compilation time for even more runtime performance by running more passes.
- EnMPSGraphOptimizationProfileThe optimization profile used as a heuristic as the graph compiler optimizes the network.
- EnMPSGraphExecutionStageExecution events that can be used with shared events.
- EnMPSGraphDeviceTypeThe device type.
- EnMPSGraphDeploymentPlatformThe options available to a graph.
- StMPSGraphReducedPrecisionFastMathiOS 26.0+MPSGraph could use these reduced precision paths to deliver faster math, but it is not guaranteed.
Operation Modes and Constants 12
Enumerations that select modes for reductions, resizing, scatter, FFT, random, and other operations.
- EnMPSGraphReductionModeThe reduction mode.
- EnMPSGraphFFTScalingModeThe scaling modes for Fourier transform operations.
- EnMPSGraphLossReductionTypeThe type of the reduction the graph applies in the loss operations.
- EnMPSGraphNonMaximumSuppressionCoordinateModeThe non-maximum suppression coordinate mode.
- EnMPSGraphPoolingReturnIndicesModeiOS 15.3+The flattening mode for returned indices with max-pooling.
- EnMPSGraphRNNActivationThe activation modes for RNN operations.
- EnMPSGraphRandomDistributionThe distributions supported by random operations.
- EnMPSGraphRandomNormalSamplingMethodThe sampling method to use when generating values in the normal distribution.
- EnMPSGraphResizeModeThe resize mode to use for resizing.
- EnMPSGraphResizeNearestRoundingModeThe rounding mode to use when using nearest resize mode.
- EnMPSGraphScatterModeThe scatter mode.
- EnMPSGraphSparseStorageTypeThe sparse storage options in the Metal Performance Shaders Graph framework.
Type Aliases 10
- TyMPSGraphCompletionHandlerA notification that appears when graph execution finishes.
- TyMPSGraphScheduledHandlerA notification that appears when graph execution schedules.
- TyMPSGraphCompilationCompletionHandlerA notification that appears when compilation finishes.
- TyMPSGraphControlFlowDependencyBlockThe scope where all the operations defined in this block get control-dependency operations.
- TyMPSGraphIfThenElseBlockA block of operations executed under either the if or else condition.
- TyMPSGraphWhileBeforeBlockThe block that executes before the condition evaluates for each iteration.
- TyMPSGraphWhileAfterBlockThe block that executes after the condition evaluates for each iteration.
- TyMPSGraphForLoopBodyBlockA block for the body in the for loop.
- TyMPSGraphExecutableCompletionHandlerA notification when graph executable execution finishes.
- TyMPSGraphExecutableScheduledHandlerA notification when graph executable execution schedules.