Skip to content

MetalPerformanceShadersGraph tvOS xcode13.3 beta1

Alex Soto edited this page Jan 27, 2022 · 1 revision

#MetalPerformanceShadersGraph.framework

diff -ruN /Applications/Xcode_13.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraph.h /Applications/Xcode_13.3.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraph.h
--- /Applications/Xcode_13.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraph.h	2021-11-19 10:26:30.000000000 -0500
+++ /Applications/Xcode_13.3.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraph.h	2022-01-25 13:03:46.000000000 -0500
@@ -36,6 +36,19 @@
     MPSGraphOptionsDefault                                         MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))                      =   MPSGraphOptionsSynchronizeResults,
 };
 
+/*!
+ *  @typedef    MPSGraphOptimization
+ *  @abstract   Optimization levels
+ *
+ *  @constant   MPSGraphOptimizationLevel0                               Default optimizations
+ *  @constant   MPSGraphOptimizationLevel1                               Additional Optimizations
+ */
+typedef NS_ENUM(uint64_t, MPSGraphOptimization)
+{
+    MPSGraphOptimizationLevel0                        MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4)) MPS_SWIFT_NAME(level0) =   0,
+    MPSGraphOptimizationLevel1                        MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4))                        =   1L,
+};
+
 /*! @abstract   A dictionary of tensors and correspondiing tensorData for them
  */
 MPS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@@ -60,6 +73,25 @@
 typedef void (^MPSGraphScheduledHandler)(MPSGraphTensorDataDictionary * resultsDictionary,
                                          NSError * _Nullable error);
 
+/*! @class      MPSGraphCompilationDescriptor
+ *  @abstract   A structure which consists of all the levers users can use to compile their graphs
+ *
+ */
+MPS_CLASS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
+@interface MPSGraphCompilationDescriptor : NSObject <NSCopying>
+
+/*!
+ *  @brief Turns off type inference and we rely on type inference during runtime
+ */
+-(void) disableTypeInference;
+
+/*! @property   optimizationLevel
+ *  @discussion optimization level for the graph execution, default is MPSGraphOptimizationLevel0
+ */
+@property (readwrite, nonatomic) MPSGraphOptimization optimizationLevel MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
+
+@end
+
 /*! @class      MPSGraphExecutionDescriptor
  *  @abstract   A structure which consists of all the levers users can use to synchronize and schedule their graph execution
  *
@@ -82,21 +114,11 @@
  */
 @property (readwrite, atomic) BOOL waitUntilCompleted;
 
-
-@end
-
-
-/*! @class      MPSGraphCompilationDescriptor
- *  @abstract   A structure which consists of all the levers users can use to compile their graphs
- *
- */
-MPS_CLASS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
-@interface MPSGraphCompilationDescriptor : NSObject
-
-/*!
- *  @brief Turns off type inference and we rely on type inference during runtime
+/*! @property   compilationDescriptor
+ *  @discussion compilationDescriptor for the graph, default value is nil
  */
--(void) disableTypeInference;
+@property (readwrite, atomic, copy, nullable) MPSGraphCompilationDescriptor *compilationDescriptor
+MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
 
 @end
 
diff -ruN /Applications/Xcode_13.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphDevice.h /Applications/Xcode_13.3.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphDevice.h
--- /Applications/Xcode_13.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphDevice.h	2021-11-19 09:40:47.000000000 -0500
+++ /Applications/Xcode_13.3.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphDevice.h	2022-01-25 13:13:24.000000000 -0500
@@ -37,7 +37,7 @@
 @property (readonly, nonatomic, nullable) id<MTLDevice> metalDevice;
 
 /*!
- *  @abstract   Creates a MEtal MPSGraphDevice from a MTLDevice
+ *  @abstract   Creates a Metal MPSGraphDevice from a MTLDevice
  *
  *  @param      metalDevice                                           MTLDevice to create an MPSGraphDevice from
  *  @return     A valid MPSGraphDevice
diff -ruN /Applications/Xcode_13.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphPoolingOps.h /Applications/Xcode_13.3.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphPoolingOps.h
--- /Applications/Xcode_13.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphPoolingOps.h	2021-11-19 10:26:29.000000000 -0500
+++ /Applications/Xcode_13.3.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphPoolingOps.h	2022-01-25 13:03:44.000000000 -0500
@@ -13,6 +13,34 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
+/*!
+ *  @typedef    MPSGraphPoolingReturnIndicesMode
+ *  @abstract   Flattening mode for returned indices with max pooling
+ *
+ *  @constant   MPSGraphPoolingReturnIndicesNone                            No indices returned
+ *  @constant   MPSGraphPoolingReturnIndicesGlobalFlatten1D           Return indices flattened in inner most (last) dimension
+ *  @constant   MPSGraphPoolingReturnIndicesGlobalFlatten2D           Return indices flattened in 2 innermost dimensions. eg: HW in NCHW
+ *  @constant   MPSGraphPoolingReturnIndicesGlobalFlatten3D           Return indices flattened in 3 innernost dimensions. eg: HWC in NHWC
+ *  @constant   MPSGraphPoolingReturnIndicesGlobalFlatten4D           Return indices flattened in 4 innermost dimensions.
+ *  @constant   MPSGraphPoolingReturnIndicesLocalFlatten1D             Return indices within pooling window, flattened in inner most dimension
+ *  @constant   MPSGraphPoolingReturnIndicesLocalFlatten2D             Return indices within pooling window, flattened in 2 innermost dimensions. eg: HW in NCHW
+ *  @constant   MPSGraphPoolingReturnIndicesLocalFlatten3D             Return indices within pooling window, flattened in 3 innernost dimensions. eg: HWC in NHWC
+ *  @constant   MPSGraphPoolingReturnIndicesLocalFlatten4D             Return indices within pooling window, flattened in 4 innermost dimensions.
+ */
+MPS_ENUM_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3))
+typedef NS_ENUM(NSUInteger, MPSGraphPoolingReturnIndicesMode)
+{
+    MPSGraphPoolingReturnIndicesNone,
+    MPSGraphPoolingReturnIndicesGlobalFlatten1D,
+    MPSGraphPoolingReturnIndicesGlobalFlatten2D,
+    MPSGraphPoolingReturnIndicesGlobalFlatten3D,
+    MPSGraphPoolingReturnIndicesGlobalFlatten4D,
+    MPSGraphPoolingReturnIndicesLocalFlatten1D,
+    MPSGraphPoolingReturnIndicesLocalFlatten2D,
+    MPSGraphPoolingReturnIndicesLocalFlatten3D,
+    MPSGraphPoolingReturnIndicesLocalFlatten4D,
+};
+
 MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
 @interface MPSGraphPooling2DOpDescriptor : NSObject<NSCopying>
 
@@ -35,6 +63,25 @@
 @property (readwrite, nonatomic) MPSGraphPaddingStyle paddingStyle;
 @property (readwrite, nonatomic) MPSGraphTensorNamedDataLayout dataLayout;
 
+/*
+ *  @property   returnIndicesMode
+ *  @discussion Used in conjunction with maxPooling2DAndReturnIndicesWithSourceTensor API.
+ *              If MPSGraphPoolingReturnIndicesNone, returns a nil tensor for indices.
+ *              Default value: @code MPSGraphPoolingReturnIndicesNone @endcode
+ */
+@property (readwrite, nonatomic) MPSGraphPoolingReturnIndicesMode returnIndicesMode
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3));
+
+/*
+ *  @property   returnIndicesDataType
+ *  @discussion Used in conjunction with maxPooling4DAndReturnIndicesWithSourceTensor API.
+ *              If MPSGraphPoolingReturnIndicesNone, this property is not used.
+ *              Currently supports MPSDataTypeInt32
+ *              Default value: @code MPSDataTypeInt32 @endcode
+ */
+@property (readwrite, nonatomic) MPSDataType returnIndicesDataType
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3));
+
 /*!
  *  @property   ceilMode
  *  @discussion If set then the output size is computed by rounding up instead of down when
@@ -143,6 +190,24 @@
  */
 @property (readwrite, nonatomic) BOOL includeZeroPadToAverage;
 
+/*
+ *  @property   returnIndicesMode
+ *  @discussion Used in conjunction with maxPooling4DAndReturnIndicesWithSourceTensor API.
+ *              If MPSGraphPoolingReturnIndicesNone, returns a nil tensor for indices.
+ *              Default value: @code MPSGraphPoolingReturnIndicesNone @endcode
+ */
+@property (readwrite, nonatomic) MPSGraphPoolingReturnIndicesMode returnIndicesMode
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3));
+
+/*
+ *  @property   returnIndicesDataType
+ *  @discussion Used in conjunction with maxPooling4DAndReturnIndicesWithSourceTensor API.
+ *              If MPSGraphPoolingReturnIndicesNone, this property is not used.
+ *              Currently supports MPSDataTypeInt32
+ *              Default value: @code MPSDataTypeInt32 @endcode
+ */
+@property (readwrite, nonatomic) MPSDataType returnIndicesDataType
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3));
 
 /*!
  *  @abstract   Creates a 4d pooling descriptor with given values.
@@ -177,6 +242,21 @@
                                       descriptor:(MPSGraphPooling2DOpDescriptor *) descriptor
                                             name:(NSString * _Nullable) name;
 
+/*!
+ *  @abstract   MaxPool2D API that returns max pool result and corresponding indices
+ *  @param      source               Source tensor on which pooling will be performed
+ *  @param      descriptor      See corresponding property above.
+ *  @return     NSArray of 2 MPSGraphTensors. The first tensor holds the result of max pool and the second tensor holds the corresponding indices
+ *  @discussion In order to compute the indices, returnIndicesMode of the descriptor must be set. The datatype of indices tensor can be set using returnIndicesDataType
+ *              If returnIndicesMode is set to default value of MPSGraphPoolingReturnIndicesNone, the second tensor in returned NSArray is nil.
+ *              If returnIndicesDataType is not set, indices tensor will default to MPSDataTypeInt32
+ */
+-(NSArray<MPSGraphTensor *> *) maxPooling2DReturnIndicesWithSourceTensor:(MPSGraphTensor *) source
+                                                              descriptor:(MPSGraphPooling2DOpDescriptor *) descriptor
+                                                                    name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( maxPooling2DReturnIndices(_:descriptor:name:))
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3));
+
 -(MPSGraphTensor *) maxPooling2DGradientWithGradientTensor:(MPSGraphTensor *) gradient
                                               sourceTensor:(MPSGraphTensor *) source
                                                 descriptor:(MPSGraphPooling2DOpDescriptor *) descriptor
@@ -198,6 +278,21 @@
 MPS_SWIFT_NAME( maxPooling4D(_:descriptor:name:))
 MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0));
 
+/*!
+ *  @abstract   MaxPool4D API that returns max pool result and corresponding indices
+ *  @param      source               Source tensor on which pooling will be performed
+ *  @param      descriptor      See corresponding property above.
+ *  @return     NSArray of 2 MPSGraphTensors. The first tensor holds the result of max pool and the second tensor holds the corresponding indices
+ *  @discussion In order to compute the indices, returnIndicesMode of the descriptor must be set. The datatype of indices tensor can be set using returnIndicesDataType
+ *              If returnIndicesMode is set to default value of MPSGraphPoolingReturnIndicesNone, the second tensor in returned NSArray is nil.
+ *              If returnIndicesDataType is not set, indices tensor will default to MPSDataTypeInt32
+ */
+-(NSArray<MPSGraphTensor *> *) maxPooling4DReturnIndicesWithSourceTensor:(MPSGraphTensor *) source
+                                                              descriptor:(MPSGraphPooling4DOpDescriptor *) descriptor
+                                                                    name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( maxPooling4DReturnIndices(_:descriptor:name:))
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3));
+
 -(MPSGraphTensor *) maxPooling4DGradientWithGradientTensor:(MPSGraphTensor *) gradient
                                               sourceTensor:(MPSGraphTensor *) source
                                                 descriptor:(MPSGraphPooling4DOpDescriptor *) descriptor
diff -ruN /Applications/Xcode_13.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphRNNOps.h /Applications/Xcode_13.3.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphRNNOps.h
--- /Applications/Xcode_13.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphRNNOps.h	1969-12-31 19:00:00.000000000 -0500
+++ /Applications/Xcode_13.3.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphRNNOps.h	2022-01-25 13:13:24.000000000 -0500
@@ -0,0 +1,211 @@
+//
+//  MPSGraphRNNOps.h
+//  MPSGraphRNNOps
+//
+//  Created by trantalaiho on 9/29/21.
+//  Copyright © 2021 Apple Inc. All rights reserved.
+//
+
+#ifndef MPSGraphRNNOps_h
+#define MPSGraphRNNOps_h
+
+
+#import <MetalPerformanceShadersGraph/MPSGraph.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/*!
+ *  @typedef    MPSGraphRNNActivation
+ *  @abstract   Activation mode for RNN ops.
+ */
+typedef NS_ENUM(NSUInteger, MPSGraphRNNActivation)
+{
+    MPSGraphRNNActivationNone           MPS_ENUM_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3)) MPS_SWIFT_NAME(none)   =  0L,
+    MPSGraphRNNActivationRelu           MPS_ENUM_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3)),
+    MPSGraphRNNActivationTanh           MPS_ENUM_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3)),
+    MPSGraphRNNActivationSigmoid        MPS_ENUM_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3)),
+    MPSGraphRNNActivationHardSigmoid    MPS_ENUM_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3)),
+};
+
+
+MPS_CLASS_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3))
+@interface MPSGraphSingleGateRNNDescriptor : NSObject<NSCopying>
+
+/*!
+ *  @property   reverse
+ *  @discussion If set then the input sequence is passed in reverse time order to the layer.
+ *              Note: Ignored when @code bidirectional = YES @endcode.
+ *              Default value: @code NO @endcode
+ */
+@property (readwrite, nonatomic) BOOL reverse;
+
+/*!
+ *  @property   bidirectional
+ *  @discussion If set then the input sequence is traversed in both directions and the two results
+ *              are concatenated together on the channel-axis.
+ *              Default value: @code NO @endcode
+ */
+@property (readwrite, nonatomic) BOOL bidirectional;
+
+
+/*!
+ *  @property   training
+ *  @discussion If set then the layer will produce training state tensor as a secondary output.
+ *              Default value: @code NO @endcode
+ */
+@property (readwrite, nonatomic) BOOL training;
+
+/*!
+ *  @property   activation
+ *  @discussion Activation function to use with the RNN op.
+ *              Default value: @code MPSGraphRNNActivationRelu @endcode
+ */
+@property (readwrite, nonatomic) MPSGraphRNNActivation activation;
+
++(nullable instancetype) descriptor;
+
+@end
+
+MPS_CLASS_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3))
+@interface MPSGraph(MPSGraphRNNOps)
+
+/*!
+ *  @abstract   Create a single-gate RNN op and return the value and optionally training state tensor.
+ *  @discussion This operation returns tensors `h` and optionally `z` that are defined recursively as follows:
+ *              @code
+ *                for t = 0 to T-1
+ *                   z[t] = x[t] W^T + (h[t-1] * m) R^T + b
+ *                   h[t] = activation( z[t] ), where
+ *              @endcode
+ *              `W` is optional @ref inputWeight, `R` is @ref recurrentWeight, `b` is @ref bias, `m` is optional @mask,
+ *              `x[t]` is @ref source `h[t]` is the first output, `z[t]` is the second output (optional) and `h[-1]` is @ref initState.
+ *              See @ref MPSGraphSingleGateRNNDescriptor for different `activation` options.
+ *
+ *  @param      source                          Tensor containing the source data `x[t]` - shape should be [T,N,I].
+ *                                In case `inputWeight = nil` and `bidirectional = NO` then the layout is [T,N,H]
+ *                                and for `inputWeight = nil` and `bidirectional = YES` the layout is [T,N,2H].
+ *  @param      recurrentWeight      Tensor containing the recurrent weights `R`.
+ *                                For `bidirectional` the layout is [2,H,H] and otherwise it is [H,H].
+ *  @param      inputWeight               Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix.
+ *                                For `bidirectional` the layout is [2H,I] and otherwise it is [H,I].
+ *  @param      bias                               Tensor containing the bias `b` - optional, if missing assumes zeroes.
+ *                                For `bidirectional` the layout is [2H] and otherwise it is [H].
+ *  @param      initState                    Initial internal state of the RNN `h[-1]` - optional, if missing assumes zeroes.
+ *                                For `bidirectional` the layout is [N,2H] and otherwise it is [N,H].
+ *  @param      mask                               Tensor containing the mask `m` - optional, if missing assumes ones. Useful for dropout.
+ *  @param      descriptor                  The RNN op definition.
+ *  @param      name                               The name for the operation.
+ *
+ *  @return     A valid MPSGraphTensor array of size 1 or 2, depending on value of @ref  `descriptor.training`.
+ *              The layout of the both outputs are [T,N,H] or [T,N,2H] for bidirectional.
+ */
+
+-(NSArray<MPSGraphTensor *> *) singleGateRNNWithSourceTensor:(MPSGraphTensor *) source
+                                             recurrentWeight:(MPSGraphTensor *) recurrentWeight
+                                                 inputWeight:(MPSGraphTensor * _Nullable) inputWeight
+                                                        bias:(MPSGraphTensor * _Nullable) bias
+                                                   initState:(MPSGraphTensor * _Nullable) initState
+                                                        mask:(MPSGraphTensor * _Nullable) mask
+                                                  descriptor:(MPSGraphSingleGateRNNDescriptor *) descriptor
+                                                        name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( singleGateRNN(_:recurrentWeight:inputWeight:bias:initState:mask:descriptor:name:))
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3));
+
+-(NSArray<MPSGraphTensor *> *) singleGateRNNWithSourceTensor:(MPSGraphTensor *) source
+                                             recurrentWeight:(MPSGraphTensor *) recurrentWeight
+                                                 inputWeight:(MPSGraphTensor * _Nullable) inputWeight
+                                                        bias:(MPSGraphTensor * _Nullable) bias
+                                                   initState:(MPSGraphTensor * _Nullable) initState
+                                                  descriptor:(MPSGraphSingleGateRNNDescriptor *) descriptor
+                                                        name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( singleGateRNN(_:recurrentWeight:inputWeight:bias:initState:descriptor:name:))
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3));
+
+-(NSArray<MPSGraphTensor *> *) singleGateRNNWithSourceTensor:(MPSGraphTensor *) source
+                                             recurrentWeight:(MPSGraphTensor *) recurrentWeight
+                                                   initState:(MPSGraphTensor * _Nullable) initState
+                                                  descriptor:(MPSGraphSingleGateRNNDescriptor *) descriptor
+                                                        name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( singleGateRNN(_:recurrentWeight:initState:descriptor:name:))
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3));
+
+/*!
+ *  @abstract   Create a single-gate RNN gradient op and return the gradient tensor values.
+ *
+ *  @param      source                          Tensor containing the source data `x[t]` - shape should be [T,N,I].
+ *                                In case `inputWeight = nil` and `bidirectional = NO` then the layout is [T,N,H]
+ *                                and for `inputWeight = nil` and `bidirectional = YES` the layout is [T,N,2H].
+ *  @param      recurrentWeight      Tensor containing the recurrent weights `R`.
+ *                                For `bidirectional` the layout is [2,H,H] and otherwise it is [H,H].
+ *                                Note: For `bidirectional` this tensor must have a static shape.
+ *  @param      sourceGradient         Input gradient, that is gradient of a tensor wrt. to first output of the forward pass.
+ *  @param      zState                          The second output of `singleGateRNNWithSourceTensor` with @ref `descriptor.training = true`.
+ *  @param      stateGradient           Input gradient coming from the future timestep - optional, if missing assumes zeroes.
+ *  @param      inputWeight               Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix.
+ *                                For `bidirectional` the layout is [2H,I] and otherwise it is [H,I].
+ *  @param      bias                               Tensor containing the bias `b` - optional, if missing assumes zeroes.
+ *                                For `bidirectional` the layout is [2H] and otherwise it is [H].
+ *  @param      initState                    Initial internal state of the RNN `h[-1]` - optional, if missing assumes zeroes.
+ *                                For `bidirectional` the layout is [N,2H] and otherwise it is [N,H].
+ *  @param      mask                               Tensor containing the mask `m` - optional, if missing assumes ones. Useful for dropout.
+ *  @param      descriptor                  The RNN op definition.
+ *  @param      name                               The name for the operation.
+ *
+ *  @return     A valid MPSGraphTensor array containing gradients for each input tensor, except for `sourceGradient` and `mask`.
+ *              In case an input is nil, no gradient will be returned for it.
+ *              The order of the gradients will be: for source, for recurrentWeight, for inputWeight, for bias, for initState.
+ */
+
+-(NSArray<MPSGraphTensor *> *) singleGateRNNGradientsWithSourceTensor:(MPSGraphTensor *) source
+                                                      recurrentWeight:(MPSGraphTensor *) recurrentWeight
+                                                       sourceGradient:(MPSGraphTensor *) sourceGradient
+                                                               zState:(MPSGraphTensor *) zState
+                                                        stateGradient:(MPSGraphTensor * _Nullable) stateGradient
+                                                          inputWeight:(MPSGraphTensor * _Nullable) inputWeight
+                                                                 bias:(MPSGraphTensor * _Nullable) bias
+                                                            initState:(MPSGraphTensor * _Nullable) initState
+                                                                 mask:(MPSGraphTensor * _Nullable) mask
+                                                           descriptor:(MPSGraphSingleGateRNNDescriptor *) descriptor
+                                                                 name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( singleGateRNNGradients(_:recurrentWeight:sourceGradient:zState:stateGradient:inputWeight:bias:initState:mask:descriptor:name:))
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3));
+
+-(NSArray<MPSGraphTensor *> *) singleGateRNNGradientsWithSourceTensor:(MPSGraphTensor *) source
+                                                      recurrentWeight:(MPSGraphTensor *) recurrentWeight
+                                                       sourceGradient:(MPSGraphTensor *) sourceGradient
+                                                               zState:(MPSGraphTensor *) zState
+                                                          inputWeight:(MPSGraphTensor * _Nullable) inputWeight
+                                                                 bias:(MPSGraphTensor * _Nullable) bias
+                                                            initState:(MPSGraphTensor * _Nullable) initState
+                                                                 mask:(MPSGraphTensor * _Nullable) mask
+                                                           descriptor:(MPSGraphSingleGateRNNDescriptor *) descriptor
+                                                                 name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( singleGateRNNGradients(_:recurrentWeight:sourceGradient:zState:inputWeight:bias:initState:mask:descriptor:name:))
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3));
+
+-(NSArray<MPSGraphTensor *> *) singleGateRNNGradientsWithSourceTensor:(MPSGraphTensor *) source
+                                                      recurrentWeight:(MPSGraphTensor *) recurrentWeight
+                                                       sourceGradient:(MPSGraphTensor *) sourceGradient
+                                                               zState:(MPSGraphTensor *) zState
+                                                          inputWeight:(MPSGraphTensor * _Nullable) inputWeight
+                                                                 bias:(MPSGraphTensor * _Nullable) bias
+                                                            initState:(MPSGraphTensor * _Nullable) initState
+                                                           descriptor:(MPSGraphSingleGateRNNDescriptor *) descriptor
+                                                                 name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( singleGateRNNGradients(_:recurrentWeight:sourceGradient:zState:inputWeight:bias:initState:descriptor:name:))
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3));
+
+-(NSArray<MPSGraphTensor *> *) singleGateRNNGradientsWithSourceTensor:(MPSGraphTensor *) source
+                                                      recurrentWeight:(MPSGraphTensor *) recurrentWeight
+                                                       sourceGradient:(MPSGraphTensor *) sourceGradient
+                                                               zState:(MPSGraphTensor *) zState
+                                                            initState:(MPSGraphTensor * _Nullable) initState
+                                                           descriptor:(MPSGraphSingleGateRNNDescriptor *) descriptor
+                                                                 name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( singleGateRNNGradients(_:recurrentWeight:sourceGradient:zState:initState:descriptor:name:))
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3));
+
+@end
+
+NS_ASSUME_NONNULL_END
+#endif /* MPSGraphRNNOps_h */
diff -ruN /Applications/Xcode_13.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphReductionOps.h /Applications/Xcode_13.3.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphReductionOps.h
--- /Applications/Xcode_13.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphReductionOps.h	2021-11-19 10:23:23.000000000 -0500
+++ /Applications/Xcode_13.3.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphReductionOps.h	2022-01-25 13:00:35.000000000 -0500
@@ -201,6 +201,64 @@
                                              name:(NSString *_Nullable)name
 MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), macCatalyst(15.0), tvos(15.0));
 
+/*!
+ *  @abstract   Create  reduction and op and return the result tensor.
+ *
+ *  @param      tensor          input tensor
+ *  @param      axis              axis of reduction
+ *  @param      name              name for the operation
+ *
+ *  @return     A valid MPSGraphTensor object.
+ */
+-(MPSGraphTensor *) reductionAndWithTensor:(MPSGraphTensor *) tensor
+                                      axis:(NSInteger) axis
+                                      name:(NSString * _Nullable) name
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), macCatalyst(15.3), tvos(15.3));
+
+
+/*!
+ *  @abstract   Create  reduction and op and return the result tensor.
+ *
+ *  @param      tensor          input tensor
+ *  @param      axes              axes of reduction
+ *  @param      name              name for the operation
+ *
+ *  @return     A valid MPSGraphTensor object.
+ */
+-(MPSGraphTensor *) reductionAndWithTensor:(MPSGraphTensor *)tensor
+                                      axes:(NSArray<NSNumber *> *_Nullable)axes
+                                      name:(NSString *_Nullable)name
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), macCatalyst(15.3), tvos(15.3));
+
+/*!
+ *  @abstract   Create  reduction or op and return the result tensor.
+ *
+ *  @param      tensor          input tensor
+ *  @param      axis              axis of reduction
+ *  @param      name              name for the operation
+ *
+ *  @return     A valid MPSGraphTensor object.
+ */
+-(MPSGraphTensor *) reductionOrWithTensor:(MPSGraphTensor *) tensor
+                                     axis:(NSInteger) axis
+                                     name:(NSString * _Nullable) name
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), macCatalyst(15.3), tvos(15.3));
+
+
+/*!
+ *  @abstract   Create  reduction or op and return the result tensor.
+ *
+ *  @param      tensor          input tensor
+ *  @param      axes              axes of reduction
+ *  @param      name              name for the operation
+ *
+ *  @return     A valid MPSGraphTensor object.
+ */
+-(MPSGraphTensor *) reductionOrWithTensor:(MPSGraphTensor *)tensor
+                                     axes:(NSArray<NSNumber *> *_Nullable)axes
+                                     name:(NSString *_Nullable)name
+MPS_AVAILABLE_STARTING(macos(12.2), ios(15.3), macCatalyst(15.3), tvos(15.3));
+
 @end
 
 NS_ASSUME_NONNULL_END
diff -ruN /Applications/Xcode_13.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphTensorShapeOps.h /Applications/Xcode_13.3.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphTensorShapeOps.h
--- /Applications/Xcode_13.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphTensorShapeOps.h	2021-11-19 10:23:23.000000000 -0500
+++ /Applications/Xcode_13.3.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphTensorShapeOps.h	2022-01-25 12:57:41.000000000 -0500
@@ -427,6 +427,80 @@
                          name:(NSString *)name
 MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0));
 
+/*!
+ *  @abstract   Create stack op and return the result
+ *  @discussion Stacks all input tensors along `axis` into a result tensor of rank + 1. Tensors must be broadcast
+ *              compatible along all dimensions, and have the same type.
+ *
+ *  @param      inputTensors        Input tensors
+ *  @param      axis            The dimension to stack tensors into result. Must be in range - rank + 1 <= dimension < rank + 1
+ *  @param      name            The name for the operation
+ *
+ *  @return     A valid MPSGraphTensor object
+ */
+-(MPSGraphTensor *) stackTensors:(NSArray<MPSGraphTensor *> *) inputTensors
+                            axis:(NSInteger) axis
+                            name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( stack(_:axis:name:) )
+MPS_AVAILABLE_STARTING(macos(12.4), ios(15.4), tvos(15.4));
+
+/*!
+ *  @abstract   Create split op and return the result
+ *  @discussion Splits the input tensor along `axis` into multiple result tensors of size determined by `splitSizes`.
+ *              Requires that the sum of `splitSizes` is equal to the lenth of the input along `axis`.
+ *
+ *  @param      tensor        Input tensor
+ *  @param      splitSizes        The length of the result tensors along the split axis
+ *  @param      axis        The dimension to split the input along
+ *  @param      name            The name for the operation
+ *
+ *  @return     A valid MPSGraphTensor object
+ */
+-(NSArray<MPSGraphTensor *> *) splitTensor:(MPSGraphTensor *) tensor
+                                splitSizes:(NSArray<NSNumber *> *) splitSizes
+                                      axis:(NSInteger) axis
+                                      name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( split(_:splitSizes:axis:name:) )
+MPS_AVAILABLE_STARTING(macos(12.4), ios(15.4), tvos(15.4));
+
+/*!
+ *  @abstract   Create split op and return the result
+ *  @discussion Splits the input tensor along `axis` into multiple result tensors of size determined by `splitSizes`.
+ *              Requires that the sum of `splitSizesTensor` is equal to the lenth of the input along `axis`.
+ *
+ *  @param      tensor        Input tensor
+ *  @param      splitSizesTensor        The length of the result tensors along the split axis
+ *  @param      axis        The dimension to split the input along
+ *  @param      name            The name for the operation
+ *
+ *  @return     A valid MPSGraphTensor object
+ */
+-(NSArray<MPSGraphTensor *> *) splitTensor:(MPSGraphTensor *) tensor
+                          splitSizesTensor:(MPSGraphTensor *) splitSizesTensor
+                                      axis:(NSInteger) axis
+                                      name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( split(_:splitSizesTensor:axis:name:) )
+MPS_AVAILABLE_STARTING(macos(12.4), ios(15.4), tvos(15.4));
+
+/*!
+ *  @abstract   Create split op and return the result
+ *  @discussion Splits the input tensor along `axis` into `numsplits` result tensors of equal size.
+ *              Requires that the lenth of the input along `axis` is divisible by `num_splits`.
+ *
+ *  @param      tensor        Input tensor
+ *  @param      numSplits        The number of result tensors to split to
+ *  @param      axis        The dimension to split the input along
+ *  @param      name            The name for the operation
+ *
+ *  @return     A valid MPSGraphTensor object
+ */
+-(NSArray<MPSGraphTensor *> *) splitTensor:(MPSGraphTensor *) tensor
+                                 numSplits:(NSUInteger) numSplits
+                                      axis:(NSInteger) axis
+                                      name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( split(_:numSplits:axis:name:) )
+MPS_AVAILABLE_STARTING(macos(12.4), ios(15.4), tvos(15.4));
+
 @end
 
 NS_ASSUME_NONNULL_END
Clone this wiki locally