From cea8228f1ae1c677258a36bb04089e98f7f927c0 Mon Sep 17 00:00:00 2001 From: Alex Soto Date: Mon, 31 Jul 2017 15:11:07 -0500 Subject: [PATCH 1/3] [CoreML] Update to Xcode 9 Beta 4 --- src/coreml.cs | 61 +++++++++++++++++++++++--- tests/introspection/ApiProtocolTest.cs | 4 ++ 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/src/coreml.cs b/src/coreml.cs index 2ab2272f03ce..64b0cc652a12 100644 --- a/src/coreml.cs +++ b/src/coreml.cs @@ -29,7 +29,7 @@ public enum MLFeatureType : nint { String = 3, Image = 4, MultiArray = 5, - Dictionary = 6 + Dictionary = 6, } [Watch (4,0), TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] @@ -38,8 +38,7 @@ public enum MLFeatureType : nint { public enum MLModelError : nint { Generic = 0, FeatureType = 1, - DescriptionMismatch = 2, - Io = 3 + IO = 3, } [Watch (4,0), TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] @@ -47,7 +46,7 @@ public enum MLModelError : nint { public enum MLMultiArrayDataType : nint { Double = 65536 | 64, Float32 = 65536 | 32, - Int32 = 131072 | 32 + Int32 = 131072 | 32, } [Watch (4,0), TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] @@ -166,11 +165,22 @@ interface MLModel { [Static] [Export ("modelWithContentsOfURL:error:")] [return: NullAllowed] - MLModel FromUrl (NSUrl url, [NullAllowed] out NSError error); + MLModel FromUrl (NSUrl url, out NSError error); [Export ("predictionFromFeatures:error:")] [return: NullAllowed] IMLFeatureProvider GetPrediction (IMLFeatureProvider input, out NSError error); + + [Export ("predictionFromFeatures:options:error:")] + [return: NullAllowed] + IMLFeatureProvider GetPrediction (IMLFeatureProvider input, MLPredictionOptions options, out NSError error); + + // Category MLModel (MLModelCompilation) + + [Static] + [Export ("compileModelAtURL:error:")] + [return: NullAllowed] + NSUrl CompileModel (NSUrl modelUrl, out NSError error); } [Watch (4,0), TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] @@ -266,5 +276,46 @@ interface MLMultiArray { [Export ("setObject:forKeyedSubscript:")] void SetObject (NSNumber obj, NSNumber [] key); } + + [Watch (4,0), TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] + [BaseType (typeof (NSObject))] + interface MLDictionaryConstraint { + + [Export ("keyType")] + MLFeatureType KeyType { get; } + } + + [Watch (4,0), TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] + [BaseType (typeof (NSObject))] + interface MLImageConstraint { + + [Export ("pixelsHigh")] + nint PixelsHigh { get; } + + [Export ("pixelsWide")] + nint PixelsWide { get; } + + [Export ("pixelFormatType")] + uint PixelFormatType { get; } + } + + [Watch (4,0), TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] + [BaseType (typeof (NSObject))] + interface MLMultiArrayConstraint { + + [Export ("shape")] + NSNumber [] Shape { get; } + + [Export ("dataType")] + MLMultiArrayDataType DataType { get; } + } + + [Watch (4,0), TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] + [BaseType (typeof (NSObject))] + interface MLPredictionOptions { + + [Export ("usesCPUOnly")] + bool UsesCpuOnly { get; set; } + } } #endif // XAMCORE_2_0 diff --git a/tests/introspection/ApiProtocolTest.cs b/tests/introspection/ApiProtocolTest.cs index 5f8ae17a00cb..c18789d3f0d9 100644 --- a/tests/introspection/ApiProtocolTest.cs +++ b/tests/introspection/ApiProtocolTest.cs @@ -81,6 +81,10 @@ protected virtual bool Skip (Type type, string protocolName) case "GKCloudPlayer": // iOS 10 : test throw because of generic usage case "NSMeasurement`1": + // Xcode 9 - Conformance not in heades + case "MLDictionaryConstraint": + case "MLImageConstraint": + case "MLMultiArrayConstraint": return true; // skip } break; From f5c15df17851ac782a57073b837808369c3535bb Mon Sep 17 00:00:00 2001 From: Alex Soto Date: Mon, 31 Jul 2017 17:06:12 -0500 Subject: [PATCH 2/3] [CoreML] Add missing props --- src/coreml.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/coreml.cs b/src/coreml.cs index 64b0cc652a12..03eb0e55b867 100644 --- a/src/coreml.cs +++ b/src/coreml.cs @@ -75,6 +75,17 @@ interface MLFeatureDescription : NSCopying { [Export ("isAllowedValue:")] bool IsAllowed (MLFeatureValue value); + + // Category MLFeatureDescription (MLFeatureValueConstraints) + + [NullAllowed, Export ("multiArrayConstraint", ArgumentSemantic.Assign)] + MLMultiArrayConstraint MultiArrayConstraint { get; set; } + + [NullAllowed, Export ("imageConstraint", ArgumentSemantic.Assign)] + MLImageConstraint ImageConstraint { get; set; } + + [NullAllowed, Export ("dictionaryConstraint", ArgumentSemantic.Assign)] + MLDictionaryConstraint DictionaryConstraint { get; set; } } interface IMLFeatureProvider { } From ec3221bb36de9e76d7b4353043e06b662c2e07f6 Mon Sep 17 00:00:00 2001 From: Alex Soto Date: Mon, 31 Jul 2017 20:34:51 -0500 Subject: [PATCH 3/3] [CoreML] Some more fixes --- src/coreml.cs | 14 +++++++++++--- tests/xtro-sharpie/common.pending | 10 +++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/coreml.cs b/src/coreml.cs index 03eb0e55b867..cc4c862bd1e2 100644 --- a/src/coreml.cs +++ b/src/coreml.cs @@ -78,14 +78,19 @@ interface MLFeatureDescription : NSCopying { // Category MLFeatureDescription (MLFeatureValueConstraints) + // HACK: radar://33643011 -> https://trello.com/c/ZN712GOi + + // [FAIL] Selector not found for CoreML.MLFeatureDescription : setMultiArrayConstraint: [NullAllowed, Export ("multiArrayConstraint", ArgumentSemantic.Assign)] - MLMultiArrayConstraint MultiArrayConstraint { get; set; } + MLMultiArrayConstraint MultiArrayConstraint { get; /*set;*/ } + // [FAIL] Selector not found for CoreML.MLFeatureDescription : setImageConstraint: [NullAllowed, Export ("imageConstraint", ArgumentSemantic.Assign)] - MLImageConstraint ImageConstraint { get; set; } + MLImageConstraint ImageConstraint { get; /*set;*/ } + // [FAIL] Selector not found for CoreML.MLFeatureDescription : setDictionaryConstraint: [NullAllowed, Export ("dictionaryConstraint", ArgumentSemantic.Assign)] - MLDictionaryConstraint DictionaryConstraint { get; set; } + MLDictionaryConstraint DictionaryConstraint { get; /*set;*/ } } interface IMLFeatureProvider { } @@ -289,6 +294,7 @@ interface MLMultiArray { } [Watch (4,0), TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] + [DisableDefaultCtor] [BaseType (typeof (NSObject))] interface MLDictionaryConstraint { @@ -297,6 +303,7 @@ interface MLDictionaryConstraint { } [Watch (4,0), TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] + [DisableDefaultCtor] [BaseType (typeof (NSObject))] interface MLImageConstraint { @@ -311,6 +318,7 @@ interface MLImageConstraint { } [Watch (4,0), TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] + [DisableDefaultCtor] [BaseType (typeof (NSObject))] interface MLMultiArrayConstraint { diff --git a/tests/xtro-sharpie/common.pending b/tests/xtro-sharpie/common.pending index a429e4757e49..b4562f889f49 100644 --- a/tests/xtro-sharpie/common.pending +++ b/tests/xtro-sharpie/common.pending @@ -653,4 +653,12 @@ # CoreML ## we do not have NSFastEnumeration and decided to not bind objectForKeyedSubscript using a local method instead !missing-protocol-conformance! MLDictionaryFeatureProvider should conform to NSFastEnumeration -!missing-selector! MLDictionaryFeatureProvider::objectForKeyedSubscript: not bound \ No newline at end of file +!missing-selector! MLDictionaryFeatureProvider::objectForKeyedSubscript: not bound + +## radar://33643011 -> https://trello.com/c/ZN712GOi +## [FAIL] Selector not found for CoreML.MLFeatureDescription : setMultiArrayConstraint: +## [FAIL] Selector not found for CoreML.MLFeatureDescription : setImageConstraint: +## [FAIL] Selector not found for CoreML.MLFeatureDescription : setDictionaryConstraint: +!missing-selector! MLFeatureDescription::setDictionaryConstraint: not bound +!missing-selector! MLFeatureDescription::setImageConstraint: not bound +!missing-selector! MLFeatureDescription::setMultiArrayConstraint: not bound