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 9 Beta 1 bindings #2275

Merged
merged 7 commits into from
Jun 30, 2017
Merged

Conversation

dalexsoto
Copy link
Member

No description provided.

@monojenkins
Copy link
Collaborator

Build failure

1 similar comment
@monojenkins
Copy link
Collaborator

Build failure

[Watch (4,0), TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)]
[BaseType (typeof (NSObject))]
interface MLDictionaryFeatureProvider : MLFeatureProvider {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace. Same applies to the rest of the new interfaces

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always leave a Whitespace between the interface line definition and the first member definition and this is the first time I've been called out :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a single empty line is fine to delimit code and help readability
whitespace changes are specially bad when updating files since they make larger diffs and contaminate git history/blame

src/coreml.cs Outdated
bool Optional { [Bind ("isOptional")] get; }

[Export ("isAllowedValue:")]
bool IsAllowedValue (MLFeatureValue value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this just be IsAllowed? Not as clearcut as some other cases.

src/coreml.cs Outdated

[Static]
[Export ("undefinedFeatureValueWithType:")]
MLFeatureValue GetUndefinedFeatureValue (MLFeatureType type);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Get' sounds wrong since this is still creating and returning an MLFeatureValue same as the other static methods. FromType doesn't work since it doesn't tell you that it's an UndefinedFeatureValue, but maybe just UndefinedFeatureValueFromType? or even CreateUndefinedFeatureValue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm I can't just use UndefinedFeatureValueFromType since it needs to start with a verb, but yeah CreateUndefinedFeatureValue sounds about right

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll just go CreateUndefined since FeatureValue is already on the type name you are creating

[Export ("dataType")]
MLMultiArrayDataType DataType { get; }

[Export ("shape")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could/should this use BindAs (does BindAs support NSNumber arrays)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, docs are not clear on the type we should use here nor is swift
var shape: [NSNumber]

[Export ("shape")]
NSNumber [] Shape { get; }

[Export ("strides")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, docs are not clear on the type we should use here nor is swift
var strides: [NSNumber]

@monojenkins
Copy link
Collaborator

Build failure

@dalexsoto
Copy link
Member Author

@timrisi Done :)

[Watch (4,0), TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)]
[BaseType (typeof (NSObject))]
interface MLDictionaryFeatureProvider : MLFeatureProvider {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a single empty line is fine to delimit code and help readability
whitespace changes are specially bad when updating files since they make larger diffs and contaminate git history/blame

src/coreml.cs Outdated

[Export ("objectForKeyedSubscript:")]
[return: NullAllowed]
MLFeatureValue ObjectForKeyedSubscript (string featureName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's already exposed by this [string] right ?
I don't mind having a method (easier to discover) but it should be named like one ;-) as this one lack a verb/action
e.g. GetValue (string)
The alternative is to mark it as [Internal]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be identical to GetFeatureValue from the protocol.
If that's the case (test needed) then it should be named identically (in fact it should not be bound as the generator will include it).


[Static]
[Export ("undefinedFeatureValueWithType:")]
MLFeatureValue CreateUndefined (MLFeatureType type);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not the name it FromUndefined to match other static methods ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Br my reading, It's creating an undefined feature value from a feature type. Normally it'd just be "fromThpe", but needs something to indicate the "undefined" part

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spouliot What @timrisi said, just extending a little

The selector name is undefinedFeatureValueWithType: which from my reading states that you will get an undefined feature from the given type so FromUndefined from my reading says that what is undefined is the type parameter, not the object I am getting back that is why I think CreateUndefined matches a little better the intent of the above selector (give me an undefined object with the following type).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense but let's double check if Apple documentation is available (and match).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From docs:

Declares a value as undefined.

From Headers:

Represent an undefined value of a specified type

@spouliot should I change it? I think the later makes sense with CreateUndefined. Naming is hard heh.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right :) Create makes more sense, it's the output (not in input) that's undefined.

src/coreml.cs Outdated
MLFeatureValue FromDictionary (NSDictionary<NSObject, NSNumber> value, out NSError error);

[Export ("isEqualToFeatureValue:")]
bool IsEqualTo (MLFeatureValue value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double check but IIRC we tend to use IsEqual in recent/newer bindings

@monojenkins
Copy link
Collaborator

Build failure

@dalexsoto
Copy link
Member Author

@spouliot fixed! thanks!

Copy link
Contributor

@spouliot spouliot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few more things to check ::)

src/coreml.cs Outdated
}

[Watch (4,0), TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)]
[Static]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not adding [Internal] on them ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they are more discoverable than the indexers but if you want them internal I'll follow suite :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are they used somewhere else than the strong dictionary ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh sorry wrong thread haha, yeah these need to be internal my bad :D

src/coreml.cs Outdated
// From MLMultiArray (NSNumberDataAccess) Category

[Export ("objectAtIndexedSubscript:")]
NSNumber GetObjectAtIndexedSubscript (nint idx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetObject ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It this a duplicate of either Shape[] or Strides[] ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I cannot determine it from the documentation

src/coreml.cs Outdated
NSNumber GetObjectAtIndexedSubscript (nint idx);

[Export ("objectForKeyedSubscript:")]
NSNumber GetObjectForKeyedSubscript (NSNumber [] key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@dalexsoto
Copy link
Member Author

@spouliot done :)

@monojenkins
Copy link
Collaborator

Build failure

@monojenkins
Copy link
Collaborator

Build failure

@monojenkins
Copy link
Collaborator

Build failure

@dalexsoto
Copy link
Member Author

unrelated failure

@timrisi Are you ok with merging this? Is there anything pending?

@dalexsoto dalexsoto merged commit f34b61d into xamarin:xcode9 Jun 30, 2017
@dalexsoto dalexsoto deleted the coremlb1 branch June 30, 2017 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants