-
Notifications
You must be signed in to change notification settings - Fork 507
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
Add MetalPerformanceShadersGraph Bindings #14303
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll continue reviewing/address questions tomorrow with a fresh brain heh, but so far it is looking great!
Co-authored-by: Alex Soto <[email protected]>
Co-authored-by: Alex Soto <[email protected]>
This comment has been minimized.
This comment has been minimized.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@rolfbjarne I know I’ve seen this error before, but I frustratingly can’t remember the context.. I’m pretty sure the Apple sample produces this error too on old bad implementations of MPSGraph. I know I ran into it, got frustrated and moved on. I was working with the Swift sample at the time, but I can’t remember the OS. I can’t tell from the tests whether this is working on Mac 12 (M1 and Intel). If it is, then I’m willing to chalk this up to old bugs in Mac 11. I know the Apple sample works on Mac 12.2 M1. If this does too, then I think we should just disable the test for older Mac versions. |
@praeclarum ok, I'll just make the test require macOS 12+ |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
📚 [CI Build] Artifacts 📚Artifacts were not provided. Pipeline on Agent XAMBOT-1167.Monterey |
📋 [PR Build] API Diff 📋API Current PR diffℹ️ API Diff (from PR only) (please review changes) View dotnet API diffView dotnet legacy API diffAPI diff✅ API Diff from stable View dotnet API diffView dotnet legacy API diffGenerator diffℹ️ Generator Diff (please review changes) Pipeline on Agent XAMBOT-1164.Monterey' |
❌ [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌Failed tests are:
Pipeline on Agent |
💻 [PR Build] Tests on macOS Mac Catalina (10.15) passed 💻✅ All tests on macOS Mac Catalina (10.15) passed. Pipeline on Agent |
❌ [CI Build] Tests failed on VSTS: simulator tests iOS ❌Tests failed on VSTS: simulator tests iOS. Test results23 tests failed, 130 tests passed.Failed tests
Pipeline on Agent XAMBOT-1023.Monterey' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like all test failures but one are network related (https://github.com/xamarin/maccore/issues/1067).
The remaining one seems to be a simulator hiccup.
I'm very pleased to present full bindings to the MetalPerformanceShadersGraph framework!
I'm happy with how everything turned out with the exception of a few notes and questions below.
I re-implemented Apple's MNIST sample (from https://developer.apple.com/documentation/metalperformanceshadersgraph/training_a_neural_network_using_mps_graph) here:
https://gist.github.com/praeclarum/b8077771fb341a1f9c28240113e00425
Fixes #14286
Notes
Although the API says it works on macOS 11, it has bugs and crashes with errors even with Apple’s Swift examples. It’s better on macOS 12. iOS 14 and on is fine.
MPSGraphSparseStorageType
has terrible names. They match Apple's but I wish they were better.I added convenience methods to
MPSNDArray
andMPSGrapTensorData
and theVariable
andConstant
operations to decrease the amount of unsafe code users have to write. I currently do this for 32-bit floats, the most common data type.Questions
In Target.cs GatherFrameworks, Metal is removed from simulator builds. Doesn’t Metal work now?
Is the way I handle
MPSGraphType
OK?MPSGraphType
was introduced in iOS 15 (macOS 12) and became the base class forMPSGraphShapedType
which existed in iOS 14. In iOS 14,MPSGraphShapedType
inherits directly fromNSObject
. To keep compatibility,MPSGraphType
is type-erased to justNSObject
and implementers have to addNSCopying
.