Skip to content

MPSCore tvOS xcode16.0 b1

Rolf Bjarne Kvinge edited this page Aug 30, 2024 · 3 revisions

#MPSCore.framework https://github.com/xamarin/xamarin-macios/pull/21155

diff -ruN /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSCore.framework/Headers/MPSCoreTypes.h /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSCore.framework/Headers/MPSCoreTypes.h
--- /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSCore.framework/Headers/MPSCoreTypes.h	2024-04-13 20:24:00
+++ /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSCore.framework/Headers/MPSCoreTypes.h	2024-05-30 04:02:02
@@ -275,12 +275,14 @@
     // signed integers
     MPSDataTypeSignedBit MPS_ENUM_AVAILABLE_STARTING( macos(10.13), ios(10.0), macCatalyst(13.0), tvos(10.0)) = 0x20000000,
     MPSDataTypeIntBit DEPRECATED_ATTRIBUTE = MPSDataTypeSignedBit,
+    MPSDataTypeInt4    MPS_ENUM_AVAILABLE_STARTING( macos(15.0), ios(18.0), macCatalyst(18.0), tvos(18.0), xros(2.0))   = MPSDataTypeSignedBit | 4,
     MPSDataTypeInt8   MPS_ENUM_AVAILABLE_STARTING( macos(10.13), ios(10.0), macCatalyst(13.0), tvos(10.0))   = MPSDataTypeSignedBit | 8,
     MPSDataTypeInt16  MPS_ENUM_AVAILABLE_STARTING( macos(10.13), ios(10.0), macCatalyst(13.0), tvos(10.0))   = MPSDataTypeSignedBit | 16,
     MPSDataTypeInt32  MPS_ENUM_AVAILABLE_STARTING( macos(10.13), ios(10.0), macCatalyst(13.0), tvos(10.0))   = MPSDataTypeSignedBit | 32,
     MPSDataTypeInt64  MPS_ENUM_AVAILABLE_STARTING( macos(11.0),  ios(14.1), macCatalyst(14.1), tvos(14.1))   = MPSDataTypeSignedBit | 64,
 
     // unsigned integers. Range: [0, UTYPE_MAX]
+    MPSDataTypeUInt4   MPS_ENUM_AVAILABLE_STARTING( macos(15.0), ios(18.0), macCatalyst(18.0), tvos(18.0), xros(2.0))    = 4,
     MPSDataTypeUInt8   MPS_ENUM_AVAILABLE_STARTING( macos(10.13), ios(10.0), macCatalyst(13.0), tvos(10.0))   = 8,
     MPSDataTypeUInt16  MPS_ENUM_AVAILABLE_STARTING( macos(10.13), ios(10.0), macCatalyst(13.0), tvos(10.0))   = 16,
     MPSDataTypeUInt32  MPS_ENUM_AVAILABLE_STARTING( macos(10.13), ios(10.0), macCatalyst(13.0), tvos(10.0))   = 32,
diff -ruN /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSCore.framework/Headers/MPSNDArray.h /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSCore.framework/Headers/MPSNDArray.h
--- /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSCore.framework/Headers/MPSNDArray.h	2024-04-13 20:24:00
+++ /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSCore.framework/Headers/MPSNDArray.h	2024-05-30 10:46:01
@@ -35,6 +35,12 @@
  *              Undefined dimensions are implicitly length 1. */
 @property (readwrite, nonatomic)  NSUInteger numberOfDimensions;
 
+/*! @property   preferPackedRows
+ *  @abstract   If YES, then new NDArrays created with this descriptor will pack the rows. Default: NO.
+ */
+@property (readwrite, nonatomic) BOOL preferPackedRows
+MPS_AVAILABLE_STARTING(macos(15.0), ios(18.0), macCatalyst(18.0), tvos(18.0), xros(2.0));
+
 /*! @abstract   The number of elements of type dataType in the indicated dimension.
  *  @discussion If dimensionIndex >= numberOfDimensions, 1 will be returned.
  *  @param      dimensionIndex  dimension the MPSNDArray for which to return the length
@@ -67,6 +73,18 @@
 -(void)     transposeDimension: (NSUInteger) dimensionIndex
                  withDimension: (NSUInteger) dimensionIndex2;
 
+/*! @abstract   Permutes the dimensions of the current descriptor
+ *  @param      dimensionOrder      A permutation of the dimensions of the NDArray.
+ *                               dimensionOrder[i] must contain the new postion of dimenson i.
+ *                               Size of the array must be equal to the original number of dimensions in the descriptor.
+ *                               Must have all the indices in [0, numberOfDimensions) present uniquely.
+ *
+ *  @discussion This permutation is applied on top of whatever transpostions/permutations that may have been performed on the descriptor before.
+ *
+ */
+-(void) permuteWithDimensionOrder: (NSUInteger*__nonnull) dimensionOrder
+MPS_AVAILABLE_STARTING(macos(15.0), ios(18.0), macCatalyst(18.0), tvos(18.0), xros(2.0));
+
 /*! @abstract    The new ordering of dimensions
  *  @discussion  If a transpose is applied, it will change the order
  *               of dimensions in the MPSNDArray. The default ordering is
@@ -74,6 +92,11 @@
  *               of dimensions 0 and 1, it will be: {1,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15}     */
 -(vector_uchar16)   dimensionOrder;
 
+/*! @abstract    Returns the shape of the NDArray as MPSShape
+ *  @discussion  The length of the array is the number of dimensions and the size of the fastest running dimension is the last element in the array.   */
+-(NSArray<NSNumber *> * _Nonnull) getShape
+MPS_AVAILABLE_STARTING(macos(15.0), ios(18.0), macCatalyst(18.0), tvos(18.0), xros(2.0));
+
 /*! @abstract   Create an MPSNDArrayDescriptor object for a given size of dimensions.
  *  @discussion Sample code:
  *   @code
@@ -270,6 +293,24 @@
 -(nonnull instancetype) initWithDevice:(id<MTLDevice> _Nonnull) device
                                 scalar:(double) value;
 
+/*! @abstract   Initialize an MPSNDArray object from a Metal Buffer with a given descriptor and offset in bytes.
+ *
+ *   @param      buffer          The buffer used for initializing. The NDArray will alias to this buffer at the given offset.
+ *   @param      offset          Offset in bytes to the buffer.
+ *   @param      descriptor  The MPSNDArrayDescriptor used for initializing the the NDArray.
+ *
+ *   @return     A valid MPSNDArray object or nil, if failure. */
+
+-(nonnull instancetype) initWithBuffer:(id<MTLBuffer> _Nonnull) buffer
+                                offset:(NSUInteger) offset
+                            descriptor:(MPSNDArrayDescriptor * _Nonnull) descriptor
+MPS_AVAILABLE_STARTING(macos(15.0), ios(18.0), macCatalyst(18.0), tvos(18.0), xros(2.0));
+
+/*! @abstract   Returns the user buffer in case the NDArray was initialized with an MTLBuffer.
+ *   @return    The user-provided MTLBuffer that was used to initialize this MPSNDArray or nil, in case it was not.. */
+-(__nullable id <MTLBuffer>) userBuffer
+MPS_AVAILABLE_STARTING(macos(15.0), ios(18.0), macCatalyst(18.0), tvos(18.0), xros(2.0));
+
 /*! @abstract       Get the number of bytes used to allocate underyling MTLResources
  *  @discussion     This is the size of the backing store of underlying MTLResources.
  *                  It does not include all storage used by the object, for example
@@ -303,6 +344,41 @@
 -(MPSNDArray * __nullable)     arrayViewWithCommandBuffer: (__nonnull id <MTLCommandBuffer>) cmdBuf
                                                descriptor: (MPSNDArrayDescriptor * _Nonnull) descriptor
                                                  aliasing: (MPSAliasingStrategy) aliasing;
+
+/*! @abstract   Make a new representation of a MPSNDArray with a slice, transpose or other change in property, trying to alias to result.
+ *  @discussion The same as `arrayViewWithCommandBuffer`, except that tries to always alias, and therefore does not require a commanbuffer.
+ *              If aliasing is not possible nil is returned.
+ *              This method is useful in making aliasing transposes and slices, that are guaranteed to be able to alias. For reshapes it is recommended
+ *              to use the `MPSNDArrayIdentity` methods.
+ *  @param      descriptor  A MPSNDArrayDescriptor describing the shape of the new view of the data
+ *  @return     A new MPSNDArray, if it is possible to make one. Otherwise nil is returned. The MPSNDArray is autoreleased. */
+-(MPSNDArray * __nullable)     arrayViewWithDescriptor: (MPSNDArrayDescriptor * _Nonnull) descriptor
+MPS_AVAILABLE_STARTING(macos(15.0), ios(18.0), macCatalyst(18.0), tvos(18.0), xros(2.0));
+
+/*! @abstract   Make a new representation of a MPSNDArray with given strides and a new shape.
+ *  @discussion This operation always returns a new view of the same underlying MTLBuffer, but works only with contiguous buffers.
+ *
+ *  @param      shape             The new shape for the NDArray. Fastest running dimension last. If nil then current shape is used.
+ *  @param      strides           The strides for each dimension. Must be at least length of new shape. Last number must be one. Must be non-increasing.
+ *
+ *  @return     A new MPSNDArray, if it is possible to make one. Otherwise nil is returned. The MPSNDArray is autoreleased. */
+-(MPSNDArray * __nullable)     arrayViewWithShape:(MPSShape * _Nullable) shape
+                                          strides:(MPSShape * _Nonnull)  strides
+MPS_AVAILABLE_STARTING(macos(15.0), ios(18.0), macCatalyst(18.0), tvos(18.0), xros(2.0));
+
+/*! @abstract   Make a new representation of a MPSNDArray with given strides and a new shape.
+ *  @discussion This operation always returns a new view of the same underlying MTLBuffer, but works only with contiguous buffers.
+ *
+ *  @param      numberOfDimensions          Number of dimensions in the new view.
+ *  @param      dimensionSizes              Size of each new dimension. Fastest running dimension first. Must be of length numberOfDimensions.
+ *  @param      dimStrides                  The strides for each dimension. First number must be one. Must be non-decreasing.  Must be of length numberOfDimensions.
+ *
+ *  @return     A new MPSNDArray, if it is possible to make one. Otherwise nil is returned. The MPSNDArray is autoreleased. */
+-(MPSNDArray * __nullable)     arrayViewWithDimensionCount:(NSUInteger) numberOfDimensions
+                                            dimensionSizes:(const NSUInteger * _Nonnull) dimensionSizes
+                                                   strides:(const NSUInteger * _Nonnull) dimStrides
+MPS_AVAILABLE_STARTING(macos(15.0), ios(18.0), macCatalyst(18.0), tvos(18.0), xros(2.0));
+
 
 /*! @abstract   The parent MPSNDArray that this object aliases
  *  @discussion If the MPSNDArray was createrd as a array view of another MPSNDArray object, and aliases content
Clone this wiki locally