Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CoreML] Add xcode 15 beta 7 support. #18898

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/CoreML/MLModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Runtime.InteropServices;
using Foundation;
using ObjCRuntime;

#nullable enable

namespace CoreML {

public partial class MLModel {
#if NET
[SupportedOSPlatform ("tvos17.0")]
[SupportedOSPlatform ("macos14.0")]
[SupportedOSPlatform ("ios17.0")]
[SupportedOSPlatform ("maccatalyst17.0")]
#else
[Watch (10, 0), TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)]
#endif
[DllImport (Constants.CoreMLLibrary)]
static extern /* MLComputeDeviceProtocol[] */ IntPtr MLAllComputeDevices ();

#if NET
[SupportedOSPlatform ("tvos17.0")]
[SupportedOSPlatform ("macos14.0")]
[SupportedOSPlatform ("ios17.0")]
[SupportedOSPlatform ("maccatalyst17.0")]
#else
[Watch (10, 0), TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)]
#endif
public static IMLComputeDeviceProtocol [] AllComputeDevices {
get {
var ptr = MLAllComputeDevices ();
if (ptr == IntPtr.Zero)
return Array.Empty<IMLComputeDeviceProtocol> ();
return NSArray.ArrayFromHandle<IMLComputeDeviceProtocol> (ptr);
}
}
}
}
47 changes: 47 additions & 0 deletions src/coreml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public enum MLModelError : long {
ModelDecryptionKeyFetch = 8,
ModelDecryption = 9,
ModelCollection = 10,
PredictionCancelled = 11,
}

[MacCatalyst (13, 1)]
Expand Down Expand Up @@ -474,6 +475,22 @@ interface MLModel {
[Static]
[Export ("compileModelAtURL:completionHandler:")]
void CompileModel (NSUrl modelUrl, Action<NSUrl, NSError> handler);

[Async]
[Watch (10, 0), TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)]
[Export ("predictionFromFeatures:completionHandler:")]
void GetPrediction (IMLFeatureProvider input, Action<IMLFeatureProvider, NSError> completionHandler);

[Async]
[Watch (10, 0), TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)]
[Export ("predictionFromFeatures:options:completionHandler:")]
void GetPrediction (IMLFeatureProvider input, MLPredictionOptions options, Action<IMLFeatureProvider, NSError> completionHandler);

// from the category MLComputeDevice (MLModel)
[Watch (10, 0), TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)]
[Static]
[Export ("availableComputeDevices", ArgumentSemantic.Copy)]
IMLComputeDeviceProtocol [] AvailableComputeDevices { get; }
}

[MacCatalyst (13, 1)]
Expand Down Expand Up @@ -1217,4 +1234,34 @@ interface MLModelAsset {
[return: NullAllowed]
MLModelAsset Create (NSData specificationData, [NullAllowed] out NSError error);
}

interface IMLComputeDeviceProtocol { }

[Watch (10, 0), TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)]
[Protocol]
interface MLComputeDeviceProtocol {
}

[Watch (10, 0), TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface MLNeuralEngineComputeDevice : MLComputeDeviceProtocol {
[Export ("totalCoreCount")]
nint TotalCoreCount { get; }
}

[Watch (10, 0), TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)]
[BaseType (typeof (NSObject), Name = "MLCPUComputeDevice")]
[DisableDefaultCtor]
interface MLCpuComputeDevice : MLComputeDeviceProtocol {
}

[Watch (10, 0), TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)]
[BaseType (typeof (NSObject), Name = "MLGPUComputeDevice")]
[DisableDefaultCtor]
interface MLGpuComputeDevice : MLComputeDeviceProtocol {
[Export ("metalDevice", ArgumentSemantic.Strong)]
IMTLDevice MetalDevice { get; }
}

}
1 change: 1 addition & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ COREMIDI_SOURCES = \

COREML_SOURCES = \
CoreML/MLDictionaryFeatureProvider.cs \
CoreML/MLModel.cs \
CoreML/MLMultiArray.cs \
CoreML/MLMultiArrayConstraint.cs \

Expand Down
11 changes: 0 additions & 11 deletions tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreML.todo

This file was deleted.

11 changes: 0 additions & 11 deletions tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreML.todo

This file was deleted.

11 changes: 0 additions & 11 deletions tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreML.todo

This file was deleted.

11 changes: 0 additions & 11 deletions tests/xtro-sharpie/iOS-CoreML.todo

This file was deleted.

11 changes: 0 additions & 11 deletions tests/xtro-sharpie/macOS-CoreML.todo

This file was deleted.

11 changes: 0 additions & 11 deletions tests/xtro-sharpie/tvOS-CoreML.todo

This file was deleted.

11 changes: 0 additions & 11 deletions tests/xtro-sharpie/watchOS-CoreML.todo

This file was deleted.