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

[MPSCore] Update for Xcode 11 beta 1 to 7 #6935

Closed
wants to merge 6 commits into from

Conversation

praeclarum
Copy link
Contributor

@praeclarum praeclarum commented Sep 7, 2019

This updates all the APIs to beta7.

Notes:

  • MPSCommandBuffer wraps an IMTLCommandBuffer - I think I got it right but please check (it's important).
  • MPSNDArray is the big new data type that is similar to MPSMatrix and MPSImage.
  • MPSNDArray has some methods that optionally return strides. I offer 3 versions of those functions: parameterless, IntPtr, and nint[].
  • MPSNDArray.WriteBytes buffer is an IntPtr which isn't ideal. But NDArrays can be any
    data type so the alternative is to write primitive type overloads. I'm putting the burden on the app developer to fixed their data.
  • MPSNDArrayAllocators aren't really user definable but I wasn't able to get NSCopying and friends working without the [Model]
  • This also removes MetalPerformanceShaders from Dlfcn as it was conflicting with the one defined in Libraries.g.cs

This also removes the hardcoded MetalPerformanceShaders library from Dlfcn
as it conflicted with Libraries.g.cs
@monojenkins
Copy link
Collaborator

Build failure
Build succeeded
API Diff (from stable)
ℹ️ API Diff (from PR only) (please review changes)
ℹ️ Generator Diff (please review changes)
🔥 Test run failed 🔥

Test results

8 tests failed, 83 tests passed.

Failed tests

  • introspection/Mac Modern/Debug: Failed (Test run failed.)
  • Xtro/Mac: BuildFailure
  • introspection/iOS Unified 32-bits - simulator/Debug: Failed
  • introspection/iOS Unified 32-bits - simulator/Debug (iOS 10.3): Failed
  • introspection/iOS Unified 64-bits - simulator/Debug: Failed
  • introspection/tvOS - simulator/Debug: Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3): Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2): Failed

Copy link
Member

@dalexsoto dalexsoto left a comment

Choose a reason for hiding this comment

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

Looking good ❤️

static extern MPSImageType MPSGetImageType (IntPtr image);

[iOS (13,0), TV (12,0), Mac (10,15)][Introduced (PlatformName.MacCatalyst, 13, 0)]
public MPSImageType ImageType => MPSGetImageType (Handle);
Copy link
Member

Choose a reason for hiding this comment

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

mmm this reminds me a little of #6530 (Which I still need to fix heh).
Will the property it be safe for the debugger?
what happens if Handle is invalid (IntPtr.Zero)?

Copy link
Contributor Author

@praeclarum praeclarum Sep 7, 2019

Choose a reason for hiding this comment

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

Fair :-)

Yes it's safe because, ImageType is just an integer. I think that this is good info to have when you're in the debugger, that's why I made it a property.

The argument is marked nonnull so I assume bad things if null is passed. FWIW, I don't know if any NSObject properties are protected from Zero Handles.

I think this is fine, but I also don't think this function will be used a lot in real code, so I won't push the property.

src/metalperformanceshaders.cs Outdated Show resolved Hide resolved
src/metalperformanceshaders.cs Outdated Show resolved Hide resolved
src/metalperformanceshaders.cs Outdated Show resolved Hide resolved
src/metalperformanceshaders.cs Outdated Show resolved Hide resolved
void Reshape (nuint numberOfDimensions, IntPtr dimensionSizes);

[Export ("reshapeWithShape:")]
void Reshape (NSNumber[] shape);
Copy link
Member

Choose a reason for hiding this comment

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

could this be a more concrete type? do you happen to know? if you do then you can do something like this

		void Reshape ([BindAs (typeof (nint []))] NSNumber[] shape);

BindAs docs https://docs.microsoft.com/en-us/xamarin/cross-platform/macios/binding/objective-c-libraries?tabs=macos#binding-nsvalue-nsnumber-and-nsstring-to-a-better-type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, no I didn't know that, thanks!

Thing is, I really want params for these puppies and that's why I provided the params version in manual code. Is there an attribute to get params?

@monojenkins
Copy link
Collaborator

Build failure
Build failed or was aborted

@monojenkins
Copy link
Collaborator

Build failure
Build failed or was aborted

@monojenkins
Copy link
Collaborator

Build failure
Build failed or was aborted

@monojenkins
Copy link
Collaborator

Build failure
Build succeeded
API Diff (from stable)
ℹ️ API Diff (from PR only) (please review changes)
ℹ️ Generator Diff (please review changes)
🔥 Test run failed 🔥

Test results

8 tests failed, 83 tests passed.

Failed tests

  • introspection/Mac Modern/Debug: Failed (Test run failed.)
  • Xtro/Mac: BuildFailure
  • introspection/iOS Unified 32-bits - simulator/Debug: Failed
  • introspection/iOS Unified 32-bits - simulator/Debug (iOS 10.3): Failed
  • introspection/iOS Unified 64-bits - simulator/Debug: Failed
  • introspection/tvOS - simulator/Debug: Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 10.3): Failed
  • introspection/tvOS - simulator/Debug (tvOS 10.2): Failed

@@ -0,0 +1,90 @@
#if (XAMCORE_2_0 && !MONOMAC) && !XAMCORE_4_0
Copy link
Member

Choose a reason for hiding this comment

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

This #if condition looks a bit weird, !XAMCORE_4_0 is used for API we'll want to remove in the future.

Exactly which are the circumstances you wanted to include/exclude?

Copy link
Contributor Author

@praeclarum praeclarum Sep 9, 2019

Choose a reason for hiding this comment

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

I'll be honest I have no idea what any of these defines mean. I stole them from MPSMatrixDescriptor.cs.

MPS files use a combination of:

#if (XAMCORE_2_0 && !MONOMAC) && !XAMCORE_4_0

and

#if XAMCORE_2_0 || !MONOMAC

I would like to include every platform. So I'm guessing XAMCORE_2_0 || !MONOMAC is the one I want? Are those just guarding against the old APIs?

Copy link
Member

Choose a reason for hiding this comment

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

Just remove the entire #if ... condition, as far as I can tell it should be fine.

public unsafe static MPSNDArrayDescriptor Create (MPSDataType dataType, params nuint[] dimensionSizes)
{
fixed (nuint* p = dimensionSizes) {
return Create (dataType, (nuint)dimensionSizes.Length, (IntPtr)p);
Copy link
Member

Choose a reason for hiding this comment

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

NullReferenceException if dimensionSizes is null. This method needs an argument check that throws an ArgumentNullException.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep!

public unsafe void Reshape (params nuint[] dimensionSizes)
{
fixed (nuint* p = dimensionSizes) {
Reshape ((nuint)dimensionSizes.Length, (IntPtr)p);
Copy link
Member

Choose a reason for hiding this comment

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

NullReferenceException if dimensionSizes is null. This method needs an argument check that throws an ArgumentNullException.

@dalexsoto dalexsoto added the community Community contribution ❤ label Sep 10, 2019
@praeclarum
Copy link
Contributor Author

praeclarum commented Nov 11, 2019

@rolfbjarne @dalexsoto Can you recommend how to proceed with this PR given that this branch has been released? Should I rebase to master and force push? Or start a new PR?

@rolfbjarne
Copy link
Member

@praeclarum I think it's best to rebase on the master branch and creating a new PR is the best way to go (alternatively rebase on the xcode11.3 branch, which will get the PR in a stable release faster, but the down side is that the code will get less tested before it's released).

@praeclarum
Copy link
Contributor Author

OK, will open a new PR against xcode11.3

@praeclarum praeclarum closed this Nov 15, 2019
praeclarum added a commit to praeclarum/xamarin-macios that referenced this pull request Nov 15, 2019
This includes updates from PRs xamarin#6932 and xamarin#6935

It adds new functionality to the neural network components.
This is still not the complete API for 11.3
dalexsoto added a commit to dalexsoto/xamarin-macios that referenced this pull request Jun 12, 2020
Co-Authored-By: Frank A. Krueger <[email protected]>

This includes updates from PRs xamarin#6932, xamarin#6935 and xamarin#7461

It adds new functionality to the neural network components.
This is still not the complete API for 11.3

* Update src/metalperformanceshaders.cs

Co-Authored-By: Rolf Bjarne Kvinge <[email protected]>

* Make changes requested by @rolfbjarne

* Fix binding of default random distribution creation

The parameterless function creates new
default distributions and is not a property.
It is a counterpart of CreateUniform.

* Expose public APIs for MPSCnnConvolutionTransposeNode

These APIs are public and documented at: https://developer.apple.com/documentation/metalperformanceshaders/mpscnnconvolutiontransposenode/2942641-initwithsource?language=objc

I have also tested that they work.

* Reintroduce compat API.

* Fix acronym casing.

* Fix introspection tests.

* Fix xtro.

* One last xtro issue.

* Fix more xtro.

* Another introspection fix.

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
dalexsoto added a commit to dalexsoto/xamarin-macios that referenced this pull request Jun 12, 2020
This includes updates from PRs xamarin#6932, xamarin#6935 and xamarin#7461

It adds new functionality to the neural network components.
This is still not the complete API for 11.3

* Update src/metalperformanceshaders.cs

Co-Authored-By: Rolf Bjarne Kvinge <[email protected]>

* Make changes requested by @rolfbjarne

* Fix binding of default random distribution creation

The parameterless function creates new
default distributions and is not a property.
It is a counterpart of CreateUniform.

* Expose public APIs for MPSCnnConvolutionTransposeNode

These APIs are public and documented at: https://developer.apple.com/documentation/metalperformanceshaders/mpscnnconvolutiontransposenode/2942641-initwithsource?language=objc

I have also tested that they work.

* Reintroduce compat API.

* Fix acronym casing.

* Fix introspection tests.

* Fix xtro.

* One last xtro issue.

* Fix more xtro.

* Another introspection fix.

Co-authored-By: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
dalexsoto added a commit that referenced this pull request Jun 13, 2020
* [MetalPerformanceShaders] Neural Networks Update to Xcode 11

This includes updates from PRs #6932, #6935 and #7461

It adds new functionality to the neural network components.
This is still not the complete API for 11.3

* Update src/metalperformanceshaders.cs

Co-Authored-By: Rolf Bjarne Kvinge <[email protected]>

* Make changes requested by @rolfbjarne

* Fix binding of default random distribution creation

The parameterless function creates new
default distributions and is not a property.
It is a counterpart of CreateUniform.

* Expose public APIs for MPSCnnConvolutionTransposeNode

These APIs are public and documented at: https://developer.apple.com/documentation/metalperformanceshaders/mpscnnconvolutiontransposenode/2942641-initwithsource?language=objc

I have also tested that they work.

* Reintroduce compat API.

* Fix acronym casing.

* Fix introspection tests.

* Fix xtro.

* One last xtro issue.

* Fix more xtro.

* Another introspection fix.

Co-authored-By: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply suggestions from code review

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply feedback

* Please the typo guardians

Co-authored-by: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
dalexsoto added a commit to dalexsoto/xamarin-macios that referenced this pull request Jul 17, 2020
…#8844)

* [MetalPerformanceShaders] Neural Networks Update to Xcode 11

This includes updates from PRs xamarin#6932, xamarin#6935 and xamarin#7461

It adds new functionality to the neural network components.
This is still not the complete API for 11.3

* Update src/metalperformanceshaders.cs

Co-Authored-By: Rolf Bjarne Kvinge <[email protected]>

* Make changes requested by @rolfbjarne

* Fix binding of default random distribution creation

The parameterless function creates new
default distributions and is not a property.
It is a counterpart of CreateUniform.

* Expose public APIs for MPSCnnConvolutionTransposeNode

These APIs are public and documented at: https://developer.apple.com/documentation/metalperformanceshaders/mpscnnconvolutiontransposenode/2942641-initwithsource?language=objc

I have also tested that they work.

* Reintroduce compat API.

* Fix acronym casing.

* Fix introspection tests.

* Fix xtro.

* One last xtro issue.

* Fix more xtro.

* Another introspection fix.

Co-authored-By: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply suggestions from code review

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply feedback

* Please the typo guardians

Co-authored-by: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
dalexsoto added a commit to dalexsoto/xamarin-macios that referenced this pull request Jul 17, 2020
…#8844)

* [MetalPerformanceShaders] Neural Networks Update to Xcode 11

This includes updates from PRs xamarin#6932, xamarin#6935 and xamarin#7461

It adds new functionality to the neural network components.
This is still not the complete API for 11.3

* Update src/metalperformanceshaders.cs

Co-Authored-By: Rolf Bjarne Kvinge <[email protected]>

* Make changes requested by @rolfbjarne

* Fix binding of default random distribution creation

The parameterless function creates new
default distributions and is not a property.
It is a counterpart of CreateUniform.

* Expose public APIs for MPSCnnConvolutionTransposeNode

These APIs are public and documented at: https://developer.apple.com/documentation/metalperformanceshaders/mpscnnconvolutiontransposenode/2942641-initwithsource?language=objc

I have also tested that they work.

* Reintroduce compat API.

* Fix acronym casing.

* Fix introspection tests.

* Fix xtro.

* One last xtro issue.

* Fix more xtro.

* Another introspection fix.

Co-authored-By: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply suggestions from code review

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply feedback

* Please the typo guardians

Co-authored-by: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
dalexsoto added a commit to dalexsoto/xamarin-macios that referenced this pull request Jul 17, 2020
…#8844)

* [MetalPerformanceShaders] Neural Networks Update to Xcode 11

This includes updates from PRs xamarin#6932, xamarin#6935 and xamarin#7461

It adds new functionality to the neural network components.
This is still not the complete API for 11.3

* Update src/metalperformanceshaders.cs

Co-Authored-By: Rolf Bjarne Kvinge <[email protected]>

* Make changes requested by @rolfbjarne

* Fix binding of default random distribution creation

The parameterless function creates new
default distributions and is not a property.
It is a counterpart of CreateUniform.

* Expose public APIs for MPSCnnConvolutionTransposeNode

These APIs are public and documented at: https://developer.apple.com/documentation/metalperformanceshaders/mpscnnconvolutiontransposenode/2942641-initwithsource?language=objc

I have also tested that they work.

* Reintroduce compat API.

* Fix acronym casing.

* Fix introspection tests.

* Fix xtro.

* One last xtro issue.

* Fix more xtro.

* Another introspection fix.

Co-authored-By: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply suggestions from code review

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply feedback

* Please the typo guardians

Co-authored-by: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
dalexsoto added a commit that referenced this pull request Jul 18, 2020
* [MetalPerformanceShaders] Neural Networks Update to Xcode 11

This includes updates from PRs #6932, #6935 and #7461

It adds new functionality to the neural network components.
This is still not the complete API for 11.3

* Update src/metalperformanceshaders.cs

Co-Authored-By: Rolf Bjarne Kvinge <[email protected]>

* Make changes requested by @rolfbjarne

* Fix binding of default random distribution creation

The parameterless function creates new
default distributions and is not a property.
It is a counterpart of CreateUniform.

* Expose public APIs for MPSCnnConvolutionTransposeNode

These APIs are public and documented at: https://developer.apple.com/documentation/metalperformanceshaders/mpscnnconvolutiontransposenode/2942641-initwithsource?language=objc

I have also tested that they work.

* Reintroduce compat API.

* Fix acronym casing.

* Fix introspection tests.

* Fix xtro.

* One last xtro issue.

* Fix more xtro.

* Another introspection fix.

Co-authored-By: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply suggestions from code review

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply feedback

* Please the typo guardians

Co-authored-by: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
dalexsoto added a commit that referenced this pull request Jul 18, 2020
* [MetalPerformanceShaders] Neural Networks Update to Xcode 11

This includes updates from PRs #6932, #6935 and #7461

It adds new functionality to the neural network components.
This is still not the complete API for 11.3

* Update src/metalperformanceshaders.cs

Co-Authored-By: Rolf Bjarne Kvinge <[email protected]>

* Make changes requested by @rolfbjarne

* Fix binding of default random distribution creation

The parameterless function creates new
default distributions and is not a property.
It is a counterpart of CreateUniform.

* Expose public APIs for MPSCnnConvolutionTransposeNode

These APIs are public and documented at: https://developer.apple.com/documentation/metalperformanceshaders/mpscnnconvolutiontransposenode/2942641-initwithsource?language=objc

I have also tested that they work.

* Reintroduce compat API.

* Fix acronym casing.

* Fix introspection tests.

* Fix xtro.

* One last xtro issue.

* Fix more xtro.

* Another introspection fix.

Co-authored-By: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply suggestions from code review

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply feedback

* Please the typo guardians

Co-authored-by: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
dalexsoto added a commit that referenced this pull request Jul 22, 2020
* [MetalPerformanceShaders] Neural Networks Update to Xcode 11

This includes updates from PRs #6932, #6935 and #7461

It adds new functionality to the neural network components.
This is still not the complete API for 11.3

* Update src/metalperformanceshaders.cs

Co-Authored-By: Rolf Bjarne Kvinge <[email protected]>

* Make changes requested by @rolfbjarne

* Fix binding of default random distribution creation

The parameterless function creates new
default distributions and is not a property.
It is a counterpart of CreateUniform.

* Expose public APIs for MPSCnnConvolutionTransposeNode

These APIs are public and documented at: https://developer.apple.com/documentation/metalperformanceshaders/mpscnnconvolutiontransposenode/2942641-initwithsource?language=objc

I have also tested that they work.

* Reintroduce compat API.

* Fix acronym casing.

* Fix introspection tests.

* Fix xtro.

* One last xtro issue.

* Fix more xtro.

* Another introspection fix.

Co-authored-By: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply suggestions from code review

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply feedback

* Please the typo guardians

Co-authored-by: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
dalexsoto added a commit to dalexsoto/xamarin-macios that referenced this pull request Jul 26, 2020
…#8844)

* [MetalPerformanceShaders] Neural Networks Update to Xcode 11

This includes updates from PRs xamarin#6932, xamarin#6935 and xamarin#7461

It adds new functionality to the neural network components.
This is still not the complete API for 11.3

* Update src/metalperformanceshaders.cs

Co-Authored-By: Rolf Bjarne Kvinge <[email protected]>

* Make changes requested by @rolfbjarne

* Fix binding of default random distribution creation

The parameterless function creates new
default distributions and is not a property.
It is a counterpart of CreateUniform.

* Expose public APIs for MPSCnnConvolutionTransposeNode

These APIs are public and documented at: https://developer.apple.com/documentation/metalperformanceshaders/mpscnnconvolutiontransposenode/2942641-initwithsource?language=objc

I have also tested that they work.

* Reintroduce compat API.

* Fix acronym casing.

* Fix introspection tests.

* Fix xtro.

* One last xtro issue.

* Fix more xtro.

* Another introspection fix.

Co-authored-By: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply suggestions from code review

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply feedback

* Please the typo guardians

Co-authored-by: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
dalexsoto added a commit that referenced this pull request Jul 26, 2020
* [MetalPerformanceShaders] Neural Networks Update to Xcode 11

This includes updates from PRs #6932, #6935 and #7461

It adds new functionality to the neural network components.
This is still not the complete API for 11.3

* Update src/metalperformanceshaders.cs

Co-Authored-By: Rolf Bjarne Kvinge <[email protected]>

* Make changes requested by @rolfbjarne

* Fix binding of default random distribution creation

The parameterless function creates new
default distributions and is not a property.
It is a counterpart of CreateUniform.

* Expose public APIs for MPSCnnConvolutionTransposeNode

These APIs are public and documented at: https://developer.apple.com/documentation/metalperformanceshaders/mpscnnconvolutiontransposenode/2942641-initwithsource?language=objc

I have also tested that they work.

* Reintroduce compat API.

* Fix acronym casing.

* Fix introspection tests.

* Fix xtro.

* One last xtro issue.

* Fix more xtro.

* Another introspection fix.

Co-authored-By: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply suggestions from code review

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>

* Apply feedback

* Please the typo guardians

Co-authored-by: Frank A. Krueger <[email protected]>
Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution ❤
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants