-
Notifications
You must be signed in to change notification settings - Fork 515
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
Bind MetalPerformanceShadersGraph Framework #14286
Comments
I have started work on the binding: https://github.com/praeclarum/xamarin-macios/blob/mpsgraph/src/metalperformanceshadersgraph.cs |
If you've already built xamarin-macios locally, you can do: $ cd tests/xtro-sharpie
$ make gen-ios and then open the |
Great. That will save a lot of time! |
@rolfbjarne I have a question about how to bind their typedef NSArray<NSNumber *> MPSShape; Sharpie projects them as The functions that take these arguments are usually involved in graph construction so I'm not concerned about the overhead of converting from Would it be OK if I use |
Hello @praeclarum! Thank you for taking a stab at this! You can use BindAs here Some examples: [Export ("makeShape:")]
void MakeShape ([BindAs (typeof (int []))] NSNumber [] numbers);
[return: BindAs (typeof (int []))]
[Export ("getShape:")]
NSNumber [] GetShape ();
[BindAs (typeof (int []))]
[Export ("shape:")]
NSNumber [] SomeShape { get; set; } Hope this helps! |
@dalexsoto Great! That will really cleanup the API. |
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 It's also added as a unit test. 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` and `MPSGrapTensorData` and the `Variable` and `Constant` 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. Co-authored-by: Alex Soto <[email protected]> Co-authored-by: Rolf Bjarne Kvinge <[email protected]> Co-authored-by: Manuel de la Pena <[email protected]>
Apple has introduced yet another neural network library. :-) It's been around since iOS 14 and works on Mac/MacCat/TV also.
This one is pretty great though. It has a lot more features than
MPSNNGraph
and is a lot easier to use. It also looks pretty easy to bind. There are the main typesMPSGraph
,MPSGraphTensor
, andMPSGraphTensorData
and the rest is just a giant set of functions onMPSGraph
(a few structs and enums too).https://github.com/xamarin/xamarin-macios/blob/dfe6c2b5ab472a522240648e2556641efd586ec8/tests/xtro-sharpie/iOS-MetalPerformanceShadersGraph.todo
Apple has an example here: https://developer.apple.com/documentation/metalperformanceshadersgraph/training_a_neural_network_using_mps_graph?language=objc
Looks like they expect users to subclass
MPSGraph
so we need to make sure that's possible.I'm willing to do the work... if I can remember how. I'd love for this to get into dotnet 6.
Steps to Reproduce
Expected Behavior
The API is fully bound.
Actual Behavior
Nothing is bound currently.
Environment
The text was updated successfully, but these errors were encountered: