-
Notifications
You must be signed in to change notification settings - Fork 512
MetalPerformanceShadersGraph iOS xcode15.0 b1
Alex Soto edited this page Jun 5, 2023
·
1 revision
#MetalPerformanceShadersGraph.framework
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraph.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraph.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraph.h 2023-03-09 19:13:38
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraph.h 2023-05-19 20:58:43
@@ -19,177 +19,134 @@
@class MPSGraphExecutable;
-/*!
- * @typedef MPSGraphOptions
- * @abstract Options to be utilized by the graph
- *
- * @constant MPSGraphOptionsNone No Options
- * @constant MPSGraphOptionsSynchronizeResults Synchronize results using a blit encoder if on a GPU
- * @constant MPSGraphOptionsVerbose Prints more logging info
- */
+/// The options available to a graph.
typedef NS_ENUM(uint64_t, MPSGraphOptions)
{
+ /// No Options.
MPSGraphOptionsNone MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) MPS_SWIFT_NAME(none) = 0,
+ /// The graph synchronizes results to the CPU using a blit encoder if on a discrete GPU at the end of execution.
MPSGraphOptionsSynchronizeResults MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) = 1L,
+ /// The framework prints more logging info.
MPSGraphOptionsVerbose MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) = 2L,
-
+ /// The framework uses these options as default if not overriden.
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
- */
+/// Optimization levels to tradeoff compilation time for even more runtime performance by running more passes.
typedef NS_ENUM(uint64_t, MPSGraphOptimization)
{
+ /// Graph performs core optimizations only.
MPSGraphOptimizationLevel0 MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4)) MPS_SWIFT_NAME(level0) = 0,
+ /// Graph performs additional Optimizations, like using the placement pass to dispatch across different HW blocks like the NeuralEngine and CPU along with the GPU.
MPSGraphOptimizationLevel1 MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4)) = 1L,
};
-/*!
- * @typedef MPSGraphOptimizationProfile
- * @abstract Optimization profile used as heuristic as graph compiler optimizes network
- *
- * @constant MPSGraphOptimizationProfilePerformance Default, optimize for performance
- * @constant MPSGraphOptimizationProfilePowerEfficiency optimize for power efficiency
- */
+/// Optimization profile used as heuristic as graph compiler optimizes network.
typedef NS_ENUM(uint64_t, MPSGraphOptimizationProfile)
{
+ /// Default, graph optimized for performance.
MPSGraphOptimizationProfilePerformance MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4)) MPS_SWIFT_NAME(performance) = 0,
+ /// Graph optimized for power efficiency.
MPSGraphOptimizationProfilePowerEfficiency MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4)) = 1L,
};
-/*!
- * @typedef MPSGraphExecutionStage
- * @abstract Execution events that can be used with shared events
- *
- * @constant MPSGraphExecutionStageCompleted execution complete
- */
+/// Execution events that can be used with shared events.
typedef NS_ENUM(uint64_t, MPSGraphExecutionStage)
{
+ /// stage when execution of the graph completes.
MPSGraphExecutionStageCompleted MPS_ENUM_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0)) MPS_SWIFT_NAME(completed) = 0L,
};
-
-/*! @abstract A dictionary of tensors and correspondiing tensorData for them
- */
+/// A dictionary of tensors and correspondiing tensorData for them.
MPS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
typedef NSDictionary<MPSGraphTensor*, MPSGraphTensorData *> MPSGraphTensorDataDictionary;
-/*! @abstract A dictionary of tensors and correspondiing shapes for them
- */
+/// A dictionary of tensors and correspondiing shapes for them.
MPS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
typedef NSDictionary<MPSGraphTensor*, MPSGraphShapedType *> MPSGraphTensorShapedTypeDictionary;
-/*! @abstract A notification when graph execution: has finished
- * @param resultsDictionary If no error, the results dictionary produced by the graph operation.
- * @param error If an error occurs, more information might be found here.
- */
+/// A notification when graph execution: has finished.
+///
+/// - Parameters:
+/// - resultsDictionary: If no error, the results dictionary produced by the graph operation.
+/// - error: If an error occurs, more information might be found here.
typedef void (^MPSGraphCompletionHandler)(MPSGraphTensorDataDictionary * resultsDictionary,
NSError * _Nullable error);
-/*! @abstract A notification when graph execution: has been scheduled
- * @param resultsDictionary If no error, the results dictionary produced by the graph operation.
- * If Graph has not yet allocated the results will be NSNull
- * @param error If an error occurs, more information might be found here.
- */
+/// A notification when graph execution: has been scheduled.
+///
+/// - Parameters:
+/// - resultsDictionary: If no error, the results dictionary produced by the graph operation. If Graph has not yet allocated the results will be NSNull.
+/// - error: If an error occurs, more information might be found here.
typedef void (^MPSGraphScheduledHandler)(MPSGraphTensorDataDictionary * resultsDictionary,
NSError * _Nullable error);
-/*! @abstract A notification when compilation: has finished
- * @param executable If no error, the executable produced by the compilation
- * @param error If an error occurs, more information might be found here.
- */
+/// A notification when compilation: has finished.
+///
+/// - Parameters:
+/// - executable: If no error, the executable produced by the compilation.
+/// - error: If an error occurs, more information might be found here.
typedef void (^MPSGraphCompilationCompletionHandler)(MPSGraphExecutable* executable,
NSError * _Nullable error);
-/*! @class MPSGraphCompilationDescriptor
- * @abstract A structure which consists of all the levers users can use to compile their graphs
- *
- */
+/// 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>
+@interface MPSGraphCompilationDescriptor : MPSGraphObject <NSCopying>
-/*!
- * @brief Turns off type inference and we rely on type inference during runtime
- */
+/// 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
- */
+/// 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));
-/*! @property optimizationProfile
- * @discussion optimization profile for the graph optimization, default is MPSGraphOptimizationProfilePerformance
- */
-@property (readwrite, nonatomic) MPSGraphOptimizationProfile optimizationProfile MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
+/// optimization profile for the graph optimization, default is MPSGraphOptimizationProfilePerformance.
+@property (readwrite, nonatomic) MPSGraphOptimizationProfile optimizationProfile
+MPS_AVAILABLE_STARTING_BUT_DEPRECATED("MPSGraph will automatically provide the best performance and power efficiency with MPSGraphOptimizationLevel1.",
+ macos(12.3, 14.0), ios(15.4, 17.0), tvos(15.4, 17.0));
-/*! @property waitForCompilationCompletion
- * @discussion makes the compile or specialize call blocking till the entire compilation is completed, defaults to NO
- */
+/// makes the compile or specialize call blocking till the entire compilation is completed, defaults to NO.
@property (readwrite, nonatomic) BOOL waitForCompilationCompletion MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*! @property compilationCompletionHandler
- * @discussion compilationCompletionHandler for the compilation, default value is nil, it is called after compilation is completed
- */
+/// compilationCompletionHandler for the compilation, default value is nil, it is called after compilation is completed.
@property (readwrite, atomic) MPSGraphCompilationCompletionHandler compilationCompletionHandler MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*! @property dispatchQueue
- * @discussion dispatchQueue for the compilation, default value is nil
- */
+/// dispatchQueue for the compilation, default value is nil.
@property (readwrite, atomic, retain) dispatch_queue_t dispatchQueue MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
@end
-/*! @class MPSGraphExecutionDescriptor
- * @abstract A structure which consists of all the levers users can use to synchronize and schedule their graph execution
- *
- */
+/// A structure which consists of all the levers users can use to synchronize and schedule their graph execution.
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
-@interface MPSGraphExecutionDescriptor : NSObject
+@interface MPSGraphExecutionDescriptor : MPSGraphObject
-/*! @property scheduledHandler
- * @discussion scheduledHandler for the graph, default value is nil
- */
+/// scheduledHandler for the graph, default value is nil.
@property (readwrite, atomic) MPSGraphScheduledHandler scheduledHandler;
-/*! @property completionHandler
- * @discussion completionHandler for the graph, default value is nil
- */
+/// completionHandler for the graph, default value is nil.
@property (readwrite, atomic) MPSGraphCompletionHandler completionHandler;
-/*! @property waitUntilCompleted
- * @discussion waitUntilCompleted for the graph, default value is false
- */
+/// waitUntilCompleted for the graph, default value is false.
@property (readwrite, atomic) BOOL waitUntilCompleted;
-/*! @property compilationDescriptor
- * @discussion compilationDescriptor for the graph, default value is nil
- */
+/// compilationDescriptor for the graph, default value is nil.
@property (readwrite, atomic, copy, nullable) MPSGraphCompilationDescriptor *compilationDescriptor
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
-/*!
- * @abstract Executable waits on these shared events before scheduling execution on the HW, this does not include encoding which can still continue.
- *
- * @param event shared event to wait on
- * @param value value for shared event to wait on
- */
+/// Executable waits on these shared events before scheduling execution on the HW, this does not include encoding which can still continue.
+///
+/// - Parameters:
+/// - event: shared event graph waits on.
+/// - value: value of shared event graph waits on.
-(void) waitForEvent:(id<MTLSharedEvent>) event
value:(uint64_t) value
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Executable signals these shared events at execution stage and immediately proceeds
- *
- * @param event shared event to signal
- * @param executionStage execution stage to signal event at
- * @param value value for shared event to wait on
- */
+/// Executable signals these shared events at execution stage and immediately proceeds.
+///
+/// - Parameters:
+/// - event: shared event to signal.
+/// - executionStage: execution stage to signal event at.
+/// - value: value for shared event to wait on.
-(void) signalEvent:(id<MTLSharedEvent>) event
atExecutionEvent:(MPSGraphExecutionStage) executionStage
value:(uint64_t) value
@@ -197,91 +154,73 @@
@end
-/*! @class MPSGraph
- * @abstract Optimized representation of a compute graph of MPSGraphOperations and MPSGraphTensors
- * @discussion An MPSGraph is a symbolic representation of operations to be utilized to execute compute graphs on a device.
- *
- */
+/// Optimized representation of a compute graph of MPSGraphOperations and MPSGraphTensors.
+///
+/// An MPSGraph is a symbolic representation of operations to be utilized to execute compute graphs on a device.
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
-@interface MPSGraph : NSObject
+@interface MPSGraph : MPSGraphObject
-/*! @property options
- * @discussion options for the graph, default value is MPSGraphOptionsDefault
- */
+/// options for the graph, default value is MPSGraphOptionsDefault.
@property (readwrite, atomic) MPSGraphOptions options;
-/*!
- * @brief Create a new MPSGraph to insert nodes in
- */
+/// Create a new MPSGraph to insert nodes in.
+(instancetype) new;
-/*!
- * @brief Initialize an MPSGraph to insert nodes in
- */
+/// Initialize an MPSGraph to insert nodes in.
-(instancetype) init;
-/*! @property placeholderTensors
- * @discussion an array of all the placeholderTensors
- */
+/// an array of all the placeholderTensors.
@property (readonly, nonnull, nonatomic) NSArray<MPSGraphTensor *> *placeholderTensors;
-/*!
- * @abstract Compiles the graph for given feeds to return targetTensor values, ensuring all target operations would be executed. This call blocks till execution has completed.
- *
- * @param device MPSGraph device to optimize for
- * @param feeds Feeds dictionary for the placeholder tensors
- * @param targetTensors Tensors for which the caller wishes MPSGraphTensorData to be returned
- * @param targetOperations Operations to be completed at the end of the run
- * @param compilationDescriptor compilation descriptor
- *
- * @return A valid MPSGraphExecutable object
- */
+/// Compiles the graph for given feeds to return targetTensor values, ensuring all target operations would be executed. This call blocks till execution has completed.
+///
+/// - Parameters:
+/// - device: MPSGraph device to optimize for.
+/// - 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.
+/// - compilationDescriptor: compilation descriptor to set different compilation parameters.
+/// - Returns: A valid MPSGraphExecutable object
-(MPSGraphExecutable *) compileWithDevice:(MPSGraphDevice * _Nullable) device
feeds:(MPSGraphTensorShapedTypeDictionary *) feeds
targetTensors:(NSArray<MPSGraphTensor *> *) targetTensors
targetOperations:(NSArray<MPSGraphOperation *> * _Nullable) targetOperations
compilationDescriptor:(MPSGraphCompilationDescriptor * _Nullable) compilationDescriptor MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0));
-/*!
- * @abstract Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed. This call blocks till execution has completed.
- *
- * @param feeds Feeds dictionary for the placeholder tensors
- * @param targetTensors Tensors for which the caller wishes MPSGraphTensorData to be returned
- * @param targetOperations Operations to be completed at the end of the run
- *
- * @return A valid MPSGraphTensor : MPSGraphTensorData dictionary with results synchronized to the CPU memory.
- */
+/// Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed. This call blocks till execution has completed.
+///
+/// - Parameters:
+/// - 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.
+/// - Returns: A valid MPSGraphTensor : MPSGraphTensorData dictionary with results synchronized to the CPU memory.
-(MPSGraphTensorDataDictionary *) runWithFeeds:(MPSGraphTensorDataDictionary *) feeds
targetTensors:(NSArray<MPSGraphTensor *> *) targetTensors
targetOperations:(NSArray<MPSGraphOperation *> * _Nullable) targetOperations
MPS_SWIFT_NAME( run(feeds:targetTensors:targetOperations:) );
-/*!
- * @abstract Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed. This call blocks till execution has completed.
- *
- * @param commandQueue CommandQueue passed to exectute the graph on
- * @param feeds Feeds dictionary for the placeholder tensors
- * @param targetTensors Tensors for which the caller wishes MPSGraphTensorData to be returned
- * @param targetOperations Operations to be completed at the end of the run
- *
- * @return A valid MPSGraphTensor : MPSGraphTensorData dictionary with results synchronized to the CPU memory.
- */
+/// Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed. This call blocks till execution has completed.
+///
+/// - Parameters:
+/// - commandQueue: CommandQueue 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.
+/// - Returns: A valid MPSGraphTensor : MPSGraphTensorData dictionary with results synchronized to the CPU memory.
-(MPSGraphTensorDataDictionary *) runWithMTLCommandQueue:(id<MTLCommandQueue>) commandQueue
feeds:(MPSGraphTensorDataDictionary *) feeds
targetTensors:(NSArray<MPSGraphTensor *> *) targetTensors
targetOperations:(NSArray<MPSGraphOperation *> * _Nullable) targetOperations
MPS_SWIFT_NAME( run(with:feeds:targetTensors:targetOperations:) );
-/*!
- * @abstract Runs the graph for given feeds to return targetTensor values in the resultsDictionary provided by the user,
- * ensuring all target operations also executed. This call blocks till execution has completed.
- *
- * @param commandQueue CommandQueue passed to exectute the graph on
- * @param feeds Feeds dictionary for the placeholder tensors
- * @param targetOperations Operations to be completed at the end of the run
- * @param resultsDictionary MPSGraphTensors dictionary passed by user, these will be filled with graph output data
- *
- */
+/// Runs the graph for given feeds to return targetTensor values in the resultsDictionary provided by the user,
+/// ensuring all target operations also executed. This call blocks till execution has completed.
+///
+/// - Parameters:
+/// - commandQueue: CommandQueue 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.
-(void) runWithMTLCommandQueue:(id<MTLCommandQueue>) commandQueue
feeds:(MPSGraphTensorDataDictionary *) feeds
targetOperations:(NSArray<MPSGraphOperation *> * _Nullable) targetOperations
@@ -291,17 +230,15 @@
// Async methods
-/*!
- * @abstract Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed.
- * This call is asynchronous and will return immediately if a completionHandler is set.
- *
- * @param feeds Feeds dictionary for the placeholder tensors
- * @param targetTensors Tensors for which the caller wishes MPSGraphTensorData to be returned
- * @param targetOperations Operations to be completed at the end of the run
- * @param executionDescriptor ExecutionDescriptor to be passed in and used,
- *
- * @return A valid MPSGraphTensor : MPSGraphTensorData dictionary with results synchronized to the CPU memory.
- */
+/// Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed.
+/// This call is asynchronous and will return immediately if a completionHandler is set.
+///
+/// - Parameters:
+/// - 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.
-(MPSGraphTensorDataDictionary *) runAsyncWithFeeds:(MPSGraphTensorDataDictionary *) feeds
targetTensors:(NSArray<MPSGraphTensor *> *) targetTensors
targetOperations:(NSArray<MPSGraphOperation *> * _Nullable) targetOperations
@@ -309,18 +246,16 @@
MPS_SWIFT_NAME( runAsync(feeds:targetTensors:targetOperations:executionDescriptor:) );
-/*!
- * @abstract Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed.
- * This call is asynchronous and will return immediately if a completionHandler is set.
- *
- * @param commandQueue CommandQueue passed to exectute the graph on
- * @param feeds Feeds dictionary for the placeholder tensors
- * @param targetTensors Tensors for which the caller wishes MPSGraphTensorData to be returned
- * @param targetOperations Operations to be completed at the end of the run
- * @param executionDescriptor ExecutionDescriptor to be passed in and used,
- *
- * @return A valid MPSGraphTensor : MPSGraphTensorData dictionary with results synchronized to the CPU memory if MPSGraphOptionsSynchronizeResults set.
- */
+/// Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed.
+/// This call is asynchronous and will return immediately if a completionHandler is set.
+///
+/// - Parameters:
+/// - commandQueue: CommandQueue 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 *) runAsyncWithMTLCommandQueue:(id<MTLCommandQueue>) commandQueue
feeds:(MPSGraphTensorDataDictionary *) feeds
targetTensors:(NSArray<MPSGraphTensor *> *) targetTensors
@@ -328,17 +263,15 @@
executionDescriptor:(MPSGraphExecutionDescriptor * _Nullable) executionDescriptor
MPS_SWIFT_NAME( runAsync(with:feeds:targetTensors:targetOperations:executionDescriptor:) );
-/*!
- * @abstract Runs the graph for given feeds to return targetTensor values in the resultsDictionary provided by the user,
- * ensuring all target operations also executed. This call is asynchronous and will return immediately if a completionHandler is set.
- *
- * @param commandQueue CommandQueue passed to exectute the graph on
- * @param feeds Feeds dictionary for the placeholder tensors
- * @param targetOperations Operations to be completed at the end of the run
- * @param resultsDictionary MPSGraphTensors dictionary passed by user, these will be filled with graph output data
- * @param executionDescriptor ExecutionDescriptor to be passed in and used,
- *
- */
+/// Runs the graph for given feeds to return targetTensor values in the resultsDictionary provided by the user,
+/// ensuring all target operations also executed. This call is asynchronous and will return immediately if a completionHandler is set.
+///
+/// - Parameters:
+/// - commandQueue: CommandQueue 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) runAsyncWithMTLCommandQueue:(id<MTLCommandQueue>) commandQueue
feeds:(MPSGraphTensorDataDictionary *) feeds
targetOperations:(NSArray<MPSGraphOperation *> * _Nullable) targetOperations
@@ -346,18 +279,16 @@
executionDescriptor:(MPSGraphExecutionDescriptor * _Nullable) executionDescriptor
MPS_SWIFT_NAME( runAsync(with:feeds:targetOperations:resultsDictionary:executionDescriptor:) );
-/*!
- * @abstract Encodes graph for given feeds to return targetTensor values, ensuring all target operations also executed.
- * This call is asynchronous and will return immediately if a completionHandler is set.
- *
- * @param commandBuffer commandBuffer passed to exectute the graph on, it is an MPSCommandBuffer, commitAndContinue might be called, please don't rely on underlying MTLCommandBuffer to remain uncommitted
- * @param feeds Feeds dictionary for the placeholder tensors
- * @param targetTensors Tensors for which the caller wishes MPSGraphTensorData to be returned
- * @param targetOperations Operations to be completed at the end of the run
- * @param executionDescriptor ExecutionDescriptor to be passed in and used,
- *
- * @return A valid MPSGraphTensor : MPSGraphTensorData dictionary with results synchronized to the CPU memory if MPSGraphOptionsSynchronizeResults set.
- */
+/// Encodes graph for given feeds to return targetTensor values, ensuring all target operations also executed.
+/// This call is asynchronous and will return immediately if a completionHandler is set.
+///
+/// - Parameters:
+/// - commandBuffer: commandBuffer passed to exectute the graph on, it is an MPSCommandBuffer, commitAndContinue might be called, please don't rely on underlying MTLCommandBuffer to remain uncommitted.
+/// - 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 *) encodeToCommandBuffer:(MPSCommandBuffer *) commandBuffer
feeds:(MPSGraphTensorDataDictionary *) feeds
targetTensors:(NSArray<MPSGraphTensor *> *) targetTensors
@@ -365,17 +296,15 @@
executionDescriptor:(MPSGraphExecutionDescriptor * _Nullable) executionDescriptor
MPS_SWIFT_NAME( encode(to:feeds:targetTensors:targetOperations:executionDescriptor:) );
-/*!
- * @abstract Encodes the graph for given feeds to return targetTensor values in the resultsDictionary provided by the user,
- * ensuring all target operations also executed. This call is asynchronous and will return immediately if a completionHandler is set.
- *
- * @param commandBuffer commandBuffer passed to execute the graph on, commitAndContinue might be called, please don't rely on underlying MTLCommandBuffer to remain uncommitted
- * @param feeds Feeds dictionary for the placeholder tensors
- * @param targetOperations Operations to be completed at the end of the run
- * @param resultsDictionary MPSGraphTensors dictionary passed by user, these will be filled with graph output data
- * @param executionDescriptor ExecutionDescriptor to be passed in and used,
- *
- */
+/// Encodes the graph for given feeds to return targetTensor values in the resultsDictionary provided by the user,
+/// ensuring all target operations also executed. This call is asynchronous and will return immediately if a completionHandler is set.
+///
+/// - Parameters:
+/// - commandBuffer: commandBuffer passed to execute the graph on, commitAndContinue might be called, please don't rely on underlying MTLCommandBuffer to remain uncommitted.
+/// - 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) encodeToCommandBuffer:(MPSCommandBuffer *) commandBuffer
feeds:(MPSGraphTensorDataDictionary *) feeds
targetOperations:(NSArray<MPSGraphOperation *> * _Nullable) targetOperations
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphActivationOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphActivationOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphActivationOps.h 2023-03-09 23:53:22
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphActivationOps.h 2023-05-22 01:17:40
@@ -16,50 +16,107 @@
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MPSGraphActivationOps)
-
+/// Computes a ReLU (rectified linear activation unit) function with an input tensor.
+/// The operation is: f(x) = max(x, 0).
+///
+/// - Parameters:
+/// - tensor: An input tensor.
+/// - name: A name for the operation.
+/// - Returns: A valid ``MPSGraphTensor`` object.
-(MPSGraphTensor *) reLUWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Computes gradient of ReLU (rectified linear activation unit) function using the incoming gradient.
+///
+/// - Parameters:
+/// - gradient: The incoming gradient tensor.
+/// - source: The input tensor from forward pass.
+/// - name: A name for the operation.
+/// - Returns: A valid ``MPSGraphTensor`` object.
-(MPSGraphTensor *) reLUGradientWithIncomingGradient:(MPSGraphTensor *) gradient
sourceTensor:(MPSGraphTensor *) source
name:(NSString * _Nullable) name;
-
+/// Computes sigmoid operation on an input tensor.
+///
+/// - Parameters:
+/// - tensor: An input tensor.
+/// - name: A name for the operation.
+/// - Returns: A valid ``MPSGraphTensor`` object.
-(MPSGraphTensor *) sigmoidWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Computes gradient of sigmoid function using the incoming gradient tensor.
+///
+/// - Parameters:
+/// - gradient: The incoming gradient tensor.
+/// - source: The input tensor.
+/// - name: A name for the operation.
+/// - Returns: A valid ``MPSGraphTensor`` object
-(MPSGraphTensor *) sigmoidGradientWithIncomingGradient:(MPSGraphTensor *) gradient
sourceTensor:(MPSGraphTensor *) source
name:(NSString * _Nullable) name;
-
+/// Computes a softmax function on an input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: An input tensor.
+/// - axis: An axis along which softmax is computed.
+/// - name: A name for the operation.
+/// - Returns: A valid ``MPSGraphTensor`` object
-(MPSGraphTensor *) softMaxWithTensor:(MPSGraphTensor *) tensor
axis:(NSInteger) axis
name:(NSString * _Nullable) name;
+/// Computes the gradient of the softmax function along a specified axis using the incoming gradient tensor.
+///
+/// - Parameters:
+/// - gradient: The incoming gradient tensor.
+/// - source: The input tensor.
+/// - axis: An axis along which softmax is computed.
+/// - name: A name for the operation
+/// - Returns: A valid ``MPSGraphTensor`` object
-(MPSGraphTensor *) softMaxGradientWithIncomingGradient:(MPSGraphTensor *) gradient
sourceTensor:(MPSGraphTensor *) source
axis:(NSInteger) axis
name:(NSString * _Nullable) name;
-
-/*!
- * @brief Leaky ReLU activation tensor
- * @discussion Specifies the leaky ReLU activation tensor.
- * For each pixel, applies the following function: f(x) = max(x, alpha * x)
- */
+/// Computes leaky ReLU (rectified linear unit activation) on an input tensor.
+/// The operation is: f(x) = max(x, alpha).
+///
+/// - Parameters:
+/// - tensor: An input tensor.
+/// - alpha: A scalar value alpha used by all elements in the input tensor.
+/// - name: A name for the operation.
+/// - Returns: A valid ``MPSGraphTensor`` object
-(MPSGraphTensor*)leakyReLUWithTensor:(MPSGraphTensor* _Nonnull)tensor
alpha:(double) alpha
name:(NSString* _Nullable) name
MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0));
+/// Computes leaky ReLU (rectified linear unit activation) on an input tensor.
+/// The operation is: f(x) = max(x, alpha).
+/// This operation supports broadcasting with the alpha tensor.
+///
+/// - Parameters:
+/// - tensor: An input tensor.
+/// - alpha: An alpha tensor.
+/// - name: A name for the operation.
+/// - Returns: A valid ``MPSGraphTensor`` object
-(MPSGraphTensor*)leakyReLUWithTensor:(MPSGraphTensor* _Nonnull) tensor
alphaTensor:(MPSGraphTensor* _Nonnull) alphaTensor
name:(NSString* _Nullable) name
MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0));
+/// Computes gradient of leaky ReLU (rectified linear unit activation).
+/// Supports broadcasting with alpha tensor.
+///
+/// - Parameters:
+/// - gradient: The incoming gradient tensor.
+/// - source: The input tensor in forward pass.
+/// - alpha: An alpha tensor
+/// - name: A name for the operation.
+/// - Returns: A valid ``MPSGraphTensor`` object
-(MPSGraphTensor*)leakyReLUGradientWithIncomingGradient:(MPSGraphTensor *) gradient
sourceTensor:(MPSGraphTensor* _Nonnull) source
alphaTensor:(MPSGraphTensor* _Nonnull) alphaTensor
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphArithmeticOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphArithmeticOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphArithmeticOps.h 2023-03-09 19:13:38
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphArithmeticOps.h 2023-05-22 01:20:38
@@ -20,188 +20,400 @@
#pragma mark - UnaryArithmeticOps
+/// Identity op - it copies input tensor values to output
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) identityWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
+/// It applies natural exponent
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) exponentWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
+/// It applies exponent with base 2
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) exponentBase2WithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
+/// It applies exponent with base 10
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) exponentBase10WithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
+/// It applies natural log to input tensor elements
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) logarithmWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
+/// It applies log with base 2 to input tensor elements
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) logarithmBase2WithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
+/// It applies log with base 10 to input tensor elements
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) logarithmBase10WithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
+/// It applies square to input tensor elements
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) squareWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
+/// It applies square root to input tensor elements
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) squareRootWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
+/// It returns reverse square root of input tensor elements
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) reverseSquareRootWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
+/// It applies reciprocal to input tensor elements
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) reciprocalWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
+/// It applies absolute to input tensor elements
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) absoluteWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
+/// Return the absolute square of the input tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor.
+/// - name: name for the operation.
+/// - Returns: A valid MPSGraphTensor object.
+-(MPSGraphTensor *) absoluteSquareWithTensor:(MPSGraphTensor *) tensor
+ name:(NSString * _Nullable) name
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0))
+MPS_SWIFT_NAME( absoluteSquare(tensor:name:) );
+
+/// It applies negative to input tensor elements
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) negativeWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
+/// Gets back sign of input tensor elements,
+/// `1.0 ifx > 0, -0.0 if x = -0.0, +0.0 ifx = +0.0, or -1.0 if x < 0. Returns 0.0 if x is a NaN.`
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) signWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Gets back signbit of input tensor elements,
+/// `true` if the sign bit is set for the floating-point value in x; otherwise returns `false`
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) signbitWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with ceil of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) ceilWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with floor of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) floorWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with round of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) roundWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with round of input tensor elements,
+/// Round values to integral value using round to nearest even rounding mode in floating-point format.
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) rintWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with sin of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) sinWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with cos of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) cosWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with tan of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) tanWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with sinh of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) sinhWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with cosh of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) coshWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with tanh of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) tanhWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with asin of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) asinWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with acos of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) acosWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with atan of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) atanWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with asinh of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) asinhWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with acosh of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) acoshWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with acosh of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) atanhWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with logical not of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) notWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with isInfinite of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) isInfiniteWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with isFinite of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) isFiniteWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with isNaN of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) isNaNWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-
+/// Output tensor of elements with erf of input tensor elements,
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) erfWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name;
-/*!
- * @abstract Truncate op - floor for positive inputs, ceil for negative.
- * @param tensor The input
- * @param name Name for the operation
- * @return A valid MPSGraphTensor object.
- */
+/// Truncate op - floor for positive inputs, ceil for negative.
+///
+/// - Parameters:
+/// - tensor: The input
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) truncateWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( truncate(_:name:) )
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Return bitwise not of tensor, takes in only integer dataTypes
- *
- * @param tensor input tensor, must be integer dataType
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Return bitwise not of tensor, takes in only integer dataTypes
+///
+/// - Parameters:
+/// - tensor: input tensor, must be integer dataType
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) bitwiseNOTWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( bitwiseNOT(_:name:) )
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.1), tvos(16.1));
-/*!
- * @abstract Return population count of a tensor, takes in only integer dataTypes
- *
- * @param tensor input tensor, must be integer dataType
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Return population count of a tensor, takes in only integer dataTypes
+///
+/// - Parameters:
+/// - tensor: input tensor, must be integer dataType
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) bitwisePopulationCountWithTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( bitwisePopulationCount(_:name:) )
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.1), tvos(16.1));
+/// Return the complex conjugate of the input tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor.
+/// - name: name for the operation.
+/// - Returns: A valid MPSGraphTensor object.
+-(MPSGraphTensor *) conjugateWithTensor:(MPSGraphTensor *) tensor
+ name:(NSString * _Nullable) name
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0))
+MPS_SWIFT_NAME( conjugate(tensor:name:) );
+
#pragma mark - BinaryArithmeticOps
-/*!
- * @abstract Create Add op and return the result tensor, it supports broadcasting as well
- *
- * @code
- * resultTensor = primaryTensor + secondaryTensor
- * @endcode
- *
- * @param primaryTensor LHS tensor of the binary Op
- * @param secondaryTensor RHS tensor of the binary Op
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create Add op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = primaryTensor + secondaryTensor
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) additionWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
@@ -209,19 +421,16 @@
-/*!
- * @abstract Create Subtract op and return the result tensor, it supports broadcasting as well
- *
- * @code
- * resultTensor = primaryTensor - secondaryTensor
- * @endcode
- *
- * @param primaryTensor LHS tensor of the binary Op
- * @param secondaryTensor RHS tensor of the binary Op
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create Subtract op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = primaryTensor - secondaryTensor
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) subtractionWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
@@ -229,266 +438,398 @@
-/*!
- * @abstract Create Multiply op and return the result tensor, it supports broadcasting as well
- *
- * @code
- * resultTensor = primaryTensor * secondaryTensor
- * @endcode
- *
- * @param primaryTensor LHS tensor of the binary Op
- * @param secondaryTensor RHS tensor of the binary Op
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create Multiply op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = primaryTensorsecondaryTensor
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) multiplicationWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( multiplication(_:_:name:) );
-/*!
- * @abstract Create Divide op and return the result tensor, it supports broadcasting as well
- *
- * @code
- * resultTensor = primaryTensor / secondaryTensor
- * @endcode
- *
- * @param primaryTensor LHS tensor of the binary Op
- * @param secondaryTensor RHS tensor of the binary Op
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create Divide op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = primaryTensor / secondaryTensor
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) divisionWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( division(_:_:name:) );
-
+/// Create modulo op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = primaryTensor % secondaryTensor
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) moduloWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( modulo(_:_:name:) );
-
+/// Create power op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = pow(primaryTensor, secondaryTensor)
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) powerWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( power(_:_:name:) );
-
+/// Create minimum op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = min(primaryTensor, secondaryTensor)
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) minimumWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( minimum(_:_:name:) );
-
+/// Create maximum op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = max(primaryTensor, secondaryTensor)
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) maximumWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( maximum(_:_:name:) );
-/*!
- * @abstract Create Minimum op and return the result tensor, it supports broadcasting as well. If any of the operands is NaN, NaN is returned
- *
- * @code
- * resultTensor = isNaN(primaryTensor) || isNan(secondaryTensor) ? NaN : min(primaryTensor, secondaryTensor)
- * @endcode
- *
- * @param primaryTensor LHS tensor of the binary Op
- * @param secondaryTensor RHS tensor of the binary Op
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create Minimum op and return the result tensor, it supports broadcasting as well. If any of the operands is NaN, NaN is returned
+/// ```md
+/// resultTensor = isNaN(primaryTensor) || isNan(secondaryTensor) ? NaN : min(primaryTensor, secondaryTensor)
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) minimumWithNaNPropagationWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( minimumWithNaNPropagation(_:_:name:) )
MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0));
-/*!
- * @abstract Create Maximum op and return the result tensor, it supports broadcasting as well. If any of the operands is NaN, NaN is returned
- *
- * @code
- * resultTensor = isNaN(primaryTensor) || isNan(secondaryTensor) ? NaN : max(primaryTensor, secondaryTensor)
- * @endcode
- *
- * @param primaryTensor LHS tensor of the binary Op
- * @param secondaryTensor RHS tensor of the binary Op
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create Maximum op and return the result tensor, it supports broadcasting as well. If any of the operands is NaN, NaN is returned
+/// ```md
+/// resultTensor = isNaN(primaryTensor) || isNan(secondaryTensor) ? NaN : max(primaryTensor, secondaryTensor)
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) maximumWithNaNPropagationWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( maximumWithNaNPropagation(_:_:name:) )
MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0));
-
+/// Create equal op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = primaryTensor == secondaryTensor
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) equalWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( equal(_:_:name:) );
-
+/// Create not equal op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = primaryTensor != secondaryTensor
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) notEqualWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( notEqual(_:_:name:) );
-
+/// Create lessThan op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = primaryTensor < secondaryTensor
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) lessThanWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( lessThan(_:_:name:) );
-
+/// Create lessThanOrEqualTo op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = primaryTensor <= secondaryTensor
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) lessThanOrEqualToWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( lessThanOrEqualTo(_:_:name:) );
-
+/// Create greaterThan op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = primaryTensor > secondaryTensor
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) greaterThanWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( greaterThan(_:_:name:) );
-
+/// Create greaterThanOrEqual op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = primaryTensor < secondaryTensor
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) greaterThanOrEqualToWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( greaterThanOrEqualTo(_:_:name:) );
-
+/// Create logical AND op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = primaryTensor && secondaryTensor
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) logicalANDWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( logicalAND(_:_:name:) );
-
+/// Create logical OR op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = primaryTensor || secondaryTensor
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) logicalORWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( logicalOR(_:_:name:) );
-
+/// Create logical NAND op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = !(primaryTensor && secondaryTensor)
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) logicalNANDWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( logicalNAND(_:_:name:) );
-
+/// Create logical NOR op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = !(primaryTensor || secondaryTensor)
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) logicalNORWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( logicalNOR(_:_:name:) );
-
+/// Create logical XOR op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = XOR(primaryTensor, secondaryTensor)
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) logicalXORWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( logicalXOR(_:_:name:) );
-
+/// Create logical XNOR op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = XNOR(primaryTensor, secondaryTensor)
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) logicalXNORWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( logicalXNOR(_:_:name:) );
-
+/// Create logical atan2 op and return the result tensor, it supports broadcasting as well.
+/// Graph computes arc tangent of primaryTensor over secondaryTensor.
+/// ```md
+/// resultTensor = atan2(primaryTensor, secondaryTensor)
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) atan2WithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name;
-/*!
- * @abstract Return bitwise AND of binary representations of 2 integer tensors
- *
- * @param primaryTensor primary input tensor, must be integer dataType
- * @param secondaryTensor secondary input tensor, must be integer dataType
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Return bitwise AND of binary representations of 2 integer tensors
+///
+/// - Parameters:
+/// - primaryTensor: primary input tensor, must be integer dataType
+/// - secondaryTensor: secondary input tensor, must be integer dataType
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) bitwiseANDWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( bitwiseAND(_:_:name:) )
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.1), tvos(16.1));
-/*!
- * @abstract Return bitwise OR of binary representations of 2 integer tensors
- *
- * @param primaryTensor primary input tensor, must be integer dataType
- * @param secondaryTensor secondary input tensor, must be integer dataType
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Return bitwise OR of binary representations of 2 integer tensors
+///
+/// - Parameters:
+/// - primaryTensor: primary input tensor, must be integer dataType
+/// - secondaryTensor: secondary input tensor, must be integer dataType
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) bitwiseORWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( bitwiseOR(_:_:name:) )
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.1), tvos(16.1));
-/*!
- * @abstract Return bitwise XOR of binary representations of 2 integer tensors
- *
- * @param primaryTensor primary input tensor, must be integer dataType
- * @param secondaryTensor secondary input tensor, must be integer dataType
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Return bitwise XOR of binary representations of 2 integer tensors
+///
+/// - Parameters:
+/// - primaryTensor: primary input tensor, must be integer dataType
+/// - secondaryTensor: secondary input tensor, must be integer dataType
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) bitwiseXORWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( bitwiseXOR(_:_:name:) )
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.1), tvos(16.1));
-/*!
- * @abstract Return bitwise left shifted binary representations of primary integer tensor by secondary tensor amount
- *
- * @param primaryTensor primary input tensor, must be integer dataType
- * @param secondaryTensor secondary input tensor, must be integer dataType
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Return bitwise left shifted binary representations of primary integer tensor by secondary tensor amount
+///
+/// - Parameters:
+/// - primaryTensor: primary input tensor, must be integer dataType
+/// - secondaryTensor: secondary input tensor, must be integer dataType
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) bitwiseLeftShiftWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( bitwiseLeftShift(_:_:name:) )
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.1), tvos(16.1));
-/*!
- * @abstract Return bitwise right shifted binary representations of primary integer tensor by secondary tensor amount
- *
- * @param primaryTensor primary input tensor, must be integer dataType
- * @param secondaryTensor secondary input tensor, must be integer dataType
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Return bitwise right shifted binary representations of primary integer tensor by secondary tensor amount
+///
+/// - Parameters:
+/// - primaryTensor: primary input tensor, must be integer dataType
+/// - secondaryTensor: secondary input tensor, must be integer dataType
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) bitwiseRightShiftWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
@@ -498,13 +839,34 @@
#pragma mark - TernaryArithmeticOps
+/// Create select op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = select(predicateTensor, truePredicateTensor, falseSelectTensor)
+/// ```
+///
+/// - Parameters:
+/// - predicateTensor: tensor with predicate tensor
+/// - truePredicateTensor: tensor we get values from if predicate is true
+/// - falseSelectTensor: tensor we get values from if predicate is false
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) selectWithPredicateTensor:(MPSGraphTensor *) predicateTensor
truePredicateTensor:(MPSGraphTensor *) truePredicateTensor
falsePredicateTensor:(MPSGraphTensor *) falseSelectTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( select(predicate:trueTensor:falseTensor:name:) );
-
+/// Create select op and return the result tensor, it supports broadcasting as well
+/// ```md
+/// resultTensor = clamp(tensor, minValueTensor, maxValueTensor)
+/// ```
+///
+/// - Parameters:
+/// - predicateTensor: tensor with input values
+/// - truePredicateTensor: tensor with min values to clamp to
+/// - falseSelectTensor: tensor with max values to clamp to
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) clampWithTensor:(MPSGraphTensor *) tensor
minValueTensor:(MPSGraphTensor *) minValueTensor
maxValueTensor:(MPSGraphTensor *) maxValueTensor
@@ -514,16 +876,72 @@
#pragma mark - ConvenienceMathOps
-
+/// Create DivideNoNaN op and return the result tensor, it supports broadcasting as well, returns 0 if divisor is 0
+/// ```md
+/// resultTensor = select(secondaryTensor, primaryTensor / secondaryTensor, 0)
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) divisionNoNaNWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( divisionNoNaN(_:_:name:) );
+/// Create floorModulo op and return the result tensor, it supports broadcasting as well, returns 0 if divisor is 0
+/// ```md
+/// resultTensor = primaryTensor - (floor(primaryTensor / secondaryTensor) * secondaryTensor)
+/// ```
+///
+/// - Parameters:
+/// - primaryTensor: LHS tensor of the binary Op
+/// - secondaryTensor: RHS tensor of the binary Op
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) floorModuloWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( floorModulo(_:_:name:) );
+
+#pragma mark - ComplexOps
+
+/// Return the real part of a tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor.
+/// - name: name for the operation.
+/// - Returns: A valid MPSGraphTensor object.
+-(MPSGraphTensor *) realPartOfTensor:(MPSGraphTensor *) tensor
+ name:(NSString * _Nullable) name
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0))
+MPS_SWIFT_NAME( realPartOfTensor(tensor:name:) );
+
+/// Return the imaginary part of a tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor.
+/// - name: name for the operation.
+/// - Returns: A valid MPSGraphTensor object.
+-(MPSGraphTensor *) imaginaryPartOfTensor:(MPSGraphTensor *) tensor
+ name:(NSString * _Nullable) name
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0))
+MPS_SWIFT_NAME( imaginaryPartOfTensor(tensor:name:) );
+
+/// Return a complex tensor from the two input tensors.
+///
+/// - Parameters:
+/// - realTensor: the real part of the complex tensor.
+/// - imaginaryTensor: the imaginary part of the complex tensor.
+/// - name: name for the operation.
+/// - Returns: A valid MPSGraphTensor object.
+-(MPSGraphTensor *) complexTensorWithRealTensor:(MPSGraphTensor *) realTensor
+ imaginaryTensor:(MPSGraphTensor *) imaginaryTensor
+ name:(NSString * _Nullable) name
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0))
+MPS_SWIFT_NAME( complexTensor(realTensor:imaginaryTensor:name:) );
@end
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphAutomaticDifferentiation.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphAutomaticDifferentiation.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphAutomaticDifferentiation.h 2023-03-09 23:53:23
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphAutomaticDifferentiation.h 2023-05-22 01:20:38
@@ -16,15 +16,13 @@
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MPSGraphGradientOps)
-/*!
- * @abstract Calculates partial derviative of primaryTensor wrt secondaryTensor
- *
- * @param primaryTensor tensor to be differentiated (numerator)
- * @param tensors tensors to do the differentiation with (denominator)
- * @param name name for the gradient operation
- *
- * @return A valid MPSGraphTensor dictionary object containing partial derivative d(primaryTensor)/d(secondaryTensor) for each tensor as key
- */
+/// Calculates partial derviative of primaryTensor wrt secondaryTensor
+///
+/// - Parameters:
+/// - primaryTensor: tensor to be differentiated (numerator)
+/// - tensors: tensors to do the differentiation with (denominator)
+/// - name: name for the gradient operation
+/// - Returns: A valid MPSGraphTensor dictionary object containing partial derivative d(primaryTensor)/d(secondaryTensor) for each tensor as key
-(NSDictionary<MPSGraphTensor *, MPSGraphTensor *> *) gradientForPrimaryTensor:(MPSGraphTensor *) primaryTensor
withTensors:(NSArray<MPSGraphTensor *> *) tensors
name:(NSString * _Nullable) name
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphControlFlowOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphControlFlowOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphControlFlowOps.h 2023-03-09 19:13:37
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphControlFlowOps.h 2023-05-22 01:17:40
@@ -16,79 +16,67 @@
MPS_CLASS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
@interface MPSGraph(MPSGraphControlFlowOps)
-/*!
- * @abstract Defines a scope where all the ops defined in this block get controlDependency operations
- * @return A valid MPSGraphTensor array with results forwarded to return of controlDependency call
- */
+/// Defines a scope where all the ops defined in this block get controlDependency operations
+///
+/// - Returns: A valid MPSGraphTensor array with results forwarded to return of controlDependency call
typedef NSArray<MPSGraphTensor *> * _Nonnull(^MPSGraphControlFlowDependencyBlock)();
-/*!
- * @abstract Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed. This call blocks till execution has completed.
- *
- * @param operations Operations maked as control dependency for all ops created inside the dependent block
- * @param dependentBlock MPSGraphControlFlowDependencyBlock which is provided by caller to create dependent ops
- * @param name name of scope
- *
- * @return A valid MPSGraphTensor array with results returned from dependentBlock forwarded
- */
+/// Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed. This call blocks till execution has completed.
+///
+/// - Parameters:
+/// - operations: Operations maked as control dependency for all ops created inside the dependent block
+/// - dependentBlock: MPSGraphControlFlowDependencyBlock which is provided by caller to create dependent ops
+/// - name: name of scope
+/// - Returns: A valid MPSGraphTensor array with results returned from dependentBlock forwarded
-(NSArray<MPSGraphTensor *> *) controlDependencyWithOperations:(NSArray<MPSGraphOperation *> *) operations
dependentBlock:(MPSGraphControlFlowDependencyBlock) dependentBlock
name:(NSString * _Nullable) name;
-/*! @abstract A block to have if/else condition in it
- * @return results If no error, the tensors returned by user. If not empty, user must define both then/else block,
- * both should have same number of arguments and each corresponding argument should have same elementTypes.
- */
+/// A block to have if/else condition in it
+///
+/// - Returns: results If no error, the tensors returned by user. If not empty, user must define both then/else block,
+/// both should have same number of arguments and each corresponding argument should have same elementTypes.
typedef NSArray<MPSGraphTensor *> * _Nonnull(^MPSGraphIfThenElseBlock)();
-/*!
- * @abstract Add an if/then/else op to the graph
- *
- * @param predicateTensor Tensor must have a single scalar value, used to decide between then/else branches
- * @param thenBlock If predicate is true operations in this block are executed
- * @param elseBlock If predicate is false operations in this block are executed
- * @param name name of operation
- *
- * @return results If no error, the tensors returned by user. If not empty, user must define both then/else block,
- * both should have same number of arguments and each corresponding argument should have same elementTypes.
- */
+/// Add an if/then/else op to the graph
+///
+/// - Parameters:
+/// - predicateTensor: Tensor must have a single scalar value, used to decide between then/else branches
+/// - thenBlock: If predicate is true operations in this block are executed
+/// - elseBlock: If predicate is false operations in this block are executed
+/// - name: name of operation
+/// - Returns: results If no error, the tensors returned by user. If not empty, user must define both then/else block,
+/// both should have same number of arguments and each corresponding argument should have same elementTypes.
-(NSArray<MPSGraphTensor *> *) ifWithPredicateTensor:(MPSGraphTensor *) predicateTensor
thenBlock:(MPSGraphIfThenElseBlock) thenBlock
elseBlock:(MPSGraphIfThenElseBlock _Nullable) elseBlock
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( if(_:then:else:name:) );
-/*!
- * @abstract While loop before block, this block executes before the condition is evaluated for each iteration
- *
- * @param inputTensors inputTensors to the whileConditionBlock, for the 1st iteration will be same as initialInputs passed to the whileLoop
- * @param resultTensors A valid MPSGraphTensor array with results forwarded to after block or returned from the whileLoop depending on the predicateTensor.
- * It will be empty and the caller block should fill it up before returning.
- *
- * @return Tensor MUST be set and have a single scalar value, used to decide between executing the bodyBlock or returning from the whileLoop
- */
+/// While loop before block, this block executes before the condition is evaluated for each iteration
+///
+/// - Parameters:
+/// - inputTensors: inputTensors to the whileConditionBlock, for the 1st iteration will be same as initialInputs passed to the whileLoop
+/// - resultTensors: A valid MPSGraphTensor array with results forwarded to after block or returned from the whileLoop depending on the predicateTensor. It will be empty and the caller block should fill it up before returning.
+/// - Returns: Tensor MUST be set and have a single scalar value, used to decide between executing the bodyBlock or returning from the whileLoop
typedef MPSGraphTensor *_Nonnull(^MPSGraphWhileBeforeBlock)(NSArray<MPSGraphTensor *> *inputTensors,
NSMutableArray<MPSGraphTensor *> *_Nonnull resultTensors);
-/*!
- * @abstract While loop after block, this block executes after the condition is evaluated for each iteration
- *
- * @param bodyBlockArguments inputs to the body of the whileLoop passed by the conditionBlock return, should be the same element types as the return of the whileLoop
- *
- * @return A valid MPSGraphTensor array with results forwarded to condition block
- */
+/// While loop after block, this block executes after the condition is evaluated for each iteration
+///
+/// - Parameters:
+/// - bodyBlockArguments: inputs to the body of the whileLoop passed by the conditionBlock return, should be the same element types as the return of the whileLoop
+/// - Returns: A valid MPSGraphTensor array with results forwarded to condition block
typedef NSArray<MPSGraphTensor *> * _Nonnull(^MPSGraphWhileAfterBlock)(NSArray<MPSGraphTensor *> *bodyBlockArguments);
-/*!
- * @abstract Adds a whileLoop operation
- *
- * @param initialInputs inputTensors to the whileBeforeBlock, for the 1st iteration will be same as initialInputs passed to the whileLoop
- * @param before beforeBlock, this will be run first and then call the afterBlock with results or return results from the loop
- * @param after afterBlock, this will execute after the condition evaluation
- * @param name name of operation
- *
- * @return A valid MPSGraphTensor array with results returned from the conditionBlock depending on the predicateTensor
- */
+/// Adds a whileLoop operation
+///
+/// - Parameters:
+/// - initialInputs: inputTensors to the whileBeforeBlock, for the 1st iteration will be same as initialInputs passed to the whileLoop
+/// - before: beforeBlock, this will be run first and then call the afterBlock with results or return results from the loop
+/// - after: afterBlock, this will execute after the condition evaluation
+/// - name: name of operation
+/// - Returns: A valid MPSGraphTensor array with results returned from the conditionBlock depending on the predicateTensor
-(NSArray<MPSGraphTensor *> *) whileWithInitialInputs:(NSArray<MPSGraphTensor *> *) initialInputs
before:(MPSGraphWhileBeforeBlock) before
after:(MPSGraphWhileAfterBlock) after
@@ -96,29 +84,25 @@
MPS_SWIFT_NAME( while(initialInputs:before:after:name:) );
-/*!
- * @abstract A block for the body in the for loop
- *
- * @param index loopIndex per iteration, it is a scalar tensor
- * @param iterationArguments arguments for this iteration, same count and corresponding elementTypes as initialIterationArguments and return types of the forLoop
- *
- * @return A valid MPSGraphTensor array with same count and corresponding elementTypes as initialIterationArguments and return types of the forLoop
- */
+/// A block for the body in the for loop
+///
+/// - Parameters:
+/// - index: loopIndex per iteration, it is a scalar tensor
+/// - iterationArguments: arguments for this iteration, same count and corresponding elementTypes as initialIterationArguments and return types of the forLoop
+/// - Returns: A valid MPSGraphTensor array with same count and corresponding elementTypes as initialIterationArguments and return types of the forLoop
typedef NSArray<MPSGraphTensor *> * _Nonnull(^MPSGraphForLoopBodyBlock)(MPSGraphTensor *index,
NSArray<MPSGraphTensor *> *iterationArguments);
-/*!
- * @abstract Adds a forLoop operation, The lower and upper bounds specify a half-open range: the range includes the lower bound but does not include the upper bound.
- *
- * @param lowerBound lowerBound value of the loop, this is a scalar tensor, this is the index the loop will start with
- * @param upperBound upperBound value of the loop, this is a scalar tensor
- * @param step step value of the loop, this is a scalar tensor and must be positive
- * @param initialBodyArguments initial set of iteration arguments passed to the bodyBlock of the for loop
- * @param body bodyBlock, this will execute the body of the forLoop
- * @param name name of operation
- *
- * @return A valid MPSGraphTensor array with same count and corresponding elementTypes as initialIterationArguments and return types of the forLoop
- */
+/// Adds a forLoop operation, The lower and upper bounds specify a half-open range: the range includes the lower bound but does not include the upper bound.
+///
+/// - Parameters:
+/// - lowerBound: lowerBound value of the loop, this is a scalar tensor, this is the index the loop will start with
+/// - upperBound: upperBound value of the loop, this is a scalar tensor
+/// - step: step value of the loop, this is a scalar tensor and must be positive
+/// - initialBodyArguments: initial set of iteration arguments passed to the bodyBlock of the for loop
+/// - body: bodyBlock, this will execute the body of the forLoop
+/// - name: name of operation
+/// - Returns: A valid MPSGraphTensor array with same count and corresponding elementTypes as initialIterationArguments and return types of the forLoop
-(NSArray<MPSGraphTensor *> *) forLoopWithLowerBound:(MPSGraphTensor *) lowerBound
upperBound:(MPSGraphTensor *) upperBound
step:(MPSGraphTensor *) step
@@ -127,16 +111,14 @@
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( for(lowerBound:upperBound:step:initialBodyArguments:body:name:) );
-/*!
- * @abstract Adds a forLoop operation, with a specific number of iterations
- *
- * @param numberOfIterations tensor with number of iterations the loop will execute
- * @param initialBodyArguments initial set of iteration arguments passed to the bodyBlock of the for loop
- * @param body bodyBlock, this will execute the body of the forLoop, index will go from 0 to numberOfIterations-1
- * @param name name of operation
- *
- * @return A valid MPSGraphTensor array with same count and corresponding elementTypes as initialIterationArguments and return types of the forLoop
- */
+/// Adds a forLoop operation, with a specific number of iterations
+///
+/// - Parameters:
+/// - numberOfIterations: tensor with number of iterations the loop will execute
+/// - initialBodyArguments: initial set of iteration arguments passed to the bodyBlock of the for loop
+/// - body: bodyBlock, this will execute the body of the forLoop, index will go from 0 to numberOfIterations-1
+/// - name: name of operation
+/// - Returns: A valid MPSGraphTensor array with same count and corresponding elementTypes as initialIterationArguments and return types of the forLoop
-(NSArray<MPSGraphTensor *> *) forLoopWithNumberOfIterations:(MPSGraphTensor *) numberOfIterations
initialBodyArguments:(NSArray<MPSGraphTensor *> *)initialBodyArguments
body:(MPSGraphForLoopBodyBlock) body
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphConvolutionOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphConvolutionOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphConvolutionOps.h 2023-03-09 23:50:16
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphConvolutionOps.h 2023-05-19 21:42:51
@@ -13,30 +13,57 @@
NS_ASSUME_NONNULL_BEGIN
+/// Descriptor for properties of convolution.
+/// It is used to create 2D convolution operation.
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
-@interface MPSGraphConvolution2DOpDescriptor : NSObject<NSCopying>
+@interface MPSGraphConvolution2DOpDescriptor : MPSGraphObject<NSCopying>
-
+/// stride in `x` or width dimension.
@property (readwrite, nonatomic) NSUInteger strideInX;
+/// stride in `y` or height dimension.
@property (readwrite, nonatomic) NSUInteger strideInY;
+/// dilation in `x` or width dimension.
@property (readwrite, nonatomic) NSUInteger dilationRateInX;
+/// dilation in `y` or height dimension.
@property (readwrite, nonatomic) NSUInteger dilationRateInY;
-
+/// padding in `x` or width dimension on left side.
@property (readwrite, nonatomic) NSUInteger paddingLeft;
+/// padding in `x` or width dimension on right side.
@property (readwrite, nonatomic) NSUInteger paddingRight;
+/// padding in `y` or height dimension at top.
@property (readwrite, nonatomic) NSUInteger paddingTop;
+/// padding in `y` or height dimension at bottom.
@property (readwrite, nonatomic) NSUInteger paddingBottom;
-
+/// padding style applied on source tensor. If paddingStyle is `MPSGraphPaddingStyleExplicit`, paddingLeft, laddingRight, paddingTop,
+/// paddingBottom must to be specified. This is symbolic padding on input tensor. For all other padding styles,
+/// paddings on left, right, top and bottom are computed internally and need not be specified.
@property (readwrite, nonatomic) MPSGraphPaddingStyle paddingStyle;
+/// layout of source tensor. Convolution operation uses this to interpret data in source tensor i.e. order of named dimensions
+/// e.g. `batch x channels x width x height` for `NCHW` layout
@property (readwrite, nonatomic) MPSGraphTensorNamedDataLayout dataLayout;
+/// layout of weights tensor. Convolution operation uses this to interpret data in weights tensor i.e. order of named dimensions
+/// e.g. `outputChannels x inputChannels x kernelHeight x kernelWidth` for `OIHW`.
@property (readwrite, nonatomic) MPSGraphTensorNamedDataLayout weightsLayout;
-
-/*! @property groups
- * @discussion groups of the operation
- */
+/// number of groups in convolution. Input and output feature channels are divided into groups and
+/// input channels in a group are only connected to output channels in corresponding group.
+/// Number of weights are `outputFeatureChannels x inputFeatureChannels/groups x kernelWidth x kernelHeight`
@property (readwrite, nonatomic) NSUInteger groups;
-
+/// creates convolution descriptor with given values for parameters.
+/// - Parameters:
+/// - strideInX: See ``strideInX`` property.
+/// - strideInY: See ``strideInY`` property.
+/// - dilationRateInX: See ``dilationRateInX`` property.
+/// - dilationRateInY: See ``dilationRateInY`` property.
+/// - groups: See ``groups`` property.
+/// - paddingLeft: See ``paddingLeft`` property.
+/// - paddingRight: See ``paddingRight`` property.
+/// - paddingTop: See ``paddingTop`` property.
+/// - paddingBottom: See ``paddingBottom`` property.
+/// - paddingStyle: See ``paddingStyle`` property.
+/// - dataLayout: See ``dataLayout`` property.
+/// - weightsLayout: See ``weightsLayout`` property.
+/// - Returns: The descriptor on autoreleasepool.
+(nullable instancetype) descriptorWithStrideInX:(NSUInteger) strideInX
strideInY:(NSUInteger) strideInY
dilationRateInX:(NSUInteger) dilationRateInX
@@ -50,6 +77,17 @@
dataLayout:(MPSGraphTensorNamedDataLayout) dataLayout
weightsLayout:(MPSGraphTensorNamedDataLayout) weightsLayout;
+/// creates convolution descriptor with given values for parameters.
+/// - Parameters:
+/// - strideInX: See ``strideInX`` property.
+/// - strideInY: See ``strideInY`` property.
+/// - dilationRateInX: See ``dilationRateInX`` property.
+/// - dilationRateInY: See ``dilationRateInY`` property.
+/// - groups: See ``groups`` property.
+/// - paddingStyle: See ``paddingStyle`` property.
+/// - dataLayout: See ``dataLayout`` property.
+/// - weightsLayout: See ``weightsLayout`` property.
+/// - Returns: The descriptor on autoreleasepool.
+(nullable instancetype) descriptorWithStrideInX:(NSUInteger) strideInX
strideInY:(NSUInteger) strideInY
dilationRateInX:(NSUInteger) dilationRateInX
@@ -59,7 +97,12 @@
dataLayout:(MPSGraphTensorNamedDataLayout) dataLayout
weightsLayout:(MPSGraphTensorNamedDataLayout) weightsLayout;
-
+/// sets values of padding to given values.
+/// - Parameters:
+/// - paddingLeft: See ``paddingLeft`` property.
+/// - paddingRight: See ``paddingRight`` property.
+/// - paddingTop: See ``paddingTop`` property.
+/// - paddingBottom: See ``paddingBottom`` property.
-(void) setExplicitPaddingWithPaddingLeft:(NSUInteger) paddingLeft
paddingRight:(NSUInteger) paddingRight
paddingTop:(NSUInteger) paddingTop
@@ -68,34 +111,69 @@
@end
+/// Descriptor for properties of convolution.
+/// It is used to create 3D convolution operation.
MPS_CLASS_AVAILABLE_STARTING(macos(13.2), ios(16.3), tvos(16.3))
-@interface MPSGraphConvolution3DOpDescriptor : NSObject<NSCopying>
+@interface MPSGraphConvolution3DOpDescriptor : MPSGraphObject<NSCopying>
-
+/// stride in `x` or width dimension.
@property (readwrite, nonatomic) NSUInteger strideInX;
+/// stride in `y` or height dimension.
@property (readwrite, nonatomic) NSUInteger strideInY;
+/// stride in `z` or depth dimension.
@property (readwrite, nonatomic) NSUInteger strideInZ;
+/// dilation in `x` or width dimension.
@property (readwrite, nonatomic) NSUInteger dilationRateInX;
+/// dilation in `y` or height dimension.
@property (readwrite, nonatomic) NSUInteger dilationRateInY;
+/// dilation in `z` or depth dimension.
@property (readwrite, nonatomic) NSUInteger dilationRateInZ;
-
+/// padding in `x` or width dimension on left side.
@property (readwrite, nonatomic) NSUInteger paddingLeft;
+/// padding in `x` or width dimension on right side.
@property (readwrite, nonatomic) NSUInteger paddingRight;
+/// padding in `y` or height dimension at top.
@property (readwrite, nonatomic) NSUInteger paddingTop;
+/// padding in `y` or height dimension at bottom.
@property (readwrite, nonatomic) NSUInteger paddingBottom;
+/// padding in `z` or depth dimension in front.
@property (readwrite, nonatomic) NSUInteger paddingFront;
+/// padding in `z` or depth dimension in back.
@property (readwrite, nonatomic) NSUInteger paddingBack;
-
+/// padding style applied on source tensor. If paddingStyle is `MPSGraphPaddingStyleExplicit`, paddingLeft, laddingRight, paddingTop,
+/// paddingBottom, paddingFront, paddingBack must to be specified. This is symbolic padding on input tensor. For all other padding styles,
+/// paddings on left, right, top, bottom, front and back are computed internally and need not be specified.
@property (readwrite, nonatomic) MPSGraphPaddingStyle paddingStyle;
+/// layout of source tensor. Convolution operation uses this to interpret data in source tensor i.e. order of named dimensions
+/// e.g. `batch x channels x depth x width x height` for `NCDHW` layout
@property (readwrite, nonatomic) MPSGraphTensorNamedDataLayout dataLayout;
+/// layout of weights tensor. Convolution operation uses this to interpret data in weights tensor i.e. order of named dimensions
+/// e.g. `outputChannels x inputChannels x kernelDepth x kernelHeight x kernelWidth` for `OIDHW`.
@property (readwrite, nonatomic) MPSGraphTensorNamedDataLayout weightsLayout;
-
-/*! @property groups
- * @discussion groups of the operation
- */
+/// number of groups in convolution. Input and output feature channels are divided into groups and
+/// input channels in a group are only connected to output channels in corresponding group.
+/// Number of weights are `outputFeatureChannels x inputFeatureChannels/groups x kernelDepth x kernelWidth x kernelHeight`
@property (readwrite, nonatomic) NSUInteger groups;
-
+/// creates convolution descriptor with given values for parameters.
+/// - Parameters:
+/// - strideInX: See ``strideInX`` property.
+/// - strideInY: See ``strideInY`` property.
+/// - strideInZ: See ``strideInZ`` property.
+/// - dilationRateInX: See ``dilationRateInX`` property.
+/// - dilationRateInY: See ``dilationRateInY`` property.
+/// - dilationRateInZ: See ``dilationRateInZ`` property.
+/// - groups: See ``groups`` property.
+/// - paddingLeft: See ``paddingLeft`` property.
+/// - paddingRight: See ``paddingRight`` property.
+/// - paddingTop: See ``paddingTop`` property.
+/// - paddingBottom: See ``paddingBottom`` property.
+/// - paddingFront: See ``paddingFront`` property.
+/// - paddingBack: See ``paddingBack`` property.
+/// - paddingStyle: See ``paddingStyle`` property.
+/// - dataLayout: See ``dataLayout`` property.
+/// - weightsLayout: See ``weightsLayout`` property.
+/// - Returns: The descriptor on autoreleasepool.
+(nullable instancetype) descriptorWithStrideInX:(NSUInteger) strideInX
strideInY:(NSUInteger) strideInY
strideInZ:(NSUInteger) strideInZ
@@ -113,6 +191,19 @@
dataLayout:(MPSGraphTensorNamedDataLayout) dataLayout
weightsLayout:(MPSGraphTensorNamedDataLayout) weightsLayout;
+/// creates convolution descriptor with given values for parameters.
+/// - Parameters:
+/// - strideInX: See ``strideInX`` property.
+/// - strideInY: See ``strideInY`` property.
+/// - strideInZ: See ``strideInZ`` property.
+/// - dilationRateInX: See ``dilationRateInX`` property.
+/// - dilationRateInY: See ``dilationRateInY`` property.
+/// - dilationRateInZ: See ``dilationRateInZ`` property.
+/// - groups: See ``groups`` property.
+/// - paddingStyle: See ``paddingStyle`` property.
+/// - dataLayout: See ``dataLayout`` property.
+/// - weightsLayout: See ``weightsLayout`` property.
+/// - Returns: The descriptor on autoreleasepool.
+(nullable instancetype) descriptorWithStrideInX:(NSUInteger) strideInX
strideInY:(NSUInteger) strideInY
strideInZ:(NSUInteger) strideInZ
@@ -124,41 +215,51 @@
dataLayout:(MPSGraphTensorNamedDataLayout) dataLayout
weightsLayout:(MPSGraphTensorNamedDataLayout) weightsLayout;
-
+/// sets values of padding to given values.
+/// - Parameters:
+/// - paddingLeft: See ``paddingLeft`` property.
+/// - paddingRight: See ``paddingRight`` property.
+/// - paddingTop: See ``paddingTop`` property.
+/// - paddingBottom: See ``paddingBottom`` property.
+/// - paddingFront: See ``paddingFront`` property.
+/// - paddingBottom: See ``paddingBottom`` property.
-(void) setExplicitPaddingWithPaddingLeft:(NSUInteger) paddingLeft
paddingRight:(NSUInteger) paddingRight
paddingTop:(NSUInteger) paddingTop
paddingBottom:(NSUInteger) paddingBottom
paddingFront:(NSUInteger) paddingFront
paddingBack:(NSUInteger) paddingBack;
-
-
@end
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MPSGraphConvolutionOps)
-
-
+/// Creates a 2d (forward) convolution operation and returns the result tensor.
+///
+/// - Parameters:
+/// - source: source tensor - must be of rank 4. The layout is defined by ``descriptor.dataLayout``.
+/// - weights: weights tensor, must be rank 4. The layout is defined by ``descriptor.weightsLayout``.
+/// - descriptor: Specifies strides, dilation rates, paddings and layouts.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) convolution2DWithSourceTensor:(MPSGraphTensor *) source
weightsTensor:(MPSGraphTensor *) weights
descriptor:(MPSGraphConvolution2DOpDescriptor *) descriptor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( convolution2D(_:weights:descriptor:name:) );
-/*!
- * @abstract Create Convolution gradient op and return the result tensor
- * @discussion Computes the gradient of source input for the forward pass Convolution op with identical parameters.
- * See discussion of convolution2DWithSourceTensor for more in depth description of paramters.
- *
- * @param incomingGradient Incoming gradient tensor
- * @param weights Forward pass weights tensor
- * @param outputShape Shape of the forward pass source tensor
- * @param forwardConvolutionDescriptor Forward pass op descriptor
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
- */
+/// Create convolution 2d gradient operation with respect to forward convolution source tensor.
+/// If `S` is source tensor to forward convoluiton, `R` is the result/returned tensor of forward convolution,
+/// and `L` is the loss function, convolution2DDataGradientWithIncomingGradientTensor returns tensor `dL/dS = dL/dR * dR/dS`,
+/// where `dL/dR` is the incomingGradient parameter.
+///
+/// - Parameters:
+/// - incomingGradient: Incoming loss gradient tensor
+/// - weights: Forward pass weights tensor
+/// - outputShape: Shape of the forward pass source tensor
+/// - forwardConvolutionDescriptor: Forward convolution 2d op ``descriptor``
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) convolution2DDataGradientWithIncomingGradientTensor:(MPSGraphTensor *) incomingGradient
weightsTensor:(MPSGraphTensor *) weights
outputShape:(MPSShape *) outputShape
@@ -166,19 +267,18 @@
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( convolution2DDataGradient(_:weights:outputShape:forwardConvolutionDescriptor:name:) );
-/*!
- * @abstract Create Convolution gradient op and return the result tensor
- * @discussion Computes the gradient of source input for the forward pass Convolution op with identical parameters.
- * See discussion of convolution2DWithSourceTensor for more in depth description of paramters.
- *
- * @param gradient Incoming gradient tensor
- * @param weights Forward pass weights tensor
- * @param outputShapeTensor 1D Int32 or Int64 Tensor. Shape of the forward pass source tensor
- * @param forwardConvolutionDescriptor Forward pass op descriptor
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
- */
+/// Create convolution 2d gradient operation with respect to forward convolution source tensor.
+/// If `S` is source tensor to forward convoluiton, `R` is the result/returned tensor of forward convolution,
+/// and `L` is the loss function, convolution2DDataGradientWithIncomingGradientTensor returns tensor `dL/dS = dL/dR * dR/dS`,
+/// where `dL/dR` is the incomingGradient parameter.
+///
+/// - Parameters:
+/// - incomingGradient: Incoming loss gradient tensor
+/// - weights: Forward pass weights tensor
+/// - outputShapeTensor: 4D Int32 or Int64 tensor. Shape of the forward pass source tensor
+/// - forwardConvolutionDescriptor: Forward convolution 2d op ``descriptor``
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) convolution2DDataGradientWithIncomingGradientTensor:(MPSGraphTensor *) gradient
weightsTensor:(MPSGraphTensor *) weights
outputShapeTensor:(MPSGraphTensor *) outputShapeTensor
@@ -187,19 +287,18 @@
MPS_CLASS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
MPS_SWIFT_NAME( convolution2DDataGradient(_:weights:outputShapeTensor:forwardConvolutionDescriptor:name:) );
-/*!
- * @abstract Create Convolution gradient op and return the result tensor
- * @discussion Computes the gradient of weights input for the forward pass Convolution op with identical parameters.
- * See discussion of convolution2DWithSourceTensor for more in depth description of paramters.
- *
- * @param incomingGradient Incoming gradient tensor
- * @param source Forward pass source tensor
- * @param outputShape Shape of the forward pass weights tensor
- * @param forwardConvolutionDescriptor Forward pass op descriptor
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
- */
+/// Create convolution 2d gradient operation with respect to forward convolution weights tensor.
+/// If `W` is weights tensor to forward convoluiton, `R` is the result/returned tensor of forward convolution,
+/// and `L` is the loss function, convolution2DWeightsGradientWithIncomingGradientTensor returns tensor `dL/dW = dL/dR * dR/dW`,
+/// where `dL/dR` is the incomingGradient parameter.
+///
+/// - Parameters:
+/// - incomingGradient: Incoming loss gradient tensor
+/// - weights: Forward pass weights tensor
+/// - outputShape: Shape of the forward pass source tensor
+/// - forwardConvolutionDescriptor: Forward convolution 2d op ``descriptor``
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) convolution2DWeightsGradientWithIncomingGradientTensor:(MPSGraphTensor *) incomingGradient
sourceTensor:(MPSGraphTensor *) source
outputShape:(MPSShape *) outputShape
@@ -207,19 +306,19 @@
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( convolution2DWeightsGradient(_:source:outputShape:forwardConvolutionDescriptor:name:) );
-/*!
- * @abstract Create Convolution gradient op and return the result tensor
- * @discussion Computes the gradient of weights input for the forward pass Convolution op with identical parameters.
- * See discussion of convolution2DWithSourceTensor for more in depth description of paramters.
- *
- * @param gradient Incoming gradient tensor
- * @param source Forward pass source tensor
- * @param outputShapeTensor 1D int32 or Int64 Tensor. Shape of the forward pass weights tensor
- * @param forwardConvolutionDescriptor Forward pass op descriptor
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
- */
+
+/// Create convolution 2d gradient operation with respect to forward convolution weights tensor.
+/// If `W` is weights tensor to forward convoluiton, `R` is the result/returned tensor of forward convolution,
+/// and `L` is the loss function, convolution2DWeightsGradientWithIncomingGradientTensor returns tensor `dL/dW = dL/dR * dR/dW`,
+/// where `dL/dR` is the incomingGradient parameter.
+///
+/// - Parameters:
+/// - incomingGradient: Incoming loss gradient tensor
+/// - weights: Forward pass weights tensor
+/// - outputShapeTensor: 4D int32 or Int64 Tensor. Shape of the forward pass source tensor
+/// - forwardConvolutionDescriptor: Forward convolution 2d op ``descriptor``
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) convolution2DWeightsGradientWithIncomingGradientTensor:(MPSGraphTensor *) gradient
sourceTensor:(MPSGraphTensor *) source
outputShapeTensor:(MPSGraphTensor *) outputShapeTensor
@@ -229,7 +328,14 @@
MPS_SWIFT_NAME( convolution2DWeightsGradient(_:source:outputShapeTensor:forwardConvolutionDescriptor:name:) );
-
+/// Creates a 3d (forward) convolution operation and returns the result tensor.
+///
+/// - Parameters:
+/// - source: source tensor - must be of rank 5. The layout is defined by ``descriptor.dataLayout``.
+/// - weights: weights tensor, must be rank 5. The layout is defined by ``descriptor.weightsLayout``.
+/// - descriptor: Specifies strides, dilation rates, paddings and layouts.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) convolution3DWithSourceTensor:(MPSGraphTensor *) source
weightsTensor:(MPSGraphTensor *) weights
descriptor:(MPSGraphConvolution3DOpDescriptor *) descriptor
@@ -237,19 +343,18 @@
MPS_CLASS_AVAILABLE_STARTING(macos(13.2), ios(16.3), tvos(16.3))
MPS_SWIFT_NAME( convolution3D(_:weights:descriptor:name:) );
-/*!
- * @abstract Create Convolution 3D gradient op and return the result tensor
- * @discussion Computes the gradient of source input for the forward pass Convolution op with identical parameters.
- * See discussion of convolution3DWithSourceTensor for more in depth description of paramters.
- *
- * @param incomingGradient Incoming gradient tensor
- * @param weights Forward pass weights tensor
- * @param outputShape Shape of the forward pass source tensor
- * @param forwardConvolutionDescriptor Forward pass op descriptor
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
- */
+/// Create convolution 3d gradient operation with respect to forward convolution source tensor.
+/// If `S` is source tensor to forward convoluiton, `R` is the result/returned tensor of forward convolution,
+/// and `L` is the loss function, convolution3DDataGradientWithIncomingGradientTensor returns tensor `dL/dS = dL/dR * dR/dS`,
+/// where `dL/dR` is the incomingGradient parameter.
+///
+/// - Parameters:
+/// - incomingGradient: Incoming loss gradient tensor
+/// - weights: Forward pass weights tensor
+/// - outputShape: Shape of the forward pass source tensor
+/// - forwardConvolutionDescriptor: Forward convolution 2d op ``descriptor``
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) convolution3DDataGradientWithIncomingGradientTensor:(MPSGraphTensor *) incomingGradient
weightsTensor:(MPSGraphTensor *) weights
outputShape:(MPSShape *) outputShape
@@ -258,19 +363,18 @@
MPS_CLASS_AVAILABLE_STARTING(macos(13.2), ios(16.3), tvos(16.3))
MPS_SWIFT_NAME( convolution3DDataGradient(_:weights:outputShape:forwardConvolutionDescriptor:name:) );
-/*!
- * @abstract Create Convolution 3D gradient op and return the result tensor
- * @discussion Computes the gradient of source input for the forward pass Convolution op with identical parameters.
- * See discussion of convolution3DWithSourceTensor for more in depth description of paramters.
- *
- * @param gradient Incoming gradient tensor
- * @param weights Forward pass weights tensor
- * @param outputShapeTensor 1D Int32 or Int64 Tensor. Shape of the forward pass source tensor
- * @param forwardConvolutionDescriptor Forward pass op descriptor
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
- */
+/// Create convolution 3d gradient operation with respect to forward convolution source tensor.
+/// If `S` is source tensor to forward convoluiton, `R` is the result/returned tensor of forward convolution,
+/// and `L` is the loss function, convolution3DDataGradientWithIncomingGradientTensor returns tensor `dL/dS = dL/dR * dR/dS`,
+/// where `dL/dR` is the incomingGradient parameter.
+///
+/// - Parameters:
+/// - incomingGradient: Incoming loss gradient tensor
+/// - weights: Forward pass weights tensor
+/// - outputShapeTensor: 4D Int32 or Int64 tensor. Shape of the forward pass source tensor
+/// - forwardConvolutionDescriptor: Forward convolution 2d op ``descriptor``
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) convolution3DDataGradientWithIncomingGradientTensor:(MPSGraphTensor *) gradient
weightsTensor:(MPSGraphTensor *) weights
outputShapeTensor:(MPSGraphTensor *) outputShapeTensor
@@ -279,19 +383,18 @@
MPS_CLASS_AVAILABLE_STARTING(macos(13.2), ios(16.3), tvos(16.3))
MPS_SWIFT_NAME( convolution3DDataGradient(_:weights:outputShapeTensor:forwardConvolutionDescriptor:name:) );
-/*!
- * @abstract Create Convolution 3D gradient op and return the result tensor
- * @discussion Computes the gradient of weights input for the forward pass Convolution op with identical parameters.
- * See discussion of convolution3DWithSourceTensor for more in depth description of paramters.
- *
- * @param incomingGradient Incoming gradient tensor
- * @param source Forward pass source tensor
- * @param outputShape Shape of the forward pass weights tensor
- * @param forwardConvolutionDescriptor Forward pass op descriptor
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
- */
+/// Create convolution 3d gradient operation with respect to forward convolution weights tensor.
+/// If `W` is weights tensor to forward convoluiton, `R` is the result/returned tensor of forward convolution,
+/// and `L` is the loss function, convolution3DWeightsGradientWithIncomingGradientTensor returns tensor `dL/dW = dL/dR * dR/dW`,
+/// where `dL/dR` is the incomingGradient parameter.
+///
+/// - Parameters:
+/// - incomingGradient: Incoming loss gradient tensor
+/// - weights: Forward pass weights tensor
+/// - outputShape: Shape of the forward pass source tensor
+/// - forwardConvolutionDescriptor: Forward convolution 2d op ``descriptor``
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) convolution3DWeightsGradientWithIncomingGradientTensor:(MPSGraphTensor *) incomingGradient
sourceTensor:(MPSGraphTensor *) source
outputShape:(MPSShape *) outputShape
@@ -300,19 +403,18 @@
MPS_CLASS_AVAILABLE_STARTING(macos(13.2), ios(16.3), tvos(16.3))
MPS_SWIFT_NAME( convolution3DWeightsGradient(_:source:outputShape:forwardConvolutionDescriptor:name:) );
-/*!
- * @abstract Create Convolution 3D gradient op and return the result tensor
- * @discussion Computes the gradient of weights input for the forward pass Convolution op with identical parameters.
- * See discussion of convolution3DWithSourceTensor for more in depth description of paramters.
- *
- * @param gradient Incoming gradient tensor
- * @param source Forward pass source tensor
- * @param outputShapeTensor 1D int32 or Int64 Tensor. Shape of the forward pass weights tensor
- * @param forwardConvolutionDescriptor Forward pass op descriptor
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
- */
+/// Create convolution 3d gradient operation with respect to forward convolution weights tensor.
+/// If `W` is weights tensor to forward convoluiton, `R` is the result/returned tensor of forward convolution,
+/// and `L` is the loss function, convolution3DWeightsGradientWithIncomingGradientTensor returns tensor `dL/dW = dL/dR * dR/dW`,
+/// where `dL/dR` is the incomingGradient parameter.
+///
+/// - Parameters:
+/// - incomingGradient: Incoming loss gradient tensor
+/// - weights: Forward pass weights tensor
+/// - outputShapeTensor: 4D int32 or Int64 Tensor. Shape of the forward pass source tensor
+/// - forwardConvolutionDescriptor: Forward convolution 2d op ``descriptor``
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) convolution3DWeightsGradientWithIncomingGradientTensor:(MPSGraphTensor *) gradient
sourceTensor:(MPSGraphTensor *) source
outputShapeTensor:(MPSGraphTensor *) outputShapeTensor
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphConvolutionTransposeOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphConvolutionTransposeOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphConvolutionTransposeOps.h 2023-03-09 23:50:16
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphConvolutionTransposeOps.h 2023-05-22 01:17:40
@@ -16,31 +16,30 @@
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MPSGraphConvolutionTransposeOps)
-/*!
- * @abstract Create ConvolutionTranspose op and return the result tensor
- * @discussion Convolution Tranpose op is exactly the same as convolution gradint with respect to input image (convolution2DDataGradient)
- * Weights tensor and source tensors are interpreted as they are in convolution2DDataGradientWithIncomingGradient. For example
- * if weightsTensor layout is HWIO, inner most (fastest moving) dimension, denoted by O here should be equal to inputFeatureChannels
- * i.e. number of channels in source tensor
- * and next fasted moving dimension denoated by I is equal to number of channels in returns (destination) tensor outputFeatureChannels.
- * TensorFlow interprets the weights tensor same way excpet that it states weights are in HWOI format. We dont define another weights format enum
- * rather we reinterpret HWIO just like TensorFlow does for gradient with data.
- * Normally in auto encoder, convoluton transpose is associated with regular convolution i.e. convolution downsamples by stride s
- * and convolution tranpose upsamples by factor s.
- * In that case, convolution transpose can map same source size to multiple destination sizes. The relationship between sourceWidth and destinationWidth is
- * (sourceWidth - 1) * stride + 1 + (kernelWidth - 1) * dilationRate <= destinationWidth + paddingLeft + paddingRight
- * so there are stride -1 destinationWidth that give same sourceWidth. In order to disambiguate, outputShape parameter is used.
- * This is what TensorFlow does.
- * PyTourch takes additional outputPadding that is applied to destination size.
- *
- * @param source input tensor
- * @param weights weights tensor
- * @param outputShape shape of the result tensor
- * @param descriptor descriptor for the corresponding forward Conv2d operation
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create ConvolutionTranspose op and return the result tensor
+///
+/// Convolution Tranpose op is exactly the same as convolution gradint with respect to input image (convolution2DDataGradient)
+/// Weights tensor and source tensors are interpreted as they are in convolution2DDataGradientWithIncomingGradient. For example
+/// if weightsTensor layout is HWIO, inner most (fastest moving) dimension, denoted by O here should be equal to inputFeatureChannels
+/// i.e. number of channels in source tensor
+/// and next fasted moving dimension denoated by I is equal to number of channels in returns (destination) tensor outputFeatureChannels.
+/// TensorFlow interprets the weights tensor same way excpet that it states weights are in HWOI format. We dont define another weights format enum
+/// rather we reinterpret HWIO just like TensorFlow does for gradient with data.
+/// Normally in auto encoder, convoluton transpose is associated with regular convolution i.e. convolution downsamples by stride s
+/// and convolution tranpose upsamples by factor s.
+/// In that case, convolution transpose can map same source size to multiple destination sizes. The relationship between sourceWidth and destinationWidth is
+/// (sourceWidth - 1)stride + 1 + (kernelWidth - 1)dilationRate <= destinationWidth + paddingLeft + paddingRight
+/// so there are stride -1 destinationWidth that give same sourceWidth. In order to disambiguate, outputShape parameter is used.
+/// This is what TensorFlow does.
+/// PyTourch takes additional outputPadding that is applied to destination size.
+///
+/// - Parameters:
+/// - source: input tensor
+/// - weights: weights tensor
+/// - outputShape: shape of the result tensor
+/// - descriptor: descriptor for the corresponding forward Conv2d operation
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) convolutionTranspose2DWithSourceTensor:(MPSGraphTensor *) source
weightsTensor:(MPSGraphTensor *) weights
outputShape:(MPSShape*) outputShape
@@ -48,52 +47,50 @@
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( convolutionTranspose2D(_:weights:outputShape:descriptor:name:) );
-/*!
- * @abstract Create ConvolutionTranspose op and return the result tensor
- * @discussion Convolution Tranpose op is exactly the same as convolution gradint with respect to input image (convolution2DDataGradient)
- * Weights tensor and source tensors are interpreted as they are in convolution2DDataGradientWithIncomingGradient. For example
- * if weightsTensor layout is HWIO, inner most (fastest moving) dimension, denoted by O here should be equal to inputFeatureChannels
- * i.e. number of channels in source tensor
- * and next fasted moving dimension denoated by I is equal to number of channels in returns (destination) tensor outputFeatureChannels.
- * TensorFlow interprets the weights tensor same way excpet that it states weights are in HWOI format. We dont define another weights format enum
- * rather we reinterpret HWIO just like TensorFlow does for gradient with data.
- * Normally in auto encoder, convoluton transpose is associated with regular convolution i.e. convolution downsamples by stride s
- * and convolution tranpose upsamples by factor s.
- * In that case, convolution transpose can map same source size to multiple destination sizes. The relationship between sourceWidth and destinationWidth is
- * (sourceWidth - 1) * stride + 1 + (kernelWidth - 1) * dilationRate <= destinationWidth + paddingLeft + paddingRight
- * so there are stride -1 destinationWidth that give same sourceWidth. In order to disambiguate, outputShape parameter is used.
- * This is what TensorFlow does.
- * PyTourch takes additional outputPadding that is applied to destination size.
- *
- * @param source input tensor
- * @param weights weights tensor
- * @param outputShape 1D Int32 or Int64 tensor. shape of the result tensor
- * @param descriptor descriptor for the corresponding forward Conv2d operation
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create ConvolutionTranspose op and return the result tensor
+///
+/// Convolution Tranpose op is exactly the same as convolution gradint with respect to input image (convolution2DDataGradient)
+/// Weights tensor and source tensors are interpreted as they are in convolution2DDataGradientWithIncomingGradient. For example
+/// if weightsTensor layout is HWIO, inner most (fastest moving) dimension, denoted by O here should be equal to inputFeatureChannels
+/// i.e. number of channels in source tensor
+/// and next fasted moving dimension denoated by I is equal to number of channels in returns (destination) tensor outputFeatureChannels.
+/// TensorFlow interprets the weights tensor same way excpet that it states weights are in HWOI format. We dont define another weights format enum
+/// rather we reinterpret HWIO just like TensorFlow does for gradient with data.
+/// Normally in auto encoder, convoluton transpose is associated with regular convolution i.e. convolution downsamples by stride s
+/// and convolution tranpose upsamples by factor s.
+/// In that case, convolution transpose can map same source size to multiple destination sizes. The relationship between sourceWidth and destinationWidth is
+/// (sourceWidth - 1)stride + 1 + (kernelWidth - 1)dilationRate <= destinationWidth + paddingLeft + paddingRight
+/// so there are stride -1 destinationWidth that give same sourceWidth. In order to disambiguate, outputShape parameter is used.
+/// This is what TensorFlow does.
+/// PyTourch takes additional outputPadding that is applied to destination size.
+///
+/// - Parameters:
+/// - source: input tensor
+/// - weights: weights tensor
+/// - outputShape: 1D Int32 or Int64 tensor. shape of the result tensor
+/// - descriptor: descriptor for the corresponding forward Conv2d operation
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) convolutionTranspose2DWithSourceTensor:(MPSGraphTensor *) source
weightsTensor:(MPSGraphTensor *) weights
outputShapeTensor:(MPSGraphTensor*) outputShape
descriptor:(MPSGraphConvolution2DOpDescriptor *) descriptor
name:(NSString * _Nullable) name
-MPS_CLASS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
+MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
MPS_SWIFT_NAME( convolutionTranspose2D(_:weights:outputShapeTensor:descriptor:name:) );
-/*!
- * @abstract Create ConvolutionTranspose gradient op and return the result tensor
- * @discussion Computes the gradient of source input for the forward pass ConvolutionTranspose op with identical parameters.
- * See discussion of convolutionTranspose2DWithSourceTensor for more in depth description of paramters.
- *
- * @param incomingGradient Incoming gradient tensor
- * @param weights Forward pass weights tensor
- * @param outputShape Shape of the forward pass source tensor
- * @param forwardConvolutionDescriptor Forward pass op descriptor
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
- */
+/// Create ConvolutionTranspose gradient op and return the result tensor
+///
+/// Computes the gradient of source input for the forward pass ConvolutionTranspose op with identical parameters.
+/// See discussion of convolutionTranspose2DWithSourceTensor for more in depth description of paramters.
+///
+/// - Parameters:
+/// - incomingGradient: Incoming gradient tensor
+/// - weights: Forward pass weights tensor
+/// - outputShape: Shape of the forward pass source tensor
+/// - forwardConvolutionDescriptor: Forward pass op descriptor
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) convolutionTranspose2DDataGradientWithIncomingGradientTensor:(MPSGraphTensor *) incomingGradient
weightsTensor:(MPSGraphTensor *) weights
outputShape:(MPSShape *) outputShape
@@ -101,40 +98,38 @@
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( convolutionTranspose2DDataGradient(_:weights:outputShape:forwardConvolutionDescriptor:name:) );
-/*!
- * @abstract Create ConvolutionTranspose gradient op and return the result tensor
- * @discussion Computes the gradient of source input for the forward pass ConvolutionTranspose op with identical parameters.
- * See discussion of convolutionTranspose2DWithSourceTensor for more in depth description of paramters.
- *
- * @param incomingGradient Incoming gradient tensor
- * @param weights Forward pass weights tensor
- * @param outputShape 1D Int32 or Int64 Tensor. Shape of the forward pass source tensor
- * @param forwardConvolutionDescriptor Forward pass op descriptor
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
- */
+/// Create ConvolutionTranspose gradient op and return the result tensor
+///
+/// Computes the gradient of source input for the forward pass ConvolutionTranspose op with identical parameters.
+/// See discussion of convolutionTranspose2DWithSourceTensor for more in depth description of paramters.
+///
+/// - Parameters:
+/// - incomingGradient: Incoming gradient tensor
+/// - weights: Forward pass weights tensor
+/// - outputShape: 1D Int32 or Int64 Tensor. Shape of the forward pass source tensor
+/// - forwardConvolutionDescriptor: Forward pass op descriptor
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) convolutionTranspose2DDataGradientWithIncomingGradientTensor:(MPSGraphTensor *) incomingGradient
weightsTensor:(MPSGraphTensor *) weights
outputShapeTensor:(MPSGraphTensor *) outputShape
forwardConvolutionDescriptor:(MPSGraphConvolution2DOpDescriptor *) forwardConvolutionDescriptor
name:(NSString * _Nullable) name
-MPS_CLASS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
+MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
MPS_SWIFT_NAME( convolutionTranspose2DDataGradient(_:weights:outputShapeTensor:forwardConvolutionDescriptor:name:) );
-/*!
- * @abstract Create ConvolutionTranspose gradient op and return the result tensor
- * @discussion Computes the gradient of weights input for the forward pass ConvolutionTranspose op with identical parameters.
- * See discussion of convolutionTranspose2DWithSourceTensor for more in depth description of paramters.
- *
- * @param incomingGradientTensor Incoming gradient tensor
- * @param source Forward pass source tensor
- * @param outputShape Shape of the forward pass source weights tensor
- * @param forwardConvolutionDescriptor Forward pass op descriptor
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
- */
+/// Create ConvolutionTranspose gradient op and return the result tensor
+///
+/// Computes the gradient of weights input for the forward pass ConvolutionTranspose op with identical parameters.
+/// See discussion of convolutionTranspose2DWithSourceTensor for more in depth description of paramters.
+///
+/// - Parameters:
+/// - incomingGradientTensor: Incoming gradient tensor
+/// - source: Forward pass source tensor
+/// - outputShape: Shape of the forward pass source weights tensor
+/// - forwardConvolutionDescriptor: Forward pass op descriptor
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) convolutionTranspose2DWeightsGradientWithIncomingGradientTensor:(MPSGraphTensor *) incomingGradientTensor
sourceTensor:(MPSGraphTensor *) source
outputShape:(MPSShape *) outputShape
@@ -142,25 +137,24 @@
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( convolutionTranspose2DWeightsGradient(_:weights:outputShape:forwardConvolutionDescriptor:name:) );
-/*!
- * @abstract Create ConvolutionTranspose gradient op and return the result tensor
- * @discussion Computes the gradient of weights input for the forward pass ConvolutionTranspose op with identical parameters.
- * See discussion of convolutionTranspose2DWithSourceTensor for more in depth description of paramters.
- *
- * @param incomingGradientTensor Incoming gradient tensor
- * @param source Forward pass source tensor
- * @param outputShape 1D Int32 or Int64 Tensor. Shape of the forward pass source weights tensor
- * @param forwardConvolutionDescriptor Forward pass op descriptor
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
- */
+/// Create ConvolutionTranspose gradient op and return the result tensor
+///
+/// Computes the gradient of weights input for the forward pass ConvolutionTranspose op with identical parameters.
+/// See discussion of convolutionTranspose2DWithSourceTensor for more in depth description of paramters.
+///
+/// - Parameters:
+/// - incomingGradientTensor: Incoming gradient tensor
+/// - source: Forward pass source tensor
+/// - outputShape: 1D Int32 or Int64 Tensor. Shape of the forward pass source weights tensor
+/// - forwardConvolutionDescriptor: Forward pass op descriptor
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) convolutionTranspose2DWeightsGradientWithIncomingGradientTensor:(MPSGraphTensor *) incomingGradientTensor
sourceTensor:(MPSGraphTensor *) source
outputShapeTensor:(MPSGraphTensor *) outputShape
forwardConvolutionDescriptor:(MPSGraphConvolution2DOpDescriptor *) forwardConvolutionDescriptor
name:(NSString * _Nullable) name
-MPS_CLASS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
+MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
MPS_SWIFT_NAME( convolutionTranspose2DWeightsGradient(_:weights:outputShapeTensor:forwardConvolutionDescriptor:name:) );
@end
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphCore.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphCore.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphCore.h 2023-03-09 23:50:16
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphCore.h 2023-05-19 20:58:42
@@ -14,127 +14,120 @@
NS_ASSUME_NONNULL_BEGIN
+MPS_CLASS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0))
+/// Common base class for all MPSGraph objects. You should use one of the child classes.
+@interface MPSGraphObject: NSObject
+@end
+
+/// Base type class for types on MPSGraph tensors
MPS_CLASS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
-@interface MPSGraphType: NSObject<NSCopying>
+@interface MPSGraphType: MPSGraphObject<NSCopying>
@end
+/// Shaped type class for types on MPSGraph tensors has a shape and a dataType
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraphShapedType: MPSGraphType
-/*! @property shape
- * @discussion shape of the shapedType
- */
+/// shape of the shapedType
@property (readwrite, nullable, copy, atomic) MPSShape *shape;
-/*! @property dataType
- * @discussion dataType of the shapedType
- */
+/// dataType of the shapedType
@property (readwrite, atomic) MPSDataType dataType;
-/*! @abstract Initialize an MPSGraphShapedType
- * @param shape The MPSShape
- * @param dataType The dataType of the shaped type
- * @return A valid MPSGraphShapedType, or nil if allocation failure.
- */
+/// Initialize an MPSGraphShapedType
+///
+/// - Parameters:
+/// - shape: The MPSShape
+/// - dataType: The dataType of the shaped type
+/// - Returns: A valid MPSGraphShapedType, or nil if allocation failure.
-(instancetype) initWithShape:(MPSShape * _Nullable) shape
dataType:(MPSDataType) dataType;
+/// checks if shapes and elementDataType are the same as the input shapedType
+///
+/// - Parameters:
+/// - object: shapedType to compare to
+/// - Returns: true if equal, false if unequal
-(BOOL)isEqualTo:(MPSGraphShapedType * _Nullable)object;
@end
-/*!
- * @typedef MPSGraphTensorNamedDataLayout
- * @abstract Tensor Layout
- *
- * @constant MPSGraphTensorNamedDataLayoutNCHW LayoutNCHW
- * @constant MPSGraphTensorNamedDataLayoutNHWC LayoutNHWC
- * @constant MPSGraphTensorNamedDataLayoutOIHW LayoutOIHW
- * @constant MPSGraphTensorNamedDataLayoutHWIO LayoutHWIO
- * @constant MPSGraphTensorNamedDataLayoutCHW LayoutCHW
- * @constant MPSGraphTensorNamedDataLayoutHWC LayoutHWC
- * @constant MPSGraphTensorNamedDataLayoutHW LayoutHW
- * @constant MPSGraphTensorNamedDataLayoutNCDHW LayoutNCDHW
- * @constant MPSGraphTensorNamedDataLayoutNDHWC LayoutNDHWC
- * @constant MPSGraphTensorNamedDataLayoutOIDHW LayoutOIDHW
- * @constant MPSGraphTensorNamedDataLayoutDHWIO LayoutDHWIO
- */
+/// Tensor Layout
typedef NS_ENUM(NSUInteger, MPSGraphTensorNamedDataLayout)
{
+ /// LayoutNCHW
MPSGraphTensorNamedDataLayoutNCHW MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) MPS_SWIFT_NAME(NCHW) = 0L,
+ /// LayoutNHWC
MPSGraphTensorNamedDataLayoutNHWC MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) = 1L,
+ /// LayoutOIHW
MPSGraphTensorNamedDataLayoutOIHW MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) = 2L,
+ /// LayoutHWIO
MPSGraphTensorNamedDataLayoutHWIO MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) = 3L,
+ /// LayoutCHW
MPSGraphTensorNamedDataLayoutCHW MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) = 4L,
+ /// LayoutHWC
MPSGraphTensorNamedDataLayoutHWC MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) = 5L,
+ /// LayoutHW
MPSGraphTensorNamedDataLayoutHW MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) = 6L,
+ /// LayoutNCDHW
MPSGraphTensorNamedDataLayoutNCDHW MPS_ENUM_AVAILABLE_STARTING(macos(13.2), ios(16.3), tvos(16.3)) = 7L,
+ /// LayoutNDHWC
MPSGraphTensorNamedDataLayoutNDHWC MPS_ENUM_AVAILABLE_STARTING(macos(13.2), ios(16.3), tvos(16.3)) = 8L,
+ /// LayoutOIDHW
MPSGraphTensorNamedDataLayoutOIDHW MPS_ENUM_AVAILABLE_STARTING(macos(13.2), ios(16.3), tvos(16.3)) = 9L,
+ /// LayoutDHWIO
MPSGraphTensorNamedDataLayoutDHWIO MPS_ENUM_AVAILABLE_STARTING(macos(13.2), ios(16.3), tvos(16.3)) = 10L,
};
-/*!
- * @typedef MPSGraphPaddingStyle
- * @abstract Tensor Layout
- *
- * @constant MPSGraphPaddingStyleExplicit Explicit
- * @constant MPSGraphPaddingStyleONNX_SAME_LOWER ONNX_SAME_LOWER
- * @constant MPSGraphPaddingStyleTF_SAME TF_SAME
- * @constant MPSGraphPaddingStyleTF_VALID TF_VALID
- * @constant MPSGraphPaddingStyleExplicitOffset Explicit offsets
- */
+/// Tensor Layout
typedef NS_ENUM(NSUInteger, MPSGraphPaddingStyle)
{
+ /// Explicit
MPSGraphPaddingStyleExplicit MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) MPS_SWIFT_NAME(explicit) = 0L,
+ /// ONNX_SAME_LOWER
MPSGraphPaddingStyleTF_VALID MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) = 1L,
+ /// TF_SAME
MPSGraphPaddingStyleTF_SAME MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) = 2L,
+ /// TF_VALID
MPSGraphPaddingStyleExplicitOffset MPS_ENUM_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0)) = 3L,
+ /// Explicit offsets
MPSGraphPaddingStyleONNX_SAME_LOWER MPS_ENUM_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0)) = 4L,
};
-/*!
- * @typedef MPSGraphPaddingMode
- * @abstract Tensor Padding mode
- *
- * @constant MPSGraphPaddingModeConstant Constant
- * @constant MPSGraphPaddingModeReflect Reflect
- * @constant MPSGraphPaddingModeSymmetric Symmetric
- * @constant MPSGraphPaddingModeClampToEdge ClampToEdge (PyTorch ReplicationPad)
- * @constant MPSGraphPaddingModeZero Zero
- * @constant MPSGraphPaddingModePeriodic Periodic
- * @constant MPSGraphPaddingModeAntiPeriodic Anti Periodic
- */
+/// Tensor Padding mode
typedef NS_ENUM(NSInteger, MPSGraphPaddingMode)
{
+ /// Constant
MPSGraphPaddingModeConstant MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) MPS_SWIFT_NAME(constant) = 0L,
+ /// Reflect
MPSGraphPaddingModeReflect MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) = 1L,
+ /// Symmetric
MPSGraphPaddingModeSymmetric MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) = 2L,
+ /// ClampToEdge (PyTorch ReplicationPad)
MPSGraphPaddingModeClampToEdge MPS_ENUM_AVAILABLE_STARTING(macos(11.1), ios(15.0), tvos(15.0)) = 3L,
+ /// Zero
MPSGraphPaddingModeZero MPS_ENUM_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0)) = 4L,
- MPSGraphPaddingModePeriodic MPS_ENUM_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0)) = 5L, // x[-2] -> x[L-3], where L is size of x.
- MPSGraphPaddingModeAntiPeriodic MPS_ENUM_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0)) = 6L, // x[-2] -> -x[L-3]
+ /// Periodic `x[-2] -> x[L-3], where L is size of x.`
+ MPSGraphPaddingModePeriodic MPS_ENUM_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0)) = 5L,
+ /// Anti Periodic `x[-2] -> -x[L-3]`
+ MPSGraphPaddingModeAntiPeriodic MPS_ENUM_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0)) = 6L,
};
-/*!
- * @typedef MPSGraphStencilReductionMode
- * @abstract Reduction Mode
- *
- * @constant MPSGraphReductionModeMin Min
- * @constant MPSGraphReductionModeMax Max
- * @constant MPSGraphReductionModeSum Sum
- * @constant MPSGraphReductionModeProduct Product
- * @constant MPSGraphReductionModeArgumentMin Argument Min
- * @constant MPSGraphReductionModeArgumentMax Argument Max
- */
+/// Reduction Mode
typedef NS_ENUM(NSUInteger, MPSGraphReductionMode)
{
+ /// Min
MPSGraphReductionModeMin MPS_ENUM_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0)) = 0L,
+ /// Max
MPSGraphReductionModeMax MPS_ENUM_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0)) = 1L,
+ /// Sum
MPSGraphReductionModeSum MPS_ENUM_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0)) = 2L,
+ /// Product
MPSGraphReductionModeProduct MPS_ENUM_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0)) = 3L,
+ /// Argument Min
MPSGraphReductionModeArgumentMin MPS_ENUM_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0)) = 4L,
+ /// Argument Max
MPSGraphReductionModeArgumentMax MPS_ENUM_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0)) = 5L
};
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphCumulativeOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphCumulativeOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphCumulativeOps.h 2023-03-09 19:09:04
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphCumulativeOps.h 2023-05-22 01:17:40
@@ -16,17 +16,15 @@
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MPSGraphCumulativeOps)
-/*!
- * @abstract Create the cumulative sum op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axis the tensor dimension over which the cumulative operation occurs
- * @param exclusive if true, performs the exclusive cumulative sum operation, and the first element will be equal to zero.
- * @param reverse reverse the direction of the cumulative sum operation along the given axis
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative sum of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: the tensor dimension where you compute the cumulative operation
+/// - exclusive: if true, perform the exclusive cumulative operation, and the first element will be equal to zero
+/// - reverse: if true, reverse the direction of the cumulative operation along the specified axis
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeSumWithTensor:(MPSGraphTensor *) tensor
axis:(NSInteger) axis
exclusive:(BOOL) exclusive
@@ -35,17 +33,15 @@
MPS_SWIFT_NAME( cumulativeSum(_:axis:exclusive:reverse:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create the cumulative sum op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axisTensor the tensor dimension over which the cumulative operation occurs
- * @param exclusive if true, performs the exclusive cumulative sum operation, and the first element will be equal to zero.
- * @param reverse reverse the direction of the cumulative sum operation along the given axis
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative sum of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axisTensor: the tensor dimension where you compute the cumulative operation
+/// - exclusive: if true, perform the exclusive cumulative operation, and the first element will be equal to zero
+/// - reverse: if true, reverse the direction of the cumulative operation along the specified axis
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeSumWithTensor:(MPSGraphTensor *) tensor
axisTensor:(MPSGraphTensor *) axisTensor
exclusive:(BOOL) exclusive
@@ -54,47 +50,41 @@
MPS_SWIFT_NAME( cumulativeSum(_:axisTensor:exclusive:reverse:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create the inclusive cumulative sum op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axis the tensor dimension over which the cumulative operation occurs
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative sum of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: the tensor dimension where you compute the cumulative operation
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeSumWithTensor:(MPSGraphTensor *) tensor
axis:(NSInteger) axis
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( cumulativeSum(_:axis:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create the inclusive cumulative sum op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axisTensor the tensor dimension over which the cumulative operation occurs
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative sum of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axisTensor: the tensor dimension where you compute the cumulative operation
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeSumWithTensor:(MPSGraphTensor *) tensor
axisTensor:(MPSGraphTensor *) axisTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( cumulativeSum(_:axisTensor:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create the cumulative product op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axis the tensor dimension over which the cumulative operation occurs
- * @param exclusive if true, performs the exclusive cumulative product operation, and the first element will be equal to one.
- * @param reverse reverse the direction of the cumulative product operation along the given axis
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative product of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: the tensor dimension where you compute the cumulative operation
+/// - exclusive: if true, perform the exclusive cumulative operation, and the first element will be equal to one
+/// - reverse: if true, reverse the direction of the cumulative operation along the specified axis
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeProductWithTensor:(MPSGraphTensor *) tensor
axis:(NSInteger) axis
exclusive:(BOOL) exclusive
@@ -103,17 +93,15 @@
MPS_SWIFT_NAME( cumulativeProduct(_:axis:exclusive:reverse:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create the cumulative product op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axisTensor the tensor dimension over which the cumulative operation occurs
- * @param exclusive if true, performs the exclusive cumulative product operation, and the first element will be equal to one.
- * @param reverse reverse the direction of the cumulative product operation along the given axis
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative product of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axisTensor: the tensor dimension where you compute the cumulative operation
+/// - exclusive: if true, perform the exclusive cumulative operation, and the first element will be equal to one
+/// - reverse: if true, reverse the direction of the cumulative operation along the specified axis
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeProductWithTensor:(MPSGraphTensor *) tensor
axisTensor:(MPSGraphTensor *) axisTensor
exclusive:(BOOL) exclusive
@@ -122,47 +110,43 @@
MPS_SWIFT_NAME( cumulativeProduct(_:axisTensor:exclusive:reverse:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create the inclusive cumulative product op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axis the tensor dimension over which the cumulative operation occurs
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative product of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: the tensor dimension where you compute the cumulative operation
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeProductWithTensor:(MPSGraphTensor *) tensor
axis:(NSInteger) axis
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( cumulativeProduct(_:axis:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create the inclusive cumulative product op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axisTensor the tensor dimension over which the cumulative operation occurs
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative product of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axisTensor: the tensor dimension where you compute the cumulative operation
+/// - exclusive: if true, perform the exclusive cumulative operation, and the first element will be equal to one
+/// - reverse: if true, reverse the direction of the cumulative operation along the specified axis
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeProductWithTensor:(MPSGraphTensor *) tensor
axisTensor:(MPSGraphTensor *) axisTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( cumulativeProduct(_:axisTensor:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create the cumulative minimum op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axis the tensor dimension over which the cumulative operation occurs
- * @param exclusive if true, performs the exclusive cumulative minimum operation, and the first element will be equal to the highest value of data type.
- * @param reverse reverse the direction of the cumulative minimum operation along the given axis
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative minimum of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: the tensor dimension where you compute the cumulative operation
+/// - exclusive: if true, perform the exclusive cumulative operation, and the first element will be equal to the largest value of the tensor data type
+/// - reverse: if true, reverse the direction of the cumulative operation along the specified axis
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeMinimumWithTensor:(MPSGraphTensor *) tensor
axis:(NSInteger) axis
exclusive:(BOOL) exclusive
@@ -171,17 +155,15 @@
MPS_SWIFT_NAME( cumulativeMinimum(_:axis:exclusive:reverse:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create the cumulative minimum op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axisTensor the tensor dimension over which the cumulative operation occurs
- * @param exclusive if true, performs the exclusive cumulative minimum operation, and the first element will be equal to the highest value of data type.
- * @param reverse reverse the direction of the cumulative minimum operation along the given axis
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative minimum of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axisTensor: the tensor dimension where you compute the cumulative operation
+/// - exclusive: if true, perform the exclusive cumulative operation, and the first element will be equal to the largest value of the tensor data type
+/// - reverse: if true, reverse the direction of the cumulative operation along the specified axis
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeMinimumWithTensor:(MPSGraphTensor *) tensor
axisTensor:(MPSGraphTensor *) axisTensor
exclusive:(BOOL) exclusive
@@ -190,47 +172,43 @@
MPS_SWIFT_NAME( cumulativeMinimum(_:axisTensor:exclusive:reverse:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create the inclusive cumulative minimum op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axis the tensor dimension over which the cumulative operation occurs
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative minimum of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: the tensor dimension where you compute the cumulative operation
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeMinimumWithTensor:(MPSGraphTensor *) tensor
axis:(NSInteger) axis
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( cumulativeMinimum(_:axis:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create the inclusive cumulative minimum op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axisTensor the tensor dimension over which the cumulative operation occurs
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative minimum of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axisTensor: the tensor dimension where you compute the cumulative operation
+/// - exclusive: if true, perform the exclusive cumulative operation, and the first element will be equal to the largest value of the tensor data type
+/// - reverse: if true, reverse the direction of the cumulative operation along the specified axis
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeMinimumWithTensor:(MPSGraphTensor *) tensor
axisTensor:(MPSGraphTensor *) axisTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( cumulativeMinimum(_:axisTensor:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create the cumulative maximum op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axis the tensor dimension over which the cumulative operation occurs
- * @param exclusive if true, performs the exclusive cumulative maximum operation, and the first element will be equal to the lowest value of data type.
- * @param reverse reverse the direction of the cumulative maximum operation along the given axis
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative maximum of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: the tensor dimension where you compute the cumulative operation
+/// - exclusive: if true, perform the exclusive cumulative operation, and the first element will be equal to the lowest value of the tensor data type
+/// - reverse: if true, reverse the direction of the cumulative operation along the specified axis
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeMaximumWithTensor:(MPSGraphTensor *) tensor
axis:(NSInteger) axis
exclusive:(BOOL) exclusive
@@ -239,17 +217,15 @@
MPS_SWIFT_NAME( cumulativeMaximum(_:axis:exclusive:reverse:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create the cumulative maximum op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axisTensor the tensor dimension over which the cumulative operation occurs
- * @param exclusive if true, performs the exclusive cumulative maximum operation, and the first element will be equal to the lowest value of data type.
- * @param reverse reverse the direction of the cumulative maximum operation along the given axis
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative maximum of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axisTensor: the tensor dimension where you compute the cumulative operation
+/// - exclusive: if true, perform the exclusive cumulative operation, and the first element will be equal to the lowest value of the tensor data type
+/// - reverse: if true, reverse the direction of the cumulative operation along the specified axis
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeMaximumWithTensor:(MPSGraphTensor *) tensor
axisTensor:(MPSGraphTensor *) axisTensor
exclusive:(BOOL) exclusive
@@ -258,30 +234,26 @@
MPS_SWIFT_NAME( cumulativeMaximum(_:axisTensor:exclusive:reverse:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create the inclusive cumulative maximum op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axis the tensor dimension over which the cumulative operation occurs
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative maximum of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: the tensor dimension where you compute the cumulative operation
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeMaximumWithTensor:(MPSGraphTensor *) tensor
axis:(NSInteger) axis
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( cumulativeMaximum(_:axis:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create the inclusive cumulative maximum op and return the result tensor.
- *
- * @param tensor input tensor
- * @param axisTensor the tensor dimension over which the cumulative operation occurs
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the cumulative maximum of the input tensor along a specified axis.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axisTensor: the tensor dimension where you compute the cumulative operation
+/// - name: name for the operation
+/// - Returns: a valid MPSGraphTensor object
-(MPSGraphTensor *) cumulativeMaximumWithTensor:(MPSGraphTensor *) tensor
axisTensor:(MPSGraphTensor *) axisTensor
name:(NSString * _Nullable) name
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphDepthwiseConvolutionOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphDepthwiseConvolutionOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphDepthwiseConvolutionOps.h 2023-03-09 19:13:36
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphDepthwiseConvolutionOps.h 2023-05-19 21:42:51
@@ -12,24 +12,53 @@
NS_ASSUME_NONNULL_BEGIN
+/// Defines a 2d depthwise convolution operation.
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
-@interface MPSGraphDepthwiseConvolution2DOpDescriptor : NSObject<NSCopying>
+@interface MPSGraphDepthwiseConvolution2DOpDescriptor : MPSGraphObject<NSCopying>
-@property (readwrite, nonatomic) NSUInteger strideInX; //!< Default = 1
-@property (readwrite, nonatomic) NSUInteger strideInY; //!< Default = 1
-@property (readwrite, nonatomic) NSUInteger dilationRateInX; //!< Default = 1
-@property (readwrite, nonatomic) NSUInteger dilationRateInY; //!< Default = 1
+/// Defines stride for X (Width) dimension. Default value: 1.
+@property (readwrite, nonatomic) NSUInteger strideInX;
+/// Defines stride for Y (Height) dimension. Default value: 1.
+@property (readwrite, nonatomic) NSUInteger strideInY;
+/// Defines dilation rate for X (Width) dimension. Default value: 1.
+@property (readwrite, nonatomic) NSUInteger dilationRateInX;
+/// Defines dilation rate for Y (Height) dimension. Default value: 1.
+@property (readwrite, nonatomic) NSUInteger dilationRateInY;
-@property (readwrite, nonatomic) NSUInteger paddingLeft; //!< Default = 0 - ignored if paddingStyle != explicit
-@property (readwrite, nonatomic) NSUInteger paddingRight; //!< Default = 0 - ignored if paddingStyle != explicit
-@property (readwrite, nonatomic) NSUInteger paddingTop; //!< Default = 0 - ignored if paddingStyle != explicit
-@property (readwrite, nonatomic) NSUInteger paddingBottom; //!< Default = 0 - ignored if paddingStyle != explicit
-@property (readwrite, nonatomic) MPSGraphPaddingStyle paddingStyle; //!< Default = MPSGraphPaddingStyleExplicit
+/// Defines explicit padding value for X (Width) dimension to add before the data. Default value: 0.
+@property (readwrite, nonatomic) NSUInteger paddingLeft;
+/// Defines explicit padding value for X (Width) dimension to add after the data. Default value: 0.
+@property (readwrite, nonatomic) NSUInteger paddingRight;
+/// Defines explicit padding value for Y (Height) dimension to add before the data. Default value: 0.
+@property (readwrite, nonatomic) NSUInteger paddingTop;
+/// Defines explicit padding value for Y (Height) dimension to add after the data. Default value: 0.
+@property (readwrite, nonatomic) NSUInteger paddingBottom;
+
+/// Defines what kind of padding to apply to operation.
+/// Default value: ``MPSGraphPaddingStyleExplicit``.
+@property (readwrite, nonatomic) MPSGraphPaddingStyle paddingStyle;
+/// Defines the data layout of the input data (in forward pass). See: ``MPSGraphTensorNamedDataLayout``.
@property (readwrite, nonatomic) MPSGraphTensorNamedDataLayout dataLayout;
-@property (readwrite, nonatomic) MPSGraphTensorNamedDataLayout weightsLayout; //!< NOTE: 'O' index is channel multiplier index
+/// Defines the data layout of the weights. See: ``MPSGraphTensorNamedDataLayout``.
+/// NOTE: 'O' index is channel multiplier index
+@property (readwrite, nonatomic) MPSGraphTensorNamedDataLayout weightsLayout;
-
+/// Creates a 2d depthwise convolution descriptor with given values.
+///
+/// - Parameters:
+/// - strideInX: See ``strideInX`` property.
+/// - strideInY: See ``strideInY`` property.
+/// - dilationRateInX: See ``dilationRateInX`` property.
+/// - dilationRateInY: See ``dilationRateInY`` property.
+/// - paddingLeft: See ``paddingLeft`` property.
+/// - paddingRight: See ``paddingRight`` property.
+/// - paddingTop: See ``paddingTop`` property.
+/// - paddingBottom: See ``paddingBottom`` property.
+/// - paddingStyle: See ``paddingStyle`` property.
+/// - dataLayout: See ``dataLayout`` property.
+/// - weightsLayout: See ``weightsLayout`` property.
+/// - Returns: The descriptor on autoreleasepool.
+(nullable instancetype) descriptorWithStrideInX:(NSUInteger) strideInX
strideInY:(NSUInteger) strideInY
dilationRateInX:(NSUInteger) dilationRateInX
@@ -42,9 +71,22 @@
dataLayout:(MPSGraphTensorNamedDataLayout) dataLayout
weightsLayout:(MPSGraphTensorNamedDataLayout) weightsLayout;
+/// Creates a 2d depthwise convolution descriptor with given properties and default values.
+///
+/// - Parameters:
+/// - dataLayout: See ``dataLayout`` property.
+/// - weightsLayout: See ``weightsLayout`` property.
+/// - Returns: The descriptor on autoreleasepool.
+(nullable instancetype) descriptorWithDataLayout:(MPSGraphTensorNamedDataLayout) dataLayout
weightsLayout:(MPSGraphTensorNamedDataLayout) weightsLayout;
+/// Sets the explicit padding values and sets ``paddingStyle`` to ``MPSGraphPaddingStyleExplicit``
+///
+/// - Parameters:
+/// - paddingLeft: See ``paddingLeft`` property.
+/// - paddingRight: See ``paddingRight`` property.
+/// - paddingTop: See ``paddingTop`` property.
+/// - paddingBottom: See ``paddingBottom`` property.
-(void) setExplicitPaddingWithPaddingLeft:(NSUInteger) paddingLeft
paddingRight:(NSUInteger) paddingRight
paddingTop:(NSUInteger) paddingTop
@@ -52,74 +94,57 @@
@end
-/*!
- * @class MPSGraphDepthwiseConvolution3DOpDescriptor
- * @abstract Defines a 3d depthwise convolution operation
- */
+/// Defines a 3d depthwise convolution operation.
MPS_CLASS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
-@interface MPSGraphDepthwiseConvolution3DOpDescriptor : NSObject<NSCopying>
+@interface MPSGraphDepthwiseConvolution3DOpDescriptor : MPSGraphObject<NSCopying>
-/*!
- * @property strides
- * @discussion Must be three numbers, one for each spatial dimension, fastest running index last.
- * Default value: @code @[ @1, @1, @1 ] @endcode
- */
+/// Defines strides for spatial dimensions. Must be three numbers, one for each spatial dimension, fastest running index last.
+/// Default value: `@[ @1, @1, @1 ]`
@property (readwrite, nonatomic, copy) NSArray<NSNumber *> * _Nonnull strides;
-/*!
- * @property dilationRates
- * @discussion Must be three numbers, one for each spatial dimension, fastest running index last.
- * Default value: @code @[ @1, @1, @1 ] @endcode
- */
+/// Defines dilation rates for spatial dimensions. Must be three numbers, one for each spatial dimension, fastest running index last.
+/// Default value: `@[ @1, @1, @1 ]`
@property (readwrite, nonatomic, copy) NSArray<NSNumber *> * _Nonnull dilationRates;
-/*!
- * @property paddingValues
- * @discussion Must be six numbers, two for each spatial dimension. `paddingValues[0]` defines the explicit padding
- * amount before the first spatial dimension (slowest running index of spatial dimensions),
- * `paddingValues[1]` defines the padding amount after the first spatial dimension etc.
- * Used only when `paddingStyle = MPSGraphPaddingStyleExplicit`.
- * Default value: @code @[ @0, @0, @0, @0, @0, @0 ] @endcode
- */
+/// Defines padding values for spatial dimensions. Must be six numbers, two for each spatial dimension.
+/// For example ``paddingValues[0]`` defines the explicit padding
+/// amount before the first spatial dimension (slowest running index of spatial dimensions),
+/// ``paddingValues[1]`` defines the padding amount after the first spatial dimension etc.
+/// Use only with ``paddingStyle = MPSGraphPaddingStyleExplicit``.
+/// Default value: `@[ @0, @0, @0, @0, @0, @0 ]`
@property (readwrite, nonatomic, copy) NSArray<NSNumber *> * _Nonnull paddingValues;
-/*!
- * @property paddingStyle
- * @discussion Defines what kind of padding to apply to operation.
- * Default value: @code MPSGraphPaddingStyleExplicit @endcode
- */
+/// Defines what kind of padding to apply to operation.
+/// Default value: ``MPSGraphPaddingStyleExplicit``
@property (readwrite, nonatomic) MPSGraphPaddingStyle paddingStyle;
-/*!
- * @property channelDimensionIndex
- * @discussion Defines which axis contains the channels in the input and the weights, within
- * the 4d tile of the last dimensions. For example the value of @code -1 @endcode
- * corresponds to @code NDHWC, NHWC @endcode layouts. This allows the placement
- * of the channel index anywhere within the last 4 dimensions of the tensor. In case the
- * weights are in a different layout it is recommended to bring them to the same layout
- * as inputs using transposes or permutations.
- * Default value: @code -4 @endcode, corresponds to @code NCDHW @endcode
- * and @code CDHW @endcode layouts.
- */
+/// Defines which axis contains the channels in the input and the weights, within
+/// the 4d tile of the last dimensions. For example the value of `-1`
+/// corresponds to `NDHWC`, `NHWC` layouts. This allows the placement
+/// of the channel index anywhere within the last 4 dimensions of the tensor. In case your
+/// weights are in a different layout it is recommended that you bring them to the same layout
+/// as inputs using transposes or permutations.
+/// Default value: `-4`, corresponds to `NCDHW` and `CDHW` layouts.
@property (readwrite, nonatomic) NSInteger channelDimensionIndex;
-/*!
- * @abstract Creates a 3d depthwise convolution descriptor with given values.
- * @param strides See corresponding property above.
- * @param dilationRates See corresponding property above.
- * @param paddingValues See corresponding property above.
- * @param paddingStyle See corresponding property above.
- * @return The descriptor on autoreleasepool.
- */
+
+/// Creates a 3d depthwise convolution descriptor with given values.
+///
+/// - Parameters:
+/// - strides: See ``strides`` property.
+/// - dilationRates: See ``dilationRates`` property.
+/// - paddingValues: See ``paddingValues`` property.
+/// - paddingStyle: See ``paddingStyle`` property.
+/// - Returns: The descriptor on autoreleasepool.
+(nullable instancetype) descriptorWithStrides:(NSArray<NSNumber *> * _Nonnull) strides
dilationRates:(NSArray<NSNumber *> * _Nonnull) dilationRates
paddingValues:(NSArray<NSNumber *> * _Nonnull) paddingValues
paddingStyle:(MPSGraphPaddingStyle) paddingStyle;
-/*!
- * @abstract Creates a 3d depthwise convolution descriptor with default values.
- * @param paddingStyle See corresponding property above.
- * @return The descriptor on autoreleasepool.
- */
+/// Creates a 3d depthwise convolution descriptor with default values.
+///
+/// - Parameters:
+/// - paddingStyle: See ``paddingStyle`` property.
+/// - Returns: The descriptor on autoreleasepool.
+(nullable instancetype) descriptorWithPaddingStyle:(MPSGraphPaddingStyle) paddingStyle;
@end
@@ -127,13 +152,29 @@
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MPSGraphDepthwiseConvolutionOps)
-
+/// Creates a 2d depthwise convolution operation and returns the result tensor.
+///
+/// - Parameters:
+/// - source: 2d Image source as tensor - must be of rank=4. The layout is defined by ``descriptor.dataLayout``.
+/// - weights: Weights tensor, must be rank=4. The layout is defined by ``descriptor.weightsLayout``.
+/// - descriptor: Specifies strides, dilation rates, paddings and layouts.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) depthwiseConvolution2DWithSourceTensor:(MPSGraphTensor *) source
weightsTensor:(MPSGraphTensor *) weights
descriptor:(MPSGraphDepthwiseConvolution2DOpDescriptor *) descriptor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( depthwiseConvolution2D(_:weights:descriptor:name:) );
+/// Creates a 2d depthwise convolution gradient for data operation and returns the result tensor.
+///
+/// - Parameters:
+/// - incomingGradient: 2d input gradient tensor - must be of rank=4. The layout is defined by ``descriptor.dataLayout``.
+/// - weights: Weights tensor, must be rank=4. The layout is defined by ``descriptor.weightsLayout``.
+/// - outputShape: Shape of the οutput tensor (and therefore input tensor of forward pass).
+/// - descriptor: Specifies strides, dilation rates, paddings and layouts.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) depthwiseConvolution2DDataGradientWithIncomingGradientTensor:(MPSGraphTensor *) incomingGradient
weightsTensor:(MPSGraphTensor *) weights
outputShape:(MPSShape *) outputShape
@@ -141,6 +182,15 @@
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( depthwiseConvolution2DDataGradient(_:weights:outputShape:descriptor:name:) );
+/// Creates a 2d depthwise convolution gradient for weights operation and returns the result tensor.
+///
+/// - Parameters:
+/// - incomingGradient: 2d input gradient tensor - must be of rank=4. The layout is defined by ``descriptor.dataLayout``.
+/// - source: 2d Image source as tensor - must be of rank=4. The layout is defined by ``descriptor.dataLayout``.
+/// - outputShape: Shape of the οutput tensor (and therefore weight tensor of forward pass).
+/// - descriptor: Specifies strides, dilation rates, paddings and layouts.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) depthwiseConvolution2DWeightsGradientWithIncomingGradientTensor:(MPSGraphTensor *) incomingGradient
sourceTensor:(MPSGraphTensor *) source
outputShape:(MPSShape *) outputShape
@@ -150,19 +200,18 @@
#pragma mark - 3D Depthwise convolution
-/*!
- * @abstract Create 3d depthwise convolution operation and return the result tensor.
- * @discussion Just like depthwise convolution2d, but in three dimensions. Different layouts are supported by using
- * the @code channelDimensionIndex @endcode property. If your weights need a different layout
- * add a permute operation on them before this operation.
-
- * @param source 3d Image source as tensor - must be at least rank=4 (CDHW when channelDimensionIndex = -4).
- * @param weights Weights tensor, must be rank=4 - axes are interpreted as CDHW when channelDimensionIndex = -4 .
- * @param descriptor Specifies strides, dilation rates and paddings.
- * @param name The name for the operation.
- *
- * @return A valid MPSGraphTensor object
- */
+/// Creates a 3d depthwise convolution operation and returns the result tensor.
+///
+/// Works exactly like depthwise convolution2d, but in three dimensions. Supports different layouts with
+/// the ``channelDimensionIndex`` property. If your weights need a different layout
+/// add a permute operation on them before this operation.
+///
+/// - Parameters:
+/// - source: 3d Image source as tensor - must be at least rank=4 (CDHW when channelDimensionIndex = -4).
+/// - weights: Weights tensor, must be rank=4 - axes are interpreted as CDHW when channelDimensionIndex = -4 .
+/// - descriptor: Specifies strides, dilation rates and paddings.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) depthwiseConvolution3DWithSourceTensor:(MPSGraphTensor *) source
weightsTensor:(MPSGraphTensor *) weights
descriptor:(MPSGraphDepthwiseConvolution3DOpDescriptor* _Nonnull) descriptor
@@ -170,17 +219,15 @@
MPS_SWIFT_NAME( depthwiseConvolution3D(_:weights:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0));
-/*!
- * @abstract Create 3d depthwise convolution gradient for data operation and return the result tensor.
-
- * @param incomingGradient 3d input gradient tensor - must be at least rank=4 (CDHW).
- * @param weights Weights tenstor, must be rank=4 - axes are interpreted as CDHW.
- * @param outputShape Shape of the οutput tensor (and therefore input tensor of forward pass).
- * @param descriptor Specifies strides, dilation rates and paddings.
- * @param name The name for the operation (NCDHW).
- *
- * @return A valid MPSGraphTensor object
- */
+/// Creates a 3d depthwise convolution gradient for data operation and returns the result tensor.
+///
+/// - Parameters:
+/// - incomingGradient: 3d input gradient tensor - must be at least rank=4 (CDHW).
+/// - weights: Weights tenstor, must be rank=4 - axes are interpreted as CDHW.
+/// - outputShape: Shape of the οutput tensor (and therefore input tensor of forward pass).
+/// - descriptor: Specifies strides, dilation rates and paddings.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) depthwiseConvolution3DDataGradientWithIncomingGradientTensor:(MPSGraphTensor *) incomingGradient
weightsTensor:(MPSGraphTensor *) weights
outputShape:(MPSShape * _Nullable) outputShape
@@ -189,17 +236,15 @@
MPS_SWIFT_NAME( depthwiseConvolution3DDataGradient(_:weights:outputShape:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0));
-/*!
- * @abstract Create 3d depthwise convolution gradient for weights operation and return the result tensor.
-
- * @param incomingGradient 3d input gradient tensor - must be at least rank=4 (NCDHW).
- * @param source Forward pass 3d Image source as tensor - must be at least rank=4 (NCDHW).
- * @param outputShape Shape of the οutput tensor (and therefore weight tensor of forward pass).
- * @param descriptor Specifies strides, dilation rates and paddings.
- * @param name The name for the operation (NCDHW).
- *
- * @return A valid MPSGraphTensor object
- */
+/// Creates a 3d depthwise convolution gradient for weights operation and returns the result tensor.
+///
+/// - Parameters:
+/// - incomingGradient: 3d input gradient tensor - must be at least rank=4 (NCDHW).
+/// - source: Forward pass 3d Image source as tensor - must be at least rank=4 (NCDHW).
+/// - outputShape: Shape of the οutput tensor (and therefore weight tensor of forward pass).
+/// - descriptor: Specifies strides, dilation rates and paddings.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) depthwiseConvolution3DWeightsGradientWithIncomingGradientTensor:(MPSGraphTensor *) incomingGradient
sourceTensor:(MPSGraphTensor *) source
outputShape:(MPSShape *) outputShape
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphDevice.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphDevice.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphDevice.h 2023-03-09 23:53:22
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphDevice.h 2023-05-22 01:20:38
@@ -13,35 +13,27 @@
NS_ASSUME_NONNULL_BEGIN
-/*!
- * @typedef MPSGraphDeviceType
- * @abstract Device type, Metal
- *
- * @constant MPSGraphDeviceTypeMetal Device of type Metal
- */
+/// Device type
typedef NS_ENUM(uint32_t, MPSGraphDeviceType)
{
+ /// Device of type Metal
MPSGraphDeviceTypeMetal MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) MPS_SWIFT_NAME(metal) = 0L,
};
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
-@interface MPSGraphDevice : NSObject
+@interface MPSGraphDevice : MPSGraphObject
-/*! @property type
- */
+/// MPSGraphDeviceType of the MPSGraphDevice
@property (readonly, nonatomic) MPSGraphDeviceType type;
-/*! @property metalDevice
- * @discussion if deviceType GPU then returns MTLDevice or nil
- */
+/// if deviceType is Metal then returns MTLDevice else nil
@property (readonly, nonatomic, nullable) id<MTLDevice> metalDevice;
-/*!
- * @abstract Creates a Metal MPSGraphDevice from a MTLDevice
- *
- * @param metalDevice MTLDevice to create an MPSGraphDevice from
- * @return A valid MPSGraphDevice
- */
+/// Creates a Metal MPSGraphDevice from a MTLDevice
+///
+/// - Parameters:
+/// - metalDevice: MTLDevice to create an MPSGraphDevice from
+/// - Returns: A valid MPSGraphDevice
+(instancetype) deviceWithMTLDevice:(id<MTLDevice>) metalDevice;
@end
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphExecutable.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphExecutable.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphExecutable.h 2023-03-09 23:53:22
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphExecutable.h 2023-05-22 01:20:38
@@ -13,57 +13,51 @@
NS_ASSUME_NONNULL_BEGIN
-/*! @abstract A notification when graph executable execution: has finished
- * @param results If no error, the results produced by the graph operation. If Graph has not yet allocated the results this will be NSNull
- * @param error If an error occurs, more information might be found here.
- */
+/// A notification when graph executable execution: has finished
+///
+/// - Parameters:
+/// - results: If no error, the results produced by the graph operation. If Graph has not yet allocated the results this will be NSNull
+/// - error: If an error occurs, more information might be found here.
MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
typedef void (^MPSGraphExecutableCompletionHandler)(NSArray<MPSGraphTensorData *> * results,
NSError * _Nullable error);
-/*! @abstract A notification when graph executable execution: has been scheduled
- * @param results If no error, the results produced by the graph operation.
- * @param error If an error occurs, more information might be found here.
- */
+/// A notification when graph executable execution: has been scheduled
+///
+/// - Parameters:
+/// - results: If no error, the results produced by the graph operation.
+/// - error: If an error occurs, more information might be found here.
MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
typedef void (^MPSGraphExecutableScheduledHandler)(NSArray<MPSGraphTensorData *> * results,
NSError * _Nullable error);
MPS_CLASS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
-@interface MPSGraphExecutableExecutionDescriptor : NSObject<NSCopying>
+@interface MPSGraphExecutableExecutionDescriptor : MPSGraphObject<NSCopying>
-/*! @property scheduledHandler
- * @discussion scheduledHandler for the graph executable, default value is nil
- */
+/// scheduledHandler for the graph executable, default value is nil
@property (readwrite, atomic) MPSGraphExecutableScheduledHandler scheduledHandler;
-/*! @property completionHandler
- * @discussion completionHandler for the graph executable, default value is nil
- */
+/// completionHandler for the graph executable, default value is nil
@property (readwrite, atomic) MPSGraphExecutableCompletionHandler completionHandler;
-/*! @property waitUntilCompleted
- * @discussion waitUntilCompleted for the graph executable, default value is false
- */
+/// waitUntilCompleted for the graph executable, default value is false
@property (readwrite, atomic) BOOL waitUntilCompleted;
-/*!
- * @abstract Executable waits on these shared events before scheduling execution on the HW, this does not include encoding which can still continue.
- *
- * @param event shared event to wait on
- * @param value value for shared event to wait on
- */
+/// Executable waits on these shared events before scheduling execution on the HW, this does not include encoding which can still continue.
+///
+/// - Parameters:
+/// - event: shared event to wait on
+/// - value: value for shared event to wait on
-(void) waitForEvent:(id<MTLSharedEvent>) event
value:(uint64_t) value
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Executable signals these shared events at execution stage and immediately proceeds
- *
- * @param event shared event to signal
- * @param executionStage execution stage to signal event at
- * @param value value for shared event to wait on
- */
+/// Executable signals these shared events at execution stage and immediately proceeds
+///
+/// - Parameters:
+/// - event: shared event to signal
+/// - executionStage: execution stage to signal event at
+/// - value: value for shared event to wait on
-(void) signalEvent:(id<MTLSharedEvent>) event
atExecutionEvent:(MPSGraphExecutionStage) executionStage
value:(uint64_t) value
@@ -71,106 +65,133 @@
@end
-/*! @class MPSGraphExecutable
- * @abstract Compiled representation of a compute graph executable
- * @discussion An MPSGraphExecutable is a compiled graph for specific feeds for specific targetTensors and targetOperations
- *
- */
+/// The options available to a graph.
+typedef NS_ENUM(uint64_t, MPSGraphDeploymentPlatform)
+{
+ /// Deployment platofmr for macOS
+ MPSGraphDeploymentPlatformMacOS MPS_ENUM_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0)) MPS_SWIFT_NAME(macOS) = 0L,
+ /// Deployment target for iOS
+ MPSGraphDeploymentPlatformIOS MPS_ENUM_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0)) MPS_SWIFT_NAME(iOS) = 1L,
+ /// Deployment target for tvOS
+ MPSGraphDeploymentPlatformTvOS MPS_ENUM_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0)) MPS_SWIFT_NAME(tvOS) = 2L,
+};
+
+
+MPS_CLASS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0))
+@interface MPSGraphExecutableSerializationDescriptor : MPSGraphObject
+
+/// If true, append to an existing .mpsgraphpackage if found at provided url. Otherwise, the exisiting .mpsgraphpackage will be overwritten
+@property (readwrite, atomic) BOOL append;
+
+/// The deployment platform used to serialize the MPSGraphExecutable. Defaults to the current platform
+@property (readwrite, atomic) MPSGraphDeploymentPlatform deploymentPlatform;
+
+/// The minimum deployment target to serialize the MPSGraphExecutable. Defaults to the current sdk
+@property (readwrite, atomic) NSString* minimumDeploymentTarget;
+
+@end
+
+/// Compiled representation of a compute graph executable
+///
+/// An MPSGraphExecutable is a compiled graph for specific feeds for specific targetTensors and targetOperations
MPS_CLASS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
-@interface MPSGraphExecutable : NSObject
+@interface MPSGraphExecutable : MPSGraphObject
-/*! @property options
- * @discussion options for the graph, default value is MPSGraphOptionsDefault
- */
+/// options for the graph, default value is MPSGraphOptionsDefault
@property (readwrite, atomic) MPSGraphOptions options;
-/*! @property feedTensors
- * @discussion feedTensors for the graph, can be used to order the inputs when executable was created with an MPSGraph
- */
+/// feedTensors for the graph, can be used to order the inputs when executable was created with an MPSGraph
@property (readonly, atomic, nullable) NSArray<MPSGraphTensor *> *feedTensors;
-/*! @property targetTensors
- * @discussion targetTensors for the graph, can be used to order the outputs when executable was created with an MPSGraph
- */
+/// targetTensors for the graph, can be used to order the outputs when executable was created with an MPSGraph
@property (readonly, atomic, nullable) NSArray<MPSGraphTensor *> *targetTensors;
-/*!
- * @abstract Specialize the MPSGraphExecutable and optimize it, use this method to choose when specialization happens, else it occurs at encode time automatically
- *
- * @param device optional MPSGraph device to compile with
- * @param inputTypes input types
- * @param compilationDescriptor compilationDescriptor to be used to specialize, since the executable was created with a compilationDescriptor already this one overrides those settings to the extent it can
- *
- */
+/// Specialize the MPSGraphExecutable and optimize it, use this method to choose when specialization happens, else it occurs at encode time automatically
+///
+/// - Parameters:
+/// - device: optional MPSGraph device to compile with
+/// - inputTypes: input types
+/// - compilationDescriptor: compilationDescriptor to be used to specialize, since the executable was created with a compilationDescriptor already this one overrides those settings to the extent it can
-(void) specializeWithDevice:(MPSGraphDevice * _Nullable) device
inputTypes:(NSArray<MPSGraphType *> *) inputTypes
compilationDescriptor:(MPSGraphCompilationDescriptor * _Nullable) compilationDescriptor;
-/*!
- * @abstract Get output shapes for a specialized MPSGraphExecutable - in case specialization has not been done yet then calling this function will specialize for the given input shapes.
- *
- * @param device optional MPSGraph device to compile with
- * @param inputTypes input types
- * @param compilationDescriptor compilationDescriptor to be used to specialize, since the executable was created with a compilationDescriptor already this one overrides those settings to the extent it can
- *
- */
+/// Get output shapes for a specialized MPSGraphExecutable - in case specialization has not been done yet then calling this function will specialize for the given input shapes.
+///
+/// - Parameters:
+/// - device: optional MPSGraph device to compile with
+/// - inputTypes: input types
+/// - compilationDescriptor: compilationDescriptor to be used to specialize, since the executable was created with a compilationDescriptor already this one overrides those settings to the extent it can
-(NSArray<MPSGraphShapedType *> * _Nullable) getOutputTypesWithDevice:(MPSGraphDevice * _Nullable) device
inputTypes:(NSArray<MPSGraphType *> *) inputTypes
compilationDescriptor:(MPSGraphCompilationDescriptor * _Nullable) compilationDescriptor
MPS_AVAILABLE_STARTING(macos(13.2), ios(16.3), tvos(16.3));
-/*!
- * @abstract Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed.
- * This call is synchronous and will return on completion of execution
- *
- * @param commandQueue CommandQueue passed to exectute the graph on
- * @param inputsArray Feeds tensorData for the placeholder tensors, same order as arguments of main function
- * @param resultsArray Results tensorData for which the caller wishes MPSGraphTensorData to be returned
- *
- * @return A valid MPSGraphTensorData array with results synchronized to the CPU memory if MPSGraphOptionsSynchronizeResults set.
- */
+/// Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed.
+/// This call is synchronous and will return on completion of execution
+///
+/// - Parameters:
+/// - commandQueue: CommandQueue 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 *> *) runWithMTLCommandQueue:(id<MTLCommandQueue>) commandQueue
inputsArray:(NSArray<MPSGraphTensorData *> *) inputsArray
resultsArray:(NSArray<MPSGraphTensorData *> * _Nullable) resultsArray
executionDescriptor:(MPSGraphExecutableExecutionDescriptor * _Nullable) executionDescriptor
MPS_SWIFT_NAME( run(with:inputs:results:executionDescriptor:) );
-/*!
- * @abstract Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed.
- * This call is asynchronous and will return immediately.
- *
- * @param commandQueue CommandQueue passed to exectute the graph on
- * @param inputsArray Feeds tensorData for the placeholder tensors, same order as arguments of main function
- * @param resultsArray Tensors for which the caller wishes MPSGraphTensorData to be returned
- * @param executionDescriptor ExecutionDescriptor to be passed in and used,
- *
- * @return A valid MPSGraphTensorData array with results synchronized to the CPU memory if MPSGraphOptionsSynchronizeResults set.
- */
+/// Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed.
+/// This call is asynchronous and will return immediately.
+///
+/// - Parameters:
+/// - commandQueue: CommandQueue 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 *> *) runAsyncWithMTLCommandQueue:(id<MTLCommandQueue>) commandQueue
inputsArray:(NSArray<MPSGraphTensorData *> *) inputsArray
resultsArray:(NSArray<MPSGraphTensorData *> * _Nullable) resultsArray
executionDescriptor:(MPSGraphExecutableExecutionDescriptor * _Nullable) executionDescriptor
MPS_SWIFT_NAME( runAsync(with:inputs:results:executionDescriptor:) );
-/*!
- * @abstract Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed.
- * This call is asynchronous and will return immediately after finishing encoding.
- *
- * @param commandBuffer commandBuffer passed to exectute the graph on, commitAndContinue might be called, please don't rely on underlying MTLCommandBuffer to remain uncommitted
- * @param inputsArray Feeds tensorData for the placeholder tensors, same order as arguments of main function
- * @param resultsArray Tensors for which the caller wishes MPSGraphTensorData to be returned
- * @param executionDescriptor ExecutionDescriptor to be passed in and used,
- *
- * @return A valid MPSGraphTensorData array with results synchronized to the CPU memory if MPSGraphOptionsSynchronizeResults set.
- */
+/// Runs the graph for given feeds to return targetTensor values, ensuring all target operations also executed.
+/// This call is asynchronous and will return immediately after finishing encoding.
+///
+/// - Parameters:
+/// - commandBuffer: commandBuffer passed to exectute the graph on, commitAndContinue might be called, please don't rely on underlying MTLCommandBuffer to remain uncommitted
+/// - 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 *> *) encodeToCommandBuffer:(MPSCommandBuffer *) commandBuffer
inputsArray:(NSArray<MPSGraphTensorData *> *) inputsArray
resultsArray:(NSArray<MPSGraphTensorData *> * _Nullable) resultsArray
executionDescriptor:(MPSGraphExecutableExecutionDescriptor * _Nullable) executionDescriptor
MPS_SWIFT_NAME( encode(to:inputs:results:executionDescriptor:) );
-@end
+/// Serialize the MPSGraph executable at the provided url.
+///
+/// - Parameters:
+/// - url: the URL where to serialize the MPSGraph executable
+/// - descriptor: the descriptor to be used to serialize the graph
+-(void) serializeToMPSGraphPackageAtURL:(NSURL *) url
+ descriptor:(MPSGraphExecutableSerializationDescriptor *_Nullable) descriptor
+MPS_SWIFT_NAME( serialize(package:descriptor:) )
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0));
+/// Initialize the MPSGraph executable with the package at the provided url.
+///
+/// - Parameters:
+/// - mpsgraphPackageURL: the URL where to read the serialized MPSGraphExecutable
+/// - compilationDescriptor: compilationDescriptor to be used to specialize, since the executable was created with a compilationDescriptor already this one overrides those settings to the extent it can
+-(instancetype) initWithMPSGraphPackageAtURL:(NSURL *)mpsgraphPackageURL
+ compilationDescriptor:(MPSGraphCompilationDescriptor * _Nullable) compilationDescriptor
+MPS_SWIFT_NAME( init(package:descriptor:) )
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0));
+
+@end
NS_ASSUME_NONNULL_END
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphFourierTransformOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphFourierTransformOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphFourierTransformOps.h 1969-12-31 19:00:00
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphFourierTransformOps.h 2023-05-19 21:42:51
@@ -0,0 +1,269 @@
+//
+// MPSGraphFourierTransformOps.h
+// MPSGraph
+//
+// Created on 2/27/23.
+// Copyright © 2023 Apple Inc. All rights reserved.
+//
+
+#ifndef MPSGraphFourierTransformOps_h
+#define MPSGraphFourierTransformOps_h
+
+#import <MetalPerformanceShadersGraph/MPSGraph.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/// Scaling modes for Fourier Transform operations. Use this descriptor with ``MPSGraph/fastFourierTransformWithTensor:axes:descriptor:name:``,
+/// ``MPSGraph/realToHermiteanFFTWithTensor:axesTensor:descriptor:name:`` and
+/// ``MPSGraph/HermiteanToRealFFTWithTensor:axesTensor:descriptor:name:``.
+typedef NS_ENUM(NSUInteger, MPSGraphFFTScalingMode)
+{
+ /// Pass through with no scaling.
+ MPSGraphFFTScalingModeNone MPS_ENUM_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0)) MPS_SWIFT_NAME(none) = 0L,
+ /// Scales FFT result with reciprocal of the total FFT size over all transformed dimensions.
+ MPSGraphFFTScalingModeSize MPS_ENUM_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0)),
+ /// Scales FFT result with reciprocal square root of the total FFT size over all transformed dimensions, resulting in signal strength conserving transformation.
+ MPSGraphFFTScalingModeUnitary MPS_ENUM_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0))
+};
+
+/// Defines a Fast Fourier Tranform (FFT) operation.
+MPS_CLASS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0))
+@interface MPSGraphFFTDescriptor : MPSGraphObject<NSCopying>
+
+/// When set to ``YES`` MPSGraph uses the positive phase factor: `exp(+i 2Pi mu nu / n)`, when computing the (inverse) Fourier transform.
+/// Otherwise MPSGraph uses the negative phase factor: `exp(-i 2Pi mu nu / n)`, when computing the Fourier transform.
+/// Default value: ``NO``.
+@property (readwrite, nonatomic) BOOL inverse;
+
+/// Scaling mode to use with the FFT operation.
+/// Default value: ``MPSGraphFFTScalingModeNone``.
+@property (readwrite, nonatomic) MPSGraphFFTScalingMode scalingMode;
+
+/// If set then MPSGraph rounds the last output dimension of the result tensor in ``MPSGraph/HermiteanToRealFFTWithTensor:axesTensor:descriptor:name:``
+/// to an odd value. Has no effect in the other Fourier transform operations.
+/// Default value: ``NO``.
+@property (readwrite, nonatomic) BOOL roundToOddHermitean;
+
++(nullable instancetype) descriptor;
+
+@end
+
+
+MPS_CLASS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0))
+@interface MPSGraph(MPSGraphFourierTransformOps)
+
+/// Creates a Fast Fourier Transform op and returns the result tensor.
+///
+/// This operation computes the Fast Fourier Transform of the input tensor according to the following formulae.
+/// ```md
+/// output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) input[nu], where
+/// ```
+/// `scale = 1` for `scaling_mode = none`,
+/// `scale = 1/V_f` for `scaling_mode = size`,
+/// `scale = 1/sqrt(V_f)` for `scaling_mode = unitary`, where
+/// `V_f` is the volume of the transformation defined by the dimensions included in `axes`
+/// (`V_f = prod_{i \in axes} shape(input)[i]`) (see ``MPSGraphFFTDescriptor/scalingMode``),
+/// `+` is selected in `+/-` when `inverse` is specified, otherwise `-` is used
+/// and the sum is done separately over each dimension in `axes` and `n` is the
+/// dimension length of that axis.
+///
+/// > Tip: Currently transformation is supported only within the last four dimensions of the input tensor. In case
+/// you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input
+/// with ``MPSGraph/transposeTensor:permutation:name:`` to be within that last four and then transpose
+/// the result tensor back with the inverse of the input transpose.
+///
+/// - Parameters:
+/// - tensor: Complex-valued input tensor. Must have datatype ``MPSDataTypeComplexFloat32`` or ``MPSDataTypeComplexFloat16``.
+/// - axes: Specifies over which axes MPSGraph performs the Fourier Transform - all axes must be contained within last four dimensions of the input tensor.
+/// - descriptor: Defines details of the Fourier transform operation - see ``MPSGraphFFTDescriptor``.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor of the same type as ``tensor``.
+-(MPSGraphTensor *) fastFourierTransformWithTensor:(MPSGraphTensor *) tensor
+ axes:(NSArray<NSNumber *> *) axes
+ descriptor:(MPSGraphFFTDescriptor *) descriptor
+ name:(NSString * _Nullable) name
+MPS_SWIFT_NAME(fastFourierTransform(_:axes:descriptor:name:))
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0));
+
+/// Creates a Fast Fourier Transform op and returns the result tensor.
+///
+/// This operation computes the Fast Fourier Transform of the input tensor according to the following formulae.
+/// ```md
+/// output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) input[nu], where
+/// ```
+/// `scale = 1` for `scaling_mode = none`,
+/// `scale = 1/V_f` for `scaling_mode = size`,
+/// `scale = 1/sqrt(V_f)` for `scaling_mode = unitary`, where
+/// `V_f` is the volume of the transformation defined by the dimensions included in `axes`
+/// (`V_f = prod_{i \in axes} shape(input)[i]`) (see ``MPSGraphFFTDescriptor/scalingMode``),
+/// `+` is selected in `+/-` when `inverse` is specified, otherwise `-` is used
+/// and the sum is done separately over each dimension in `axes` and `n` is the
+/// dimension length of that axis.
+///
+/// > Tip: Currently transformation is supported only within the last four dimensions of the input tensor. In case
+/// you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input
+/// with ``MPSGraph/transposeTensor:permutation:name:`` to be within that last four and then transpose
+/// the result tensor back with the inverse of the input transpose.
+///
+/// - Parameters:
+/// - tensor: Complex-valued input tensor. Must have datatype ``MPSDataTypeComplexFloat32`` or ``MPSDataTypeComplexFloat16``.
+/// - axesTensor: Tensor of rank one containing the axes over which MPSGraph performs the transformation. See ``MPSGraph/fastFourierTransformWithTensor:axes:descriptor:name:``.
+/// - descriptor: Defines details of the Fourier transform operation - see ``MPSGraphFFTDescriptor``.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor of the same type as ``tensor``.
+-(MPSGraphTensor *) fastFourierTransformWithTensor:(MPSGraphTensor *) tensor
+ axesTensor:(MPSGraphTensor *) axesTensor
+ descriptor:(MPSGraphFFTDescriptor *) descriptor
+ name:(NSString * _Nullable) name
+MPS_SWIFT_NAME(fastFourierTransform(_:axesTensor:descriptor:name:))
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0));
+
+/// Creates a Real-to-Hermitean Fast Fourier Transform op and returns the result tensor.
+///
+/// This operation computes the Fast Fourier Transform of a real-valued input tensor according to the following formulae.
+/// ```md
+/// output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) input[nu], where
+/// ```
+/// `scale = 1` for `scaling_mode = none`,
+/// `scale = 1/V_f` for `scaling_mode = size`,
+/// `scale = 1/sqrt(V_f)` for `scaling_mode = unitary`, where
+/// `V_f` is the volume of the transformation defined by the dimensions included in `axes`
+/// (`V_f = prod_{i \in axes} shape(input)[i]`) (see ``MPSGraphFFTDescriptor/scalingMode``),
+/// `+` is selected in `+/-` when `inverse` is specified, otherwise `-` is used
+/// and the sum is done separately over each dimension in `axes` and `n` is the
+/// dimension length of that axis. With this API MPSGraph writes out only the results for the unique
+/// frequencies, resulting in a tensor which has size `(n/2)+1` in the last dimension defined by `axes`.
+///
+/// > Tip: Currently transformation is supported only within the last four dimensions of the input tensor. In case
+/// you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input
+/// with ``MPSGraph/transposeTensor:permutation:name:`` to be within that last four and then transpose
+/// the result tensor back with the inverse of the input transpose.
+///
+/// - Parameters:
+/// - tensor: Real-valued input tensor. Must have datatype ``MPSDataTypeFloat32`` or ``MPSDatatypeFloat16``.
+/// - axes: Specifies over which axes MPSGraph performs the Fourier Transform - all axes must be contained within last four dimensions of the input tensor.
+/// - descriptor: Defines details 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).
+-(MPSGraphTensor *) realToHermiteanFFTWithTensor:(MPSGraphTensor *) tensor
+ axes:(NSArray<NSNumber *> *) axes
+ descriptor:(MPSGraphFFTDescriptor *) descriptor
+ name:(NSString * _Nullable) name
+MPS_SWIFT_NAME(realToHermiteanFFT(_:axes:descriptor:name:))
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0));
+
+
+/// Creates a Real-to-Hermitean Fast Fourier Transform op and returns the result tensor.
+///
+/// This operation computes the Fast Fourier Transform of a real-valued input tensor according to the following formulae.
+/// ```md
+/// output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) input[nu], where
+/// ```
+/// `scale = 1` for `scaling_mode = none`,
+/// `scale = 1/V_f` for `scaling_mode = size`,
+/// `scale = 1/sqrt(V_f)` for `scaling_mode = unitary`, where
+/// `V_f` is the volume of the transformation defined by the dimensions included in `axes`
+/// (`V_f = prod_{i \in axes} shape(input)[i]`) (see ``MPSGraphFFTDescriptor/scalingMode``),
+/// `+` is selected in `+/-` when `inverse` is specified, otherwise `-` is used
+/// and the sum is done separately over each dimension in `axes` and `n` is the
+/// dimension length of that axis. With this API MPSGraph writes out only the results for the unique
+/// frequencies, resulting in a tensor which has size `(n/2)+1` in the last dimension defined by `axes`.
+///
+/// > Tip: Currently transformation is supported only within the last four dimensions of the input tensor. In case
+/// you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input
+/// with ``MPSGraph/transposeTensor:permutation:name:`` to be within that last four and then transpose
+/// the result tensor back with the inverse of the input transpose.
+///
+/// - Parameters:
+/// - tensor: Real-valued input tensor. Must have datatype ``MPSDataTypeFloat32`` or ``MPSDatatypeFloat16``.
+/// - axesTensor: Tensor of rank one containing the axes over which MPSGraph performs the transformation. See ``MPSGraph/fastFourierTransformWithTensor:axes:descriptor:name:``.
+/// - descriptor: Defines details 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).
+-(MPSGraphTensor *) realToHermiteanFFTWithTensor:(MPSGraphTensor *) tensor
+ axesTensor:(MPSGraphTensor *) axesTensor
+ descriptor:(MPSGraphFFTDescriptor *) descriptor
+ name:(NSString * _Nullable) name
+MPS_SWIFT_NAME(realToHermiteanFFT(_:axesTensor:descriptor:name:))
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0));
+
+/// Creates a Hermitean-to-Real Fast Fourier Transform op and returns the result tensor.
+///
+/// This operation computes the Fast Fourier Transform of a complex-valued input tensor according to the following formulae.
+/// ```md
+/// output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) in'[nu], where
+/// ```
+/// `in'[nu] = conjugate(in[n - nu])`, for the last dimension defined by `axes` when `nu` is out of range of the input dimension.
+/// `scale = 1` for `scaling_mode = none`,
+/// `scale = 1/V_f` for `scaling_mode = size`,
+/// `scale = 1/sqrt(V_f)` for `scaling_mode = unitary`, where
+/// `V_f` is the volume of the transformation defined by the dimensions included in `axes`
+/// (`V_f = prod_{i \in axes} shape(input)[i]`) (see ``MPSGraphFFTDescriptor/scalingMode``),
+/// `+` is selected in `+/-` when `inverse` is specified, otherwise `-` is used
+/// and the sum is done separately over each dimension in `axes` and `n` is the
+/// dimension length of that axis. With this API MPSGraph treats the input tensor to have only the unique
+/// frequencies, which means that the resulting tensor has size `(inSize-1)*2 + x` in the last dimension defined by `axes`,
+/// where `inSize = shape(input)[axis] ( = (n/2)+1 )` is the size of the input ``tensor`` in the last transformed dimension and
+/// `x = 1` when ``MPSGraphFFTDescriptor/roundToOddHermitean`` = `YES` and `x = 0` otherwise.
+///
+/// > Tip: Currently transformation is supported only within the last four dimensions of the input tensor. In case
+/// you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input
+/// with ``MPSGraph/transposeTensor:permutation:name:`` to be within that last four and then transpose
+/// the result tensor back with the inverse of the input transpose.
+///
+/// - Parameters:
+/// - tensor: Complex-valued input tensor with reduced size (see Discussion). Must have datatype ``MPSDataTypeComplexFloat32`` or ``MPSDataTypeComplexFloat16``.
+/// - axes: Specifies over which axes MPSGraph performs the Fourier Transform - all axes must be contained within last four dimensions of the input tensor.
+/// - descriptor: Defines details of the Fourier transform operation - see ``MPSGraphFFTDescriptor``.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor of type ``MPSDataTypeFloat32`` or ``MPSDataTypeFloat16`` (full size).
+-(MPSGraphTensor *) HermiteanToRealFFTWithTensor:(MPSGraphTensor *) tensor
+ axes:(NSArray<NSNumber *> *) axes
+ descriptor:(MPSGraphFFTDescriptor *) descriptor
+ name:(NSString * _Nullable) name
+MPS_SWIFT_NAME(HermiteanToRealFFT(_:axes:descriptor:name:))
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0));
+
+
+/// Creates a Hermitean-to-Real Fast Fourier Transform op and returns the result tensor.
+///
+/// This operation computes the Fast Fourier Transform of a complex-valued input tensor according to the following formulae.
+/// ```md
+/// output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) in'[nu], where
+/// ```
+/// `in'[nu] = conjugate(in[n - nu])`, for the last dimension defined by `axes` when `nu` is out of range of the input dimension.
+/// `scale = 1` for `scaling_mode = none`,
+/// `scale = 1/V_f` for `scaling_mode = size`,
+/// `scale = 1/sqrt(V_f)` for `scaling_mode = unitary`, where
+/// `V_f` is the volume of the transformation defined by the dimensions included in `axes`
+/// (`V_f = prod_{i \in axes} shape(input)[i]`) (see ``MPSGraphFFTDescriptor/scalingMode``),
+/// `+` is selected in `+/-` when `inverse` is specified, otherwise `-` is used
+/// and the sum is done separately over each dimension in `axes` and `n` is the
+/// dimension length of that axis. With this API MPSGraph treats the input tensor to have only the unique
+/// frequencies, which means that the resulting tensor has size `(inSize-1)*2 + x` in the last dimension defined by `axes`,
+/// where `inSize = shape(input)[axis] ( = (n/2)+1 )` is the size of the input ``tensor`` in the last transformed dimension and
+/// `x = 1` when ``MPSGraphFFTDescriptor/roundToOddHermitean`` = `YES` and `x = 0` otherwise.
+///
+/// > Tip: Currently transformation is supported only within the last four dimensions of the input tensor. In case
+/// you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input
+/// with ``MPSGraph/transposeTensor:permutation:name:`` to be within that last four and then transpose
+/// the result tensor back with the inverse of the input transpose.
+///
+/// - Parameters:
+/// - tensor: Complex-valued input tensor with reduced size (see Discussion). Must have datatype ``MPSDataTypeComplexFloat32`` or ``MPSDataTypeComplexFloat16``.
+/// - axesTensor: Tensor of rank one containing the axes over which MPSGraph performs the transformation. See ``MPSGraph/fastFourierTransformWithTensor:axes:descriptor:name:``.
+/// - descriptor: Defines details of the Fourier transform operation - see ``MPSGraphFFTDescriptor``.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor of type ``MPSDataTypeFloat32`` or ``MPSDataTypeFloat16`` (full size).
+-(MPSGraphTensor *) HermiteanToRealFFTWithTensor:(MPSGraphTensor *) tensor
+ axesTensor:(MPSGraphTensor *) axesTensor
+ descriptor:(MPSGraphFFTDescriptor *) descriptor
+ name:(NSString * _Nullable) name
+MPS_SWIFT_NAME(HermiteanToRealFFT(_:axesTensor:descriptor:name:))
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0));
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif /* MPSGraphFourierTransformOps_h */
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphGatherOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphGatherOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphGatherOps.h 2023-03-09 19:09:04
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphGatherOps.h 2023-05-22 01:20:38
@@ -13,123 +13,124 @@
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(GatherNDOps)
-/*!
- * @abstract Create GatherND op and return the result tensor
- * @discussion Gathers the slices in updatesTensor to the result tensor along the indices in indicesTensor.
- * The gather is defined as
- * @code
- * B = batchDims
- * U = updates.rank - B
- * P = res.rank - B
- * Q = inds.rank - B
- * K = inds.shape[-1]
- * index_slice = indices[i_{b0},...,i_{bB},i_{0},..,i_{Q-1}]
- * res[i_{b0},...,i_{bB},i_{0},...,i_{Q-1}] = updates[i_{b0},...,i_{bB},index_slice[0],...,index_slice[K-1]]
- * @endcode
- * The tensors have the following shape requirements
- * @code
- * U > 0; P > 0; Q > 0
- * K <= U
- * P = (U-K) + Q-1
- * indices.shape[0:Q-1] = res.shape[0:Q-1]
- * res.shape[Q:P] = updates.shape[K:U]
- * @endcode
- *
- * @param updatesTensor Tensor containing slices to be inserted into the result tensor
- * @param indicesTensor Tensor containg the updates indices to read slices from
- * @param batchDimensions The number of batch dimensions
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
-*/
--(MPSGraphTensor *) gatherNDWithUpdatesTensor:(MPSGraphTensor *) updatesTensor
- indicesTensor:(MPSGraphTensor *) indicesTensor
- batchDimensions:(NSUInteger) batchDimensions
- name:(NSString * _Nullable) name;
+/// Create GatherND op and return the result tensor
+///
+/// Gathers the slices in updatesTensor to the result tensor along the indices in indicesTensor.
+/// The gather is defined as
+/// ```md
+/// B = batchDims
+/// U = updates.rank - B
+/// P = res.rank - B
+/// Q = inds.rank - B
+/// K = inds.shape[-1]
+/// index_slice = indices[i_{b0},...,i_{bB},i_{0},..,i_{Q-1}]
+/// res[i_{b0},...,i_{bB},i_{0},...,i_{Q-1}] = updates[i_{b0},...,i_{bB},index_slice[0],...,index_slice[K-1]]
+/// ```
+/// The tensors have the following shape requirements
+/// ```md
+/// U > 0; P > 0; Q > 0
+/// K <= U
+/// P = (U-K) + Q-1
+/// indices.shape[0:Q-1] = res.shape[0:Q-1]
+/// res.shape[Q:P] = updates.shape[K:U]
+/// ```
+///
+/// - Parameters:
+/// - updatesTensor: Tensor containing slices to be inserted into the result tensor
+/// - indicesTensor: Tensor containg the updates indices to read slices from
+/// - batchDimensions: The number of batch dimensions
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
+///
+- (MPSGraphTensor *) gatherNDWithUpdatesTensor:(MPSGraphTensor *) updatesTensor
+ indicesTensor:(MPSGraphTensor *) indicesTensor
+ batchDimensions:(NSUInteger) batchDimensions
+ name:(NSString * _Nullable) name;
@end
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(GatherOps)
-/*!
- * @abstract Create Gather op and return the result tensor
- * @discussion Gathers the values in updatesTensor to the result tensor along the indices in indicesTensor.
- * The gather is defined as
- * @code
- * B = batchDims
- * U = updates.rank
- * P = res.rank
- * Q = inds.rank
- *
- * res[p_{0},...p_{axis-1}, i_{B},...,i_{Q}, ...,p_{axis+1},...,p{U-1}] =
- * updates[p_{0},...p_{axis-1}, indices[p_{0},...,p_{B-1},i_{B},...,i_{Q}, ...,p_{axis+1},...,p{U-1}]
- *
- * @endcode
- * The tensors have the following shape requirements
- * @code
- * P = Q-B + U-1
- * indices.shape[0:B] = updates.shape[0:B] = res.shape[0:B]
- * res.shape[0:axis] = updates.shape[0:axis]
- * res.shape[axis:axis+Q-B] = indices.shape[B:]
- * res.shape[axis+1+Q-B:] = updates.shape[axis+1:]
- * @endcode
- *
- * @param updatesTensor Tensor containing slices to be inserted into the result tensor
- * @param indicesTensor Tensor containg the updates indices to read slices from
- * @param axis The dimension on which to perform the gather
- * @param batchDimensions The number of batch dimensions
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
-*/
--(MPSGraphTensor *) gatherWithUpdatesTensor:(MPSGraphTensor *) updatesTensor
- indicesTensor:(MPSGraphTensor *) indicesTensor
- axis:(NSUInteger) axis
- batchDimensions:(NSUInteger) batchDimensions
- name:(NSString * _Nullable) name;
+/// Create Gather op and return the result tensor
+///
+/// Gathers the values in updatesTensor to the result tensor along the indices in indicesTensor.
+/// The gather is defined as
+/// ```md
+/// B = batchDims
+/// U = updates.rank
+/// P = res.rank
+/// Q = inds.rank
+/// res[p_{0},...p_{axis-1}, i_{B},...,i_{Q}, ...,p_{axis+1},...,p{U-1}] =
+/// updates[p_{0},...p_{axis-1}, indices[p_{0},...,p_{B-1},i_{B},...,i_{Q}, ...,p_{axis+1},...,p{U-1}]
+/// ```
+/// The tensors have the following shape requirements
+/// ```md
+/// P = Q-B + U-1
+/// indices.shape[0:B] = updates.shape[0:B] = res.shape[0:B]
+/// res.shape[0:axis] = updates.shape[0:axis]
+/// res.shape[axis:axis+Q-B] = indices.shape[B:]
+/// res.shape[axis+1+Q-B:] = updates.shape[axis+1:]
+/// ```
+///
+/// - Parameters:
+/// - updatesTensor: Tensor containing slices to be inserted into the result tensor
+/// - indicesTensor: Tensor containg the updates indices to read slices from
+/// - axis: The dimension on which to perform the gather
+/// - batchDimensions: The number of batch dimensions
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
+///
+- (MPSGraphTensor *) gatherWithUpdatesTensor:(MPSGraphTensor *) updatesTensor
+ indicesTensor:(MPSGraphTensor *) indicesTensor
+ axis:(NSUInteger) axis
+ batchDimensions:(NSUInteger) batchDimensions
+ name:(NSString * _Nullable) name;
@end
@interface MPSGraph(MPSGraphGatherAlongAxisOps)
-/*!
- * @abstract Create GatherAlongAxis op and return the result tensor
- * @discussion Gather values from `updatesTensor` along the specified `axis` at indices in `indicesTensor`.
- * The shape of `updatesTensor` and `indicesTensor` must match except at `axis`.
- * The shape of the result tensor is equal to the shape of `indicesTensor`.
- * If an index is out of bounds of the `updatesTensor` along `axis` a 0 is inserted.
- *
- * @param axis The axis to gather from. Negative values wrap around
- * @param updatesTensor The input tensor to gather values from
- * @param indicesTensor Int32 or Int64 tensor used to index `updatesTensor`
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
-*/
+/// Create GatherAlongAxis op and return the result tensor
+///
+/// Gather values from `updatesTensor` along the specified `axis` at indices in `indicesTensor`.
+/// The shape of `updatesTensor` and `indicesTensor` must match except at `axis`.
+/// The shape of the result tensor is equal to the shape of `indicesTensor`.
+/// If an index is out of bounds of the `updatesTensor` along `axis` a 0 is inserted.
+///
+/// - Parameters:
+/// - axis: The axis to gather from. Negative values wrap around
+/// - updatesTensor: The input tensor to gather values from
+/// - indicesTensor: Int32 or Int64 tensor used to index `updatesTensor`
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
+///
--(MPSGraphTensor *) gatherAlongAxis:(NSInteger) axis
- withUpdatesTensor:(MPSGraphTensor *) updatesTensor
- indicesTensor:(MPSGraphTensor *) indicesTensor
- name:(NSString * _Nullable) name
+- (MPSGraphTensor *) gatherAlongAxis:(NSInteger) axis
+ withUpdatesTensor:(MPSGraphTensor *) updatesTensor
+ indicesTensor:(MPSGraphTensor *) indicesTensor
+ name:(NSString * _Nullable) name
MPS_SWIFT_NAME( gatherAlongAxis(_:updates:indices:name:) )
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
-/*!
- * @abstract Create GatherAlongAxis op and return the result tensor
- * @discussion See above discussion of gatherAlongAxis: withUpdatesTensor: indicesTensor: name:
- *
- * @param axisTensor Scalar Int32 tensor. The axis to gather from. Negative values wrap around
- * @param updatesTensor The input tensor to gather values from
- * @param indicesTensor Int32 or Int64 tensor used to index `updatesTensor`
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
-*/
--(MPSGraphTensor *) gatherAlongAxisTensor:(MPSGraphTensor *) axisTensor
- withUpdatesTensor:(MPSGraphTensor *) updatesTensor
- indicesTensor:(MPSGraphTensor *) indicesTensor
- name:(NSString * _Nullable) name
+/// Create GatherAlongAxis op and return the result tensor
+///
+/// Gather values from `updatesTensor` along the specified `axis` at indices in `indicesTensor`.
+/// The shape of `updatesTensor` and `indicesTensor` must match except at `axis`.
+/// The shape of the result tensor is equal to the shape of `indicesTensor`.
+/// If an index is out of bounds of the `updatesTensor` along `axis` a 0 is inserted.
+///
+/// - Parameters:
+/// - axisTensor: Scalar Int32 tensor. The axis to gather from. Negative values wrap around
+/// - updatesTensor: The input tensor to gather values from
+/// - indicesTensor: Int32 or Int64 tensor used to index `updatesTensor`
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
+///
+- (MPSGraphTensor *) gatherAlongAxisTensor:(MPSGraphTensor *) axisTensor
+ withUpdatesTensor:(MPSGraphTensor *) updatesTensor
+ indicesTensor:(MPSGraphTensor *) indicesTensor
+ name:(NSString * _Nullable) name
MPS_SWIFT_NAME( gatherAlongAxisTensor(_:updates:indices:name:) )
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphImToColOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphImToColOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphImToColOps.h 1969-12-31 19:00:00
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphImToColOps.h 2023-05-22 01:17:40
@@ -0,0 +1,136 @@
+//
+// MPSGraphImToColOps.h
+// MetalPerformanceShadersGraph
+//
+// Created by local on 4/26/23.
+// Copyright © 2023 Apple Inc. All rights reserved.
+//
+
+#ifndef MPSGraphImToColOps_h
+#define MPSGraphImToColOps_h
+
+#import <MetalPerformanceShadersGraph/MPSGraph.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/// Descriptor for properties of convolution.
+/// It is used to create ImToCol operation.
+MPS_CLASS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0))
+@interface MPSGraphImToColOpDescriptor : MPSGraphObject<NSCopying>
+
+/// kernel in `x` or width dimension.
+@property (readwrite, nonatomic) NSUInteger kernelWidth;
+/// kernel in `y` or height dimension.
+@property (readwrite, nonatomic) NSUInteger kernelHeight;
+/// stride in `x` or width dimension.
+@property (readwrite, nonatomic) NSUInteger strideInX;
+/// stride in `y` or height dimension.
+@property (readwrite, nonatomic) NSUInteger strideInY;
+/// dilation in `x` or width dimension.
+@property (readwrite, nonatomic) NSUInteger dilationRateInX;
+/// dilation in `y` or height dimension.
+@property (readwrite, nonatomic) NSUInteger dilationRateInY;
+/// padding in `x` or width dimension on left side.
+@property (readwrite, nonatomic) NSUInteger paddingLeft;
+/// padding in `x` or width dimension on right side.
+@property (readwrite, nonatomic) NSUInteger paddingRight;
+/// padding in `y` or height dimension at top.
+@property (readwrite, nonatomic) NSUInteger paddingTop;
+/// padding in `y` or height dimension at bottom.
+@property (readwrite, nonatomic) NSUInteger paddingBottom;
+/// layout of source tensor.
+/// e.g. `batch x channels x width x height` for `NCHW` layout
+@property (readwrite, nonatomic) MPSGraphTensorNamedDataLayout dataLayout;
+
+/// Creates imToCol descriptor with given values for parameters.
+/// - Parameters:
+/// - kernelWidth: See ``kernelWidth`` property.
+/// - kernelHeight: See ``kernelHeight`` property.
+/// - strideInX: See ``strideInX`` property.
+/// - strideInY: See ``strideInY`` property.
+/// - dilationRateInX: See ``dilationRateInX`` property.
+/// - dilationRateInY: See ``dilationRateInY`` property.
+/// - paddingLeft: See ``paddingLeft`` property.
+/// - paddingRight: See ``paddingRight`` property.
+/// - paddingTop: See ``paddingTop`` property.
+/// - paddingBottom: See ``paddingBottom`` property.
+/// - dataLayout: See ``dataLayout`` property.
+/// - Returns: The descriptor on autoreleasepool.
++(nullable instancetype) descriptorWithKernelWidth:(NSUInteger) kernelWidth
+ kernelHeight:(NSUInteger) kernelHeight
+ strideInX:(NSUInteger) strideInX
+ strideInY:(NSUInteger) strideInY
+ dilationRateInX:(NSUInteger) dilationRateInX
+ dilationRateInY:(NSUInteger) dilationRateInY
+ paddingLeft:(NSUInteger) paddingLeft
+ paddingRight:(NSUInteger) paddingRight
+ paddingTop:(NSUInteger) paddingTop
+ paddingBottom:(NSUInteger) paddingBottom
+ dataLayout:(MPSGraphTensorNamedDataLayout) dataLayout;
+
+/// Creates imToCol descriptor with given values for parameters.
+/// - Parameters:
+/// - kernelWidth: See ``kernelWidth`` property.
+/// - kernelHeight: See ``kernelHeight`` property.
+/// - strideInX: See ``strideInX`` property.
+/// - strideInY: See ``strideInY`` property.
+/// - dilationRateInX: See ``dilationRateInX`` property.
+/// - dilationRateInY: See ``dilationRateInY`` property.
+/// - dataLayout: See ``dataLayout`` property.
+/// - Returns: The descriptor on autoreleasepool.
++(nullable instancetype) descriptorWithKernelWidth:(NSUInteger) kernelWidth
+ kernelHeight:(NSUInteger) kernelHeight
+ strideInX:(NSUInteger) strideInX
+ strideInY:(NSUInteger) strideInY
+ dilationRateInX:(NSUInteger) dilationRateInX
+ dilationRateInY:(NSUInteger) dilationRateInY
+ dataLayout:(MPSGraphTensorNamedDataLayout) dataLayout;
+
+/// Sets values of padding to given values.
+/// - Parameters:
+/// - paddingLeft: See ``paddingLeft`` property.
+/// - paddingRight: See ``paddingRight`` property.
+/// - paddingTop: See ``paddingTop`` property.
+/// - paddingBottom: See ``paddingBottom`` property.
+-(void) setExplicitPaddingWithPaddingLeft:(NSUInteger) paddingLeft
+ paddingRight:(NSUInteger) paddingRight
+ paddingTop:(NSUInteger) paddingTop
+ paddingBottom:(NSUInteger) paddingBottom;
+
+
+@end
+
+MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
+@interface MPSGraph(MPSGraphImToColOps)
+
+/// Creates an imToCol operation and returns the result tensor.
+///
+/// - Parameters:
+/// - source: source tensor - must be of rank 4. The layout is defined by ``descriptor.dataLayout``.
+/// - descriptor: Specifies strides, dilation rates, paddings and layout.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
+-(MPSGraphTensor *) imToColWithSourceTensor:(MPSGraphTensor *) source
+ descriptor:(MPSGraphImToColOpDescriptor *) descriptor
+ name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( imToCol(_:descriptor:name:) );
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0));
+
+/// Creates an colToIm operation and returns the result tensor.
+///
+/// - Parameters:
+/// - source: source tensor - must be of rank 3. The layout is defined by ``descriptor.dataLayout``.
+/// - descriptor: Specifies strides, dilation rates, paddings and layout.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
+-(MPSGraphTensor *) colToImWithSourceTensor:(MPSGraphTensor *) source
+ outputShape:(MPSShape *)outputShape
+ descriptor:(MPSGraphImToColOpDescriptor *) descriptor
+ name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( colToIm(_:outputShape:descriptor:name:) );
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0));
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif /* MPSGraphImToColOps_h */
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphLinearAlgebraOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphLinearAlgebraOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphLinearAlgebraOps.h 2023-03-09 23:53:23
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphLinearAlgebraOps.h 2023-05-22 01:20:38
@@ -17,39 +17,37 @@
MPS_CLASS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4))
@interface MPSGraph(MPSGraphLinearAlgebraOps)
-/*!
- * @abstract Create band part op and return the result
- * @discussion Copies a diagonal band of values from input tensor to a result tensor of the same size.
- * A coordinate @code [..., i, j] @endcode is in the band if
- * @code
- * (numLower < 0 || (i-j) <= numLower) && (numUpper < 0 || (j-i) <= numUpper)
- * @endcode
- * Values outside of the band are set to 0.
- *
- * @param inputTensor The source tensor to copy
- * @param numLower The number of diagonals in the lower triangle to keep. If -1, keep all
- * @param numUpper The number of diagonals in the upper triangle to keep. If -1, keep all
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
- */
+/// Compute the band part of an input tensor
+///
+/// The framework copies a diagonal band of values from input tensor to a result tensor of the same size.
+/// A coordinate `[..., i, j]` is in the band if
+/// ```md
+/// (numLower < 0 || (i-j) <= numLower) && (numUpper < 0 || (j-i) <= numUpper)
+/// ```
+/// Values outside of the band are set to 0.
+///
+/// - Parameters:
+/// - inputTensor: input tensor
+/// - numLower: the number of diagonals in the lower triangle to keep. If -1, the framework returns all sub diagnols
+/// - numUpper: the number of diagonals in the upper triangle to keep. If -1, the framework returns all super diagnols
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) bandPartWithTensor:(MPSGraphTensor *) inputTensor
numLower:(NSInteger) numLower
numUpper:(NSInteger) numUpper
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( bandPart(_:numLower:numUpper:name:) );
-/*!
- * @abstract Create band part op and return the result
- * @discussion See above discussion of bandPartWithTensor: numLower: numUpper: name:
- *
- * @param inputTensor The source tensor to copy
- * @param numLowerTensor Scalar Int32 tensor. The number of diagonals in the lower triangle to keep. If -1, keep all.
- * @param numUpperTensor Scalar Int32 tensor. The number of diagonals in the upper triangle to keep. If -1, keep all.
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor object
- */
+/// Create band part op and return the result
+///
+/// See above discussion of bandPartWithTensor: numLower: numUpper: name:
+///
+/// - Parameters:
+/// - inputTensor: The source tensor to copy
+/// - numLowerTensor: Scalar Int32 tensor. The number of diagonals in the lower triangle to keep. If -1, keep all.
+/// - numUpperTensor: Scalar Int32 tensor. The number of diagonals in the upper triangle to keep. If -1, keep all.
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) bandPartWithTensor:(MPSGraphTensor *) inputTensor
numLowerTensor:(MPSGraphTensor *) numLowerTensor
numUpperTensor:(MPSGraphTensor *) numUpperTensor
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphLossOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphLossOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphLossOps.h 2023-03-09 23:53:24
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphLossOps.h 2023-05-22 01:20:39
@@ -13,36 +13,33 @@
NS_ASSUME_NONNULL_BEGIN
-/*!
- * @typedef MPSGraphLossReductionType
- * @abstract Options to be utilized by the graph
- *
- * @constant MPSGraphLossReductionTypeAxis No Reductions
- * @constant MPSGraphLossReductionTypeSum ReduceSum down to a scalar
- * @constant MPSGraphLossReductionTypeMean ReduceMean down to a scalar
- */
+/// Defines the type of the reduction the graph applies in the loss operations.
typedef NS_ENUM(uint64_t, MPSGraphLossReductionType)
{
- MPSGraphLossReductionTypeAxis MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) MPS_SWIFT_NAME(none) = 0,
+ /// No Reductions
+ MPSGraphLossReductionTypeNone MPS_ENUM_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0)) MPS_SWIFT_NAME(none) = 0L,
+ /// No Reductions
+ MPSGraphLossReductionTypeAxis MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) MPS_SWIFT_NAME(axis) = MPSGraphLossReductionTypeNone,
+ /// Reduce sum down to a scalar.
MPSGraphLossReductionTypeSum MPS_ENUM_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0)) = 1L,
+ /// Reduce mean down to a scalar.
MPSGraphLossReductionTypeMean MPS_ENUM_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0)) = 2L,
};
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MPSGraphLossOps)
-/*!
- * @abstract Create a softmax cross entropy loss op and return the result tensor
- *
- *
- * @param sourceTensor sourceTensor
- * @param labelsTensor labelsTensor
- * @param axis axis over which loss reuction happens
- * @param reductionType reductionType which reduces across all other axes
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Creates a softmax cross entropy loss operation and returns the result tensor.
+/// This computes: `loss = reduction( - labels*ln( softmax(source) ))`,
+/// where `sotfmax(source) = exp(source) / sum( exp(source) )`, where the sum is computed over ``axis``.
+///
+/// - Parameters:
+/// - sourceTensor: The source tensor.
+/// - labelsTensor: The labels tensor.
+/// - axis: Axis over which the softmax reduction happens.
+/// - reductionType: The type of reduction MPSGraph uses to reduce across all other axes.
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) softMaxCrossEntropyWithSourceTensor:(MPSGraphTensor *) sourceTensor
labelsTensor:(MPSGraphTensor *) labelsTensor
axis:(NSInteger) axis
@@ -50,18 +47,16 @@
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( softMaxCrossEntropy(_:labels:axis:reuctionType:name:) );
-/*!
- * @abstract Create a softmax cross entropy loss op and return the result tensor
- *
- * @param gradientTensor gradientTensor
- * @param sourceTensor sourceTensor
- * @param labelsTensor labelsTensor
- * @param axis axis over which loss reuction happens
- * @param reductionType reductionType which reduces across all other axes
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Creates a softmax cross entropy loss operation and returns the result tensor.
+///
+/// - Parameters:
+/// - gradientTensor: gradientTensor - Note: in most cases you want to pass in the initial gradient tensor, which is a constant tensor with value one.
+/// - sourceTensor: The source tensor.
+/// - labelsTensor: The labels tensor.
+/// - axis: Axis over which loss reduction happens.
+/// - reductionType: The type of reduction MPSGraph uses to reduce across all other axes.
+/// - name: Name for the operation.
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) softMaxCrossEntropyGradientWithIncomingGradientTensor:(MPSGraphTensor *) gradientTensor
sourceTensor:(MPSGraphTensor *) sourceTensor
labelsTensor:(MPSGraphTensor *) labelsTensor
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMatrixInverseOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMatrixInverseOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMatrixInverseOps.h 2023-03-09 23:53:24
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMatrixInverseOps.h 2023-05-22 01:20:39
@@ -15,17 +15,16 @@
@interface MPSGraph(MPSGraphMatrixInverseOps)
-/*!
- * @abstract Create Matrix inverse op and return the result tensor
- * @discussion Find the inverse of a square matrix by calling LU decomposition and solver
- * The op computes inverse for all batches If the input tensor has more than
- * 2 dimensions. Results are undefined for ill conditioned matrices.
- *
- * @param inputTensor input tensor to inverse op
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Compute the inverse of an input tensor.
+///
+/// The framework computes the inverse of a square matrix by calling LU decomposition and LU solver.
+/// All dimensions after the first 2 are treated as batch dimensions and the inverse for each batch is computed
+/// Results are undefined for ill conditioned matrices.
+///
+/// - Parameters:
+/// - inputTensor: An input tensor.
+/// - name: A name for the operation.
+/// - Returns: A valid ``MPSGraphTensor`` object.
-(MPSGraphTensor *) inverseOfTensor:(MPSGraphTensor *) inputTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( inverse(input:name:) )
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMatrixMultiplicationOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMatrixMultiplicationOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMatrixMultiplicationOps.h 2023-03-09 23:53:24
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMatrixMultiplicationOps.h 2023-05-22 01:20:39
@@ -16,39 +16,29 @@
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MPSGraphMatrixMultiplicationOps)
-/*!
- * @abstract Create MatMul op and return the result tensor, it supports broadcasting as well
- *
- * @code
- * resultTensor = matmul(primaryTensor, secondaryTensor)
- * @endcode
- *
- * @param primaryTensor LHS tensor of the binary Op
- * @param secondaryTensor RHS tensor of the binary Op
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Computes matrix multiplication of 2 input tensors with support for broadcasting.
+///
+/// - Parameters:
+/// - primaryTensor: A lhs tensor.
+/// - secondaryTensor: A rhs tensor.
+/// - name: A name for the operation.
+/// - Returns: A valid ``MPSGraphTensor`` object
-(MPSGraphTensor *) matrixMultiplicationWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( matrixMultiplication(primary:secondary:name:) );
-/*!
- * @abstract Create a Hamming Distance op and return the result tensor, it supports broadcasting as well.
- * @discussion The Hamming Distance is computed between sets of vectors and the last dimension(s) of each
- * input tensor is considered a vector. If the shape of @ref primaryTensor is `[Na, M, K]` and the shape
- * of @ref secondaryTensor is `[Nb, N, K]`, with Na, Nb being any batch dimensions,
- * then the result shape is `[Na/Nb, M, N]`, where `Na/Nb` are the broadcasted batch dimensions.
- * The result datatype is either MPSDataTypeUInt32 or MPSDataTypeUInt16.
- *
- * @param primaryTensor LHS tensor of the binary Op
- * @param secondaryTensor RHS tensor of the binary Op
- * @param resultDataType Must be either MPSDataTypeUInt32 or MPSDataTypeUInt16
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Computes hamming distance of 2 input tensors with support for broadcasting.
+///
+/// The hamming distance is computed between sets of vectors and the last dimension(s) of each
+/// input tensor is considered a vector.
+///
+/// - Parameters:
+/// - primaryTensor: A lhs tensor.
+/// - secondaryTensor: A rhs tensor.
+/// - resultDataType: A datatype of the return MPSGraphTensor. Must be either MPSDataTypeUInt32 or MPSDataTypeUInt16.
+/// - name: A name for the operation
+/// - Returns: A valid ``MPSGraphTensor`` object.
-(MPSGraphTensor *) HammingDistanceWithPrimaryTensor:(MPSGraphTensor *) primaryTensor
secondaryTensor:(MPSGraphTensor *) secondaryTensor
resultDataType:(MPSDataType) resultDataType
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMemoryOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMemoryOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMemoryOps.h 2023-03-09 23:53:23
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphMemoryOps.h 2023-05-22 01:17:40
@@ -16,14 +16,10 @@
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraphVariableOp : MPSGraphOperation
-/*! @property shape
- * @discussion shape of the variable
- */
+/// shape of the variable
@property (readonly, nonnull, nonatomic) MPSShape *shape;
-/*! @property dataType
- * @discussion dataType of the variable
- */
+/// dataType of the variable
@property (readonly, nonatomic) MPSDataType dataType;
@end
@@ -31,111 +27,134 @@
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MemoryOps)
-/*!
- * @abstract Create a placeholder op and return the result tensor
- *
- *
- * @param shape shape of the output tensor, nil shape will result in an unranked tensor
- * @param dataType dataType of the placeholder tensor
- * @param name name for the placeholder operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create a placeholder op and return the result tensor
+///
+/// - Parameters:
+/// - shape: shape of the output tensor, nil shape will result in an unranked tensor
+/// - dataType: dataType of the placeholder tensor
+/// - name: name for the placeholder operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) placeholderWithShape:(MPSShape * _Nullable) shape
dataType:(MPSDataType) dataType
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( placeholder(shape:dataType:name:) );
-/*!
- * @abstract Create a placeholder op and return the result tensor
- * dataType of the placeholder tensor set to MPSDataTypeFloat32
- *
- * @param shape shape of the output tensor, nil shape will result in an unranked tensor
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create a placeholder op and return the result tensor
+/// dataType of the placeholder tensor set to MPSDataTypeFloat32
+///
+/// - Parameters:
+/// - shape: shape of the output tensor, nil shape will result in an unranked tensor
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) placeholderWithShape:(MPSShape * _Nullable) shape
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( placeholder(shape:name:) );
-/*!
- * @abstract Create a constant op and return the result tensor
- *
- * @param data data for the tensor, number of bytes should be sizeof(dataType) * numberOfElements
- * @param shape shape of the output tensor, has to be statically shaped
- * @param dataType dataType of theconstant tensor
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create a constant op and return the result tensor
+///
+/// - Parameters:
+/// - data: data for the tensor, number of bytes should be sizeof(dataType)numberOfElements
+/// - shape: shape of the output tensor, has to be statically shaped
+/// - dataType: dataType of theconstant tensor
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) constantWithData:(NSData *) data
shape:(MPSShape *) shape
dataType:(MPSDataType) dataType
MPS_SWIFT_NAME( constant(_:shape:dataType:) );
-/*!
- * @abstract Create a constant op and return the result tensor
- *
- * @param scalar scalar to fill the entire tensor values with
- * @param dataType dataType of the constant tensor
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create a constant op and return the result tensor
+///
+/// - Parameters:
+/// - scalar: scalar to fill the entire tensor values with
+/// - dataType: dataType of the constant tensor
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) constantWithScalar:(double) scalar
dataType:(MPSDataType) dataType
MPS_SWIFT_NAME( constant(_:dataType:) );
-/*!
- * @abstract Create a constant op and return the result tensor
- *
- * @param scalar scalar to fill the entire tensor values with
- * @param shape shape of the output tensor. @[], @[@1] or @[@-1] means that the shape will be resolved via shape inference at runtime
- * @param dataType dataType of the constant tensor
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create a constant op and return the result tensor
+///
+/// - Parameters:
+/// - scalar: scalar to fill the entire tensor values with
+/// - shape: shape of the output tensor.
+/// - dataType: dataType of the constant tensor
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) constantWithScalar:(double) scalar
shape:(MPSShape *) shape
dataType:(MPSDataType) dataType
MPS_SWIFT_NAME( constant(_:shape:dataType:) );
-/*!
- * @abstract Create a variable op and return the result tensor
- *
- * @param data data for the tensor, number of bytes should be sizeof(dataType) * numberOfElements
- * @param shape shape of the output tensor, has to be statically shaped
- * @param dataType dataType of theconstant tensor
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create a complex constant op with MPSDataTypeComplexFloat32 data type and return the result tensor.
+///
+/// - Parameters:
+/// - realPart: the real part of the complex scalar to fill the entire tensor values with.
+/// - imaginaryPart: the imaginary part of the complex scalar to fill the entire tensor values with.
+/// - dataType: dataType of the constant tensor.
+/// - Returns: A valid MPSGraphTensor object.
+-(MPSGraphTensor *) constantWithRealPart:(double) realPart
+ imaginaryPart:(double) imaginaryPart
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0))
+MPS_SWIFT_NAME( complexConstant(realPart:imaginaryPart:) );
+
+/// Create a complex constant op and return the result tensor.
+///
+/// - Parameters:
+/// - realPart: the real part of the complex scalar to fill the entire tensor values with.
+/// - imaginaryPart: the imaginary part of the complex scalar to fill the entire tensor values with.
+/// - dataType: dataType of the constant tensor.
+/// - Returns: A valid MPSGraphTensor object.
+-(MPSGraphTensor *) constantWithRealPart:(double) realPart
+ imaginaryPart:(double) imaginaryPart
+ dataType:(MPSDataType) dataType
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0))
+MPS_SWIFT_NAME( complexConstant(realPart:imaginaryPart:dataType:) );
+
+/// Create a complex constant op and return the result tensor.
+///
+/// - Parameters:
+/// - realPart: the real part of the complex scalar to fill the entire tensor values with.
+/// - imaginaryPart: the imaginary part of the complex scalar to fill the entire tensor values with.
+/// - shape: shape of the output tensor, has to be statically shaped.
+/// - dataType: dataType of the constant tensor.
+/// - Returns: A valid MPSGraphTensor object.
+-(MPSGraphTensor *) constantWithRealPart:(double) realPart
+ imaginaryPart:(double) imaginaryPart
+ shape:(MPSShape *) shape
+ dataType:(MPSDataType) dataType
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0))
+MPS_SWIFT_NAME( complexConstant(realPart:imaginaryPart:shape:dataType:) );
+
+/// Create a variable op and return the result tensor
+///
+/// - Parameters:
+/// - data: data for the tensor, number of bytes should be sizeof(dataType)numberOfElements
+/// - shape: shape of the output tensor, has to be statically shaped
+/// - dataType: dataType of theconstant tensor
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) variableWithData:(NSData *) data
shape:(MPSShape *) shape
dataType:(MPSDataType) dataType
name:(NSString * _Nullable) name;
-/*!
- * @abstract Create a read op which reads at this point of execution of the graph and return the result tensor
- *
- * @param variable variable resource tensor to read from
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create a read op which reads at this point of execution of the graph and return the result tensor
+///
+/// - Parameters:
+/// - variable: variable resource tensor to read from
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) readVariable:(MPSGraphTensor *) variable
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( read(_:name:) );
-/*!
- * @abstract Create a read op which reads at this point of execution of the graph and return the result tensor
- *
- * @param variable variable resource tensor to read from
- * @param tensor tensor to assign to variable
- * @param name name for the operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create a read op which reads at this point of execution of the graph and return the result tensor
+///
+/// - Parameters:
+/// - variable: variable resource tensor to read from
+/// - tensor: tensor to assign to variable
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphOperation *) assignVariable:(MPSGraphTensor *) variable
withValueOfTensor:(MPSGraphTensor *) tensor
name:(NSString * _Nullable) name
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphNonZeroOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphNonZeroOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphNonZeroOps.h 1969-12-31 19:00:00
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphNonZeroOps.h 2023-05-22 01:20:38
@@ -0,0 +1,44 @@
+//
+// MPSGraphNonZeroOps.h
+// MPSGraph
+//
+// Created by Matteo Franciolini on 2/27/23.
+// Copyright © 2023 Apple Inc. All rights reserved.
+//
+
+#ifndef MPSGraphNonZeroOps_h
+#define MPSGraphNonZeroOps_h
+
+#import <MetalPerformanceShadersGraph/MPSGraph.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
+@interface MPSGraph(NonZeroOps)
+
+/// Compute the indices of the non-zero elements of the input tensor. The indices are
+/// returned as a two-dimensional tensor of size `[number_of_nonzeros, input_rank]`.
+/// Each row in the result contains indices of a nonzero elements in input.
+///
+/// For example:
+/// ```md
+/// tensor = [[ 1, 0, 3],
+/// [ 0, 10, 0]]
+/// indices = [[ 0, 0],
+/// [ 0, 2],
+/// [ 1, 1]]
+/// ```
+///
+/// - Parameters:
+/// - tensor: An MPSGraphTensor of which to compute the non-zero indices.
+/// - Returns: A valid MPSGraphTensor containing indices in signed int32 data type.
+-(MPSGraphTensor *) nonZeroIndicesOfTensor:(MPSGraphTensor *) tensor
+ name:(NSString * _Nullable) name
+MPS_SWIFT_NAME( nonZeroIndices(_:name:))
+MPS_AVAILABLE_STARTING(macos(14.0), ios(17.0), tvos(17.0));
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif /* MPSGraphNonZeroOps_h */
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphNormalizationOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphNormalizationOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphNormalizationOps.h 2023-03-09 19:13:38
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphNormalizationOps.h 2023-05-22 01:20:38
@@ -16,68 +16,57 @@
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MPSGraphNormalizationOps)
-/*!
- * @abstract Create a mean op and return the result tensor
- *
- *
- * @param axes A list of axes over which to perform the reduction. The order of dimensions goes from the slowest moving at axis=0 to the fastest moving dimension.
- * @param name name for the placeholder operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create a mean op and return the result tensor
+///
+/// - Parameters:
+/// - axes: A list of axes over which to perform the reduction. The order of dimensions goes from the slowest moving at axis=0 to the fastest moving dimension.
+/// - name: name for the placeholder operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) meanOfTensor:(MPSGraphTensor *) tensor
axes:(NSArray<NSNumber *> *) axes
name:(NSString * _Nullable) name;
-/*!
- * @abstract Create a variance op when you already have a precomputed mean and return the result tensor
- *
- *
- * @param axes A list of axes over which to perform the reduction such that the order of dimensions goes from the slowest moving at axis=0 to the fastest moving dimension.
- * @param name name for the placeholder operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create a variance op when you already have a precomputed mean and return the result tensor
+///
+/// - Parameters:
+/// - axes: A list of axes over which to perform the reduction such that the order of dimensions goes from the slowest moving at axis=0 to the fastest moving dimension.
+/// - name: name for the placeholder operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) varianceOfTensor:(MPSGraphTensor *) tensor
meanTensor:(MPSGraphTensor *) meanTensor
axes:(NSArray<NSNumber *> *) axes
name:(NSString * _Nullable) name;
-/*!
- * @abstract Create a variance op and return the result tensor
- *
- *
- * @param axes A list of axes over which to perform the reduction. Tthe order of dimensions goes from the slowest moving at axis=0 to the fastest moving dimension.
- * @param name name for the placeholder operation
- *
- * @return A valid MPSGraphTensor object.
- */
+/// Create a variance op and return the result tensor
+///
+/// - Parameters:
+/// - axes: A list of axes over which to perform the reduction. Tthe order of dimensions goes from the slowest moving at axis=0 to the fastest moving dimension.
+/// - name: name for the placeholder operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) varianceOfTensor:(MPSGraphTensor *) tensor
axes:(NSArray<NSNumber *> *) axes
name:(NSString * _Nullable) name;
-/*!
- * @abstract Create a batch normalization op and return the result tensor
- *
- * @discussion The mean and variance tensors should be outputs of meanWithTensor:axes:name and varianceWithTensor:meanTensor:axes:name.
- * Use the axes parameter to achieve different types of normalizations.
- * For example (assuming your data is in NxHxWxC format)
- * Batch normalization: axes = [0, 1, 2]
- * Instance normalization: axes = [1, 2]
- * Shapes for gamma and beta must match the input data along at least one dimension and will be broadcast along the rest.
- * For batch normalization, gamma and beta would typically be 1x1x1xC i.e. one value per channel.
- *
- *
- * @param mean mean
- * @param variance variance
- * @param gamma Tensor used to scale the normalized result
- * @param beta Tensor used to bias the normalized result
- * @param epsilon A small value to add to the variance when normalizing the inputs.
- * @param name name for the placeholder operation
- *
- * @return A valid MPSGraphTensor object.
-*/
-
+/// Create a batch normalization op and return the result tensor
+///
+/// The mean and variance tensors should be outputs of meanWithTensor:axes:name and varianceWithTensor:meanTensor:axes:name.
+/// Use the axes parameter to achieve different types of normalizations.
+/// For example (assuming your data is in NxHxWxC format)
+/// Batch normalization: axes = [0, 1, 2]
+/// Instance normalization: axes = [1, 2]
+/// Shapes for gamma and beta must match the input data along at least one dimension and will be broadcast along the rest.
+/// For batch normalization, gamma and beta would typically be 1x1x1xC i.e. one value per channel.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - mean: mean
+/// - variance: variance
+/// - gamma: Tensor used to scale the normalized result
+/// - beta: Tensor used to bias the normalized result
+/// - epsilon: A small value to add to the variance when normalizing the inputs.
+/// - name: name for the placeholder operation
+/// - Returns: A valid MPSGraphTensor object.
+///
-(MPSGraphTensor *) normalizationWithTensor:(MPSGraphTensor *) tensor
meanTensor:(MPSGraphTensor *) mean
varianceTensor:(MPSGraphTensor *) variance
@@ -87,7 +76,24 @@
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( normalize(_:mean:variance:gamma:beta:epsilon:name:) );
-
+/// Create a normalization gamma gradient op and return the result tensor
+///
+/// The mean and variance tensors should be outputs of ``meanWithTensor:axes:name`` and ``varianceWithTensor:meanTensor:axes:name``.
+/// Use the axes parameter to achieve different types of normalizations.
+/// For example (assuming your data is in `NxHxWxC` format)
+/// Batch normalization: axes = [0, 1, 2]
+/// Instance normalization: axes = [1, 2]
+///
+/// - Parameters:
+/// - incomingGradientTensor: incoming original resultTensor gradient
+/// - sourceTensor: original input source in forward direction
+/// - meanTensor: mean tensor
+/// - varianceTensor: variance
+/// - axes: axes to which were normalized
+/// - epsilon: A small value to add to the variance when normalizing the inputs.
+/// - name: name for the placeholder operation
+/// - Returns: A valid MPSGraphTensor object.
+///
-(MPSGraphTensor *) normalizationGammaGradientWithIncomingGradientTensor:(MPSGraphTensor *) incomingGradientTensor
sourceTensor:(MPSGraphTensor *) sourceTensor
meanTensor:(MPSGraphTensor *) meanTensor
@@ -96,11 +102,45 @@
epsilon:(float) epsilon
name:(NSString * _Nullable) name;
+/// Create a normalization beta gradient op and return the result tensor
+///
+/// The mean and variance tensors should be outputs of ``meanWithTensor:axes:name`` and ``varianceWithTensor:meanTensor:axes:name``.
+/// Use the axes parameter to achieve different types of normalizations.
+/// For example (assuming your data is in `NxHxWxC` format)
+/// Batch normalization: axes = [0, 1, 2]
+/// Instance normalization: axes = [1, 2]
+///
+/// - Parameters:
+/// - incomingGradientTensor: incoming original resultTensor gradient
+/// - sourceTensor: original input source in forward direction
+/// - axes: axes to which were normalized
+/// - name: name for the placeholder operation
+/// - Returns: A valid MPSGraphTensor object.
+///
-(MPSGraphTensor *) normalizationBetaGradientWithIncomingGradientTensor:(MPSGraphTensor *) incomingGradientTensor
sourceTensor:(MPSGraphTensor *) sourceTensor
reductionAxes:(NSArray<NSNumber *> *) axes
name:(NSString * _Nullable) name;
-
+/// Create a normalization input gradient op and return the result tensor
+///
+/// The mean and variance tensors should be outputs of ``meanWithTensor:axes:name`` and ``varianceWithTensor:meanTensor:axes:name``.
+/// Use the axes parameter to achieve different types of normalizations.
+/// For example (assuming your data is in `NxHxWxC` format)
+/// Batch normalization: axes = [0, 1, 2]
+/// Instance normalization: axes = [1, 2]
+///
+/// - Parameters:
+/// - incomingGradientTensor: incoming original resultTensor gradient
+/// - sourceTensor: original input source in forward direction
+/// - meanTensor: mean tensor
+/// - varianceTensor: variance tensor
+/// - gamma: gamma tensor
+/// - gammaGradient: gammaGradient tensor
+/// - betaGradient: betaGradient tensor
+/// - axes: axes to which were normalized
+/// - epsilon: A small value to add to the variance when normalizing the inputs.
+/// - name: name for the placeholder operation
+///
-(MPSGraphTensor *) normalizationGradientWithIncomingGradientTensor:(MPSGraphTensor *) incomingGradientTensor
sourceTensor:(MPSGraphTensor *) sourceTensor
meanTensor:(MPSGraphTensor *) meanTensor
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphOneHotOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphOneHotOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphOneHotOps.h 2023-03-09 23:53:23
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphOneHotOps.h 2023-05-22 01:17:40
@@ -16,62 +16,129 @@
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MPSGraphOneHotOps)
-/*!
- * @abstract Create oneHot op and return the result tensor
- *
- * @discussion Creates a tensor of rank equal to the indicesTensor rank + 1.
- * A new axis is inserted at the axis specified, or the minor axis if axis is -1.
- * The values at the indices in the indicesTensor will have the onValue,
- * and all other values will be set to the offValue.
- *
- * @param indicesTensor Tensor of indices for on values
- * @param depth Depth of the oneHot vector along the axis
- * @param axis The axis to insert the new oneHot vector at.
- * Defaults to -1, the minor axis
- * @param dataType MPSDataType of the result tensor
- * Defaults to MPSDataTypeFloat
- * @param onValue The value for indices designated by the indicesTensor. This value must match the specified data type.
- * Defaults to 1.0f
- * @param offValue The value for indices not designated by the indicesTensor. This value must match the specified data type.
- * Defaults to 0.0f
- * @param name Name for the operation
- *
- * @return A valid MPSGraphTensor object.
-*/
--(MPSGraphTensor *) oneHotWithIndicesTensor:(MPSGraphTensor *) indicesTensor
- depth:(NSUInteger) depth
- axis:(NSUInteger) axis
- dataType:(MPSDataType) dataType
- onValue:(double) onValue
- offValue:(double) offValue
- name:(NSString * _Nullable) name;
+/// Create oneHot op and return the result tensor
+///
+/// Creates a tensor of rank equal to the indicesTensor rank + 1.
+/// Inserts a new axis at the axis specified, or the minor axis if axis is -1.
+/// The values at the indices in the indicesTensor will have the onValue,
+/// and all other values will be set to the offValue.
+///
+/// - Parameters:
+/// - indicesTensor: Tensor of indices for on values
+/// - depth: Depth of the oneHot vector along the axis
+/// - axis: The axis to insert the new oneHot vector at. Defaults to -1, the minor axis
+/// - dataType: MPSDataType of the result tensor Defaults to MPSDataTypeFloat
+/// - onValue: The value for indices designated by the indicesTensor. This value must match the specified data type. Defaults to 1.0f
+/// - offValue: The value for indices not designated by the indicesTensor. This value must match the specified data type. Defaults to 0.0f
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+///
+- (MPSGraphTensor *) oneHotWithIndicesTensor:(MPSGraphTensor *) indicesTensor
+ depth:(NSUInteger) depth
+ axis:(NSUInteger) axis
+ dataType:(MPSDataType) dataType
+ onValue:(double) onValue
+ offValue:(double) offValue
+ name:(NSString * _Nullable) name;
--(MPSGraphTensor *) oneHotWithIndicesTensor:(MPSGraphTensor *) indicesTensor
- depth:(NSUInteger) depth
- dataType:(MPSDataType) dataType
- onValue:(double) onValue
- offValue:(double) offValue
- name:(NSString * _Nullable) name;
+/// Create oneHot op and return the result tensor
+///
+/// Creates a tensor of rank equal to the rank of `indicesTensor` + 1.
+/// Inserts a new axis at the minor dimension.
+/// The values at the indices in the indicesTensor will have the onValue,
+/// and all other values will be set to the offValue.
+///
+/// - Parameters:
+/// - indicesTensor: Tensor of indices for on values
+/// - depth: Depth of the oneHot vector along the axis
+/// - dataType: MPSDataType of the result tensor
+/// - onValue: The value for indices designated by the indicesTensor. This value must match the specified data type.
+/// - offValue: The value for indices not designated by the indicesTensor. This value must match the specified data type.
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+///
+- (MPSGraphTensor *) oneHotWithIndicesTensor:(MPSGraphTensor *) indicesTensor
+ depth:(NSUInteger) depth
+ dataType:(MPSDataType) dataType
+ onValue:(double) onValue
+ offValue:(double) offValue
+ name:(NSString * _Nullable) name;
--(MPSGraphTensor *) oneHotWithIndicesTensor:(MPSGraphTensor *) indicesTensor
- depth:(NSUInteger) depth
- axis:(NSUInteger) axis
- dataType:(MPSDataType) dataType
- name:(NSString * _Nullable) name;
+/// Create oneHot op and return the result tensor
+///
+/// Creates a tensor of rank equal to the rank of `indicesTensor` + 1.
+/// Inserts a new axis at the axis specified, or the minor axis if `axis` is -1.
+/// The values at the indices in the indicesTensor will be set to 1,
+/// and all other values will be set to 0.
+///
+/// - Parameters:
+/// - indicesTensor: Tensor of indices for on values
+/// - depth: Depth of the oneHot vector along the axis
+/// - axis: The axis to insert the new oneHot vector at
+/// - dataType: MPSDataType of the result tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+///
+- (MPSGraphTensor *) oneHotWithIndicesTensor:(MPSGraphTensor *) indicesTensor
+ depth:(NSUInteger) depth
+ axis:(NSUInteger) axis
+ dataType:(MPSDataType) dataType
+ name:(NSString * _Nullable) name;
--(MPSGraphTensor *) oneHotWithIndicesTensor:(MPSGraphTensor *) indicesTensor
- depth:(NSUInteger) depth
- axis:(NSUInteger) axis
- name:(NSString * _Nullable) name;
+/// Create oneHot op and return the result tensor
+///
+/// Creates a tensor of rank equal to the rank of `indicesTensor` + 1, of type MPSDataTypeFloat32.
+/// Inserts a new axis at the axis specified, or the minor axis if `axis` is -1.
+/// The values at the indices in the indicesTensor will be set to 1,
+/// and all other values will be set to 0.
+///
+/// - Parameters:
+/// - indicesTensor: Tensor of indices for on values
+/// - depth: Depth of the oneHot vector along the axis
+/// - axis: The axis to insert the new oneHot vector at
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+///
+- (MPSGraphTensor *) oneHotWithIndicesTensor:(MPSGraphTensor *) indicesTensor
+ depth:(NSUInteger) depth
+ axis:(NSUInteger) axis
+ name:(NSString * _Nullable) name;
--(MPSGraphTensor *) oneHotWithIndicesTensor:(MPSGraphTensor *) indicesTensor
- depth:(NSUInteger) depth
- dataType:(MPSDataType) dataType
- name:(NSString * _Nullable) name;
+/// Create oneHot op and return the result tensor
+///
+/// Creates a tensor of rank equal to the rank of `indicesTensor` + 1.
+/// Inserts a new axis at the minor dimension.
+/// The values at the indices in the indicesTensor will be set to 1,
+/// and all other values will be set to 0.
+///
+/// - Parameters:
+/// - indicesTensor: Tensor of indices for on values
+/// - depth: Depth of the oneHot vector along the axis
+/// - dataType: MPSDataType of the result tensor
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+///
+- (MPSGraphTensor *) oneHotWithIndicesTensor:(MPSGraphTensor *) indicesTensor
+ depth:(NSUInteger) depth
+ dataType:(MPSDataType) dataType
+ name:(NSString * _Nullable) name;
--(MPSGraphTensor *) oneHotWithIndicesTensor:(MPSGraphTensor *) indicesTensor
- depth:(NSUInteger) depth
- name:(NSString * _Nullable) name;
+/// Create oneHot op and return the result tensor
+///
+/// Creates a tensor of rank equal to the rank of `indicesTensor` + 1, of type MPSDataTypeFloat32.
+/// Inserts a new axis at the minor dimension.
+/// The values at the indices in the indicesTensor will be set to 1,
+/// and all other values will be set to 0.
+///
+/// - Parameters:
+/// - indicesTensor: Tensor of indices for on values
+/// - depth: Depth of the oneHot vector along the axis
+/// - name: Name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+///
+- (MPSGraphTensor *) oneHotWithIndicesTensor:(MPSGraphTensor *) indicesTensor
+ depth:(NSUInteger) depth
+ name:(NSString * _Nullable) name;
@end
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphOperation.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphOperation.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphOperation.h 2023-03-09 23:53:23
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphOperation.h 2023-05-22 01:20:38
@@ -16,42 +16,29 @@
@class MPSGraph;
-/*! @class MPSGraphOperation
- * @abstract Symbolic representation of a compute operation, all tensors are created, owned and destroyed by the MPSGraph
- * @discussion NSCopy will cause a refrence to be taken, this is so NSDictionary can work with the tensor.
- * All operations are created, owned and destroyed by the MPSGraph
- */
+/// Symbolic representation of a compute operation, all tensors are created, owned and destroyed by the MPSGraph
+///
+/// NSCopy will cause a refrence to be taken, this is so NSDictionary can work with the tensor.
+/// All operations are created, owned and destroyed by the MPSGraph
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
-@interface MPSGraphOperation : NSObject <NSCopying>
+@interface MPSGraphOperation : MPSGraphObject <NSCopying>
-/*! @property inputTensors
- * @discussion inputTensors of the operation
- */
+/// inputTensors of the operation
@property (readonly, nonnull, nonatomic) NSArray<MPSGraphTensor *> *inputTensors;
-/*! @property outputTensors
- * @discussion outputTensors of the operation
- */
+/// outputTensors of the operation
@property (readonly, nonnull, nonatomic) NSArray<MPSGraphTensor *> *outputTensors;
-/*! @property controlDependencies
- * @discussion operations guaranteed to execute before this operation
- */
+/// operations guaranteed to execute before this operation
@property (readonly, nonnull, nonatomic) NSArray<MPSGraphOperation *> *controlDependencies;
-/*! @property graph
- * @discussion graph on which the operation is defined
- */
+/// graph on which the operation is defined
@property (readonly, nonatomic) MPSGraph *graph;
-/*! @property name
- * @discussion name of the operation
- */
+/// name of the operation
@property (readonly, nonnull, nonatomic) NSString *name;
-/*!
- * @brief Unvaiable, please utilize graph methods to create and initialize operations
- */
+/// Unvaiable, please utilize graph methods to create and initialize operations
-(instancetype) init NS_UNAVAILABLE;
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphOptimizerOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphOptimizerOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphOptimizerOps.h 2023-03-09 23:53:22
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphOptimizerOps.h 2023-05-19 20:58:42
@@ -16,41 +16,65 @@
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MPSGraphOptimizerOps)
-/*!
- * @abstract StochasticGradientDescent
- * @discussion The StochasticGradientDescent performs a gradient descent
- *
- * variable = variable - (learningRate * g)
- *
- * where,
- * g is gradient of error wrt variable
- *
- */
+/// The StochasticGradientDescent performs a gradient descent
+/// `variable = variable - (learningRate * g)`
+/// where,
+/// `g` is gradient of error wrt variable
+///
+/// - Parameters:
+/// - learningRateTensor: scalar tensor which indicates the learning rate to use with the optimizer
+/// - valuesTensor: values tensor, usually representing the trainable parameters
+/// - gradientTensor: partial gradient of the trainable parameters with respect to loss
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) stochasticGradientDescentWithLearningRateTensor:(MPSGraphTensor *) learningRateTensor
valuesTensor:(MPSGraphTensor *) valuesTensor
gradientTensor:(MPSGraphTensor *) gradientTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( stochasticGradientDescent(learningRate:values:gradient:name:) );
+/// The StochasticGradientDescent performs a gradient descent
+/// `variable = variable - (learningRate * g)`
+/// where,
+/// `g` is gradient of error wrt variable
+/// this op directly writes to the variable
+///
+/// - Parameters:
+/// - learningRateTensor: scalar tensor which indicates the learning rate to use with the optimizer
+/// - variable: variable operation with trainable parameters
+/// - gradientTensor: partial gradient of the trainable parameters with respect to loss
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphOperation *) applyStochasticGradientDescentWithLearningRateTensor:(MPSGraphTensor *) learningRateTensor
variable:(MPSGraphVariableOp *) variable
gradientTensor:(MPSGraphTensor *) gradientTensor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( applyStochasticGradientDescent(learningRate:variable:gradient:name:) );
-/*!
- * @abstract Adam
- * @discussion The adam update ops are added
- *
- * current learning rate:
- * lr[t] = learningRate * sqrt(1 - beta2^t) / (1 - beta1^t)
- *
- * m[t] = beta1 * m[t-1] + (1 - beta1) * g
- * v[t] = beta2 * v[t-1] + (1 - beta2) * (g ^ 2)
- * maxVel[t] = max(maxVel[t-1],v[t])
- * variable = variable - lr[t] * m[t] / (sqrt(maxVel) + epsilon)
- * @return if maximumVelocity is nil array of 3 tensors (update, newMomentum, newVelocity) else array of 4 tensors (update, newMomentum, newVelocity, newMaximumVelocity)
- */
+/// Adam
+///
+/// The adam update ops are added
+/// current learning rate:
+/// ```md
+/// lr[t] = learningRate * sqrt(1 - beta2^t) / (1 - beta1^t)
+/// m[t] = beta1 * m[t-1] + (1 - beta1) * g
+/// v[t] = beta2 * v[t-1] + (1 - beta2) * (g ^ 2)
+/// maxVel[t] = max(maxVel[t-1], v[t])
+/// variable = variable - lr[t] * m[t] / (sqrt(maxVel) + epsilon)
+/// ```
+/// - Parameters:
+/// - learningRateTensor: scalar tensor which indicates the learning rate to use with the optimizer
+/// - beta1Tensor: beta1Tensor
+/// - beta2Tensor: beta2Tensor
+/// - beta1PowerTensor: `beta1^t` beta1 power tensor
+/// - beta2PowerTensor: `beta2^t` beta2 power tensor
+/// - valuesTensor: values to update with optimization
+/// - momentumTensor: momentum tensor
+/// - velocityTensor: velocity tensor
+/// - maximumVelocityTensor: optional maximum velocity tensor
+/// - gradientTensor: partial gradient of the trainable parameters with respect to loss
+/// - name: name for the operation
+/// - Returns: if maximumVelocity is nil array of 3 tensors (update, newMomentum, newVelocity) else array of 4 tensors (update, newMomentum, newVelocity, newMaximumVelocity)
-(NSArray<MPSGraphTensor *> *) adamWithLearningRateTensor:(MPSGraphTensor *) learningRateTensor
beta1Tensor:(MPSGraphTensor *) beta1Tensor
beta2Tensor:(MPSGraphTensor *) beta2Tensor
@@ -66,16 +90,27 @@
MPS_SWIFT_NAME( adam(learningRate:beta1:beta2:epsilon:beta1Power:beta2Power:values:momentum:velocity:maximumVelocity:gradient:name:) );
-/*!
- * @abstract Adam
- * @discussion The adam update ops are added
- *
- * m[t] = beta1 * m[t-1] + (1 - beta1) * g
- * v[t] = beta2 * v[t-1] + (1 - beta2) * (g ^ 2)
- * maxVel[t] = max(maxVel[t-1],v[t])
- * variable = variable - lr[t] * m[t] / (sqrt(maxVel) + epsilon)
- * @return if maximumVelocity is nil array of 3 tensors (update, newMomentum, newVelocity) else array of 4 tensors (update, newMomentum, newVelocity, newMaximumVelocity)
- */
+/// Adam
+///
+/// The adam update ops are added
+/// ```md
+/// m[t] = beta1m[t-1] + (1 - beta1) * g
+/// v[t] = beta2v[t-1] + (1 - beta2) * (g ^ 2)
+/// maxVel[t] = max(maxVel[t-1],v[t])
+/// variable = variable - lr[t] * m[t] / (sqrt(maxVel) + epsilon)
+/// ```
+/// - Parameters:
+/// - learningRateTensor: scalar tensor which indicates the learning rate to use with the optimizer
+/// - beta1Tensor: beta1Tensor
+/// - beta2Tensor: beta2Tensor
+/// - epsilonTensor: epsilon tensor
+/// - valuesTensor: values to update with optimization
+/// - momentumTensor: momentum tensor
+/// - velocityTensor: velocity tensor
+/// - maximumVelocityTensor: optional maximum velocity tensor
+/// - gradientTensor: partial gradient of the trainable parameters with respect to loss
+/// - name: name for the operation
+/// - Returns: if maximumVelocity is nil array of 3 tensors (update, newMomentum, newVelocity) else array of 4 tensors (update, newMomentum, newVelocity, newMaximumVelocity)
-(NSArray<MPSGraphTensor *> *) adamWithCurrentLearningRateTensor:(MPSGraphTensor *) currentLearningRateTensor
beta1Tensor:(MPSGraphTensor *) beta1Tensor
beta2Tensor:(MPSGraphTensor *) beta2Tensor
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphPoolingOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphPoolingOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphPoolingOps.h 2023-03-09 23:50:15
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphPoolingOps.h 2023-05-22 01:17:40
@@ -13,93 +13,104 @@
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.
- */
+/// Flattening mode for returned indices with max pooling.
MPS_ENUM_AVAILABLE_STARTING(macos(12.2), ios(15.3), tvos(15.3))
typedef NS_ENUM(NSUInteger, MPSGraphPoolingReturnIndicesMode)
{
+ /// No indices returned.
MPSGraphPoolingReturnIndicesNone,
+ /// Return indices flattened in inner most (last) dimension.
MPSGraphPoolingReturnIndicesGlobalFlatten1D,
+ /// Return indices flattened in 2 innermost dimensions. eg: HW in NCHW.
MPSGraphPoolingReturnIndicesGlobalFlatten2D,
+ /// Return indices flattened in 3 innernost dimensions. eg: HWC in NHWC.
MPSGraphPoolingReturnIndicesGlobalFlatten3D,
+ /// Return indices flattened in 4 innermost dimensions.
MPSGraphPoolingReturnIndicesGlobalFlatten4D,
+ /// Return indices within pooling window, flattened in inner most dimension.
MPSGraphPoolingReturnIndicesLocalFlatten1D,
+ /// Return indices within pooling window, flattened in 2 innermost dimensions. eg: HW in NCHW.
MPSGraphPoolingReturnIndicesLocalFlatten2D,
+ /// Return indices within pooling window, flattened in 3 innernost dimensions. eg: HWC in NHWC.
MPSGraphPoolingReturnIndicesLocalFlatten3D,
+ /// Return indices within pooling window, flattened in 4 innermost dimensions.
MPSGraphPoolingReturnIndicesLocalFlatten4D,
};
+/// Defines a 2d pooling operation.
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
-@interface MPSGraphPooling2DOpDescriptor : NSObject<NSCopying>
+@interface MPSGraphPooling2DOpDescriptor : MPSGraphObject<NSCopying>
-/*! @property groups
- * @discussion groups of the operation
- */
+/// Defines the pooling window size for X (Width) dimension.
@property (readwrite, nonatomic) NSUInteger kernelWidth;
+/// Defines the pooling window size for Y (Height) dimension.
@property (readwrite, nonatomic) NSUInteger kernelHeight;
+/// Defines stride for X (Width) dimension. Default value: 1.
@property (readwrite, nonatomic) NSUInteger strideInX;
+/// Defines stride for Y (Height) dimension. Default value: 1.
@property (readwrite, nonatomic) NSUInteger strideInY;
+/// Defines dilation rate for X (Width) dimension. Default value: 1.
@property (readwrite, nonatomic) NSUInteger dilationRateInX;
+/// Defines dilation rate for Y (Height) dimension. Default value: 1.
@property (readwrite, nonatomic) NSUInteger dilationRateInY;
+/// Defines explicit padding value for X (Width) dimension to add before the data. Default value: 0.
@property (readwrite, nonatomic) NSUInteger paddingLeft;
+/// Defines explicit padding value for X (Width) dimension to add after the data. Default value: 0.
@property (readwrite, nonatomic) NSUInteger paddingRight;
+/// Defines explicit padding value for Y (Height) dimension to add before the data. Default value: 0.
@property (readwrite, nonatomic) NSUInteger paddingTop;
+/// Defines explicit padding value for Y (Height) dimension to add after the data. Default value: 0.
@property (readwrite, nonatomic) NSUInteger paddingBottom;
+/// Defines what kind of padding to apply to operation.
+/// Default value: ``MPSGraphPaddingStyleExplicit``.
@property (readwrite, nonatomic) MPSGraphPaddingStyle paddingStyle;
+/// Defines the data layout of the input data (in forward pass). See: ``MPSGraphTensorNamedDataLayout``.
@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
- */
+/// Use this in conjunction with ``maxPooling2DReturnIndicesWithSourceTensor`` API.
+/// If ``returnIndicesMode = MPSGraphPoolingReturnIndicesNone`` then only the first result
+/// MPSGraph returns from ``maxPooling2DReturnIndicesWithSourceTensor`` will be valid and using the
+/// second result will assert.
+/// Default value: ``MPSGraphPoolingReturnIndicesNone``.
@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
- */
+/// Use this in conjunction with ``maxPooling2DReturnIndicesWithSourceTensor`` API.
+/// Currently MPSGraph supports the following datatypes: ``MPSDataTypeInt32``.
+/// Default value: ``MPSDataTypeInt32``.
@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
- * dividing by stride.
- * Default value: @code NO @endcode
- */
+/// Affects how MPSGraph computes the output size: if set to ``YES`` then output size is
+/// computed by rounding up instead of down when dividing input size by stride.
+/// Default value: ``NO``.
@property (readwrite, nonatomic) BOOL ceilMode MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0));
-/*!
- * @property includeZeroPadToAverage
- * @discussion For average pooling use a mode where samples outside the input tensor count as
- * zeroes in the average computation. Otherwise the result is sum over samples divided by
- * number of samples that didn't come from padding.
- * Default value: @code NO @endcode
- */
+/// For average pooling use a mode where samples outside the input tensor count as
+/// zeroes in the average computation. Otherwise the result is sum over samples divided by
+/// number of samples that didn't come from padding.
+/// Default value: ``NO``.
@property (readwrite, nonatomic) BOOL includeZeroPadToAverage MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0));
-
+/// Creates a 2d pooling descriptor with given values.
+///
+/// - Parameters:
+/// - kernelWidth: See ``kernelWidth`` property.
+/// - kernelHeight: See ``kernelHeight`` property.
+/// - strideInX: See ``strideInX`` property.
+/// - strideInY: See ``strideInY`` property.
+/// - dilationRateInX: See ``dilationRateInX`` property.
+/// - dilationRateInY: See ``dilationRateInY`` property.
+/// - paddingLeft: See ``paddingLeft`` property.
+/// - paddingRight: See ``paddingRight`` property.
+/// - paddingTop: See ``paddingTop`` property.
+/// - paddingBottom: See ``paddingBottom`` property.
+/// - paddingStyle: See ``paddingStyle`` property.
+/// - dataLayout: See ``dataLayout`` property.
+/// - Returns: The descriptor on autoreleasepool.
+(nullable instancetype) descriptorWithKernelWidth:(NSUInteger) kernelWidth
kernelHeight:(NSUInteger) kernelHeight
strideInX:(NSUInteger) strideInX
@@ -113,6 +124,16 @@
paddingStyle:(MPSGraphPaddingStyle) paddingStyle
dataLayout:(MPSGraphTensorNamedDataLayout) dataLayout;
+/// Creates a 2d pooling descriptor with given values.
+///
+/// - Parameters:
+/// - kernelWidth: See ``kernelWidth`` property.
+/// - kernelHeight: See ``kernelHeight`` property.
+/// - strideInX: See ``strideInX`` property.
+/// - strideInY: See ``strideInY`` property.
+/// - paddingStyle: See ``paddingStyle`` property.
+/// - dataLayout: See ``dataLayout`` property.
+/// - Returns: The descriptor on autoreleasepool.
+(nullable instancetype) descriptorWithKernelWidth:(NSUInteger) kernelWidth
kernelHeight:(NSUInteger) kernelHeight
strideInX:(NSUInteger) strideInX
@@ -120,7 +141,13 @@
paddingStyle:(MPSGraphPaddingStyle) paddingStyle
dataLayout:(MPSGraphTensorNamedDataLayout) dataLayout;
-
+/// Sets the explicit padding values and sets ``paddingStyle`` to ``MPSGraphPaddingStyleExplicit``.
+///
+/// - Parameters:
+/// - paddingLeft: See ``paddingLeft`` property.
+/// - paddingRight: See ``paddingRight`` property.
+/// - paddingTop: See ``paddingTop`` property.
+/// - paddingBottom: See ``paddingBottom`` property.
-(void) setExplicitPaddingWithPaddingLeft:(NSUInteger) paddingLeft
paddingRight:(NSUInteger) paddingRight
paddingTop:(NSUInteger) paddingTop
@@ -128,108 +155,80 @@
@end
-/*!
- * @class MPSGraphPooling4DOpDescriptor
- * @abstract Defines a 4d pooling operation
- */
+/// Defines a 4d pooling operation.
MPS_CLASS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0))
-@interface MPSGraphPooling4DOpDescriptor : NSObject<NSCopying>
+@interface MPSGraphPooling4DOpDescriptor : MPSGraphObject<NSCopying>
-/*!
- * @property kernelSizes
- * @discussion Defines the pooling window size.
- * Must be four numbers, one for each spatial dimension, fastest running index last.
- */
+/// Defines the pooling window size.
+/// Must be four numbers, one for each spatial dimension, fastest running index last.
@property (readwrite, nonatomic, copy) NSArray<NSNumber *> * _Nonnull kernelSizes;
-/*!
- * @property strides
- * @discussion Must be four numbers, one for each spatial dimension, fastest running index last.
- * Default value: @code @[ @1, @1, @1, @1 ] @endcode
- */
+/// Defines strides for spatial dimensions. Must be four numbers, one for each spatial dimension, fastest running index last.
+/// Default value: `@[ @1, @1, @1, @1 ]`
@property (readwrite, nonatomic, copy) NSArray<NSNumber *> * _Nonnull strides;
-/*!
- * @property dilationRates
- * @discussion Must be four numbers, one for each spatial dimension, fastest running index last.
- * Default value: @code @[ @1, @1, @1, @1 ] @endcode
- */
+/// Defines dilation rates for spatial dimensions. Must be four numbers, one for each spatial dimension, fastest running index last.
+/// Default value: `@[ @1, @1, @1, @1 ]`
@property (readwrite, nonatomic, copy) NSArray<NSNumber *> * _Nonnull dilationRates;
-/*!
- * @property paddingValues
- * @discussion Must be eight numbers, two for each spatial dimension. `paddingValues[0]` defines the explicit padding
- * amount before the first spatial dimension (slowest running index of spatial dimensions),
- * `paddingValues[1]` defines the padding amount after the first spatial dimension etc.
- * Used only when `paddingStyle = MPSGraphPaddingStyleExplicit`.
- * Default value: @code @[ @0, @0, @0, @0, @0, @0, @0, @0 ] @endcode
- */
+/// Defines padding values for spatial dimensions. Must be eight numbers, two for each spatial dimension.
+/// For example ``paddingValues[0]`` defines the explicit padding
+/// amount before the first spatial dimension (slowest running index of spatial dimensions),
+/// ``paddingValues[1]`` defines the padding amount after the first spatial dimension etc.
+/// Used only when ``paddingStyle = MPSGraphPaddingStyleExplicit``.
+/// Default value: `@[ @0, @0, @0, @0, @0, @0, @0, @0 ]`
@property (readwrite, nonatomic, copy) NSArray<NSNumber *> * _Nonnull paddingValues;
-/*!
- * @property paddingStyle
- * @discussion Defines what kind of padding to apply to operation.
- * Default value: @code MPSGraphPaddingStyleExplicit @endcode
- */
+/// Defines what kind of padding to apply to operation.
+/// Default value: ``MPSGraphPaddingStyleExplicit``.
@property (readwrite, nonatomic) MPSGraphPaddingStyle paddingStyle;
-/*!
- * @property ceilMode
- * @discussion If set then the output size is computed by rounding up instead of down when
- * dividing by stride.
- * Default value: @code NO @endcode
- */
+/// Affects how MPSGraph computes the output size: if set to ``YES`` then output size is
+/// computed by rounding up instead of down when dividing input size by stride.
+/// Default value: ``NO``.
@property (readwrite, nonatomic) BOOL ceilMode;
-/*!
- * @property includeZeroPadToAverage
- * @discussion For average pooling use a mode where samples outside the input tensor count as
- * zeroes in the average computation. Otherwise the result is sum over samples divided by
- * number of samples that didn't come from padding.
- * Default value: @code NO @endcode
- */
+/// For average pooling use a mode where samples outside the input tensor count as
+/// zeroes in the average computation. Otherwise the result is sum over samples divided by
+/// number of samples that didn't come from padding.
+/// Default value: ``NO``.
@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
- */
+/// Use this in conjunction with ``maxPooling4DReturnIndicesWithSourceTensor`` API.
+/// If ``returnIndicesMode = MPSGraphPoolingReturnIndicesNone`` then only the first result
+/// MPSGraph returns from ``maxPooling4DReturnIndicesWithSourceTensor`` will be valid and using the
+/// second result will assert.
+/// Default value: ``MPSGraphPoolingReturnIndicesNone``.
@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
- */
+/// Use this in conjunction with ``maxPooling4DReturnIndicesWithSourceTensor`` API.
+/// Currently MPSGraph supports the following datatypes: ``MPSDataTypeInt32``.
+/// Default value: ``MPSDataTypeInt32``.
@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.
- * @param kernelSizes See corresponding property above.
- * @param strides See corresponding property above.
- * @param dilationRates See corresponding property above.
- * @param paddingValues See corresponding property above.
- * @param paddingStyle See corresponding property above.
- * @return The descriptor on autoreleasepool.
- */
+/// Creates a 4d pooling descriptor with given values.
+///
+/// - Parameters:
+/// - kernelSizes: See ``kernelSizes`` property.
+/// - strides: See ``strides`` property.
+/// - dilationRates: See ``dilationRates`` property.
+/// - paddingValues: See ``paddingValues`` property.
+/// - paddingStyle: See ``paddingStyle`` property.
+/// - Returns: The descriptor on autoreleasepool.
+(nullable instancetype) descriptorWithKernelSizes:(NSArray<NSNumber *> * _Nonnull) kernelSizes
strides:(NSArray<NSNumber *> * _Nonnull) strides
dilationRates:(NSArray<NSNumber *> * _Nonnull) dilationRates
paddingValues:(NSArray<NSNumber *> * _Nonnull) paddingValues
paddingStyle:(MPSGraphPaddingStyle) paddingStyle;
-/*!
- * @abstract Creates a 4d pooling descriptor with default values.
- * @param kernelSizes See corresponding property above.
- * @param paddingStyle See corresponding property above.
- * @return The descriptor on autoreleasepool.
- */
+/// Creates a 4d pooling descriptor with default values.
+///
+/// - Parameters:
+/// - kernelSizes: See ``kernelSizes`` property.
+/// - paddingStyle: See ``paddingStyle`` property.
+/// - Returns: The descriptor on autoreleasepool.
+(nullable instancetype) descriptorWithKernelSizes:(NSArray<NSNumber *> * _Nonnull) kernelSizes
paddingStyle:(MPSGraphPaddingStyle) paddingStyle;
@@ -238,40 +237,60 @@
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MPSGraphPoolingOps)
+/// Creates a 2d max-pooling operation and returns the result tensor.
+///
+/// - Parameters:
+/// - source: 2d Image source as tensor - must be of rank=4. The layout is defined by ``descriptor.dataLayout``.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates, paddings and layouts.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) maxPooling2DWithSourceTensor:(MPSGraphTensor *) source
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
- */
+/// Creates a 2d max-pooling operation and returns the result tensor and the corresponding indices tensor.
+///
+/// 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 = MPSGraphPoolingReturnIndicesNone`` then only the first result
+/// MPSGraph returns will be valid and using the second result will assert.
+///
+/// - Parameters:
+/// - source: 2d Image source as tensor - must be of rank=4. The layout is defined by ``descriptor.dataLayout``.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates, paddings and layouts.
+/// - name: The name for the operation.
+/// - Returns: NSArray of 2 MPSGraphTensors. The first tensor holds the result of max pool and the second tensor holds the corresponding indices
-(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));
+/// Creates a max pooling gradient operation and returns the result tensor.
+///
+/// - Parameters:
+/// - gradient: 2d input gradient tensor - must be of rank=4. The layout is defined by ``descriptor.dataLayout``.
+/// - source: Input tensor for the forward pass.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates, paddings and layouts.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) maxPooling2DGradientWithGradientTensor:(MPSGraphTensor *) gradient
sourceTensor:(MPSGraphTensor *) source
descriptor:(MPSGraphPooling2DOpDescriptor *) descriptor
name:(NSString * _Nullable) name;
-/*!
- * @abstract MaxPool2D Gradient API
- * @param gradient Input gradient tensor
- * @param indices Indices tensor returned from maxPooling2DReturnIndicesWithSourceTensor API
- * @param outputShape shape of the destination gradient
- * @param descriptor See corresponding property above.
- * @return Destination gradient tensor
- * @discussion MaxPool2D gradient is computed efficiently by reusing the indices from the forward API instead of recomputing them.
- * The descriptor must set returnIndicesMode and returnIndicesDataType to the same value as that set by the forward pass
- */
+/// Creates a max pooling gradient operation and returns the result tensor.
+///
+/// With this API MPSGraph computes the max pooling gradient efficiently by reusing the indices from the forward API instead of recomputing them.
+/// The descriptor must set ``returnIndicesMode`` and ``returnIndicesDataType`` to the same value as that set by the forward pass.
+///
+/// - Parameters:
+/// - gradient: 2d input gradient tensor - must be of rank=4. The layout is defined by ``descriptor.dataLayout``.
+/// - indices: Indices tensor returned from ``maxPooling2DReturnIndicesWithSourceTensor``.
+/// - outputShape: Shape of the destination gradient.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates, paddings and layouts.
+/// - name: The name for the operation.
+/// - Returns: Destination gradient tensor.
-(MPSGraphTensor *) maxPooling2DGradientWithGradientTensor:(MPSGraphTensor *) gradient
indicesTensor:(MPSGraphTensor *) indices
outputShape:(MPSShape*) outputShape
@@ -279,16 +298,18 @@
name:(NSString * _Nullable) name
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract MaxPool2D Gradient API
- * @param gradient Input gradient tensor
- * @param indices Indices tensor returned from maxPooling2DReturnIndicesWithSourceTensor API
- * @param outputShape shape of the destination gradient
- * @param descriptor See corresponding property above.
- * @return Destination gradient tensor
- * @discussion MaxPool2D gradient is computed efficiently by reusing the indices from the forward API instead of recomputing them.
- * The descriptor must set returnIndicesMode and returnIndicesDataType to the same value as that set by the forward pass
- */
+/// Creates a max pooling gradient operation and returns the result tensor.
+///
+/// With this API MPSGraph computes the max pooling gradient efficiently by reusing the indices from the forward API instead of recomputing them.
+/// The descriptor must set ``returnIndicesMode`` and ``returnIndicesDataType`` to the same value as that set by the forward pass.
+///
+/// - Parameters:
+/// - gradient: 2d input gradient tensor - must be of rank=4. The layout is defined by ``descriptor.dataLayout``.
+/// - indices: Indices tensor returned from ``maxPooling2DReturnIndicesWithSourceTensor``.
+/// - outputShape: Tensor containing the shape of the destination gradient.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates, paddings and layouts.
+/// - name: The name for the operation.
+/// - Returns: Destination gradient tensor.
-(MPSGraphTensor *) maxPooling2DGradientWithGradientTensor:(MPSGraphTensor *) gradient
indicesTensor:(MPSGraphTensor *) indices
outputShapeTensor:(MPSGraphTensor*) outputShape
@@ -296,37 +317,69 @@
name:(NSString * _Nullable) name
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
+/// Creates a 2d average-pooling operation and returns the result tensor.
+///
+/// - Parameters:
+/// - source: 2d Image source as tensor - must be of rank=4. The layout is defined by ``descriptor.dataLayout``.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates, paddings and layouts.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) avgPooling2DWithSourceTensor:(MPSGraphTensor *) source
descriptor:(MPSGraphPooling2DOpDescriptor *) descriptor
name:(NSString * _Nullable) name;
+/// Creates a 2d average pooling gradient operation and returns the result tensor.
+///
+/// - Parameters:
+/// - gradient: 2d input gradient tensor - must be of rank=4. The layout is defined by ``descriptor.dataLayout``.
+/// - source: Input tensor for the forward pass.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates, paddings and layouts.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) avgPooling2DGradientWithGradientTensor:(MPSGraphTensor *) gradient
sourceTensor:(MPSGraphTensor *) source
descriptor:(MPSGraphPooling2DOpDescriptor *) descriptor
name:(NSString * _Nullable) name;
-
+/// Creates a 4d max-pooling operation and returns the result tensor.
+///
+/// - Parameters:
+/// - source: Image source as tensor.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates and paddings.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) maxPooling4DWithSourceTensor:(MPSGraphTensor *) source
descriptor:(MPSGraphPooling4DOpDescriptor *) descriptor
name:(NSString * _Nullable) name
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
- */
+/// Creates a 4d max-pooling operation and returns the result tensor and the corresponding indices tensor.
+///
+/// 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 = MPSGraphPoolingReturnIndicesNone`` then only the first result
+/// MPSGraph returns will be valid and using the second result will assert.
+///
+/// - Parameters:
+/// - source: Source tensor on which pooling will be performed.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates and paddings.
+/// - name: The name for the operation.
+/// - Returns: NSArray of 2 MPSGraphTensors. The first tensor holds the result of max pool and the second tensor holds the corresponding indices.
-(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));
+/// Creates a max pooling gradient operation and returns the result tensor.
+///
+/// - Parameters:
+/// - gradient: Input gradient tensor.
+/// - source: Input tensor for the forward pass.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates and paddings.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) maxPooling4DGradientWithGradientTensor:(MPSGraphTensor *) gradient
sourceTensor:(MPSGraphTensor *) source
descriptor:(MPSGraphPooling4DOpDescriptor *) descriptor
@@ -334,17 +387,18 @@
MPS_SWIFT_NAME( maxPooling4DGradient(_:source:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0));
-/*!
- * @abstract MaxPool4D Gradient API
- * @param gradient Input gradient tensor
- * @param indices Indices tensor returned from maxPooling4DReturnIndicesWithSourceTensor API
- * @param outputShape Shape of source tensor
- * @param descriptor See corresponding property above.
- * @return Destination gradient tensor
- * @discussion MaxPool4D gradient is computed efficiently by reusing the indices from the forward API instead of recomputing them.
- * The descriptor must set returnIndicesMode and returnIndicesDataType to the same value as that set by the forward pass
- * This API should be used for NCHW and NHWC layouts
- */
+/// Creates a max pooling gradient operation and returns the result tensor.
+///
+/// With this API MPSGraph computes the max pooling gradient efficiently by reusing the indices from the forward API instead of recomputing them.
+/// The descriptor must set ``returnIndicesMode`` and ``returnIndicesDataType`` to the same value as that set by the forward pass.
+///
+/// - Parameters:
+/// - gradient: 2d input gradient tensor - must be of rank=4. The layout is defined by ``descriptor.dataLayout``.
+/// - indices: Indices tensor returned from ``maxPooling2DReturnIndicesWithSourceTensor``.
+/// - outputShape: Shape of the destination gradient.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates, paddings and layouts.
+/// - name: The name for the operation.
+/// - Returns: Destination gradient tensor.
-(MPSGraphTensor *) maxPooling4DGradientWithGradientTensor:(MPSGraphTensor *) gradient
indicesTensor:(MPSGraphTensor *) indices
outputShape:(MPSShape*) outputShape
@@ -352,17 +406,18 @@
name:(NSString * _Nullable) name
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract MaxPool4D Gradient API
- * @param gradient Input gradient tensor
- * @param indices Indices tensor returned from maxPooling4DReturnIndicesWithSourceTensor API
- * @param outputShape Shape of source tensor
- * @param descriptor See corresponding property above.
- * @return Destination gradient tensor
- * @discussion MaxPool4D gradient is computed efficiently by reusing the indices from the forward API instead of recomputing them.
- * The descriptor must set returnIndicesMode and returnIndicesDataType to the same value as that set by the forward pass
- * This API should be used for NCHW and NHWC layouts
- */
+/// Creates a max pooling gradient operation and returns the result tensor.
+///
+/// With this API MPSGraph computes the max pooling gradient efficiently by reusing the indices from the forward API instead of recomputing them.
+/// The descriptor must set ``returnIndicesMode`` and ``returnIndicesDataType`` to the same value as that set by the forward pass.
+///
+/// - Parameters:
+/// - gradient: 2d input gradient tensor - must be of rank=4. The layout is defined by ``descriptor.dataLayout``.
+/// - indices: Indices tensor returned from ``maxPooling2DReturnIndicesWithSourceTensor``.
+/// - outputShape: Tensor containing the shape of the destination gradient.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates, paddings and layouts.
+/// - name: The name for the operation.
+/// - Returns: Destination gradient tensor.
-(MPSGraphTensor *) maxPooling4DGradientWithGradientTensor:(MPSGraphTensor *) gradient
indicesTensor:(MPSGraphTensor *) indices
outputShapeTensor:(MPSGraphTensor*) outputShape
@@ -370,13 +425,27 @@
name:(NSString * _Nullable) name
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
+/// Creates a 4d average pooling operation and returns the result tensor.
+///
+/// - Parameters:
+/// - source: Image source as tensor.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates and paddings.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) avgPooling4DWithSourceTensor:(MPSGraphTensor *) source
descriptor:(MPSGraphPooling4DOpDescriptor *) descriptor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( avgPooling4D(_:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0));
-
+/// Creates an average pooling gradient operation and returns the result tensor.
+///
+/// - Parameters:
+/// - gradient: Input gradient tensor.
+/// - source: Input tensor for the forward pass.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates and paddings.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) avgPooling4DGradientWithGradientTensor:(MPSGraphTensor *) gradient
sourceTensor:(MPSGraphTensor *) source
descriptor:(MPSGraphPooling4DOpDescriptor *) descriptor
@@ -384,14 +453,27 @@
MPS_SWIFT_NAME( avgPooling4DGradient(_:source:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0));
-
+/// Creates a 4d L2-Norm pooling operation and returns the result tensor.
+///
+/// - Parameters:
+/// - source: Image source as tensor.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates and paddings.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object
-(MPSGraphTensor *) L2NormPooling4DWithSourceTensor:(MPSGraphTensor *) source
descriptor:(MPSGraphPooling4DOpDescriptor *) descriptor
name:(NSString * _Nullable) name
MPS_SWIFT_NAME( L2NormPooling4D(_:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), tvos(15.0));
-
+/// Creates a L2-Norm pooling gradient operation and returns the result tensor.
+///
+/// - Parameters:
+/// - gradient: Input gradient tensor.
+/// - source: Input tensor for the forward pass.
+/// - descriptor: Specifies pooling window sizes, strides, dilation rates and paddings.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) L2NormPooling4DGradientWithGradientTensor:(MPSGraphTensor *) gradient
sourceTensor:(MPSGraphTensor *) source
descriptor:(MPSGraphPooling4DOpDescriptor *) descriptor
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphQuantizationOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphQuantizationOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphQuantizationOps.h 2023-03-09 19:09:03
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphQuantizationOps.h 2023-05-22 01:20:38
@@ -17,19 +17,18 @@
@interface MPSGraph(MPSGraphQuantizationOps)
-/*!
- * @abstract Create Quantize op and return the result tensor
- * @discussion Convert the float `tensor` to an i8 or u8 tensor by applying a scale + bias transform:
- * result = (tensor / scale) + zeroPoint
- *
- * @param tensor Input tensor to be quantized
- * @param scale Scale scalar parameter
- * @param zeroPoint Bias scalar parameter (converted to dataType of resultTensor)
- * @param dataType Integer data type of the result tensor
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor array of datatype dataType
- */
+/// Create Quantize op and return the result tensor
+///
+/// Convert the float `tensor` to an i8 or u8 tensor by applying a scale + bias transform:
+/// result = (tensor / scale) + zeroPoint
+///
+/// - Parameters:
+/// - tensor: Input tensor to be quantized
+/// - scale: Scale scalar parameter
+/// - zeroPoint: Bias scalar parameter (converted to dataType of resultTensor)
+/// - dataType: Integer data type of the result tensor
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor array of datatype dataType
-(MPSGraphTensor*) quantizeTensor:(MPSGraphTensor*)tensor
scale:(double)scale
zeroPoint:(double)zeroPoint
@@ -38,19 +37,18 @@
MPS_AVAILABLE_STARTING(macos(13.1), ios(16.2), tvos(16.2))
MPS_SWIFT_NAME( quantize(_:scale:zeroPoint:dataType:name:) );
-/*!
- * @abstract Create Dequantize op and return the result tensor
- * @discussion Convert the i8 or u8 `tensor` to a float tensor by applying a scale + bias transform:
- * result = scale * (tensor - zeroPoint)
- *
- * @param tensor Input tensor to be dequantized
- * @param scale Scale scalar parameter
- * @param zeroPoint Bias scalar parameter (converted to dataType of tensor)
- * @param dataType Float data type of the result tensor
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor array of datatype dataType
- */
+/// Create Dequantize op and return the result tensor
+///
+/// Convert the i8 or u8 `tensor` to a float tensor by applying a scale + bias transform:
+/// result = scale(tensor - zeroPoint)
+///
+/// - Parameters:
+/// - tensor: Input tensor to be dequantized
+/// - scale: Scale scalar parameter
+/// - zeroPoint: Bias scalar parameter (converted to dataType of tensor)
+/// - dataType: Float data type of the result tensor
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor array of datatype dataType
-(MPSGraphTensor*) dequantizeTensor:(MPSGraphTensor*)tensor
scale:(double)scale
zeroPoint:(double)zeroPoint
@@ -59,20 +57,19 @@
MPS_AVAILABLE_STARTING(macos(13.1), ios(16.2), tvos(16.2))
MPS_SWIFT_NAME( dequantize(_:scale:zeroPoint:dataType:name:) );
-/*!
- * @abstract Create Quantize op and return the result tensor
- * @discussion Convert the float `tensor` to an i8 or u8 tensor by applying a scale + bias transform:
- * result = (tensor / scaleTensor) + zeroPoint
- *
- * @param tensor Input tensor to be quantized
- * @param scaleTensor Scale 1D Tensor parameter with size == tensor.shape[axis]
- * @param zeroPoint Bias scalar parameter (converted to dataType of resultTensor)
- * @param dataType Integer data type of the result tensor
- * @param axis Axis on which the scale 1D value is being broadcasted
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor array of datatype dataType
- */
+/// Create Quantize op and return the result tensor
+///
+/// Convert the float `tensor` to an i8 or u8 tensor by applying a scale + bias transform:
+/// result = (tensor / scaleTensor) + zeroPoint
+///
+/// - Parameters:
+/// - tensor: Input tensor to be quantized
+/// - scaleTensor: Scale 1D Tensor parameter with size == tensor.shape[axis]
+/// - zeroPoint: Bias scalar parameter (converted to dataType of resultTensor)
+/// - dataType: Integer data type of the result tensor
+/// - axis: Axis on which the scale 1D value is being broadcasted
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor array of datatype dataType
-(MPSGraphTensor*) quantizeTensor:(MPSGraphTensor*)tensor
scaleTensor:(MPSGraphTensor*)scaleTensor
zeroPoint:(double)zeroPoint
@@ -82,20 +79,19 @@
MPS_AVAILABLE_STARTING(macos(13.1), ios(16.2), tvos(16.2))
MPS_SWIFT_NAME( quantize(_:scaleTensor:zeroPoint:dataType:axis:name:) );
-/*!
- * @abstract Create Dequantize op and return the result tensor
- * @discussion Convert the i8 or u8 `tensor` to a float tensor by applying a scale + bias transform:
- * result = scaleTensor * (tensor - zeroPoint)
- *
- * @param tensor Input tensor to be dequantized
- * @param scaleTensor Scale scalar or 1D Tensor parameter with size == tensor.shape[axis]
- * @param zeroPoint Bias scalar parameter (converted to dataType of tensor)
- * @param dataType Float data type of the result tensor
- * @param axis Axis on which the scale 1D value is being broadcasted
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor array of datatype dataType
- */
+/// Create Dequantize op and return the result tensor
+///
+/// Convert the i8 or u8 `tensor` to a float tensor by applying a scale + bias transform:
+/// result = scaleTensor(tensor - zeroPoint)
+///
+/// - Parameters:
+/// - tensor: Input tensor to be dequantized
+/// - scaleTensor: Scale scalar or 1D Tensor parameter with size == tensor.shape[axis]
+/// - zeroPoint: Bias scalar parameter (converted to dataType of tensor)
+/// - dataType: Float data type of the result tensor
+/// - axis: Axis on which the scale 1D value is being broadcasted
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor array of datatype dataType
-(MPSGraphTensor*) dequantizeTensor:(MPSGraphTensor*)tensor
scaleTensor:(MPSGraphTensor*)scaleTensor
zeroPoint:(double)zeroPoint
@@ -105,20 +101,19 @@
MPS_AVAILABLE_STARTING(macos(13.1), ios(16.2), tvos(16.2))
MPS_SWIFT_NAME( dequantize(_:scaleTensor:zeroPoint:dataType:axis:name:) );
-/*!
- * @abstract Create Quantize op and return the result tensor
- * @discussion Convert the float `tensor` to an i8 or u8 tensor by applying a scale + bias transform:
- * result = (tensor / scaleTensor) + zeroPointTensor
- *
- * @param tensor Input tensor to be quantized
- * @param scaleTensor Scale scalar or 1D Tensor parameter with size == tensor.shape[axis]
- * @param zeroPointTensor Bias scalar or 1D Tensor parameter with size == tensor.shape[axis]
- * @param dataType Integer data type of the result tensor
- * @param axis Axis on which the scale 1D value is being broadcasted
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor array of datatype dataType
- */
+/// Create Quantize op and return the result tensor
+///
+/// Convert the float `tensor` to an i8 or u8 tensor by applying a scale + bias transform:
+/// result = (tensor / scaleTensor) + zeroPointTensor
+///
+/// - Parameters:
+/// - tensor: Input tensor to be quantized
+/// - scaleTensor: Scale scalar or 1D Tensor parameter with size == tensor.shape[axis]
+/// - zeroPointTensor: Bias scalar or 1D Tensor parameter with size == tensor.shape[axis]
+/// - dataType: Integer data type of the result tensor
+/// - axis: Axis on which the scale 1D value is being broadcasted
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor array of datatype dataType
-(MPSGraphTensor*) quantizeTensor:(MPSGraphTensor*)tensor
scaleTensor:(MPSGraphTensor*)scaleTensor
zeroPointTensor:(MPSGraphTensor*)zeroPointTensor
@@ -128,20 +123,19 @@
MPS_AVAILABLE_STARTING(macos(13.1), ios(16.2), tvos(16.2))
MPS_SWIFT_NAME( quantize(_:scaleTensor:zeroPointTensor:dataType:axis:name:) );
-/*!
- * @abstract Create Dequantize op and return the result tensor
- * @discussion Convert the i8 or u8 `tensor` to a float tensor by applying a scale + bias transform:
- * result = scaleTensor * (tensor - zeroPointTensor)
- *
- * @param tensor Input tensor to be dequantized
- * @param scaleTensor Scale scalar or 1D Tensor parameter with size == tensor.shape[axis]
- * @param zeroPointTensor Bias scalar or 1D Tensor parameter with size == tensor.shape[axis]
- * @param dataType Float data type of the result tensor
- * @param axis Axis on which the scale 1D value is being broadcasted
- * @param name The name for the operation
- *
- * @return A valid MPSGraphTensor array of datatype dataType
- */
+/// Create Dequantize op and return the result tensor
+///
+/// Convert the i8 or u8 `tensor` to a float tensor by applying a scale + bias transform:
+/// result = scaleTensor(tensor - zeroPointTensor)
+///
+/// - Parameters:
+/// - tensor: Input tensor to be dequantized
+/// - scaleTensor: Scale scalar or 1D Tensor parameter with size == tensor.shape[axis]
+/// - zeroPointTensor: Bias scalar or 1D Tensor parameter with size == tensor.shape[axis]
+/// - dataType: Float data type of the result tensor
+/// - axis: Axis on which the scale 1D value is being broadcasted
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor array of datatype dataType
-(MPSGraphTensor*) dequantizeTensor:(MPSGraphTensor*)tensor
scaleTensor:(MPSGraphTensor*)scaleTensor
zeroPointTensor:(MPSGraphTensor*)zeroPointTensor
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphRNNOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphRNNOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphRNNOps.h 2023-03-09 23:53:23
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphRNNOps.h 2023-05-22 01:17:40
@@ -14,207 +14,145 @@
NS_ASSUME_NONNULL_BEGIN
-/*!
- * @typedef MPSGraphRNNActivation
- * @abstract Activation mode for RNN ops.
- */
+/// Activation modes for RNN ops.
typedef NS_ENUM(NSUInteger, MPSGraphRNNActivation)
{
+ /// Pass through activation.
MPSGraphRNNActivationNone MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4)) MPS_SWIFT_NAME(none) = 0L,
+ /// ReLU activation.
MPSGraphRNNActivationRelu MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4)),
+ /// Tanh activation.
MPSGraphRNNActivationTanh MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4)),
+ /// Sigmoid activation.
MPSGraphRNNActivationSigmoid MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4)),
+ /// Hard sigmoid activation.
MPSGraphRNNActivationHardSigmoid MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4)),
};
-
+/// Defines a single gate (vanilla) RNN operation.
MPS_CLASS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4))
-@interface MPSGraphSingleGateRNNDescriptor : NSObject<NSCopying>
+@interface MPSGraphSingleGateRNNDescriptor : MPSGraphObject<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
- */
+/// If set then the input sequence is passed in reverse time order to the layer.
+/// Note: Ignored when ``bidirectional = YES``.
+/// Default value: ``NO``.
@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
- */
+/// If set then the input sequence is traversed in both directions and the two results
+/// are concatenated together on the channel-axis.
+/// Default value: ``NO``.
@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
- */
+/// If set then the layer will produce training state tensor as a secondary output.
+/// Default value: ``NO``.
@property (readwrite, nonatomic) BOOL training;
-/*!
- * @property activation
- * @discussion Activation function to use with the RNN op.
- * Default value: @code MPSGraphRNNActivationRelu @endcode
- */
+/// Activation function to use with the RNN op.
+/// Default value: ``MPSGraphRNNActivationRelu``.
@property (readwrite, nonatomic) MPSGraphRNNActivation activation;
+/// Creates a single gate RNN descriptor with default values.
+(nullable instancetype) descriptor;
@end
+/// Defines a Long Short Term Memory (LSTM) operation.
MPS_CLASS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4))
-@interface MPSGraphLSTMDescriptor : NSObject<NSCopying>
+@interface MPSGraphLSTMDescriptor : MPSGraphObject<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
- */
+/// If set then the input sequence is passed in reverse time order to the layer.
+/// Note: Ignored when ``bidirectional = YES``.
+/// Default value: ``NO``.
@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
- */
+/// If set then the input sequence is traversed in both directions and the two results
+/// are concatenated together on the channel-axis.
+/// Default value: ``NO``.
@property (readwrite, nonatomic) BOOL bidirectional;
-/*!
- * @property produceCell
- * @discussion If set then this layer will produce the internal cell of the LSTM unit as secondary output.
- * Default value: @code NO @endcode
- */
+/// If set then this layer will produce the internal cell of the LSTM unit as secondary output.
+/// Default value: ``NO``.
@property (readwrite, nonatomic) BOOL produceCell;
-/*!
- * @property training
- * @discussion If set then the layer will produce training state tensor as a secondary or third output.
- * Default value: @code NO @endcode
- */
+/// If set then the layer will produce training state tensor as a secondary or third output.
+/// Default value: ``NO``
@property (readwrite, nonatomic) BOOL training;
-/*!
- * @property forgetGateLast
- * @discussion If set then the layer will use the gate-ordering `[ i, z, f, o ]` instead of default `[ i, f, z, o ]`.
- * Default value: @code NO @endcode
- */
+/// If set then the layer will use the gate-ordering `[ i, z, f, o ]` instead of default `[ i, f, z, o ]`.
+/// Default value: ``NO``
@property (readwrite, nonatomic) BOOL forgetGateLast;
-/*!
- * @property inputGateActivation
- * @discussion Activation function to use with the input gate of the LSTM op.
- * Default value: @code MPSGraphRNNActivationSigmoid @endcode
- */
+/// Activation function to use with the input gate of the LSTM op.
+/// Default value: ``MPSGraphRNNActivationSigmoid``.
@property (readwrite, nonatomic) MPSGraphRNNActivation inputGateActivation;
-/*!
- * @property forgetGateActivation
- * @discussion Activation function to use with the forget gate of the LSTM op.
- * Default value: @code MPSGraphRNNActivationSigmoid @endcode
- */
+/// Activation function to use with the forget gate of the LSTM op.
+/// Default value: ``MPSGraphRNNActivationSigmoid``.
@property (readwrite, nonatomic) MPSGraphRNNActivation forgetGateActivation;
-/*!
- * @property cellGateActivation
- * @discussion Activation function to use with the cell gate of the LSTM op.
- * Default value: @code MPSGraphRNNActivationTanh @endcode
- */
+/// Activation function to use with the cell gate of the LSTM op.
+/// Default value: ``MPSGraphRNNActivationTanh``.
@property (readwrite, nonatomic) MPSGraphRNNActivation cellGateActivation;
-/*!
- * @property outputGateActivation
- * @discussion Activation function to use with the output gate of the LSTM op.
- * Default value: @code MPSGraphRNNActivationSigmoid @endcode
- */
+/// Activation function to use with the output gate of the LSTM op.
+/// Default value: ``MPSGraphRNNActivationSigmoid``.
@property (readwrite, nonatomic) MPSGraphRNNActivation outputGateActivation;
-/*!
- * @property activation
- * @discussion Activation function to use with the current cell value of the LSTM op.
- * Default value: @code MPSGraphRNNActivationTanh @endcode
- */
+/// Activation function to use with the current cell value of the LSTM op.
+/// Default value: ``MPSGraphRNNActivationTanh``.
@property (readwrite, nonatomic) MPSGraphRNNActivation activation;
+/// Creates an LSTM descriptor with default values.
+(nullable instancetype) descriptor;
@end
+/// Defines a Gated Recurrent Unit (GRU) operation.
MPS_CLASS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0))
-@interface MPSGraphGRUDescriptor : NSObject<NSCopying>
+@interface MPSGraphGRUDescriptor : MPSGraphObject<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
- */
+/// If set then the input sequence is passed in reverse time order to the layer.
+/// Note: Ignored when ``bidirectional = YES``.
+/// Default value: ``NO``.
@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
- */
+/// If set then the input sequence is traversed in both directions and the two results
+/// are concatenated together on the channel-axis.
+/// Default value: ``NO``.
@property (readwrite, nonatomic) BOOL bidirectional;
-/*!
- * @property training
- * @discussion If set then the layer will produce training state tensor as a secondary or third output.
- * Default value: @code NO @endcode
- */
+/// If set then the layer will produce training state tensor as a secondary or third output.
+/// Default value: ``NO``.
@property (readwrite, nonatomic) BOOL training;
-/*!
- * @property resetGateFirst
- * @discussion If set then the layer will use the gate-ordering `[ r, z, o ]` instead of default `[ z, r, o ]`.
- * Default value: @code NO @endcode
- */
+/// If set then the layer will use the gate-ordering `[ r, z, o ]` instead of default `[ z, r, o ]`.
+/// Default value: ``NO``.
@property (readwrite, nonatomic) BOOL resetGateFirst;
-/*!
- * @property resetAfter
- * @discussion If set then the layer will compute the intermediate value as `c[t] = ( b + (h[t-1] m ) R^T) r[t]`.
- * Otherwise it's computed as `c[t] = (h[t-1] r[t] m) R^T`.
- * Default value: @code NO @endcode
- */
+/// If set then the layer will compute the intermediate value as `c[t] = ( b + (h[t-1] m ) R^T) r[t]`.
+/// Otherwise it's computed as `c[t] = (h[t-1] r[t] m) R^T`.
+/// Default value: ``NO``.
@property (readwrite, nonatomic) BOOL resetAfter;
-/*!
- * @property flipZ
- * @discussion If set then the layer will compute the final value as `h[t] = z[t] h[t-1] + (1-z[t]) o[t]`.
- * Otherwise it's computed as `h[t] = (1-z[t]) h[t-1] + z[t] o[t]`.
- * Default value: @code NO @endcode
- */
+/// If set then the layer will compute the final value as `h[t] = z[t] h[t-1] + (1-z[t]) o[t]`.
+/// Otherwise it's computed as `h[t] = (1-z[t]) h[t-1] + z[t] o[t]`.
+/// Default value: ``NO``.
@property (readwrite, nonatomic) BOOL flipZ;
-/*!
- * @property updateGateActivation
- * @discussion Activation function to use with the z-gate of the GRU op.
- * Default value: @code MPSGraphRNNActivationSigmoid @endcode
- */
+/// Activation function to use with the z-gate of the GRU op.
+/// Default value: ``MPSGraphRNNActivationSigmoid``.
@property (readwrite, nonatomic) MPSGraphRNNActivation updateGateActivation;
-/*!
- * @property resetGateActivation
- * @discussion Activation function to use with the r-gate of the GRU op.
- * Default value: @code MPSGraphRNNActivationSigmoid @endcode
- */
+/// Activation function to use with the r-gate of the GRU op.
+/// Default value: ``MPSGraphRNNActivationSigmoid``.
@property (readwrite, nonatomic) MPSGraphRNNActivation resetGateActivation;
-/*!
- * @property outputGateActivation
- * @discussion Activation function to use with the o-gate of the LSTM op.
- * Default value: @code MPSGraphRNNActivationTanh @endcode
- */
+/// Activation function to use with the o-gate of the LSTM op.
+/// Default value: ``MPSGraphRNNActivationTanh``.
@property (readwrite, nonatomic) MPSGraphRNNActivation outputGateActivation;
+/// Creates an GRU descriptor with default values.
+(nullable instancetype) descriptor;
@end
@@ -222,37 +160,29 @@
MPS_CLASS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4))
@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.
- */
-
+/// Creates a single-gate RNN operation and returns the value and optionally training state tensor.
+///
+/// This operation returns tensors `h` and optionally `z` that are defined recursively as follows:
+/// ```md
+/// 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
+/// ```
+/// `W` is optional ``inputWeight``, `R` is ``recurrentWeight``, `b` is ``bias``, `m` is optional ``mask``,
+/// `x[t]` is ``source`` `h[t]` is the first output, `z[t]` is the second output (optional) and `h[-1]` is ``initState``.
+/// See ``MPSGraphSingleGateRNNDescriptor`` for different `activation` options.
+///
+/// - Parameters:
+/// - 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].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,H,H] and otherwise it is [H,H].
+/// - 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].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [2H] and otherwise it is [H].
+/// - 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].
+/// - mask: Tensor containing the mask `m` - optional, if missing assumes ones. Useful for dropout.
+/// - descriptor: The RNN op definition.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor array of size 1 or 2, depending on value of ``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
@@ -264,6 +194,27 @@
MPS_SWIFT_NAME( singleGateRNN(_:recurrentWeight:inputWeight:bias:initState:mask:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
+/// Creates a single-gate RNN operation and returns the value and optionally training state tensor.
+///
+/// This operation returns tensors `h` and optionally `z` that are defined recursively as follows:
+/// ```md
+/// 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
+/// ```
+/// `W` is optional ``inputWeight``, `R` is ``recurrentWeight``, `b` is ``bias``, `m` is optional ``mask``,
+/// `x[t]` is ``source`` `h[t]` is the first output, `z[t]` is the second output (optional) and `h[-1]` is ``initState``.
+/// See ``MPSGraphSingleGateRNNDescriptor`` for different `activation` options.
+///
+/// - Parameters:
+/// - 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].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,H,H] and otherwise it is [H,H].
+/// - 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].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [2H] and otherwise it is [H].
+/// - 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].
+/// - descriptor: The RNN op definition.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor array of size 1 or 2, depending on value of ``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
@@ -274,6 +225,25 @@
MPS_SWIFT_NAME( singleGateRNN(_:recurrentWeight:inputWeight:bias:initState:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
+/// Creates a single-gate RNN operation and returns the value and optionally training state tensor.
+///
+/// This operation returns tensors `h` and optionally `z` that are defined recursively as follows:
+/// ```md
+/// 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
+/// ```
+/// `W` is optional ``inputWeight``, `R` is ``recurrentWeight``, `b` is ``bias``, `m` is optional ``mask``,
+/// `x[t]` is ``source`` `h[t]` is the first output, `z[t]` is the second output (optional) and `h[-1]` is ``initState``.
+/// See ``MPSGraphSingleGateRNNDescriptor`` for different `activation` options.
+///
+/// - Parameters:
+/// - 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].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,H,H] and otherwise it is [H,H].
+/// - 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].
+/// - descriptor: The RNN op definition.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor array of size 1 or 2, depending on value of ``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
initState:(MPSGraphTensor * _Nullable) initState
@@ -282,33 +252,23 @@
MPS_SWIFT_NAME( singleGateRNN(_:recurrentWeight:initState:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
-/*!
- * @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.
- */
-
+/// Creates a single-gate RNN gradient operation and returns the gradient tensor values.
+///
+/// - Parameters:
+/// - 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].
+/// - 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.
+/// - sourceGradient: Input gradient, that is gradient of a tensor wrt. to first output of the forward pass.
+/// - zState: The second output of ``singleGateRNNWithSourceTensor`` with ``descriptor.training = true``.
+/// - stateGradient: Input gradient coming from the future timestep - optional, if missing assumes zeroes.
+/// - 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].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [2H] and otherwise it is [H].
+/// - 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].
+/// - mask: Tensor containing the mask `m` - optional, if missing assumes ones. Useful for dropout.
+/// - descriptor: The RNN op definition.
+/// - name: The name for the operation.
+/// - Returns: 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
@@ -323,6 +283,22 @@
MPS_SWIFT_NAME( singleGateRNNGradients(_:recurrentWeight:sourceGradient:zState:stateGradient:inputWeight:bias:initState:mask:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
+/// Creates a single-gate RNN gradient operation and returns the gradient tensor values.
+///
+/// - Parameters:
+/// - 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].
+/// - 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.
+/// - sourceGradient: Input gradient, that is gradient of a tensor wrt. to first output of the forward pass.
+/// - zState: The second output of ``singleGateRNNWithSourceTensor`` with ``descriptor.training = true``.
+/// - 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].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [2H] and otherwise it is [H].
+/// - 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].
+/// - mask: Tensor containing the mask `m` - optional, if missing assumes ones. Useful for dropout.
+/// - descriptor: The RNN op definition.
+/// - name: The name for the operation.
+/// - Returns: 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
@@ -336,6 +312,21 @@
MPS_SWIFT_NAME( singleGateRNNGradients(_:recurrentWeight:sourceGradient:zState:inputWeight:bias:initState:mask:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
+/// Creates a single-gate RNN gradient operation and returns the gradient tensor values.
+///
+/// - Parameters:
+/// - 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].
+/// - 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.
+/// - sourceGradient: Input gradient, that is gradient of a tensor wrt. to first output of the forward pass.
+/// - zState: The second output of ``singleGateRNNWithSourceTensor`` with ``descriptor.training = true``.
+/// - 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].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [2H] and otherwise it is [H].
+/// - 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].
+/// - descriptor: The RNN op definition.
+/// - name: The name for the operation.
+/// - Returns: 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
@@ -348,6 +339,21 @@
MPS_SWIFT_NAME( singleGateRNNGradients(_:recurrentWeight:sourceGradient:zState:inputWeight:bias:initState:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
+/// Creates a single-gate RNN gradient operation and returns the gradient tensor values.
+///
+/// - Parameters:
+/// - 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].
+/// - 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.
+/// - sourceGradient: Input gradient, that is gradient of a tensor wrt. to first output of the forward pass.
+/// - zState: The second output of ``singleGateRNNWithSourceTensor`` with ``descriptor.training = true``.
+/// - 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].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [2H] and otherwise it is [H].
+/// - 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].
+/// - descriptor: The RNN op definition.
+/// - name: The name for the operation.
+/// - Returns: 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
@@ -358,46 +364,35 @@
MPS_SWIFT_NAME( singleGateRNNGradients(_:recurrentWeight:sourceGradient:zState:initState:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
-/*!
- * @abstract Create a LSTM op and return the value and optionally the cell state and optionally the training state tensor.
- * @discussion This operation returns tensors `h` and optionally `c` and optionally `z` that are defined recursively as follows:
- * @code
- * for t = 0 to T-1
- * z[t] = [i, f, z, o][t] = f( (h[t-1] m) R^T + x'[t] + p*c[t-1] )`
- * x'[t] = x[t] W^T + b
- * c[t] = f[t] * c[t-1] + i[t] * z[t]
- * h[t] = o[t] * g(c[t]), where
- * @endcode
- * `W` is optional @ref inputWeight, `R` is @ref recurrentWeight, `b` is optional @ref bias, `m` is optional @mask,
- * `x[t]` is @ref source `h[t]` is the first output, `c[t]` is the second output (optional),
- * `z[t]` is either the second or third output (optional), `h[-1]` is @ref initCell. and `h[-1]` is @ref initState.
- * `p` is an optional peephole vector.
- * See @ref MPSGraphLSTMDescriptor for different `activation` options for `f()` and `g()`.
- *
- * @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,4H]
- * and for `inputWeight = nil` and `bidirectional = YES` the layout is [T,N,8H].
- * @param recurrentWeight Tensor containing the recurrent weights `R`.
- * For `bidirectional` the layout is [2,4H,H] and otherwise it is [4H,H].
- * @param inputWeight Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix.
- * For `bidirectional` the layout is [8H,I] and otherwise it is [4H,I].
- * @param bias Tensor containing the bias `b` - optional, if missing assumes zeroes.
- * For `bidirectional` the layout is [8H] and otherwise it is [4H].
- * @param initState Initial internal state of the LSTM `h[-1]` - optional, if missing assumes zeroes.
- * For `bidirectional` the layout is [N,2H] and otherwise it is [N,H].
- * @param initCell Initial internal cell of the LSTM `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 peephole Tensor containing the peephole vector `v` - optional, if missing assumes zeroes.
- * Shape is [4H], ie. a vector for each gate, or [2,4H] for bidirectional.
- * @param descriptor The LSTM op definition.
- * @param name The name for the operation.
- *
- * @return A valid MPSGraphTensor array of size 1 or 2 or 3, depending on value of @ref `descriptor.produceCell` and @ref `descriptor.training`.
- * The layout of the both state and cell outputs are [T,N,H] or [T,N,2H] for bidirectional,
- * and the layout of the trainingState output is [T,N,4H] or [T,N,8H] for bidirectional,.
- */
-
+/// Creates an LSTM operation and returns the value tensor and optionally the cell state tensor and optionally the training state tensor.
+///
+/// This operation returns tensors `h` and optionally `c` and optionally `z` that are defined recursively as follows:
+/// ```md
+/// for t = 0 to T-1
+/// z[t] = [i, f, z, o][t] = f( (h[t-1] m) R^T + x'[t] + p c[t-1] )
+/// x'[t] = x[t] W^T + b
+/// c[t] = f[t]c[t-1] + i[t]z[t]
+/// h[t] = o[t]g(c[t]), where
+/// ```
+/// `W` is optional ``inputWeight``, `R` is ``recurrentWeight``, `b` is optional ``bias``, `m` is optional ``mask``,
+/// `x[t]` is ``source`` `h[t]` is the first output, `c[t]` is the second output (optional),
+/// `z[t]` is either the second or third output (optional), `h[-1]` is ``initCell``. and `h[-1]` is ``initState``.
+/// `p` is an optional peephole vector.
+/// See ``MPSGraphLSTMDescriptor`` for different ``activation`` options for `f()` and `g()`.
+///
+/// - Parameters:
+/// - 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,4H] and for ``inputWeight = nil`` and ``bidirectional = YES`` the layout is [T,N,8H].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,4H,H] and otherwise it is [4H,H].
+/// - inputWeight: Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix. For ``bidirectional`` the layout is [8H,I] and otherwise it is [4H,I].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [8H] and otherwise it is [4H].
+/// - initState: Initial internal state of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - initCell: Initial internal cell of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - mask: Tensor containing the mask `m` - optional, if missing assumes ones. Useful for dropout.
+/// - peephole: Tensor containing the peephole vector `v` - optional, if missing assumes zeroes. Shape is [4H], ie. a vector for each gate, or [2,4H] for bidirectional.
+/// - descriptor: The LSTM op definition.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor array of size 1 or 2 or 3, depending on values of ``descriptor.produceCell`` and ``descriptor.training``.
+/// The layout of the both state and cell outputs are [T,N,H] or [T,N,2H] for bidirectional, and the layout of the trainingState output is [T,N,4H] or [T,N,8H] for bidirectional.
-(NSArray<MPSGraphTensor *> *) LSTMWithSourceTensor:(MPSGraphTensor *) source
recurrentWeight:(MPSGraphTensor *) recurrentWeight
inputWeight:(MPSGraphTensor * _Nullable) inputWeight
@@ -411,6 +406,33 @@
MPS_SWIFT_NAME( LSTM(_:recurrentWeight:inputWeight:bias:initState:initCell:mask:peephole:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
+/// Creates an LSTM operation and returns the value tensor and optionally the cell state tensor and optionally the training state tensor.
+///
+/// This operation returns tensors `h` and optionally `c` and optionally `z` that are defined recursively as follows:
+/// ```md
+/// for t = 0 to T-1
+/// z[t] = [i, f, z, o][t] = f( (h[t-1] m) R^T + x'[t] + p c[t-1] )
+/// x'[t] = x[t] W^T + b
+/// c[t] = f[t]c[t-1] + i[t]z[t]
+/// h[t] = o[t]g(c[t]), where
+/// ```
+/// `W` is optional ``inputWeight``, `R` is ``recurrentWeight``, `b` is optional ``bias``, `m` is optional ``mask``,
+/// `x[t]` is ``source`` `h[t]` is the first output, `c[t]` is the second output (optional),
+/// `z[t]` is either the second or third output (optional), `h[-1]` is ``initCell``. and `h[-1]` is ``initState``.
+/// `p` is an optional peephole vector.
+/// See ``MPSGraphLSTMDescriptor`` for different ``activation`` options for `f()` and `g()`.
+///
+/// - Parameters:
+/// - 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,4H] and for ``inputWeight = nil`` and ``bidirectional = YES`` the layout is [T,N,8H].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,4H,H] and otherwise it is [4H,H].
+/// - inputWeight: Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix. For ``bidirectional`` the layout is [8H,I] and otherwise it is [4H,I].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [8H] and otherwise it is [4H].
+/// - initState: Initial internal state of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - initCell: Initial internal cell of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - descriptor: The LSTM op definition.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor array of size 1 or 2 or 3, depending on values of ``descriptor.produceCell`` and ``descriptor.training``.
+/// The layout of the both state and cell outputs are [T,N,H] or [T,N,2H] for bidirectional, and the layout of the trainingState output is [T,N,4H] or [T,N,8H] for bidirectional.
-(NSArray<MPSGraphTensor *> *) LSTMWithSourceTensor:(MPSGraphTensor *) source
recurrentWeight:(MPSGraphTensor *) recurrentWeight
inputWeight:(MPSGraphTensor * _Nullable) inputWeight
@@ -422,6 +444,31 @@
MPS_SWIFT_NAME( LSTM(_:recurrentWeight:inputWeight:bias:initState:initCell:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
+/// Creates an LSTM operation and returns the value tensor and optionally the cell state tensor and optionally the training state tensor.
+///
+/// This operation returns tensors `h` and optionally `c` and optionally `z` that are defined recursively as follows:
+/// ```md
+/// for t = 0 to T-1
+/// z[t] = [i, f, z, o][t] = f( (h[t-1] m) R^T + x'[t] + p c[t-1] )
+/// x'[t] = x[t] W^T + b
+/// c[t] = f[t]c[t-1] + i[t]z[t]
+/// h[t] = o[t]g(c[t]), where
+/// ```
+/// `W` is optional ``inputWeight``, `R` is ``recurrentWeight``, `b` is optional ``bias``, `m` is optional ``mask``,
+/// `x[t]` is ``source`` `h[t]` is the first output, `c[t]` is the second output (optional),
+/// `z[t]` is either the second or third output (optional), `h[-1]` is ``initCell``. and `h[-1]` is ``initState``.
+/// `p` is an optional peephole vector.
+/// See ``MPSGraphLSTMDescriptor`` for different ``activation`` options for `f()` and `g()`.
+///
+/// - Parameters:
+/// - 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,4H] and for ``inputWeight = nil`` and ``bidirectional = YES`` the layout is [T,N,8H].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,4H,H] and otherwise it is [4H,H].
+/// - initState: Initial internal state of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - initCell: Initial internal cell of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - descriptor: The LSTM op definition.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor array of size 1 or 2 or 3, depending on values of ``descriptor.produceCell`` and ``descriptor.training``.
+/// The layout of the both state and cell outputs are [T,N,H] or [T,N,2H] for bidirectional, and the layout of the trainingState output is [T,N,4H] or [T,N,8H] for bidirectional.
-(NSArray<MPSGraphTensor *> *) LSTMWithSourceTensor:(MPSGraphTensor *) source
recurrentWeight:(MPSGraphTensor *) recurrentWeight
initState:(MPSGraphTensor * _Nullable) initState
@@ -431,37 +478,27 @@
MPS_SWIFT_NAME( LSTM(_:recurrentWeight:initState:initCell:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
-/*!
- * @abstract Create a LSTM 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,4H]
- * and for `inputWeight = nil` and `bidirectional = YES` the layout is [T,N,8H].
- * @param recurrentWeight Tensor containing the recurrent weights `R`.
- * For `bidirectional` the layout is [2,4H,H] and otherwise it is [4H,H].
- * @param sourceGradient Input gradient, that is gradient of a tensor wrt. to first output of the forward pass.
- * @param zState The third output of `LSTMWithSourceTensor` with @ref `descriptor.training = true`.
- * @param cellOutputFwd The second output of `LSTMWithSourceTensor` with @ref `descriptor.training = true` or `descriptor.produceCell = true`.
- * @param stateGradient Input gradient for state coming from the future timestep - optional, if missing assumes zeroes.
- * @param cellGradient Input gradient for cell 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 [8H,I] and otherwise it is [4H,I].
- * @param bias Tensor containing the bias `b` - optional, if missing assumes zeroes.
- * For `bidirectional` the layout is [8H] and otherwise it is [4H].
- * @param initState Initial internal state of the LSTM `h[-1]` - optional, if missing assumes zeroes.
- * For `bidirectional` the layout is [N,2H] and otherwise it is [N,H].
- * @param initCell Initial internal cell of the LSTM `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 peephole Tensor containing the peephole vector `v` - optional, if missing assumes zeroes. Shape is [8H], ie. a vector for each gate.
- * @param descriptor The LSTM 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 peephole, for initState, for initCell.
- */
-
+/// Creates an LSTM gradient operation and returns the gradient tensor values.
+///
+/// - Parameters:
+/// - 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,4H] and for ``inputWeight = nil`` and ``bidirectional = YES`` the layout is [T,N,8H].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,4H,H] and otherwise it is [4H,H].
+/// - sourceGradient: Input gradient, that is gradient of a tensor wrt. to first output of the forward pass.
+/// - zState: The third output of ``LSTMWithSourceTensor`` with ``descriptor.training = true``.
+/// - cellOutputFwd: The second output of ``LSTMWithSourceTensor`` with ``descriptor.training = true`` or ``descriptor.produceCell = true``.
+/// - stateGradient: Input gradient for state coming from the future timestep - optional, if missing assumes zeroes.
+/// - cellGradient: Input gradient for cell coming from the future timestep - optional, if missing assumes zeroes.
+/// - inputWeight: Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix. For ``bidirectional`` the layout is [8H,I] and otherwise it is [4H,I].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [8H] and otherwise it is [4H].
+/// - initState: Initial internal state of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - initCell: Initial internal cell of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - mask: Tensor containing the mask `m` - optional, if missing assumes ones. Useful for dropout.
+/// - peephole: Tensor containing the peephole vector `v` - optional, if missing assumes zeroes. Shape is [8H], ie. a vector for each gate.
+/// - descriptor: The LSTM op definition.
+/// - name: The name for the operation.
+/// - Returns: 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 peephole, for initState and for initCell.
-(NSArray<MPSGraphTensor *> *) LSTMGradientsWithSourceTensor:(MPSGraphTensor *) source
recurrentWeight:(MPSGraphTensor *) recurrentWeight
sourceGradient:(MPSGraphTensor *) sourceGradient
@@ -480,6 +517,24 @@
MPS_SWIFT_NAME( LSTMGradients(_:recurrentWeight:sourceGradient:zState:cellOutputFwd:stateGradient:cellGradient:inputWeight:bias:initState:initCell:mask:peephole:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
+/// Creates an LSTM gradient operation and returns the gradient tensor values.
+///
+/// - Parameters:
+/// - 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,4H] and for ``inputWeight = nil`` and ``bidirectional = YES`` the layout is [T,N,8H].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,4H,H] and otherwise it is [4H,H].
+/// - sourceGradient: Input gradient, that is gradient of a tensor wrt. to first output of the forward pass.
+/// - zState: The third output of ``LSTMWithSourceTensor`` with ``descriptor.training = true``.
+/// - cellOutputFwd: The second output of ``LSTMWithSourceTensor`` with ``descriptor.training = true`` or ``descriptor.produceCell = true``.
+/// - inputWeight: Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix. For ``bidirectional`` the layout is [8H,I] and otherwise it is [4H,I].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [8H] and otherwise it is [4H].
+/// - initState: Initial internal state of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - initCell: Initial internal cell of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - mask: Tensor containing the mask `m` - optional, if missing assumes ones. Useful for dropout.
+/// - descriptor: The LSTM op definition.
+/// - name: The name for the operation.
+/// - Returns: 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 and for initCell.
-(NSArray<MPSGraphTensor *> *) LSTMGradientsWithSourceTensor:(MPSGraphTensor *) source
recurrentWeight:(MPSGraphTensor *) recurrentWeight
sourceGradient:(MPSGraphTensor *) sourceGradient
@@ -495,6 +550,23 @@
MPS_SWIFT_NAME( LSTMGradients(_:recurrentWeight:sourceGradient:zState:cellOutputFwd:inputWeight:bias:initState:initCell:mask:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
+/// Creates an LSTM gradient operation and returns the gradient tensor values.
+///
+/// - Parameters:
+/// - 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,4H] and for ``inputWeight = nil`` and ``bidirectional = YES`` the layout is [T,N,8H].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,4H,H] and otherwise it is [4H,H].
+/// - sourceGradient: Input gradient, that is gradient of a tensor wrt. to first output of the forward pass.
+/// - zState: The third output of ``LSTMWithSourceTensor`` with ``descriptor.training = true``.
+/// - cellOutputFwd: The second output of ``LSTMWithSourceTensor`` with ``descriptor.training = true`` or ``descriptor.produceCell = true``.
+/// - inputWeight: Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix. For ``bidirectional`` the layout is [8H,I] and otherwise it is [4H,I].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [8H] and otherwise it is [4H].
+/// - initState: Initial internal state of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - initCell: Initial internal cell of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - descriptor: The LSTM op definition.
+/// - name: The name for the operation.
+/// - Returns: 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 and for initCell.
-(NSArray<MPSGraphTensor *> *) LSTMGradientsWithSourceTensor:(MPSGraphTensor *) source
recurrentWeight:(MPSGraphTensor *) recurrentWeight
sourceGradient:(MPSGraphTensor *) sourceGradient
@@ -509,6 +581,23 @@
MPS_SWIFT_NAME( LSTMGradients(_:recurrentWeight:sourceGradient:zState:cellOutputFwd:inputWeight:bias:initState:initCell:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
+/// Creates an LSTM gradient operation and returns the gradient tensor values.
+///
+/// - Parameters:
+/// - 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,4H] and for ``inputWeight = nil`` and ``bidirectional = YES`` the layout is [T,N,8H].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,4H,H] and otherwise it is [4H,H].
+/// - sourceGradient: Input gradient, that is gradient of a tensor wrt. to first output of the forward pass.
+/// - zState: The third output of ``LSTMWithSourceTensor`` with ``descriptor.training = true``.
+/// - cellOutputFwd: The second output of ``LSTMWithSourceTensor`` with ``descriptor.training = true`` or ``descriptor.produceCell = true``.
+/// - inputWeight: Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix. For ``bidirectional`` the layout is [8H,I] and otherwise it is [4H,I].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [8H] and otherwise it is [4H].
+/// - initState: Initial internal state of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - initCell: Initial internal cell of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - descriptor: The LSTM op definition.
+/// - name: The name for the operation.
+/// - Returns: 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 and for initCell.
-(NSArray<MPSGraphTensor *> *) LSTMGradientsWithSourceTensor:(MPSGraphTensor *) source
recurrentWeight:(MPSGraphTensor *) recurrentWeight
sourceGradient:(MPSGraphTensor *) sourceGradient
@@ -519,53 +608,43 @@
MPS_SWIFT_NAME( LSTMGradients(_:recurrentWeight:sourceGradient:zState:cellOutputFwd:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4));
-/*!
- * @abstract Create a GRU op and return the value and optionally the 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] = fz( (h[t-1] m) R^T + x[t] W^T + b ),
- * r[t] = fr( (h[t-1] m) R^T + x[t] W^T + b ),
- * c[t] = (h[t-1] r[t] m) R^T
- * o[t] = fo( c[t] + x[t] W^T + b )
- * h[t] = z[t]h[t-1] + (1-z[t])o[t]
- * @endcode
- * If `resetAfter = YES` then `c[t]` is replaced by
- * @code
- * c[t] = ( (h[t-1] m) R^T + b2 ) r[t]
- * @endcode
- * If `flipZ = YES` then `h[t]` is replaced by
- * @code
- * h[t] = (1-z[t])h[t-1] + z[t]o[t].
- * @endcode
- * `W` is optional @ref inputWeight, `R` is @ref recurrentWeight, `b` is optional @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.
- * `b2` is an optional `resetBias` vector, only used when `resetAfter = YES`.
- * See @ref MPSGraphGRUDescriptor for different `activation` options for `f()`.
- *
- * @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,3H]
- * and for `inputWeight = nil` and `bidirectional = YES` the layout is [T,N,6H].
- * @param recurrentWeight Tensor containing the recurrent weights `R`.
- * For `bidirectional` the layout is [2,3H,H] and otherwise it is [3H,H].
- * @param inputWeight Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix.
- * For `bidirectional` the layout is [6H,I] and otherwise it is [3H,I].
- * @param bias Tensor containing the bias `b` - optional, if missing assumes zeroes.
- * For `bidirectional` the layout is [6H] and otherwise it is [3H].
- * @param initState Initial internal state of the LSTM `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 secondaryBias Tensor containing the secondary bias vector `b2` - optional, if missing assumes zeroes.
- * Only used with `reset_after = YES`.
- * Shape is [H], ie. a vector for each gate, or [2H] for bidirectional.
- * @param descriptor The GRU 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 state output is [T,N,H] or [T,N,2H] for bidirectional,
- * and the layout of the trainingState output is [T,N,3H] or [T,N,6H] for bidirectional,.
- */
-
+/// Creates a GRU operation and return the value and optionally the training state tensor.
+///
+/// This operation returns tensors `h` and optionally `z` that are defined recursively as follows:
+/// ```md
+/// for t = 0 to T-1
+/// z[t] = fz( (h[t-1] m) R^T + x[t] W^T + b ),
+/// r[t] = fr( (h[t-1] m) R^T + x[t] W^T + b ),
+/// c[t] = (h[t-1] r[t] m) R^T
+/// o[t] = fo( c[t] + x[t] W^T + b )
+/// h[t] = z[t]h[t-1] + (1-z[t])o[t]
+/// ```
+/// If ``resetAfter = YES`` then `c[t]` is replaced by
+/// ```md
+/// c[t] = ( (h[t-1] m) R^T + b2 ) r[t]
+/// ```
+/// If ``flipZ = YES`` then `h[t]` is replaced by
+/// ```md
+/// h[t] = (1-z[t])h[t-1] + z[t]o[t].
+/// ```
+/// `W` is optional ``inputWeight``, `R` is ``recurrentWeight``, `b` is optional ``bias``, `m` is optional ``mask``,
+/// `x[t]` is ``source`` `h[t]` is the first output, `z[t]` is the second output (optional) and `h[-1]` is ``initState``.
+/// `b2` is an optional ``resetBias`` vector, only used when ``resetAfter = YES``.
+/// See ``MPSGraphGRUDescriptor`` for different `activation` options for `f()`.
+///
+/// - Parameters:
+/// - 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,3H] and for ``inputWeight = nil`` and ``bidirectional = YES`` the layout is [T,N,6H].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,3H,H] and otherwise it is [3H,H].
+/// - inputWeight: Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix. For ``bidirectional`` the layout is [6H,I] and otherwise it is [3H,I].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [6H] and otherwise it is [3H].
+/// - initState: Initial internal state of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - mask: Tensor containing the mask `m` - optional, if missing assumes ones. Useful for dropout.
+/// - secondaryBias: Tensor containing the secondary bias vector `b2` - optional, if missing assumes zeroes. Only used with ``reset_after = YES``. Shape is [H], ie. a vector for each gate, or [2H] for bidirectional.
+/// - descriptor: The GRU op definition.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor array of size 1 or 2 depending on value of ``descriptor.training``.
+/// The layout of the state output is [T,N,H] or [T,N,2H] for bidirectional,
+/// and the layout of the trainingState output is [T,N,3H] or [T,N,6H] for bidirectional.
-(NSArray<MPSGraphTensor *> *) GRUWithSourceTensor:(MPSGraphTensor *) source
recurrentWeight:(MPSGraphTensor *) recurrentWeight
inputWeight:(MPSGraphTensor * _Nullable) inputWeight
@@ -578,6 +657,41 @@
MPS_SWIFT_NAME( GRU(_:recurrentWeight:inputWeight:bias:initState:mask:secondaryBias:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
+/// Creates a GRU operation and return the value and optionally the training state tensor.
+///
+/// This operation returns tensors `h` and optionally `z` that are defined recursively as follows:
+/// ```md
+/// for t = 0 to T-1
+/// z[t] = fz( (h[t-1] m) R^T + x[t] W^T + b ),
+/// r[t] = fr( (h[t-1] m) R^T + x[t] W^T + b ),
+/// c[t] = (h[t-1] r[t] m) R^T
+/// o[t] = fo( c[t] + x[t] W^T + b )
+/// h[t] = z[t]h[t-1] + (1-z[t])o[t]
+/// ```
+/// If ``resetAfter = YES`` then `c[t]` is replaced by
+/// ```md
+/// c[t] = ( (h[t-1] m) R^T + b2 ) r[t]
+/// ```
+/// If ``flipZ = YES`` then `h[t]` is replaced by
+/// ```md
+/// h[t] = (1-z[t])h[t-1] + z[t]o[t].
+/// ```
+/// `W` is optional ``inputWeight``, `R` is ``recurrentWeight``, `b` is optional ``bias``, `m` is optional ``mask``,
+/// `x[t]` is ``source`` `h[t]` is the first output, `z[t]` is the second output (optional) and `h[-1]` is ``initState``.
+/// `b2` is an optional ``resetBias`` vector, only used when ``resetAfter = YES``.
+/// See ``MPSGraphGRUDescriptor`` for different `activation` options for `f()`.
+///
+/// - Parameters:
+/// - 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,3H] and for ``inputWeight = nil`` and ``bidirectional = YES`` the layout is [T,N,6H].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,3H,H] and otherwise it is [3H,H].
+/// - inputWeight: Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix. For ``bidirectional`` the layout is [6H,I] and otherwise it is [3H,I].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [6H] and otherwise it is [3H].
+/// - initState: Initial internal state of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - descriptor: The GRU op definition.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor array of size 1 or 2 depending on value of ``descriptor.training``.
+/// The layout of the state output is [T,N,H] or [T,N,2H] for bidirectional,
+/// and the layout of the trainingState output is [T,N,3H] or [T,N,6H] for bidirectional.
-(NSArray<MPSGraphTensor *> *) GRUWithSourceTensor:(MPSGraphTensor *) source
recurrentWeight:(MPSGraphTensor *) recurrentWeight
inputWeight:(MPSGraphTensor * _Nullable) inputWeight
@@ -588,6 +702,40 @@
MPS_SWIFT_NAME( GRU(_:recurrentWeight:inputWeight:bias:initState:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
+/// Creates a GRU operation and return the value and optionally the training state tensor.
+///
+/// This operation returns tensors `h` and optionally `z` that are defined recursively as follows:
+/// ```md
+/// for t = 0 to T-1
+/// z[t] = fz( (h[t-1] m) R^T + x[t] W^T + b ),
+/// r[t] = fr( (h[t-1] m) R^T + x[t] W^T + b ),
+/// c[t] = (h[t-1] r[t] m) R^T
+/// o[t] = fo( c[t] + x[t] W^T + b )
+/// h[t] = z[t]h[t-1] + (1-z[t])o[t]
+/// ```
+/// If ``resetAfter = YES`` then `c[t]` is replaced by
+/// ```md
+/// c[t] = ( (h[t-1] m) R^T + b2 ) r[t]
+/// ```
+/// If ``flipZ = YES`` then `h[t]` is replaced by
+/// ```md
+/// h[t] = (1-z[t])h[t-1] + z[t]o[t].
+/// ```
+/// `W` is optional ``inputWeight``, `R` is ``recurrentWeight``, `b` is optional ``bias``, `m` is optional ``mask``,
+/// `x[t]` is ``source`` `h[t]` is the first output, `z[t]` is the second output (optional) and `h[-1]` is ``initState``.
+/// `b2` is an optional ``resetBias`` vector, only used when ``resetAfter = YES``.
+/// See ``MPSGraphGRUDescriptor`` for different `activation` options for `f()`.
+///
+/// - Parameters:
+/// - 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,3H] and for ``inputWeight = nil`` and ``bidirectional = YES`` the layout is [T,N,6H].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,3H,H] and otherwise it is [3H,H].
+/// - inputWeight: Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix. For ``bidirectional`` the layout is [6H,I] and otherwise it is [3H,I].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [6H] and otherwise it is [3H].
+/// - descriptor: The GRU op definition.
+/// - name: The name for the operation.
+/// - Returns: A valid MPSGraphTensor array of size 1 or 2 depending on value of ``descriptor.training``.
+/// The layout of the state output is [T,N,H] or [T,N,2H] for bidirectional,
+/// and the layout of the trainingState output is [T,N,3H] or [T,N,6H] for bidirectional.
-(NSArray<MPSGraphTensor *> *) GRUWithSourceTensor:(MPSGraphTensor *) source
recurrentWeight:(MPSGraphTensor *) recurrentWeight
inputWeight:(MPSGraphTensor * _Nullable) inputWeight
@@ -597,36 +745,25 @@
MPS_SWIFT_NAME( GRU(_:recurrentWeight:inputWeight:bias:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
-/*!
- * @abstract Create a GRU 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,3H]
- * and for `inputWeight = nil` and `bidirectional = YES` the layout is [T,N,6H].
- * @param recurrentWeight Tensor containing the recurrent weights `R`.
- * For `bidirectional` the layout is [2,3H,H] and otherwise it is [3H,H].
- * @param sourceGradient Input gradient, that is gradient of a tensor wrt. to first output of the forward pass.
- * @param zState The second output of `GRUWithSourceTensor` with @ref `descriptor.training = true`.
- * @param outputFwd The first output of `GRUWithSourceTensor` with @ref `descriptor.training = true`.
- * @param stateGradient Input gradient for state 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 [6H,I] and otherwise it is [3H,I].
- * @param bias Tensor containing the bias `b` - optional, if missing assumes zeroes.
- * For `bidirectional` the layout is [6H] and otherwise it is [3H].
- * @param initState Initial internal state of the LSTM `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 secondaryBias Tensor containing the secondary bias vector `b2` - optional, if missing assumes zeroes.
- * Only used with `reset_after = YES`.
- * Shape is [H], ie. a vector for each gate, or [2H] for bidirectional.
- * @param descriptor The GRU 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, for secondaryBias.
- */
-
+/// Creates a GRU gradient operation and returns the gradient tensor values.
+///
+/// - Parameters:
+/// - 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,3H] and for ``inputWeight = nil`` and ``bidirectional = YES`` the layout is [T,N,6H].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,3H,H] and otherwise it is [3H,H].
+/// - sourceGradient: Input gradient, that is gradient of a tensor wrt. to first output of the forward pass.
+/// - zState: The second output of ``GRUWithSourceTensor`` with ``descriptor.training = true``.
+/// - outputFwd: The first output of ``GRUWithSourceTensor`` with ``descriptor.training = true``.
+/// - stateGradient: Input gradient for state coming from the future timestep - optional, if missing assumes zeroes.
+/// - inputWeight: Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix. For ``bidirectional`` the layout is [6H,I] and otherwise it is [3H,I].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [6H] and otherwise it is [3H].
+/// - initState: Initial internal state of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - mask: Tensor containing the mask `m` - optional, if missing assumes ones. Useful for dropout.
+/// - secondaryBias: Tensor containing the secondary bias vector `b2` - optional, if missing assumes zeroes. Only used with ``reset_after = YES``. Shape is [H], ie. a vector for each gate, or [2H] for bidirectional.
+/// - descriptor: The GRU op definition.
+/// - name: The name for the operation.
+/// - Returns: 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, for secondaryBias.
-(NSArray<MPSGraphTensor *> *) GRUGradientsWithSourceTensor:(MPSGraphTensor *) source
recurrentWeight:(MPSGraphTensor *) recurrentWeight
sourceGradient:(MPSGraphTensor *) sourceGradient
@@ -643,6 +780,22 @@
MPS_SWIFT_NAME( GRUGradients(_:recurrentWeight:sourceGradient:zState:outputFwd:stateGradient:inputWeight:bias:initState:mask:secondaryBias:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
+/// Creates a GRU gradient operation and returns the gradient tensor values.
+///
+/// - Parameters:
+/// - 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,3H] and for ``inputWeight = nil`` and ``bidirectional = YES`` the layout is [T,N,6H].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,3H,H] and otherwise it is [3H,H].
+/// - sourceGradient: Input gradient, that is gradient of a tensor wrt. to first output of the forward pass.
+/// - zState: The second output of ``GRUWithSourceTensor`` with ``descriptor.training = true``.
+/// - outputFwd: The first output of ``GRUWithSourceTensor`` with ``descriptor.training = true``.
+/// - inputWeight: Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix. For ``bidirectional`` the layout is [6H,I] and otherwise it is [3H,I].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [6H] and otherwise it is [3H].
+/// - initState: Initial internal state of the LSTM `h[-1]` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [N,2H] and otherwise it is [N,H].
+/// - descriptor: The GRU op definition.
+/// - name: The name for the operation.
+/// - Returns: 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 *> *) GRUGradientsWithSourceTensor:(MPSGraphTensor *) source
recurrentWeight:(MPSGraphTensor *) recurrentWeight
sourceGradient:(MPSGraphTensor *) sourceGradient
@@ -656,6 +809,21 @@
MPS_SWIFT_NAME( GRUGradients(_:recurrentWeight:sourceGradient:zState:outputFwd:inputWeight:bias:initState:descriptor:name:))
MPS_AVAILABLE_STARTING(macos(13.0), ios(16.0), tvos(16.0));
+/// Creates a GRU gradient operation and returns the gradient tensor values.
+///
+/// - Parameters:
+/// - 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,3H] and for ``inputWeight = nil`` and ``bidirectional = YES`` the layout is [T,N,6H].
+/// - recurrentWeight: Tensor containing the recurrent weights `R`. For ``bidirectional`` the layout is [2,3H,H] and otherwise it is [3H,H].
+/// - sourceGradient: Input gradient, that is gradient of a tensor wrt. to first output of the forward pass.
+/// - zState: The second output of ``GRUWithSourceTensor`` with ``descriptor.training = true``.
+/// - outputFwd: The first output of ``GRUWithSourceTensor`` with ``descriptor.training = true``.
+/// - inputWeight: Tensor containing the input weights matrix `W` - optional, if missing assumes diagonal unit-matrix. For ``bidirectional`` the layout is [6H,I] and otherwise it is [3H,I].
+/// - bias: Tensor containing the bias `b` - optional, if missing assumes zeroes. For ``bidirectional`` the layout is [6H] and otherwise it is [3H].
+/// - descriptor: The GRU op definition.
+/// - name: The name for the operation.
+/// - Returns: 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.
-(NSArray<MPSGraphTensor *> *) GRUGradientsWithSourceTensor:(MPSGraphTensor *) source
recurrentWeight:(MPSGraphTensor *) recurrentWeight
sourceGradient:(MPSGraphTensor *) sourceGradient
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphRandomOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphRandomOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphRandomOps.h 2023-03-09 23:53:22
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphRandomOps.h 2023-05-19 20:58:42
@@ -13,93 +13,76 @@
NS_ASSUME_NONNULL_BEGIN
-/*!
- * @typedef MPSGraphRandomDistribution
- * @abstract The distributions supported by MPSGraphRandom ops.
- *
- * @constant MPSGraphRandomDistributionUniform The uniform distribution, with samples drawn uniformly from [min, max) for float types, and [min, max] for integer types.
- * @constant MPSGraphRandomDistributionNormal The normal distribution defined by mean and standardDeviation.
- * @constant MPSGraphRandomDistributionTruncatedNormal The normal distribution defined by mean and standardDeviation, truncated to the range [min, max)
- */
+/// The distributions supported by MPSGraphRandom ops.
typedef NS_ENUM(uint64_t, MPSGraphRandomDistribution)
{
+ /// The uniform distribution, with samples drawn uniformly from [min, max) for float types, and [min, max] for integer types.
MPSGraphRandomDistributionUniform MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4)) MPS_SWIFT_NAME(uniform) = 0,
+ /// The normal distribution defined by mean and standardDeviation.
MPSGraphRandomDistributionNormal MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4)) = 1L,
+ /// The normal distribution defined by mean and standardDeviation, truncated to the range [min, max)
MPSGraphRandomDistributionTruncatedNormal MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4)) = 2L,
};
-/*!
- * @typedef MPSGraphRandomNormalSamplingMethod
- * @abstract Specify what sampling method to use when generating values in the normal distribution.
- *
- * @constant MPSGraphRandomNormalSamplingInvCDF Use inverse erf to convert uniform values to values in the normal distribution
- * @constant MPSGraphRandomNormalSamplingBoxMuller Use Box Muller transform to convert uniform values to values in the normal distribution. For bounded distributions this is a rejection sampling method.
- */
+/// Specify what sampling method to use when generating values in the normal distribution.
typedef NS_ENUM(uint64_t, MPSGraphRandomNormalSamplingMethod)
{
+ /// Use inverse erf to convert uniform values to values in the normal distribution
MPSGraphRandomNormalSamplingInvCDF MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4)) MPS_SWIFT_NAME(invCDF) = 0,
+ /// Use Box Muller transform to convert uniform values to values in the normal distribution. For bounded distributions this is a rejection sampling method.
MPSGraphRandomNormalSamplingBoxMuller MPS_ENUM_AVAILABLE_STARTING(macos(12.3), ios(15.4), tvos(15.4)) = 1L,
};
-@interface MPSGraphRandomOpDescriptor : NSObject<NSCopying>
+@interface MPSGraphRandomOpDescriptor : MPSGraphObject<NSCopying>
-/*! @property distribution
- * @discussion The type of distribution to draw samples from. See MPSGraphRandomDistribution.
-*/
+/// The type of distribution to draw samples from. See MPSGraphRandomDistribution.
+///
@property (readwrite, nonatomic) MPSGraphRandomDistribution distribution;
-/*! @property dataType
- * @discussion The data type of the generated result values.
- * When sampling from the uniform distribution, valid types are MPSDataTypeFloat16,
- * MPSDataTypeFloat32, and MPSDataTypeInt32.
- * When sampling from the normal or truncated normal distribution, valid types are
- * MPSDataTypeFloat16 and MPSDataTypeFloat32.
-*/
+/// The data type of the generated result values.
+/// When sampling from the uniform distribution, valid types are MPSDataTypeFloat16,
+/// MPSDataTypeFloat32, and MPSDataTypeInt32.
+/// When sampling from the normal or truncated normal distribution, valid types are
+/// MPSDataTypeFloat16 and MPSDataTypeFloat32.
+///
@property (readwrite, nonatomic) MPSDataType dataType;
-/*! @property min
- * @discussion The lower range of the distribution. This value is used for Uniform distributions with float data types and Truncated Normal disributions.
- * Defaults to 0 for uniform distributions and -2 for normal distributions.
-*/
+/// The lower range of the distribution. This value is used for Uniform distributions with float data types and Truncated Normal disributions.
+/// Defaults to 0 for uniform distributions and -2 for normal distributions.
+///
@property (readwrite, nonatomic) float min;
-/*! @property max
- * @discussion The upper range of the distribution. This value is used for Uniform distributions with float data types and Truncated Normal disributions.
- * Defaults to 1 for uniform distributions and 2 for normal distributions.
-*/
+/// The upper range of the distribution. This value is used for Uniform distributions with float data types and Truncated Normal disributions.
+/// Defaults to 1 for uniform distributions and 2 for normal distributions.
+///
@property (readwrite, nonatomic) float max;
-/*! @property minInteger
- * @discussion The lower range of the distribution. This value is used for Uniform with integer data types
- * Defaults to 0.
-*/
+/// The lower range of the distribution. This value is used for Uniform with integer data types
+/// Defaults to 0.
+///
@property (readwrite, nonatomic) NSInteger minInteger;
-/*! @property maxInteger
- * @discussion The upper range of the distribution. This value is used for Uniform with integer data types
- * Defaults to INT32_MAX for uniform distributions and 0 for normal distributions.
-*/
+/// The upper range of the distribution. This value is used for Uniform with integer data types
+/// Defaults to INT32_MAX for uniform distributions and 0 for normal distributions.
+///
@property (readwrite, nonatomic) NSInteger maxInteger;
-/*! @property mean
- * @discussion The mean of the distribution. This value is used for Normal and Truncated Normal disributions.
- * Defaults to 0.
-*/
+/// The mean of the distribution. This value is used for Normal and Truncated Normal disributions.
+/// Defaults to 0.
+///
@property (readwrite, nonatomic) float mean;
-/*! @property standardDeviation
- * @discussion The standardDeviation of the distribution. This value is used for Normal and Truncated Normal disributions.
- * For Truncated Normal distribution this defines the standard deviation parameter of the underlying Normal distribution, that is the width
- * of the Gaussian, not the true standard deviation of the truncated distribution which typically differs from the standard deviation of the
- * original Normal distribution.
- * Defaults to 0 for uniform distributions and 1 for normal distributions.
-*/
+/// The standardDeviation of the distribution. This value is used for Normal and Truncated Normal disributions.
+/// For Truncated Normal distribution this defines the standard deviation parameter of the underlying Normal distribution, that is the width
+/// of the Gaussian, not the true standard deviation of the truncated distribution which typically differs from the standard deviation of the
+/// original Normal distribution.
+/// Defaults to 0 for uniform distributions and 1 for normal distributions.
+///
@property (readwrite, nonatomic) float standardDeviation;
-/*! @property samplingMethod
- * @discussion The sampling method of the distribution. This value is used for Normal and Truncated Normal disributions. See MPSGraphRandomNormalSamplingMethod.
- * Defaults to MPSGraphRandomNormalSamplingInvCDF.
-*/
+/// The sampling method of the distribution. This value is used for Normal and Truncated Normal disributions. See MPSGraphRandomNormalSamplingMethod.
+/// Defaults to MPSGraphRandomNormalSamplingInvCDF.
+///
@property (readwrite, nonatomic) MPSGraphRandomNormalSamplingMethod samplingMethod;
+(nullable instancetype) descriptorWithDistribution:(MPSGraphRandomDistribution) distribution
@@ -110,191 +93,261 @@
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MPSGraphRandomOps)
-/*!
- * @abstract Creates an MPSGraphTensor representing state using the Philox algorithm with given counter and key values.
- * @discussion Generates random numbers using the Philox counter-based algorithm, for further details see:
- * John K. Salmon, Mark A. Moraes, Ron O. Dror, and David E. Shaw. Parallel Random Numbers: As Easy as 1, 2, 3.
- *
- * A stateTensor generated with this API can be used in MPSGraph Random APIs which accept a stateTensor. The
- * updated stateTensor is returned alongside the random values, and can be fed to the following random layer. In
- * most use cases, a stateTensor should only need to be initialized once at the start of the graph. A stateTensor can
- * be set as a target tensor of an MPSGraph execution to obtain a stateTensor serialized as an NDArray. This can be
- * used as input to a placeholder in the graph to avoid ever needing to have a state intilization layer in an MPSGraph.
- * This can allow for a continued stream through multiple executions of a single MPSGraph by having the final
- * stateTensor as a target tensor passed into the following MPSGraph execution as a placeholder input. This may be
- * helpful for training graphs in particular.
- *
- * @code
- * MPSGraph *graph = [MPSGraph new];
- * MPSGraphTensor *stateTensor = [graph randomPhiloxStateTensorWithSeed: seed name: nil];
- * NSArray<MPSGraphTensor*> *resultTensors0 = [graph randomUniformTensorWithShape:@[@10, @10]
- * stateTensor:stateTensor
- * name:nil];
- * NSArray<MPSGraphTensor*> *resultTensors1 = [graph randomUniformTensorWithShape:@[@10, @10]
- * stateTensor:resultTensors0[1]
- * name:nil];
- *
- * @endcode
- *
- * @param seed Initial counter and key values will be generated using seed.
- *
- * @return An MPSGraphTensor representing a random state, to be passed as an input to a random op.
- */
--(MPSGraphTensor *) randomPhiloxStateTensorWithSeed:(NSUInteger) seed
- name:(NSString * _Nullable) name;
-
-/*!
- * @abstract Creates an MPSGraphTensor representing state using the Philox algorithm with given counter and key values.
- * @discussion See randomPhiloxStateTensorWithSeed.
- *
- * @param counterLow The value to initilaize lower 64 bits of counter to. Philox utilizes a 128 bit counter
- * @param counterHigh The value to initilaize upper 64 bits of counter to. Philox utilizes a 128 bit counter
- * @param key The value to initialize the key to in Philox algorithm.
- *
- * @return An MPSGraphTensor representing a random state, to be passed as an input to a random op.
- */
--(MPSGraphTensor *) randomPhiloxStateTensorWithCounterLow:(NSUInteger) counterLow
- counterHigh:(NSUInteger) counterHigh
- key:(NSUInteger) key
- name:(NSString * _Nullable) name;
-
-/*!
- * @abstract Create Random op of type matching distribution in descriptor and return random values
- * @discussion Returns a tensor of provided shape of random values in the distribution specified. A random seed value is used
- * to initalize state. No state is preserved, and subsequent calls are not guaranteed to result in a unique stream of
- * random values.
- *
- * @param shape The shape of the tensor generated
- * @param descriptor The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
- * @param name The name for the operation
- *
- * @return An MPSGraphTensor of shape containing random values in the defined range.
- */
--(MPSGraphTensor *) randomTensorWithShape:(MPSShape *) shape
- descriptor:(MPSGraphRandomOpDescriptor *) descriptor
- name:(NSString * _Nullable) name;
--(MPSGraphTensor *) randomTensorWithShapeTensor:(MPSGraphTensor *) shapeTensor
- descriptor:(MPSGraphRandomOpDescriptor *) descriptor
- name:(NSString * _Nullable) name;
-
-/*!
- * @abstract Create Random op of type matching distribution in descriptor and return random values
- * @discussion Returns a tensor of provided shape of random values in the distribution specified. The provided seed value is
- * used to initalize state. No state is preserved, and all calls with equal seed yield an identical stream of random values.
- *
- * @param shape The shape of the tensor generated
- * @param descriptor The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
- * @param seed The seed to use to initialize state. All calls with equal seed yield an identical stream of random values.
- * @param name The name for the operation
- *
- * @return An MPSGraphTensor of shape containing random values in the defined range.
- */
--(MPSGraphTensor *) randomTensorWithShape:(MPSShape *) shape
- descriptor:(MPSGraphRandomOpDescriptor *) descriptor
- seed:(NSUInteger) seed
- name:(NSString * _Nullable) name;
--(MPSGraphTensor *) randomTensorWithShapeTensor:(MPSGraphTensor *) shapeTensor
- descriptor:(MPSGraphRandomOpDescriptor *) descriptor
- seed:(NSUInteger) seed
- name:(NSString * _Nullable) name;
-
-/*!
- * @abstract Create Random op of type matching distribution in descriptor, and return random values and updated state
- * @discussion Returns an array of 2 tensors, where the first is of provided shape of random values in the distribution specified.
- * The updated state tensor is returned as the second result tensor.
- *
- * The provided state is used to define a stream of random values. No state is preserved, and all calls with equal state
- * yield an identical stream of random values. The initial stateTensor provided should be created using the MPSGraph
- * randomPhiloxStateTensor APIs. The resulting stateTensor from this op can be passed as an argument to the following
- * random calls to continue sampling from the stream.
- *
- * @param shape The shape of the tensor generated
- * @param descriptor The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
- * @param state The state to define a stream of random values. All calls with equal state yield an identical stream of random values.
- * @param name The name for the operation
- *
- * @return An array of MPSGraphTensor of size 2. The first MPSGraphTensor is of shape containing random values in the defined range.
- * The second MPSGraphTensor is the updated state tensor.
- */
--(NSArray<MPSGraphTensor *> *) randomTensorWithShape:(MPSShape *) shape
- descriptor:(MPSGraphRandomOpDescriptor *) descriptor
- stateTensor:(MPSGraphTensor *) state
+/// Creates an MPSGraphTensor representing state using the Philox algorithm with given counter and key values.
+///
+/// Generates random numbers using the Philox counter-based algorithm, for further details see:
+/// John K. Salmon, Mark A. Moraes, Ron O. Dror, and David E. Shaw. Parallel Random Numbers: As Easy as 1, 2, 3.
+/// A stateTensor generated with this API can be used in MPSGraph Random APIs which accept a stateTensor. The
+/// updated stateTensor is returned alongside the random values, and can be fed to the following random layer. In
+/// most use cases, a stateTensor should only need to be initialized once at the start of the graph. A stateTensor can
+/// be set as a target tensor of an MPSGraph execution to obtain a stateTensor serialized as an NDArray. This can be
+/// used as input to a placeholder in the graph to avoid ever needing to have a state intilization layer in an MPSGraph.
+/// This can allow for a continued stream through multiple executions of a single MPSGraph by having the final
+/// stateTensor as a target tensor passed into the following MPSGraph execution as a placeholder input. This may be
+/// helpful for training graphs in particular.
+/// ```md
+/// MPSGraph *graph = [MPSGraph new];
+/// MPSGraphTensor *stateTensor = [graph randomPhiloxStateTensorWithSeed: seed name: nil];
+/// NSArray<MPSGraphTensor*> *resultTensors0 = [graph randomUniformTensorWithShape:
+///
+/// - Parameters:
+/// - seed: Initial counter and key values will be generated using seed.
+/// - name: Name for the operation
+/// - Returns: An MPSGraphTensor representing a random state, to be passed as an input to a random op.
+- (MPSGraphTensor *) randomPhiloxStateTensorWithSeed:(NSUInteger) seed
name:(NSString * _Nullable) name;
--(NSArray<MPSGraphTensor *> *) randomTensorWithShapeTensor:(MPSGraphTensor *) shapeTensor
- descriptor:(MPSGraphRandomOpDescriptor *) descriptor
- stateTensor:(MPSGraphTensor *) state
+
+/// Creates an MPSGraphTensor representing state using the Philox algorithm with given counter and key values.
+///
+/// See randomPhiloxStateTensorWithSeed.
+///
+/// - Parameters:
+/// - counterLow: The value to initilaize lower 64 bits of counter to. Philox utilizes a 128 bit counter
+/// - counterHigh: The value to initilaize upper 64 bits of counter to. Philox utilizes a 128 bit counter
+/// - key: The value to initialize the key to in Philox algorithm.
+/// - name: Name for the operation
+/// - Returns: An MPSGraphTensor representing a random state, to be passed as an input to a random op.
+- (MPSGraphTensor *) randomPhiloxStateTensorWithCounterLow:(NSUInteger) counterLow
+ counterHigh:(NSUInteger) counterHigh
+ key:(NSUInteger) key
name:(NSString * _Nullable) name;
-/*!
- * @abstract Create RandomUniform op and return random uniform values
- * @discussion Returns a tensor of provided shape of random uniform values in the range [0.0, 1.0). A random seed value is used
- * to initalize state. No state is preserved, and subsequent calls are not guaranteed to result in a unique stream of
- * random values.
- *
- * @param shape The shape of the tensor generated
- * @param name The name for the operation
- *
- * @return An MPSGraphTensor of shape containing random values in the defined range.
- */
--(MPSGraphTensor *) randomUniformTensorWithShape:(MPSShape *) shape
+/// Create Random op of type matching distribution in descriptor and return random values
+///
+/// Returns a tensor of provided shape of random values in the distribution specified. Uses a random seed value
+/// to initalize state. No state is preserved, and subsequent calls are not guaranteed to result in a unique stream of
+/// random values.
+///
+/// - Parameters:
+/// - shape: The shape of the tensor generated
+/// - descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
+/// - name: The name for the operation
+/// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
+- (MPSGraphTensor *) randomTensorWithShape:(MPSShape *) shape
+ descriptor:(MPSGraphRandomOpDescriptor *) descriptor
+ name:(NSString * _Nullable) name;
+/// Create Random op of type matching distribution in descriptor and return random values
+///
+/// Returns a tensor of provided shape of random values in the distribution specified. Uses a random seed value
+/// to initalize state. No state is preserved, and subsequent calls are not guaranteed to result in a unique stream of
+/// random values.
+///
+/// - Parameters:
+/// - shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
+/// - descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
+/// - name: The name for the operation
+/// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
+- (MPSGraphTensor *) randomTensorWithShapeTensor:(MPSGraphTensor *) shapeTensor
+ descriptor:(MPSGraphRandomOpDescriptor *) descriptor
name:(NSString * _Nullable) name;
--(MPSGraphTensor *) randomUniformTensorWithShapeTensor:(MPSGraphTensor *) shapeTensor
- name:(NSString * _Nullable) name;
-
-/*!
- * @abstract Create RandomUniform op and return random uniform values
- * @discussion Returns a tensor of provided shape of random uniform values in the range [0.0, 1.0). The provided seed value is
- * used to initalize state. No state is preserved, and all calls with equal seed yield an identical stream of random values.
- *
- * @param shape The shape of the tensor generated
- * @param seed The seed to use to initialize state. All calls with equal seed yield an identical stream of random values.
- * @param name The name for the operation
- *
- * @return An MPSGraphTensor of shape containing random values in the defined range.
- */
--(MPSGraphTensor *) randomUniformTensorWithShape:(MPSShape *) shape
+/// Create Random op of type matching distribution in descriptor and return random values
+///
+/// Returns a tensor of provided shape of random values in the distribution specified. Uses the provided seed value
+/// to initalize state. No state is preserved, and all calls with equal seed yield an identical stream of random values.
+///
+/// - Parameters:
+/// - shape: The shape of the tensor generated
+/// - descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
+/// - seed: The seed to use to initialize state. All calls with equal seed yield an identical stream of random values.
+/// - name: The name for the operation
+/// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
+- (MPSGraphTensor *) randomTensorWithShape:(MPSShape *) shape
+ descriptor:(MPSGraphRandomOpDescriptor *) descriptor
+ seed:(NSUInteger) seed
+ name:(NSString * _Nullable) name;
+/// Create Random op of type matching distribution in descriptor and return random values
+///
+/// Returns a tensor of provided shape of random values in the distribution specified. Uses the provided seed value
+/// to initalize state. No state is preserved, and all calls with equal seed yield an identical stream of random values.
+///
+/// - Parameters:
+/// - shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
+/// - descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
+/// - seed: The seed to use to initialize state. All calls with equal seed yield an identical stream of random values.
+/// - name: The name for the operation
+/// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
+- (MPSGraphTensor *) randomTensorWithShapeTensor:(MPSGraphTensor *) shapeTensor
+ descriptor:(MPSGraphRandomOpDescriptor *) descriptor
seed:(NSUInteger) seed
name:(NSString * _Nullable) name;
--(MPSGraphTensor *) randomUniformTensorWithShapeTensor:(MPSGraphTensor *) shapeTensor
- seed:(NSUInteger) seed
- name:(NSString * _Nullable) name;
-
-/*!
- * @abstract Create RandomUniform op and return random uniform values and updated state
- * @discussion Returns an array of 2 tensors, where the first is a tensor of provided shape of random uniform values in the range
- * [0.0, 1.0). The updated state tensor is returned as the second result tensor.
- *
- * The provided state is used to define a stream of random values. No state is preserved, and all calls with equal state
- * yield an identical stream of random values. The initial stateTensor provided should be created using the MPSGraph
- * randomPhiloxStateTensor APIs. The resulting stateTensor from this op can be passed as an argument to the following
- * random calls to continue sampling from the stream.
- *
- * @param shape The shape of the tensor generated
- * @param state The state to define a stream of random values. All calls with equal state yield an identical stream of random values.
- * @param name The name for the operation
- *
- * @return An array of MPSGraphTensor of size 2. The first MPSGraphTensor is of shape containing random values in the defined range.
- * The second MPSGraphTensor is the updated state tensor.
- */
--(NSArray<MPSGraphTensor *> *) randomUniformTensorWithShape:(MPSShape *) shape
+/// Create Random op of type matching distribution in descriptor, and return random values and updated state
+///
+/// Returns an array of 2 tensors, where the first is of provided shape of random values in the distribution specified,
+/// and the second is the updated state tensor.
+/// Uses the provided state to define a stream of random values. No state is preserved, and all calls with equal state
+/// yield an identical stream of random values. The initial stateTensor provided should be created using the MPSGraph
+/// randomPhiloxStateTensor APIs. The resulting stateTensor from this op can be passed as an argument to the following
+/// random calls to continue sampling from the stream.
+///
+/// - Parameters:
+/// - shape: The shape of the tensor generated
+/// - descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
+/// - state: The state to define a stream of random values. All calls with equal state yield an identical stream of random values.
+/// - name: The name for the operation
+/// - Returns: An array of MPSGraphTensor of size 2. The first MPSGraphTensor is of shape containing random values in the defined range.
+/// The second MPSGraphTensor is the updated state tensor.
+- (NSArray<MPSGraphTensor *> *) randomTensorWithShape:(MPSShape *) shape
+ descriptor:(MPSGraphRandomOpDescriptor *) descriptor
+ stateTensor:(MPSGraphTensor *) state
+ name:(NSString * _Nullable) name;
+/// Create Random op of type matching distribution in descriptor, and return random values and updated state
+///
+/// Returns an array of 2 tensors, where the first is of provided shape of random values in the distribution specified,
+/// and the second is the updated state tensor.
+/// Uses the provided state to define a stream of random values. No state is preserved, and all calls with equal state
+/// yield an identical stream of random values. The initial stateTensor provided should be created using the MPSGraph
+/// randomPhiloxStateTensor APIs. The resulting stateTensor from this op can be passed as an argument to the following
+/// random calls to continue sampling from the stream.
+///
+/// - Parameters:
+/// - shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
+/// - descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
+/// - state: The state to define a stream of random values. All calls with equal state yield an identical stream of random values.
+/// - name: The name for the operation
+/// - Returns: An array of MPSGraphTensor of size 2. The first MPSGraphTensor is of shape containing random values in the defined range.
+/// The second MPSGraphTensor is the updated state tensor.
+- (NSArray<MPSGraphTensor *> *) randomTensorWithShapeTensor:(MPSGraphTensor *) shapeTensor
+ descriptor:(MPSGraphRandomOpDescriptor *) descriptor
stateTensor:(MPSGraphTensor *) state
name:(NSString * _Nullable) name;
--(NSArray<MPSGraphTensor *> *) randomUniformTensorWithShapeTensor:(MPSGraphTensor *) shapeTensor
- stateTensor:(MPSGraphTensor *) state
- name:(NSString * _Nullable) name;
+/// Create RandomUniform op and return random uniform values
+///
+/// Returns a tensor of provided shape of random uniform values in the range [0.0, 1.0). Uses a random seed value
+/// to initalize state. No state is preserved, and subsequent calls are not guaranteed to result in a unique stream of
+/// random values.
+///
+/// - Parameters:
+/// - shape: The shape of the tensor generated
+/// - name: The name for the operation
+/// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
+- (MPSGraphTensor *) randomUniformTensorWithShape:(MPSShape *) shape
+ name:(NSString * _Nullable) name;
+/// Create RandomUniform op and return random uniform values
+///
+/// Returns a tensor of provided shape of random uniform values in the range [0.0, 1.0). Uses a random seed value
+/// to initalize state. No state is preserved, and subsequent calls are not guaranteed to result in a unique stream of
+/// random values.
+///
+/// - Parameters:
+/// - shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
+/// - name: The name for the operation
+/// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
+- (MPSGraphTensor *) randomUniformTensorWithShapeTensor:(MPSGraphTensor *) shapeTensor
+ name:(NSString * _Nullable) name;
+/// Create RandomUniform op and return random uniform values
+///
+/// Returns a tensor of provided shape of random uniform values in the range [0.0, 1.0). Uses the provided seed value
+/// to initalize state. No state is preserved, and all calls with equal seed yield an identical stream of random values.
+///
+/// - Parameters:
+/// - shape: The shape of the tensor generated
+/// - seed: The seed to use to initialize state. All calls with equal seed yield an identical stream of random values.
+/// - name: The name for the operation
+/// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
+- (MPSGraphTensor *) randomUniformTensorWithShape:(MPSShape *) shape
+ seed:(NSUInteger) seed
+ name:(NSString * _Nullable) name;
+/// Create RandomUniform op and return random uniform values
+///
+/// Returns a tensor of provided shape of random uniform values in the range [0.0, 1.0). Uses the provided seed value
+/// to initalize state. No state is preserved, and all calls with equal seed yield an identical stream of random values.
+///
+/// - Parameters:
+/// - shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
+/// - seed: The seed to use to initialize state. All calls with equal seed yield an identical stream of random values.
+/// - name: The name for the operation
+/// - Returns: An MPSGraphTensor of shape containing random values in the defined range.
+- (MPSGraphTensor *) randomUniformTensorWithShapeTensor:(MPSGraphTensor *) shapeTensor
+ seed:(NSUInteger) seed
+ name:(NSString * _Nullable) name;
--(MPSGraphTensor *) dropoutTensor:(MPSGraphTensor *) tensor
- rate:(double) rate
- name:(NSString * _Nullable) name
+/// Create RandomUniform op and return random uniform values and updated state
+///
+/// Returns an array of 2 tensors, where the first is a tensor of provided shape of random uniform values in the range
+/// [0.0, 1.0), and the second is the updated state tensor.
+/// The provided state is used to define a stream of random values. No state is preserved, and all calls with equal state
+/// yield an identical stream of random values. The initial stateTensor provided should be created using the MPSGraph
+/// randomPhiloxStateTensor APIs. The resulting stateTensor from this op can be passed as an argument to the following
+/// random calls to continue sampling from the stream.
+///
+/// - Parameters:
+/// - shape: The shape of the tensor generated
+/// - state: The state to define a stream of random values. All calls with equal state yield an identical stream of random values.
+/// - name: The name for the operation
+/// - Returns: An array of MPSGraphTensor of size 2. The first MPSGraphTensor is of shape containing random values in the defined range.
+/// The second MPSGraphTensor is the updated state tensor.
+- (NSArray<MPSGraphTensor *> *) randomUniformTensorWithShape:(MPSShape *) shape
+ stateTensor:(MPSGraphTensor *) state
+ name:(NSString * _Nullable) name;
+/// Create RandomUniform op and return random uniform values and updated state
+///
+/// Returns an array of 2 tensors, where the first is a tensor of provided shape of random uniform values in the range
+/// [0.0, 1.0), and the second is the updated state tensor.
+/// The provided state is used to define a stream of random values. No state is preserved, and all calls with equal state
+/// yield an identical stream of random values. The initial stateTensor provided should be created using the MPSGraph
+/// randomPhiloxStateTensor APIs. The resulting stateTensor from this op can be passed as an argument to the following
+/// random calls to continue sampling from the stream.
+///
+/// - Parameters:
+/// - shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
+/// - state: The state to define a stream of random values. All calls with equal state yield an identical stream of random values.
+/// - name: The name for the operation
+/// - Returns: An array of MPSGraphTensor of size 2. The first MPSGraphTensor is of shape containing random values in the defined range.
+/// The second MPSGraphTensor is the updated state tensor.
+- (NSArray<MPSGraphTensor *> *) randomUniformTensorWithShapeTensor:(MPSGraphTensor *) shapeTensor
+ stateTensor:(MPSGraphTensor *) state
+ name:(NSString * _Nullable) name;
+
+/// Creates a dropout op and return the result
+///
+/// Removes values in the `tensor` with a percentage chance equal to `rate`. Removed values are set to 0
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - rate: The rate of values to be set to 0
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
+- (MPSGraphTensor *) dropoutTensor:(MPSGraphTensor *) tensor
+ rate:(double) rate
+ name:(NSString * _Nullable) name
MPS_SWIFT_NAME( dropout(_:rate:name:) );
--(MPSGraphTensor *) dropoutTensor:(MPSGraphTensor *) tensor
- rateTensor:(MPSGraphTensor *) rate
- name:(NSString * _Nullable) name
+/// Creates a dropout op and return the result
+///
+/// Removes values in the `tensor` with a percentage chance equal to `rate`. Removed values are set to 0
+///
+/// - Parameters:
+/// - tensor: Input tensor
+/// - rate: The rate of values to be set to 0
+/// - name: The name for the operation
+/// - Returns: A valid MPSGraphTensor object
+- (MPSGraphTensor *) dropoutTensor:(MPSGraphTensor *) tensor
+ rateTensor:(MPSGraphTensor *) rate
+ name:(NSString * _Nullable) name
MPS_SWIFT_NAME( dropout(_:rate:name:) );
@end
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphReductionOps.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphReductionOps.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphReductionOps.h 2023-03-09 23:50:17
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Headers/MPSGraphReductionOps.h 2023-05-19 20:58:42
@@ -16,247 +16,211 @@
MPS_CLASS_AVAILABLE_STARTING(macos(11.0), ios(14.0), tvos(14.0))
@interface MPSGraph(MPSGraphReductionOps)
-/*!
- * @abstract Create reduction sum 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 *) reductionSumWithTensor:(MPSGraphTensor *) tensor
- axis:(NSInteger) axis
- name:(NSString * _Nullable) name;
+/// Create reduction sum op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: axis of reduction
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+- (MPSGraphTensor *) reductionSumWithTensor:(MPSGraphTensor *) tensor
+ axis:(NSInteger) axis
+ name:(NSString * _Nullable) name;
-/*!
- * @abstract Create reduction sum 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 *) reductionSumWithTensor:(MPSGraphTensor *)tensor
- axes:(NSArray<NSNumber *> *_Nullable)axes
- name:(NSString *_Nullable)name;
+/// Create reduction sum op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axes: axes of reduction
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+- (MPSGraphTensor *) reductionSumWithTensor:(MPSGraphTensor *)tensor
+ axes:(NSArray<NSNumber *> *_Nullable)axes
+ name:(NSString *_Nullable)name;
-/*!
- * @abstract Create reduction max 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.
- */
+/// Create reduction max op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: axis of reduction
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) reductionMaximumWithTensor:(MPSGraphTensor *) tensor
axis:(NSInteger) axis
name:(NSString * _Nullable) name;
-/*!
- * @abstract Create reduction max 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 *) reductionMaximumWithTensor:(MPSGraphTensor *)tensor
- axes:(NSArray<NSNumber *> *_Nullable)axes
- name:(NSString *_Nullable)name;
+/// Create reduction max op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axes: axes of reduction
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+- (MPSGraphTensor *) reductionMaximumWithTensor:(MPSGraphTensor *)tensor
+ axes:(NSArray<NSNumber *> *_Nullable)axes
+ name:(NSString *_Nullable)name;
-/*!
- * @abstract Create reduction minimum 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 *) reductionMinimumWithTensor:(MPSGraphTensor *) tensor
- axis:(NSInteger) axis
- name:(NSString * _Nullable) name;
+/// Create reduction minimum op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: axis of reduction
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+- (MPSGraphTensor *) reductionMinimumWithTensor:(MPSGraphTensor *) tensor
+ axis:(NSInteger) axis
+ name:(NSString * _Nullable) name;
-/*!
- * @abstract Create reduction min 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.
- */
+/// Create reduction min op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axes: axes of reduction
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) reductionMinimumWithTensor:(MPSGraphTensor *)tensor
axes:(NSArray<NSNumber *> *_Nullable)axes
name:(NSString *_Nullable)name;
-/*!
- * @abstract Create reduction max propagate NaN 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 *) reductionMaximumPropagateNaNWithTensor:(MPSGraphTensor *) tensor
- axis:(NSInteger) axis
- name:(NSString * _Nullable) name;
+/// Create reduction max propagate NaN op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: axis of reduction
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+- (MPSGraphTensor *) reductionMaximumPropagateNaNWithTensor:(MPSGraphTensor *) tensor
+ axis:(NSInteger) axis
+ name:(NSString * _Nullable) name;
-/*!
- * @abstract Create reduction max propagate NaN 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 *) reductionMaximumPropagateNaNWithTensor:(MPSGraphTensor *)tensor
- axes:(NSArray<NSNumber *> *_Nullable)axes
- name:(NSString *_Nullable)name;
+/// Create reduction max propagate NaN op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axes: axes of reduction
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+- (MPSGraphTensor *) reductionMaximumPropagateNaNWithTensor:(MPSGraphTensor *)tensor
+ axes:(NSArray<NSNumber *> *_Nullable)axes
+ name:(NSString *_Nullable)name;
-/*!
- * @abstract Create reduction min propagate NaN 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 *) reductionMinimumPropagateNaNWithTensor:(MPSGraphTensor *) tensor
- axis:(NSInteger) axis
- name:(NSString * _Nullable) name;
+/// Create reduction min propagate NaN op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: axis of reduction
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+- (MPSGraphTensor *) reductionMinimumPropagateNaNWithTensor:(MPSGraphTensor *) tensor
+ axis:(NSInteger) axis
+ name:(NSString * _Nullable) name;
-/*!
- * @abstract Create reduction min propagate NaN 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 *) reductionMinimumPropagateNaNWithTensor:(MPSGraphTensor *)tensor
- axes:(NSArray<NSNumber *> *_Nullable)axes
- name:(NSString *_Nullable)name;
+/// Create reduction min propagate NaN op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axes: axes of reduction
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+- (MPSGraphTensor *) reductionMinimumPropagateNaNWithTensor:(MPSGraphTensor *)tensor
+ axes:(NSArray<NSNumber *> *_Nullable)axes
+ name:(NSString *_Nullable)name;
-/*!
- * @abstract Create reduction product 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.
- */
+/// Create reduction product op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: axis of reduction
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) reductionProductWithTensor:(MPSGraphTensor *) tensor
axis:(NSInteger) axis
name:(NSString * _Nullable) name;
-/*!
- * @abstract Create reduction product 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 *) reductionProductWithTensor:(MPSGraphTensor *)tensor
- axes:(NSArray<NSNumber *> *_Nullable)axes
- name:(NSString *_Nullable)name;
+/// Create reduction product op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axes: axes of reduction
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+- (MPSGraphTensor *) reductionProductWithTensor:(MPSGraphTensor *)tensor
+ axes:(NSArray<NSNumber *> *_Nullable)axes
+ name:(NSString *_Nullable)name;
-/*!
- * @abstract Create reduction argMax 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 *) reductionArgMaximumWithTensor:(MPSGraphTensor *)tensor
- axis:(NSInteger)axis
- name:(NSString *_Nullable)name
+/// Create reduction argMax op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: axis of reduction
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
+- (MPSGraphTensor *) reductionArgMaximumWithTensor:(MPSGraphTensor *)tensor
+ axis:(NSInteger)axis
+ name:(NSString *_Nullable)name
MPS_AVAILABLE_STARTING(macos(12.0), ios(15.0), macCatalyst(15.0), tvos(15.0));
-/*!
- * @abstract Create reduction argMin 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.
- */
+/// Create reduction argMin op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: axis of reduction
+/// - name: name for the operation
+/// - Returns: A valid MPSGraphTensor object.
-(MPSGraphTensor *) reductionArgMinimumWithTensor:(MPSGraphTensor *)tensor
axis:(NSInteger)axis
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
+/// Create reduction and op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axis: axis of reduction
+/// - name: name for the operation
+/// - Returns: 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
+/// Create reduction and op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: input tensor
+/// - axes: axes of reduction
+/// - name: name for the operation
+/// - Returns: 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
+/// Create reduction or op and return the result tensor.
+///
+/// - Parameters:
+/// - tensor: inpu
- README
- xcode13.0 Binding Status
- xcode13.1 Binding Status
- xcode13.2 Binding Status
- xcode13.3 Binding Status
- xcode13.4 Binding Status
- xcode14.0 Binding Status
- xcode14.1 Binding Status
- xcode14.2 Binding Status
- xcode14.3 Binding Status
- xcode15.0 Binding Status
- xcode15.1 Binding Status
- xcode15.3 Binding Status
- xcode15.4 Binding Status
- xcode16.0 Binding Status
- xcode16.1 Binding Status