Skip to content

CoreML watchOS xcode15.0 b1

Manuel de la Pena edited this page Aug 31, 2023 · 3 revisions

#CoreML.framework https://github.com/xamarin/xamarin-macios/pull/18898

diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/CoreML.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/CoreML.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/CoreML.h	2023-03-04 16:38:15
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/CoreML.h	2023-05-31 04:24:53
@@ -37,6 +37,7 @@
 #import <CoreML/MLModelConfiguration.h>
 
 #import <CoreML/MLModel+MLModelCompilation.h>
+#import <CoreML/MLModel+MLComputeDevice.h>
 
 #import <CoreML/MLModelError.h>
 
@@ -60,3 +61,9 @@
 #import <CoreML/MLModelCollection.h>
 #import <CoreML/MLModelCollectionEntry.h>
 #import <CoreML/MLModelAsset.h>
+
+#import <CoreML/MLAllComputeDevices.h>
+#import <CoreML/MLComputeDeviceProtocol.h>
+#import <CoreML/MLCPUComputeDevice.h>
+#import <CoreML/MLGPUComputeDevice.h>
+#import <CoreML/MLNeuralEngineComputeDevice.h>
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLAllComputeDevices.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLAllComputeDevices.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLAllComputeDevices.h	1969-12-31 19:00:00
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLAllComputeDevices.h	2023-05-31 04:24:54
@@ -0,0 +1,30 @@
+//
+//  MLAllComputeDevices.h
+//  CoreML_framework
+//
+//  Copyright © 2022 Apple Inc. All rights reserved.
+//
+
+#import <CoreML/MLExport.h>
+
+@protocol MLComputeDeviceProtocol;
+
+NS_ASSUME_NONNULL_BEGIN
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+    /*!
+     * @abstract Returns an array containing all compute devices.
+     *
+     * @discussion The returned array contains all compute devices that are accessible. If a compute
+     * device becomes inaccessible for some reason (for e.g. if an external GPU is unplugged)
+     * then the subsequent call to`MLAllComputeDevices` will return an array without the compute device.
+     *
+     */
+    ML_EXPORT NSArray<id<MLComputeDeviceProtocol>> *MLAllComputeDevices(void) API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) NS_REFINED_FOR_SWIFT;
+#ifdef __cplusplus
+}
+#endif
+
+NS_ASSUME_NONNULL_END
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLCPUComputeDevice.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLCPUComputeDevice.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLCPUComputeDevice.h	1969-12-31 19:00:00
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLCPUComputeDevice.h	2023-05-31 04:24:54
@@ -0,0 +1,23 @@
+//
+//  MLCPUComputeDevice.h
+//  CoreML_framework
+//
+//  Copyright © 2022 Apple Inc. All rights reserved.
+//
+
+#import <CoreML/MLComputeDeviceProtocol.h>
+
+/*!
+ * Represents a CPU compute device.
+ *
+ */
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+ML_EXPORT NS_SWIFT_SENDABLE
+__attribute__((objc_subclassing_restricted))
+@interface MLCPUComputeDevice : NSObject<MLComputeDeviceProtocol>
+
+- (instancetype)init NS_UNAVAILABLE;
+
++ (instancetype)new NS_UNAVAILABLE;
+
+@end
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLComputeDeviceProtocol.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLComputeDeviceProtocol.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLComputeDeviceProtocol.h	1969-12-31 19:00:00
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLComputeDeviceProtocol.h	2023-05-31 04:24:55
@@ -0,0 +1,26 @@
+//
+//  MLComputeDeviceProtocol.h
+//  CoreML_framework
+//
+//  Copyright © 2022 Apple Inc. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+#import <CoreML/MLExport.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/*!
+ * Protocol for representing a compute device. The represented device
+ * is capable of running machine learning computations and other tasks like
+ * analysis and processing of images, sound, etc.
+ *
+ */
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+ML_EXPORT
+@protocol MLComputeDeviceProtocol <NSObject>
+
+@end
+
+NS_ASSUME_NONNULL_END
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLGPUComputeDevice.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLGPUComputeDevice.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLGPUComputeDevice.h	1969-12-31 19:00:00
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLGPUComputeDevice.h	2023-05-31 04:24:54
@@ -0,0 +1,28 @@
+//
+//  MLGPUComputeDevice.h
+//  CoreML_framework
+//
+//  Copyright © 2022 Apple Inc. All rights reserved.
+//
+
+#import <CoreML/MLComputeDeviceProtocol.h>
+
+@protocol MTLDevice;
+
+/*!
+ * Represents a GPU compute device.
+ *
+ */
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+ML_EXPORT NS_SWIFT_SENDABLE
+__attribute__((objc_subclassing_restricted))
+@interface MLGPUComputeDevice : NSObject<MLComputeDeviceProtocol>
+
+- (instancetype)init NS_UNAVAILABLE;
+
++ (instancetype)new NS_UNAVAILABLE;
+
+/// The underlying metal device.
+@property (strong, readonly, nonatomic) id<MTLDevice> metalDevice;
+
+@end
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModel+MLComputeDevice.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModel+MLComputeDevice.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModel+MLComputeDevice.h	1969-12-31 19:00:00
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModel+MLComputeDevice.h	2023-05-31 04:24:55
@@ -0,0 +1,30 @@
+//
+//  MLModel+MLComputeDevice.h
+//  CoreML
+//
+//  Copyright © 2023 Apple Inc. All rights reserved.
+//
+#import <Foundation/Foundation.h>
+#import <CoreML/MLModel.h>
+
+@protocol MLComputeDeviceProtocol;
+
+NS_ASSUME_NONNULL_BEGIN
+
+/// MLModel (MLComputeDevice)
+///
+/// Class with utilties for getting the available compute devices.
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+@interface MLModel (MLComputeDevice)
+
+/// The list of available compute devices for CoreML.
+///
+/// Use the method to get the list of compute devices that MLModel's prediction can use.
+///
+/// Some compute devices on the hardware are exclusive to the domain ML frameworks such as Vision and SoundAnalysis and
+/// not available to CoreML. See also `MLComputeDevice.allComputeDevices`.
+@property (class, readonly, nonatomic, copy) NSArray<id<MLComputeDeviceProtocol>> *availableComputeDevices API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) NS_REFINED_FOR_SWIFT;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModel.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModel.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModel.h	2023-03-09 23:50:52
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModel.h	2023-05-31 04:07:27
@@ -55,14 +55,40 @@
             configuration:(MLModelConfiguration *)configuration
         completionHandler:(void (^)(MLModel * _Nullable model, NSError * _Nullable error))handler API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) NS_REFINED_FOR_SWIFT NS_SWIFT_DISABLE_ASYNC;
 
-/// All models can predict on a specific set of input features.
+/// Convenience method to run a prediction synchronously with default prediction options.
 - (nullable id<MLFeatureProvider>)predictionFromFeatures:(id<MLFeatureProvider>)input
                                                    error:(NSError **)error;
 
-/// Prediction with explicit options
+/*!
+ Run a prediction on a model synchronously
+
+ @param input The input features to make a prediction from
+ @param options Prediction options to modify how the prediction is run
+ @param error The out parameter for error when nil is returned. On success, it is nil
+ @returns The output features from the prediction
+*/
 - (nullable id<MLFeatureProvider>)predictionFromFeatures:(id<MLFeatureProvider>)input
                                                  options:(MLPredictionOptions *)options
                                                    error:(NSError **)error;
+
+/// Convenience method to run a prediction asynchronously with default prediction options.
+- (void)predictionFromFeatures:(id<MLFeatureProvider>)input
+             completionHandler:(void (^)(_Nullable id<MLFeatureProvider> output, NSError * _Nullable error))completionHandler
+                 API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+                 NS_REFINED_FOR_SWIFT NS_SWIFT_DISABLE_ASYNC;
+
+/*!
+ Run a prediction on a model asynchronously.
+
+ @param input The input features to make a prediction from
+ @param options Prediction options to modify how the prediction is run
+ @param completionHandler A block that will be invoked once the prediction has completed successfully or unsuccessfully. On success, it is invoked with a valid model output. On failure, it is invoked with a nil output and NSError
+*/
+- (void)predictionFromFeatures:(id<MLFeatureProvider>)input
+                       options:(MLPredictionOptions *)options
+             completionHandler:(void (^)(_Nullable id<MLFeatureProvider> output, NSError * _Nullable error))completionHandler
+                 API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+                 NS_REFINED_FOR_SWIFT NS_SWIFT_DISABLE_ASYNC;
 
 /// Batch prediction without explicit options
 - (nullable id<MLBatchProvider>)predictionsFromBatch:(id<MLBatchProvider>)inputBatch
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModelAsset.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModelAsset.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModelAsset.h	2023-03-09 19:24:33
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModelAsset.h	2023-05-31 04:24:55
@@ -2,7 +2,6 @@
 //  MLModelAsset.h
 //  CoreML
 //
-//  Created by Anil Katti on 1/14/22.
 //  Copyright © 2022 Apple Inc. All rights reserved.
 //
 
@@ -15,7 +14,7 @@
 @interface MLModelAsset : NSObject
 
 /*!
- * Construct an optimized model asset asynchronously from the contents of specification data.
+ * Construct an optimized model asset from the contents of specification data.
  *
  * @param specificationData Contents of .mlmodel as a data blob.
  * @param error When the model asset creation fails error is populated with the reason for failure.
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModelError.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModelError.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModelError.h	2023-03-09 19:24:35
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLModelError.h	2023-05-19 20:03:35
@@ -106,6 +106,9 @@
       server.
     */
     MLModelErrorModelCollection API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) = 10,
+    
+    /// Core ML throws/returns this error when the prediction is cancelled prior to completing.
+    MLModelErrorPredictionCancelled API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0)) = 11,
 } API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0));
 
 NS_ASSUME_NONNULL_END
diff -ruN /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLNeuralEngineComputeDevice.h /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLNeuralEngineComputeDevice.h
--- /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLNeuralEngineComputeDevice.h	1969-12-31 19:00:00
+++ /Applications/Xcode_15.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/CoreML.framework/Headers/MLNeuralEngineComputeDevice.h	2023-05-31 04:24:55
@@ -0,0 +1,23 @@
+//
+//  MLNeuralEngineComputeDevice.h
+//  CoreML_framework
+//
+//  Copyright © 2022 Apple Inc. All rights reserved.
+//
+
+#import <CoreML/MLComputeDeviceProtocol.h>
+
+/*!
+ * Represents a NeuralEngine compute device for inference of machine learning models.
+ *
+ */
+API_AVAILABLE(macos(14.0), ios(17.0), watchos(10.0), tvos(17.0))
+ML_EXPORT NS_SWIFT_SENDABLE
+__attribute__((objc_subclassing_restricted))
+@interface MLNeuralEngineComputeDevice : NSObject<MLComputeDeviceProtocol>
+
+- (instancetype)init NS_UNAVAILABLE;
+
++ (instancetype)new NS_UNAVAILABLE;
+
+@end
Clone this wiki locally