Skip to content

Commit 9edb314

Browse files
authored
[MetalPerforanceShadersGraph] Implement Xcode 16.0 beta 1-6 changes. (#21154)
Note: there were no changes in beta 2, beta 3, beta 5 or beta 6.
1 parent 7439acc commit 9edb314

15 files changed

+1597
-2553
lines changed

src/MetalPerformanceShadersGraph/MPSGraphEnums.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ public enum MPSGraphTensorNamedDataLayout : ulong {
2323
Chw = 4,
2424
Hwc = 5,
2525
Hw = 6,
26+
[Mac (13, 2), iOS (16, 3), TV (16, 3), MacCatalyst (16, 3)]
27+
Ncdhw = 7,
28+
[Mac (13, 2), iOS (16, 3), TV (16, 3), MacCatalyst (16, 3)]
29+
Ndhwc = 8,
30+
[Mac (13, 2), iOS (16, 3), TV (16, 3), MacCatalyst (16, 3)]
31+
Oidhw = 9,
32+
[Mac (13, 2), iOS (16, 3), TV (16, 3), MacCatalyst (16, 3)]
33+
Dhwio = 10,
2634
}
2735

2836
[Native]
@@ -31,6 +39,8 @@ public enum MPSGraphPaddingStyle : ulong {
3139
Valid = 1,
3240
Same = 2,
3341
ExplicitOffset = 3,
42+
[Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0)]
43+
OnnxSameLower = 4,
3444
}
3545

3646
[Native]
@@ -101,4 +111,15 @@ public enum MPSGraphRandomNormalSamplingMethod : ulong {
101111
BoxMuller = 1,
102112
}
103113

114+
[TV (15, 4), Mac (12, 3), iOS (15, 4), MacCatalyst (15, 4)]
115+
public enum MPSGraphOptimization : ulong {
116+
Level0 = 0,
117+
Level1 = 1L,
118+
}
119+
120+
[TV (15, 4), Mac (12, 3), iOS (15, 4), MacCatalyst (15, 4)]
121+
public enum MPSGraphOptimizationProfile : ulong {
122+
Performance = 0,
123+
PowerEfficiency = 1L,
124+
}
104125
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#nullable enable
2+
3+
using System;
4+
using System.Buffers;
5+
using System.Runtime.InteropServices;
6+
7+
using Foundation;
8+
using ObjCRuntime;
9+
using Metal;
10+
using MetalPerformanceShaders;
11+
12+
namespace MetalPerformanceShadersGraph {
13+
/// <summary>This enum is used to select how to initialize a new instance of a <see cref="MPSGraphExecutable" />.</summary>
14+
#if NET
15+
[SupportedOSPlatform ("ios17.0")]
16+
[SupportedOSPlatform ("maccatalyst17.0")]
17+
[SupportedOSPlatform ("macos14.0")]
18+
[SupportedOSPlatform ("tvos17.0")]
19+
#else
20+
[TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)]
21+
#endif
22+
public enum MPSGraphExecutableInitializationOption {
23+
/// <summary>The <c>packageUrl</c> parameter passed to the constructor is a url to a CoreML package.</summary>
24+
#if NET
25+
[SupportedOSPlatform ("ios18.0")]
26+
[SupportedOSPlatform ("maccatalyst18.0")]
27+
[SupportedOSPlatform ("macos15.0")]
28+
[SupportedOSPlatform ("tvos18.0")]
29+
#else
30+
[TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)]
31+
#endif
32+
CoreMLPackage,
33+
34+
/// <summary>The <c>packageUrl</c> parameter passed to the constructor is a url to a MPSGraph package.</summary>
35+
MPSGraphPackage,
36+
}
37+
38+
public partial class MPSGraphExecutable {
39+
/// <summary>Create a new MPSGraphExecutable instance from a package url and a compilation descriptor..</summary>
40+
/// <param name="packageUrl">The url to the package to use.</param>
41+
/// <param name="compilationDescriptor">The optional compilation descriptor use.</param>
42+
/// <param name="option">Use this option to specify whether the package url points to a CoreML package or an MPSGraph package.</param>
43+
#if NET
44+
[SupportedOSPlatform ("ios17.0")]
45+
[SupportedOSPlatform ("maccatalyst17.0")]
46+
[SupportedOSPlatform ("macos14.0")]
47+
[SupportedOSPlatform ("tvos17.0")]
48+
#else
49+
[TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)]
50+
#endif
51+
public MPSGraphExecutable (NSUrl packageUrl, MPSGraphCompilationDescriptor? compilationDescriptor, MPSGraphExecutableInitializationOption option)
52+
: base (NSObjectFlag.Empty)
53+
{
54+
switch (option) {
55+
case MPSGraphExecutableInitializationOption.CoreMLPackage:
56+
InitializeHandle (_InitWithCoreMLPackage (packageUrl, compilationDescriptor));
57+
break;
58+
case MPSGraphExecutableInitializationOption.MPSGraphPackage:
59+
InitializeHandle (_InitWithMPSGraphPackage (packageUrl, compilationDescriptor));
60+
break;
61+
default:
62+
throw new ArgumentOutOfRangeException (nameof (option), option, "Invalid enum value.");
63+
}
64+
}
65+
}
66+
}

src/frameworks.sources

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,7 @@ METALPERFORMANCESHADERSGRAPH_API_SOURCES = \
12751275
MetalPerformanceShadersGraph/MPSGraphEnums.cs \
12761276

12771277
METALPERFORMANCESHADERSGRAPH_SOURCES = \
1278+
MetalPerformanceShadersGraph/MPSGraphExecutable.cs \
12781279
MetalPerformanceShadersGraph/MPSGraphExtensions.cs \
12791280
MetalPerformanceShadersGraph/MPSGraphTensorData.cs \
12801281

src/metalperformanceshadersgraph.cs

Lines changed: 1164 additions & 21 deletions
Large diffs are not rendered by default.

tests/cecil-tests/ApiTest.KnownFailures.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ public partial class ApiTest {
6464
"The field 'Metal.MTLTextureType Metal.MTLTextureType::kCube' has incorrect capitalization: first letter is not upper case.",
6565
"The field 'Metal.MTLTextureType Metal.MTLTextureType::kCubeArray' has incorrect capitalization: first letter is not upper case.",
6666
"The field 'Metal.MTLTextureType Metal.MTLTextureType::kTextureBuffer' has incorrect capitalization: first letter is not upper case.",
67+
"The field 'MetalPerformanceShadersGraph.MPSGraphDeploymentPlatform MetalPerformanceShadersGraph.MPSGraphDeploymentPlatform::iOS' has incorrect capitalization: first letter is not upper case.",
68+
"The field 'MetalPerformanceShadersGraph.MPSGraphDeploymentPlatform MetalPerformanceShadersGraph.MPSGraphDeploymentPlatform::macOS' has incorrect capitalization: first letter is not upper case.",
69+
"The field 'MetalPerformanceShadersGraph.MPSGraphDeploymentPlatform MetalPerformanceShadersGraph.MPSGraphDeploymentPlatform::tvOS' has incorrect capitalization: first letter is not upper case.",
70+
"The field 'MetalPerformanceShadersGraph.MPSGraphDeploymentPlatform MetalPerformanceShadersGraph.MPSGraphDeploymentPlatform::visionOS' has incorrect capitalization: first letter is not upper case.",
6771
"The field 'ObjCRuntime.LinkTarget ObjCRuntime.LinkTarget::i386' has incorrect capitalization: first letter is not upper case.",
6872
"The field 'ObjCRuntime.LinkTarget ObjCRuntime.LinkTarget::x86_64' has incorrect capitalization: first letter is not upper case.",
6973
"The field 'Photos.PHAssetSourceType Photos.PHAssetSourceType::iTunesSynced' has incorrect capitalization: first letter is not upper case.",

0 commit comments

Comments
 (0)