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] Update to Xcode 9 Beta 4 #2387

Merged
merged 3 commits into from
Aug 1, 2017
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
80 changes: 75 additions & 5 deletions src/coreml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -38,16 +38,15 @@ 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)]
[Native]
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)]
Expand Down Expand Up @@ -76,6 +75,22 @@ interface MLFeatureDescription : NSCopying {

[Export ("isAllowedValue:")]
bool IsAllowed (MLFeatureValue value);

// 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;*/ }

// [FAIL] Selector not found for CoreML.MLFeatureDescription : setImageConstraint:
[NullAllowed, Export ("imageConstraint", ArgumentSemantic.Assign)]
MLImageConstraint ImageConstraint { get; /*set;*/ }

// [FAIL] Selector not found for CoreML.MLFeatureDescription : setDictionaryConstraint:
[NullAllowed, Export ("dictionaryConstraint", ArgumentSemantic.Assign)]
MLDictionaryConstraint DictionaryConstraint { get; /*set;*/ }
}

interface IMLFeatureProvider { }
Expand Down Expand Up @@ -166,11 +181,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)]
Expand Down Expand Up @@ -266,5 +292,49 @@ 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)]
[DisableDefaultCtor]
[BaseType (typeof (NSObject))]
interface MLDictionaryConstraint {

[Export ("keyType")]
MLFeatureType KeyType { get; }
}

[Watch (4,0), TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)]
[DisableDefaultCtor]
[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)]
[DisableDefaultCtor]
[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
4 changes: 4 additions & 0 deletions tests/introspection/ApiProtocolTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion tests/xtro-sharpie/common.pending
Original file line number Diff line number Diff line change
Expand Up @@ -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
!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