Skip to content

Commit

Permalink
[MLCompute] Add support for Xcode 13 beta 4. (#12348)
Browse files Browse the repository at this point in the history
  • Loading branch information
mandel-macaque committed Aug 5, 2021
1 parent 41253c3 commit 818198b
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 151 deletions.
20 changes: 20 additions & 0 deletions src/MLCompute/MLHelpers.cs
Expand Up @@ -235,4 +235,24 @@ public static string GetDebugDescription (this MLCComparisonOperation self)
return CFString.FromHandle (MLCComparisonOperationDebugDescription (self));
}
}

#if NET
[SupportedOSPlatform ("ios15.0")]
[SupportedOSPlatform ("tvos15.0")]
[SupportedOSPlatform ("macos12.0")]
[SupportedOSPlatform ("maccatalyst15.0")]
#else
[NoWatch]
[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
#endif
public static class MLCGradientClippingTypeExtensions {

[DllImport (Constants.MLComputeLibrary)]
static extern /* NSString */ IntPtr MLCGradientClippingTypeDebugDescription (MLCGradientClippingType gradientClippingType);

public static string GetDebugDescription (this MLCGradientClippingType self)
{
return CFString.FromHandle (MLCGradientClippingTypeDebugDescription (self));
}
}
}
142 changes: 141 additions & 1 deletion src/mlcompute.cs
Expand Up @@ -92,9 +92,15 @@ enum MLCConvolutionType {
enum MLCDataType {
Invalid = 0,
Float32 = 1,
[iOS (15,0), TV (15,0), Mac (12,0), MacCatalyst (15,0)]
Float16 = 3,
Boolean = 4,
Int64 = 5,
Int32 = 7,
Inot32 = 7,
[iOS (15,0), TV (15,0), Mac (12,0), MacCatalyst (15,0)]
Int8 = 8,
[iOS (15,0), TV (15,0), Mac (12,0), MacCatalyst (15,0)]
UInt8 = 9,
// Count, // must be last, not available in swift
}

Expand All @@ -104,6 +110,8 @@ enum MLCDeviceType /* int32_t */ {
Cpu = 0,
Gpu = 1,
Any = 2,
[iOS (15,0), TV (15,0), Mac (12,0), MacCatalyst (15,0)]
Ane = 3, // Apple neural engine
// Count, // must be last, not available in swift
}

Expand All @@ -116,6 +124,8 @@ enum MLCExecutionOptions : ulong {
Synchronous = 0x2,
Profiling = 0x4,
ForwardForInference = 0x8,
[iOS (15,0), TV (15,0), Mac (12,0), MacCatalyst (15,0)]
PerLayerProfiling = 0x10,
}

[iOS (14,0)][TV (14,0)][Mac (11,0)]
Expand Down Expand Up @@ -229,6 +239,14 @@ enum MLCSoftmaxOperation {
LogSoftmax = 1,
}

[iOS (15,0), TV (15,0), Mac (12,0), NoWatch, MacCatalyst (15,0)]
public enum MLCGradientClippingType {
Value = 0,
Norm = 1,
GlobalNorm = 2,
}


[iOS (14,0)][TV (14,0)][Mac (11,0)]
[NoWatch]
[BaseType (typeof (NSObject))]
Expand Down Expand Up @@ -286,6 +304,10 @@ interface MLCLayer {
[Static]
[Export ("supportsDataType:onDevice:")]
bool SupportsDataType (MLCDataType dataType, MLCDeviceType device);

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("deviceType")]
MLCDeviceType DeviceType { get; }
}

[iOS (14,0)][TV (14,0)][Mac (11,0)]
Expand Down Expand Up @@ -442,6 +464,18 @@ interface MLCOptimizer : NSCopying {

[Export ("regularizationType")]
MLCRegularizationType RegularizationType { get; }

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("gradientClippingType")]
MLCGradientClippingType GradientClippingType { get; }

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("maximumClippingNorm")]
float MaximumClippingNorm { get; }

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("customGlobalNorm")]
float CustomGlobalNorm { get; }
}

[iOS (14,0)][TV (14,0)][Mac (11,0)]
Expand Down Expand Up @@ -478,6 +512,23 @@ interface MLCOptimizerDescriptor : NSCopying {
[Static]
[Export ("descriptorWithLearningRate:gradientRescale:appliesGradientClipping:gradientClipMax:gradientClipMin:regularizationType:regularizationScale:")]
MLCOptimizerDescriptor Create (float learningRate, float gradientRescale, bool appliesGradientClipping, float gradientClipMax, float gradientClipMin, MLCRegularizationType regularizationType, float regularizationScale);

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Static]
[Export ("descriptorWithLearningRate:gradientRescale:appliesGradientClipping:gradientClippingType:gradientClipMax:gradientClipMin:maximumClippingNorm:customGlobalNorm:regularizationType:regularizationScale:")]
MLCOptimizerDescriptor Create (float learningRate, float gradientRescale, bool appliesGradientClipping, MLCGradientClippingType gradientClippingType, float gradientClipMax, float gradientClipMin, float maximumClippingNorm, float customGlobalNorm, MLCRegularizationType regularizationType, float regularizationScale);

[TV (15, 0), Mac (12, 0), iOS (15, 0), MacCatalyst (15,0)]
[Export ("gradientClippingType")]
MLCGradientClippingType GradientClippingType { get; }

[TV (15, 0), Mac (12, 0), iOS (15, 0), MacCatalyst (15,0)]
[Export ("maximumClippingNorm")]
float MaximumClippingNorm { get; }

[TV (15, 0), Mac (12, 0), iOS (15, 0), MacCatalyst (15,0)]
[Export ("customGlobalNorm")]
float CustomGlobalNorm { get; }
}

[iOS (14,0)][TV (14,0)][Mac (11,0)]
Expand All @@ -498,13 +549,22 @@ interface MLCAdamOptimizer : NSCopying {
[Export ("timeStep")]
nuint TimeStep { get; }

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("usesAMSGrad")]
bool UsesAmsGrad { get; }

[Static]
[Export ("optimizerWithDescriptor:")]
MLCAdamOptimizer Create (MLCOptimizerDescriptor optimizerDescriptor);

[Static]
[Export ("optimizerWithDescriptor:beta1:beta2:epsilon:timeStep:")]
MLCAdamOptimizer Create (MLCOptimizerDescriptor optimizerDescriptor, float beta1, float beta2, float epsilon, nuint timeStep);

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Static]
[Export ("optimizerWithDescriptor:beta1:beta2:epsilon:usesAMSGrad:timeStep:")]
MLCAdamOptimizer Create (MLCOptimizerDescriptor optimizerDescriptor, float beta1, float beta2, float epsilon, bool usesAmsGrad, nuint timeStep);
}

[iOS (14,0)][TV (14,0)][Mac (11,0)]
Expand Down Expand Up @@ -538,11 +598,21 @@ interface MLCDevice : NSCopying {
[return: NullAllowed]
MLCDevice GetDevice (IMTLDevice[] gpus);

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Static]
[Export ("aneDevice")]
[return: NullAllowed]
MLCDevice GetAneDevice ();

[iOS (14,2)][TV (14,2)]
[Static]
[Export ("deviceWithType:selectsMultipleComputeDevices:")]
[return: NullAllowed]
MLCDevice GetDevice (MLCDeviceType type, bool selectsMultipleComputeDevices);

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("actualDeviceType")]
MLCDeviceType ActualDeviceType { get; }
}

[iOS (14,0)][TV (14,0)][Mac (11,0)]
Expand Down Expand Up @@ -673,6 +743,31 @@ interface MLCTensor : NSCopying {

[Export ("bindOptimizerData:deviceData:")]
bool BindOptimizer (MLCTensorData[] data, [NullAllowed] MLCTensorOptimizerDeviceData[] deviceData);

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("tensorByQuantizingToType:scale:bias:")]
[return: NullAllowed]
MLCTensor CreateByQuantizing (MLCDataType type, float scale, nint bias);

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("tensorByDequantizingToType:scale:bias:")]
[return: NullAllowed]
MLCTensor CreateByDequantizing (MLCDataType type, MLCTensor scale, MLCTensor bias);

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("tensorByQuantizingToType:scale:bias:axis:")]
[return: NullAllowed]
MLCTensor CreateByQuantizing (MLCDataType type, MLCTensor scale, MLCTensor bias, nint axis);

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("tensorByDequantizingToType:scale:bias:axis:")]
[return: NullAllowed]
MLCTensor CreateByDequantizing (MLCDataType type, MLCTensor scale, MLCTensor bias, nint axis);

[Static]
[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("tensorWithShape:randomInitializerType:dataType:")]
MLCTensor Create ([BindAs (typeof (nint[]))] NSNumber[] shape, MLCRandomInitializerType randomInitializerType, MLCDataType dataType);
}

[iOS (14,0)][TV (14,0)][Mac (11,0)]
Expand Down Expand Up @@ -2282,4 +2377,49 @@ interface MLCSelectionLayer {
[Export ("layer")]
MLCSelectionLayer Create ();
}

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface MLCPlatform {

[Static]
[Export ("setRNGSeedTo:")]
void SetRngSeed ([BindAs (typeof (nuint))] NSNumber seed);

[return: BindAs (typeof (nuint)), NullAllowed]
[Static]
[Export ("getRNGseed")]
NSNumber GetRngSeed ();
}

[TV (15,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[BaseType (typeof (MLCOptimizer))]
[DisableDefaultCtor]
interface MLCAdamWOptimizer : NSCopying
{
[Export ("beta1")]
float Beta1 { get; }

[Export ("beta2")]
float Beta2 { get; }

[Export ("epsilon")]
float Epsilon { get; }

[Export ("usesAMSGrad")]
bool UsesAmsGrad { get; }

[Export ("timeStep")]
nuint TimeStep { get; }

[Static]
[Export ("optimizerWithDescriptor:")]
MLCAdamWOptimizer GetOptimizer (MLCOptimizerDescriptor optimizerDescriptor);

[Static]
[Export ("optimizerWithDescriptor:beta1:beta2:epsilon:usesAMSGrad:timeStep:")]
MLCAdamWOptimizer GetOptimizer (MLCOptimizerDescriptor optimizerDescriptor, float beta1, float beta2, float epsilon, bool usesAmsGrad, nuint timeStep);
}

}
37 changes: 0 additions & 37 deletions tests/xtro-sharpie/MacCatalyst-MLCompute.todo

This file was deleted.

4 changes: 2 additions & 2 deletions tests/xtro-sharpie/common-MLCompute.ignore
Expand Up @@ -2,9 +2,9 @@
!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
!missing-enum-value! MLCDeviceType native value MLCDeviceTypeCount = 4 not bound
!missing-enum-value! MLCDataType native value MLCDataTypeCount = 10 not bound
37 changes: 0 additions & 37 deletions tests/xtro-sharpie/iOS-MLCompute.todo

This file was deleted.

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

This file was deleted.

4 comments on commit 818198b

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

❌ [CI Build] Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

API & Generator diff

ℹ️ API Diff (from PR only) (please review changes)
ℹ️ Generator Diff (please review changes)

Packages generated

View packages

Test results

3 tests failed, 222 tests passed.

Failed tests

  • monotouch-test/Mac Catalyst/Debug [dotnet]: Failed (Tests run: 2638 Passed: 2490 Inconclusive: 35 Failed: 1 Ignored: 147)
  • Documentation/All: Failed
  • DotNet tests: Failed (Execution failed with exit code 1)

Pipeline on Agent XAMBOT-1030.BigSur
[MLCompute] Add support for Xcode 13 beta 4. (#12348)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Tests were not ran (VSTS: device tests tvOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
[MLCompute] Add support for Xcode 13 beta 4. (#12348)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Tests were not ran (VSTS: device tests iOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
[MLCompute] Add support for Xcode 13 beta 4. (#12348)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

❌ Tests failed on macOS M1 - Mac Big Sur (11.5) ❌

Tests failed on M1 - Mac Big Sur (11.5).

Failed tests are:

  • xammac_tests

Pipeline on Agent
[MLCompute] Add support for Xcode 13 beta 4. (#12348)

Please sign in to comment.