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

[mlcompute] Update for xcode12.5 beta 3 #10905

Merged
merged 2 commits into from
Mar 19, 2021
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
13 changes: 13 additions & 0 deletions src/MLCompute/MLHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,17 @@ public static string GetDebugDescription (this MLCLstmResultMode self)
return CFString.FetchString (MLCLSTMResultModeDebugDescription (self));
}
}

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[NoWatch]
public static class MLCComparisonOperationExtensions {

[DllImport (Constants.MLComputeLibrary)]
static extern /* NSString */ IntPtr MLCComparisonOperationDebugDescription (MLCComparisonOperation operation);

public static string GetDebugDescription (this MLCComparisonOperation self)
{
return CFString.FetchString (MLCComparisonOperationDebugDescription (self));
}
}
}
155 changes: 155 additions & 0 deletions src/mlcompute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ enum MLCActivationType {
TanhShrink = 16,
Threshold = 17,
Gelu = 18,
[TV (14,5)][Mac (11,3)][iOS (14,5)]
HardSwish = 19,
[TV (14,5)][Mac (11,3)][iOS (14,5)]
Clamp = 20,
// Count, // must be last, not available in swift
}

Expand Down Expand Up @@ -64,6 +68,14 @@ enum MLCArithmeticOperation {
Exp2 = 23,
Log = 24,
Log2 = 25,
[TV (14,5)][Mac (11,3)][iOS (14,5)]
MultiplyNoNaN = 26,
[TV (14,5)][Mac (11,3)][iOS (14,5)]
DivideNoNaN = 27,
[TV (14,5)][Mac (11,3)][iOS (14,5)]
Min = 28,
[TV (14,5)][Mac (11,3)][iOS (14,5)]
Max = 29,
// Count, // must be last, not available in swift
}

Expand Down Expand Up @@ -186,6 +198,12 @@ enum MLCReductionType {
Min = 4,
ArgMax = 5,
ArgMin = 6,
[TV (14,5)][Mac (11,3)][iOS (14,5)]
L1Norm = 7,
[TV (14,5)][Mac (11,3)][iOS (14,5)]
Any = 8,
[TV (14,5)][Mac (11,3)][iOS (14,5)]
All = 9,
// Count, // must be last, not available in swift
}

Expand Down Expand Up @@ -386,6 +404,16 @@ interface MLCActivationLayer {
[Static]
[Export ("geluLayer")]
MLCActivationLayer GeluLayer { get; }

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[Static]
[Export ("hardSwishLayer")]
MLCActivationLayer CreateHardSwishLayer ();

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[Static]
[Export ("clampLayerWithMinValue:maxValue:")]
MLCActivationLayer CreateClampLayer (float minValue, float maxValue);
}

[iOS (14,0)][TV (14,0)][Mac (11,0)]
Expand Down Expand Up @@ -660,6 +688,11 @@ interface MLCTensorData {
[Static]
[Export ("dataWithImmutableBytesNoCopy:length:")]
MLCTensorData CreateFromImmutableBytesNoCopy (IntPtr bytes, nuint length);

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[Static]
[Export ("dataWithBytesNoCopy:length:deallocator:")]
MLCTensorData CreateFromBytesNoCopy (IntPtr bytes, nuint length, Action<IntPtr, nuint> deallocator);
}

[iOS (14,0)][TV (14,0)][Mac (11,0)]
Expand Down Expand Up @@ -1135,6 +1168,14 @@ interface MLCInstanceNormalizationLayer {
[Export ("momentum")]
float Momentum { get; }

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[NullAllowed, Export ("mean", ArgumentSemantic.Retain)]
MLCTensor Mean { get; }

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[NullAllowed, Export ("variance", ArgumentSemantic.Retain)]
MLCTensor Variance { get; }

[Static]
[Export ("layerWithFeatureChannelCount:beta:gamma:varianceEpsilon:")]
[return: NullAllowed]
Expand All @@ -1144,6 +1185,12 @@ interface MLCInstanceNormalizationLayer {
[Export ("layerWithFeatureChannelCount:beta:gamma:varianceEpsilon:momentum:")]
[return: NullAllowed]
MLCInstanceNormalizationLayer Create (nuint featureChannelCount, [NullAllowed] MLCTensor beta, [NullAllowed] MLCTensor gamma, float varianceEpsilon, float momentum);

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[Static]
[Export ("layerWithFeatureChannelCount:mean:variance:beta:gamma:varianceEpsilon:momentum:")]
[return: NullAllowed]
MLCInstanceNormalizationLayer Create (nuint featureChannelCount, MLCTensor mean, MLCTensor variance, [NullAllowed] MLCTensor beta, [NullAllowed] MLCTensor gamma, float varianceEpsilon, float momentum);
}

[iOS (14,0)][TV (14,0)][Mac (11,0)]
Expand Down Expand Up @@ -1668,10 +1715,21 @@ interface MLCReductionLayer {
[Export ("dimension")]
nuint Dimension { get; }

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[Export ("dimensions")]
[BindAs (typeof (nuint[]))]
NSNumber[] Dimensions { get; }

[Static]
[Export ("layerWithReductionType:dimension:")]
[return: NullAllowed]
MLCReductionLayer Create (MLCReductionType reductionType, nuint dimension);

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[Static]
[Export ("layerWithReductionType:dimensions:")]
[return: NullAllowed]
MLCReductionLayer Create (MLCReductionType reductionType, [BindAs (typeof (nuint[]))] NSNumber[] dimensions);
}

[iOS (14,0)][TV (14,0)][Mac (11,0)]
Expand All @@ -1680,6 +1738,11 @@ interface MLCReductionLayer {
[DisableDefaultCtor]
interface MLCReshapeLayer {

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[Export ("shape", ArgumentSemantic.Copy)]
[BindAs (typeof (nint[]))]
NSNumber[] Shape { get; }

[Static]
[Export ("layerWithShape:")]
[return: NullAllowed]
Expand Down Expand Up @@ -1981,6 +2044,21 @@ interface MLCGraph {

[Export ("resultTensorsForLayer:")]
MLCTensor[] GetResultTensors (MLCLayer layer);

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[Export ("gatherWithDimension:source:indices:")]
[return: NullAllowed]
MLCTensor Gather (nuint dimension, MLCTensor source, MLCTensor indices);

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[Export ("scatterWithDimension:source:indices:copyFrom:reductionType:")]
[return: NullAllowed]
MLCTensor Scatter (nuint dimension, MLCTensor source, MLCTensor indices, MLCTensor copyFrom, MLCReductionType reductionType);

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[Export ("selectWithSources:condition:")]
[return: NullAllowed]
MLCTensor Select (MLCTensor[] sources, MLCTensor condition);
}

[TV (14,0), Mac (11,0), iOS (14,0)]
Expand Down Expand Up @@ -2014,6 +2092,10 @@ interface MLCTrainingGraph {
[Export ("compileWithOptions:device:")]
bool Compile (MLCGraphCompilationOptions options, MLCDevice device);

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[Export ("compileWithOptions:device:inputTensors:inputTensorsData:")]
bool Compile (MLCGraphCompilationOptions options, MLCDevice device, [NullAllowed] NSDictionary<NSString, MLCTensor> inputTensors, [NullAllowed] NSDictionary<NSString, MLCTensorData> inputTensorsData);

[Export ("compileOptimizer:")]
bool Compile (MLCOptimizer optimizer);

Expand Down Expand Up @@ -2102,6 +2184,10 @@ interface MLCInferenceGraph {
[Export ("compileWithOptions:device:")]
bool Compile (MLCGraphCompilationOptions options, MLCDevice device);

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[Export ("compileWithOptions:device:inputTensors:inputTensorsData:")]
bool Compile (MLCGraphCompilationOptions options, MLCDevice device, [NullAllowed] NSDictionary<NSString, MLCTensor> inputTensors, [NullAllowed] NSDictionary<NSString, MLCTensorData> inputTensorsData);

[Export ("linkWithGraphs:")]
bool Link (MLCInferenceGraph[] graphs);

Expand All @@ -2121,4 +2207,73 @@ interface MLCInferenceGraph {
[Export ("executeWithInputsData:lossLabelsData:lossLabelWeightsData:outputsData:batchSize:options:completionHandler:")]
bool Execute (NSDictionary<NSString, MLCTensorData> inputsData, [NullAllowed] NSDictionary<NSString, MLCTensorData> lossLabelsData, [NullAllowed] NSDictionary<NSString, MLCTensorData> lossLabelWeightsData, [NullAllowed] NSDictionary<NSString, MLCTensorData> outputsData, nuint batchSize, MLCExecutionOptions options, [NullAllowed] MLCGraphCompletionHandler completionHandler);
}

[TV (14,5)][Mac (11,3)][iOS (14,5)]
enum MLCComparisonOperation {
Equal = 0,
NotEqual = 1,
Less = 2,
Greater = 3,
LessOrEqual = 4,
GreaterOrEqual = 5,
LogicalAnd = 6,
LogicalOr = 7,
LogicalNot = 8,
LogicalNand = 9,
LogicalNor = 10,
LogicalXor = 11,
}

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[BaseType (typeof (MLCLayer))]
[DisableDefaultCtor]
interface MLCComparisonLayer {

[Export ("operation")]
MLCComparisonOperation Operation { get; }

[Static]
[Export ("layerWithOperation:")]
MLCComparisonLayer Create (MLCComparisonOperation operation);
}

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[BaseType (typeof (MLCLayer))]
[DisableDefaultCtor]
interface MLCGatherLayer {

[Export ("dimension")]
nuint Dimension { get; }

[Static]
[Export ("layerWithDimension:")]
MLCGatherLayer Create (nuint dimension);
}

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[BaseType (typeof (MLCLayer))]
[DisableDefaultCtor]
interface MLCScatterLayer {

[Export ("dimension")]
nuint Dimension { get; }

[Export ("reductionType")]
MLCReductionType ReductionType { get; }

[Static]
[Export ("layerWithDimension:reductionType:")]
[return: NullAllowed]
MLCScatterLayer Create (nuint dimension, MLCReductionType reductionType);
}

[TV (14,5)][Mac (11,3)][iOS (14,5)]
[BaseType (typeof (MLCLayer))]
[DisableDefaultCtor]
interface MLCSelectionLayer {

[Static]
[Export ("layer")]
MLCSelectionLayer Create ();
}
}
4 changes: 4 additions & 0 deletions tests/xtro-sharpie/common-MLCompute.ignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## `*Count` are not constant values and can change in the future
!missing-enum-value! MLCActivationType native value MLCActivationTypeCount = 21 not bound
!missing-enum-value! MLCArithmeticOperation native value MLCArithmeticOperationCount = 30 not bound
!missing-enum-value! MLCComparisonOperation native value MLCComparisonOperationCount = 12 not bound
!missing-enum-value! MLCDataType native value MLCDataTypeCount = 8 not bound
!missing-enum-value! MLCDeviceType native value MLCDeviceTypeCount = 3 not bound
!missing-enum-value! MLCLossType native value MLCLossTypeCount = 9 not bound
!missing-enum-value! MLCPoolingType native value MLCPoolingTypeCount = 4 not bound
!missing-enum-value! MLCRandomInitializerType native value MLCRandomInitializerTypeCount = 4 not bound
!missing-enum-value! MLCReductionType native value MLCReductionTypeCount = 10 not bound
41 changes: 0 additions & 41 deletions tests/xtro-sharpie/iOS-MLCompute.todo

This file was deleted.

41 changes: 0 additions & 41 deletions tests/xtro-sharpie/macOS-MLCompute.todo

This file was deleted.

Loading