-
Notifications
You must be signed in to change notification settings - Fork 569
MetalPerformanceShadersGraph macOS xcode27.0 b1
Alex Soto edited this page Jun 9, 2026
·
1 revision
#MetalPerformanceShadersGraph.framework
diff -ruN /Applications/Xcode_26.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraph.h /Applications/Xcode_27.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraph.h
--- /Applications/Xcode_26.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraph.h 2026-04-18 23:10:17
+++ /Applications/Xcode_27.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraph.h 2026-05-21 09:32:50
@@ -118,7 +118,10 @@
-(void) disableTypeInference;
/// Turns on Automatic Layout Conversion (for conv like operations) for GPU.
+/// DEPRECATED: Layout conversion is now default, so this function is a no-op.
-(void) convertLayoutToNHWC MPS_AVAILABLE_STARTING(macos(26.4), ios(26.4), tvos(26.4));
+/// Turns off Automatic Layout Conversion (for conv like operations) for GPU.
+-(void) disableAutoLayoutConversion MPS_AVAILABLE_STARTING(macos(27.0), ios(27.0), tvos(27.0));
/// The optimization level for the graph execution, default is MPSGraphOptimizationLevel1.
@property (readwrite, nonatomic) MPSGraphOptimization optimizationLevel MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
@@ -334,6 +337,48 @@
resultsDictionary:(MPSGraphTensorDataDictionary *) resultsDictionary
executionDescriptor:(MPSGraphExecutionDescriptor * _Nullable) executionDescriptor
MPS_SWIFT_NAME( runAsync(with:feeds:targetOperations:resultsDictionary:executionDescriptor:) );
+
+#if !TARGET_IPHONE_SIMULATOR
+
+/// Runs the graph for the given feeds and returns the target tensor values, ensuring all target operations also executed.
+///
+/// This call is asynchronous and will return immediately if a completionHandler is set.
+///
+/// - Parameters:
+/// - commandQueue: MTL4CommandQueue passed to exectute the graph on.
+/// - feeds: Feeds dictionary for the placeholder tensors.
+/// - targetTensors: Tensors for which the caller wishes MPSGraphTensorData to be returned.
+/// - targetOperations: Operations to be completed at the end of the run.
+/// - executionDescriptor: ExecutionDescriptor to be passed in and used.
+/// - Returns: A valid MPSGraphTensor : MPSGraphTensorData dictionary with results synchronized to the CPU memory if MPSGraphOptionsSynchronizeResults set.
+-(MPSGraphTensorDataDictionary *) runAsyncWithMTL4CommandQueue:(id<MTL4CommandQueue>) commandQueue
+ feeds:(MPSGraphTensorDataDictionary *) feeds
+ targetTensors:(NSArray<MPSGraphTensor *> *) targetTensors
+ targetOperations:(NSArray<MPSGraphOperation *> * _Nullable) targetOperations
+ executionDescriptor:(MPSGraphExecutionDescriptor * _Nullable) executionDescriptor
+MPS_SWIFT_NAME( runAsync(on:feeds:targetTensors:targetOperations:executionDescriptor:) )
+MPS_AVAILABLE_STARTING(macos(27.0), ios(27.0));
+
+
+/// Encodes the graph for the given feeds to returns the target tensor values in the results dictionary provided by the user.
+///
+/// It ensures all target operations also executed. This call is asynchronous and will return immediately if a completionHandler is set.
+///
+/// - Parameters:
+/// - commandQueue: MTL4CommandQueue passed to exectute the graph on.
+/// - feeds: Feeds dictionary for the placeholder tensors.
+/// - targetOperations: Operations to be completed at the end of the run.
+/// - resultsDictionary: MPSGraphTensors dictionary passed by user, these will be filled with graph output data.
+/// - executionDescriptor: ExecutionDescriptor to be passed in and used.
+-(void) runAsyncWithMTL4CommandQueue:(id<MTL4CommandQueue>) commandQueue
+ feeds:(MPSGraphTensorDataDictionary *) feeds
+ targetOperations:(NSArray<MPSGraphOperation *> * _Nullable) targetOperations
+ resultsDictionary:(MPSGraphTensorDataDictionary *) resultsDictionary
+ executionDescriptor:(MPSGraphExecutionDescriptor * _Nullable) executionDescriptor
+MPS_SWIFT_NAME( runAsync(on:feeds:targetOperations:resultsDictionary:executionDescriptor:) )
+MPS_AVAILABLE_STARTING(macos(27.0), ios(27.0));
+
+#endif
/// Encodes the graph for the given feeds to returns the target tensor values, ensuring all target operations also executed.
///
diff -ruN /Applications/Xcode_26.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphExecutable.h /Applications/Xcode_27.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphExecutable.h
--- /Applications/Xcode_26.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphExecutable.h 2026-04-18 22:22:31
+++ /Applications/Xcode_27.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphExecutable.h 2026-05-29 23:54:31
@@ -181,6 +181,42 @@
executionDescriptor:(MPSGraphExecutableExecutionDescriptor * _Nullable) executionDescriptor
MPS_SWIFT_NAME( runAsync(with:inputs:results:executionDescriptor:) );
+#if !TARGET_IPHONE_SIMULATOR
+
+/// Runs the graph for the given feeds and returns the target tensor values, ensuring all target operations also executed.
+///
+/// This call is synchronous and will return on completion of execution.
+///
+/// - Parameters:
+/// - commandQueue: MTL4CommandQueue passed to exectute the graph on.
+/// - inputsArray: Feeds tensorData for the placeholder tensors, same order as arguments of main function.
+/// - resultsArray: Results tensorData for which the caller wishes MPSGraphTensorData to be returned.
+/// - Returns: A valid MPSGraphTensorData array with results synchronized to the CPU memory if MPSGraphOptionsSynchronizeResults set.
+-(NSArray<MPSGraphTensorData *> *) runWithMTL4CommandQueue:(id<MTL4CommandQueue>) commandQueue
+ inputsArray:(NSArray<MPSGraphTensorData *> *) inputsArray
+ resultsArray:(NSArray<MPSGraphTensorData *> * _Nullable) resultsArray
+ executionDescriptor:(MPSGraphExecutableExecutionDescriptor * _Nullable) executionDescriptor
+MPS_SWIFT_NAME( run(on:inputs:results:executionDescriptor:) )
+MPS_AVAILABLE_STARTING(macos(27.0), ios(27.0));
+
+/// Runs the graph for the given feeds and returns the target tensor values, ensuring all target operations also executed.
+/// This call is asynchronous and will return immediately.
+///
+/// - Parameters:
+/// - commandQueue: MTL4CommandQueue passed to exectute the graph on.
+/// - inputsArray: Feeds tensorData for the placeholder tensors, same order as arguments of main function.
+/// - resultsArray: Tensors for which the caller wishes MPSGraphTensorData to be returned.
+/// - executionDescriptor: ExecutionDescriptor to be passed in and used.
+/// - Returns: A valid MPSGraphTensorData array with results synchronized to the CPU memory if MPSGraphOptionsSynchronizeResults set.
+-(NSArray<MPSGraphTensorData *> *) runAsyncWithMTL4CommandQueue:(id<MTL4CommandQueue>) commandQueue
+ inputsArray:(NSArray<MPSGraphTensorData *> *) inputsArray
+ resultsArray:(NSArray<MPSGraphTensorData *> * _Nullable) resultsArray
+ executionDescriptor:(MPSGraphExecutableExecutionDescriptor * _Nullable) executionDescriptor
+MPS_SWIFT_NAME( runAsync(on:inputs:results:executionDescriptor:) )
+MPS_AVAILABLE_STARTING(macos(27.0), ios(27.0));;
+
+#endif
+
/// Runs the graph for the given feeds and returns the target tensor values, ensuring all target operations also executed.
/// This call is asynchronous and will return immediately after finishing encoding.
///
diff -ruN /Applications/Xcode_26.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphFourierTransformOps.h /Applications/Xcode_27.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphFourierTransformOps.h
--- /Applications/Xcode_26.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphFourierTransformOps.h 2026-04-18 22:22:16
+++ /Applications/Xcode_27.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphFourierTransformOps.h 2026-05-30 00:40:17
@@ -149,11 +149,11 @@
/// the result tensor back with the inverse of the input transpose.
///
/// - Parameters:
-/// - tensor: A Real-valued input tensor. Must have datatype `MPSDataTypeFloat32` or `MPSDatatypeFloat16`.
+/// - tensor: A Real-valued input tensor. Must have datatype `MPSDataTypeFloat32`, `MPSDatatypeFloat16` or `MPSDatatypeBFloat16`.
/// - axes: An array of numbers that specifies over which axes MPSGraph performs the Fourier transform - all axes must be contained within last four dimensions of the input tensor.
/// - descriptor: A descriptor that defines the parameters of the Fourier transform operation - see ``MPSGraphFFTDescriptor``.
/// - name: The name for the operation.
-/// - Returns: A valid MPSGraphTensor of type `MPSDataTypeComplexFloat32` or `MPSDataTypeComplexFloat16` with reduced size (see Discussion).
+/// - Returns: A valid MPSGraphTensor of type `MPSDataTypeComplexFloat32`, `MPSDataTypeComplexFloat16` or `MPSDataTypeComplexBFloat16` with reduced size (see Discussion).
-(MPSGraphTensor *) realToHermiteanFFTWithTensor:(MPSGraphTensor *) tensor
axes:(NSArray<NSNumber *> *) axes
descriptor:(MPSGraphFFTDescriptor *) descriptor
@@ -184,11 +184,11 @@
/// the result tensor back with the inverse of the input transpose.
///
/// - Parameters:
-/// - tensor: A real-valued input tensor. Must have datatype `MPSDataTypeFloat32` or `MPSDatatypeFloat16`.
+/// - tensor: A real-valued input tensor. Must have datatype `MPSDataTypeFloat32` , `MPSDatatypeFloat16`, or `MPSDatatypeBFloat16`.
/// - axesTensor: A tensor of rank one containing the axes over which MPSGraph performs the transformation. See ``MPSGraph/fastFourierTransformWithTensor:axes:descriptor:name:``.
/// - descriptor: A descriptor that defines the parameters of the Fourier transform operation - see ``MPSGraphFFTDescriptor``.
/// - name: The name for the operation.
-/// - Returns: A valid MPSGraphTensor of type `MPSDataTypeComplexFloat32` or `MPSDataTypeComplexFloat16` with reduced size (see Discussion).
+/// - Returns: A valid MPSGraphTensor of type `MPSDataTypeComplexFloat32`, `MPSDataTypeComplexFloat16` or `MPSDataTypeComplexBFloat16` with reduced size (see Discussion).
-(MPSGraphTensor *) realToHermiteanFFTWithTensor:(MPSGraphTensor *) tensor
axesTensor:(MPSGraphTensor *) axesTensor
descriptor:(MPSGraphFFTDescriptor *) descriptor
@@ -221,11 +221,11 @@
/// the result tensor back with the inverse of the input transpose.
///
/// - Parameters:
-/// - tensor: A complex-valued input tensor with reduced size (see Discussion). Must have datatype `MPSDataTypeComplexFloat32` or `MPSDataTypeComplexFloat16`.
+/// - tensor: A complex-valued input tensor with reduced size (see Discussion). Must have datatype `MPSDataTypeComplexFloat32`, `MPSDataTypeComplexFloat16` or `MPSDataTypeComplexBFloat16`.
/// - axes: An array of numbers that specifies over which axes MPSGraph performs the Fourier transform - all axes must be contained within last four dimensions of the input tensor.
/// - descriptor: A descriptor that defines the parameters of the Fourier transform operation - see ``MPSGraphFFTDescriptor``.
/// - name: The name for the operation.
-/// - Returns: A valid MPSGraphTensor of type `MPSDataTypeFloat32` or `MPSDataTypeFloat16` (full size).
+/// - Returns: A valid MPSGraphTensor of type `MPSDataTypeFloat32`, `MPSDataTypeFloat16` or `MPSDataTypeBFloat16` (full size).
-(MPSGraphTensor *) HermiteanToRealFFTWithTensor:(MPSGraphTensor *) tensor
axes:(NSArray<NSNumber *> *) axes
descriptor:(MPSGraphFFTDescriptor *) descriptor
@@ -259,11 +259,11 @@
/// the result tensor back with the inverse of the input transpose.
///
/// - Parameters:
-/// - tensor: A complex-valued input tensor with reduced size (see Discussion). Must have datatype `MPSDataTypeComplexFloat32` or `MPSDataTypeComplexFloat16`.
+/// - tensor: A complex-valued input tensor with reduced size (see Discussion). Must have datatype `MPSDataTypeComplexFloat32`, `MPSDataTypeComplexFloat16` or `MPSDataTypeComplexBFloat16`.
/// - axesTensor: A tensor of rank one containing the axes over which MPSGraph performs the transformation. See ``MPSGraph/fastFourierTransformWithTensor:axes:descriptor:name:``.
/// - descriptor: A descriptor that defines the parameters of the Fourier transform operation - see ``MPSGraphFFTDescriptor``.
/// - name: The name for the operation.
-/// - Returns: A valid MPSGraphTensor of type `MPSDataTypeFloat32` or `MPSDataTypeFloat16` (full size).
+/// - Returns: A valid MPSGraphTensor of type `MPSDataTypeFloat32`, `MPSDataTypeFloat16` or `MPSDataTypeBFloat16` (full size).
-(MPSGraphTensor *) HermiteanToRealFFTWithTensor:(MPSGraphTensor *) tensor
axesTensor:(MPSGraphTensor *) axesTensor
descriptor:(MPSGraphFFTDescriptor *) descriptor
diff -ruN /Applications/Xcode_26.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMatrixMultiplicationOps.h /Applications/Xcode_27.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMatrixMultiplicationOps.h
--- /Applications/Xcode_26.5.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMatrixMultiplicationOps.h 2026-04-18 22:22:17
+++ /Applications/Xcode_27.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMatrixMultiplicationOps.h 2026-05-23 03:56:39
@@ -13,6 +13,38 @@
NS_ASSUME_NONNULL_BEGIN
+/// A descriptor that configures a scaled dot product attention (SDPA) operation.
+///
+/// Use this descriptor with
+/// ``MPSGraph/scaledDotProductAttentionWithQueryTensor:keyTensor:valueTensor:descriptor:name:``
+/// to specify optional features such as an attention mask, causal masking, and attention sinks.
+MPS_CLASS_AVAILABLE_STARTING(macos(26.0), ios(26.0), macCatalyst(26.0), tvos(26.0))
+@interface MPSGraphSDPADescriptor : MPSGraphObject
+
+/// The scale applied to the result of the query–key matrix multiply before softmax.
+/// Typically set to ``1/sqrt(headDimension)``.
+@property(nonatomic) float scale;
+
+/// An optional additive mask tensor applied to the scaled QK^T scores before softmax.
+/// Must be broadcast-compatible with shape ``[batch, heads, T_q, T_kv]``.
+/// Mutually exclusive with ``isCausal``.
+@property(nonatomic, nullable) MPSGraphTensor *maskTensor;
+
+/// When YES, a causal (lower-triangular) mask is applied so that each query position
+/// attends only to key positions at or before it. Mutually exclusive with ``maskTensor``.
+@property(nonatomic) BOOL isCausal;
+
+/// An optional attention-sinks tensor of shape ``[nHeads]``. Each element seeds the
+/// online-softmax accumulator for the corresponding query head with a virtual token logit,
+/// causing real-token attention weights to sum to less than one.
+@property(nonatomic, nullable) MPSGraphTensor *sinksTensor;
+
+/// Creates a descriptor with the given scale and all other properties set to their defaults
+/// (no mask, isCausal = NO, no sinks).
++ (instancetype)descriptorWithScale:(float)scale;
+
+@end
+
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MPSGraphMatrixMultiplicationOps)
@@ -88,6 +120,26 @@
name:(NSString *_Nullable)name
MPS_SWIFT_NAME(scaledDotProductAttention(query:key:value:scale:name:) )
MPS_AVAILABLE_STARTING(macos(15.0), ios(18.0), macCatalyst(18.0), tvos(18.0));
+
+/// Creates a scaled dot product attention (SDPA) operation using a descriptor and returns the result tensor.
+///
+/// The descriptor allows configuring an optional attention mask, causal masking, and attention sinks
+/// without requiring a separate API method for each combination of features.
+///
+/// - Parameters:
+/// - queryTensor: A tensor that represents the query projection.
+/// - keyTensor: A tensor that represents the key projection.
+/// - valueTensor: A tensor that represents the value projection.
+/// - descriptor: A descriptor specifying scale and optional features (mask, isCausal, sinks).
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object.
+- (MPSGraphTensor *)scaledDotProductAttentionWithQueryTensor:(MPSGraphTensor *)queryTensor
+ keyTensor:(MPSGraphTensor *)keyTensor
+ valueTensor:(MPSGraphTensor *)valueTensor
+ descriptor:(MPSGraphSDPADescriptor *)descriptor
+ name:(NSString *_Nullable)name
+ MPS_SWIFT_NAME(scaledDotProductAttention(query:key:value:descriptor:name:))
+ MPS_AVAILABLE_STARTING(macos(26.0), ios(26.0), macCatalyst(26.0), tvos(26.0));
@end