Questions tagged [metal-performance-shaders]

This tag is for questions pertaining to the MetalPerformanceShaders.framework on macOS, tvOS and iOS on Apple's platforms.

This tag is for questions pertaining to the MetalPerformanceShaders.framework (a.k.a. MPS) on macOS, tvOS and iOS on Apple's platforms. The MetalPerformanceShaders framework is a toolkit of image processing, linear algebra and neural networking filters designed to use and interoperate with Metal.

82 questions
19
votes
7 answers

Continuously train CoreML model after shipping

In looking over the new CoreML API, I don't see any way to continue training the model after generating the .mlmodel and bundling it in your app. This makes me think that I won't be able to perform machine learning on my user's content or actions…
Patrick Goley
  • 5,397
  • 22
  • 42
18
votes
1 answer

CoreML / MLModelConfig preferredMetalDevice - understanding device placement heuristics

Is there any public document that clearly states CoreML's strategy for GPU device placement when running inference models on macOS? How does it decide if it should run on integrated, discrete or CPU? Can one reliably 'force' one path? How does this…
vade
  • 702
  • 4
  • 22
12
votes
1 answer

MTKView Drawing Performance

What I am Trying to Do I am trying to show filters on a camera feed by using a Metal view: MTKView. I am closely following the method of Apple's sample code - Enhancing Live Video by Leveraging TrueDepth Camera Data (link). What I Have So…
Gizmodo
  • 3,151
  • 7
  • 45
  • 92
10
votes
1 answer

Applying MPSImageGaussianBlur with depth data

I am trying to create an imitation of the portrait mode in Apple's native camera. The problem is, that applying the blur effect using CIImage with respect to depth data, is too slow for the live preview I want to show to the user. My code for this…
Eyzuky
  • 1,843
  • 2
  • 22
  • 45
10
votes
3 answers

Linear Algebra library using OpenGL ES 2.0 for iOS

Does anyone know of a linear algebra library for iOS that uses OpenGL ES 2.0 under the covers? Specifically, I am looking for a way to do matrix multiplication on arbitrary-sized matrices (e.g., much larger than 4x4, more like 5,000 x 100,000)…
cklin
  • 900
  • 4
  • 16
7
votes
2 answers

How do you synchronize a Metal Performance Shader with an MTLBlitCommandEncoder?

I'm trying to better understand the synchronization requirements when working with Metal Performance Shaders and an MTLBlitCommandEncoder. I have an MTLCommandBuffer that is set up as follows: Use MTLBlitCommandEncoder to copy a region of Texture…
kennyc
  • 5,490
  • 5
  • 34
  • 57
5
votes
2 answers

Apple Metal Element-wise Matrix Multiplication (Hadamard Product)

Is it possible to perform a Hadamard Product using Apple's Metal Performance Shaders? I see that a normal matrix multiplication can be performed using this, but I am specifically looking for an element-wise multiplication, or a clever way to…
mrplants
  • 657
  • 2
  • 9
  • 20
4
votes
0 answers

Is there any way to use metal performance shader on the docker container?

I'm currently using mac book m2 pro and installed Docker desktop to create an development container on linux. I know there is a --gpus option in docker run to add gpu to the container when starting the container. But is there any way to use the MPS…
Quacker
  • 41
  • 1
4
votes
1 answer

Metal RGB to YUV conversion compute shader

I am trying to write a Metal compute shader for converting from RGB to YUV, but am getting build errors. typedef struct { float3x3 matrix; float3 offset; } ColorConversion; // Compute kernel kernel void kernelRGBtoYUV(texture2d
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
4
votes
1 answer

How can I find the brightest point in a CIImage (in Metal maybe)?

I created a custom CIKernel in Metal. This is useful because it is close to real-time. I am avoiding any cgcontext or cicontext that might lag in real time. My kernel essentially does a Hough transform, but I can't seem to figure out how to read the…
Michael
  • 1,115
  • 9
  • 24
4
votes
1 answer

Metal atomic operations performance on iOS

If one needs to compute image statistics such as Histogram, is using atomic operations such as atomic load and add as good as accumulating results using repeated blend operations? Does repeated blending in OpenGLES (such as below) or Metal…
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
4
votes
1 answer

How to convert a MTLTexture to CVpixelBuffer to write into an AVAssetWriter?

I have a requirement to apply filters on the live video and I'm trying to do it in Metal. But I have encountered problem with converting the MTLTexture into CVPixelBuffer after encoding the filter into destination filter. Reference…
4
votes
3 answers

Deconvolution with Metal Performance Shaders

Turns out there is no such operation as deconvolution in MPS. The closest analogue in tensorflow is conv2d_transpose. Is it possible to sort of plug-in custom operations between MPS default operations?
s1ddok
  • 4,615
  • 1
  • 18
  • 31
3
votes
2 answers

My custom metal image filter is slow. How can I make it faster?

I've seen a lot of other's online tutorial that are able to achieve 0.0X seconds mark on filtering an image. Meanwhile my code here took 1.09 seconds to filter an image.(Just to reduce brightness by half). edit after first comment time measured with…
3
votes
3 answers

Efficiently count how many transparent pixels are in UIImage/CIImage with Metal

What is the fastest way we can count how many transparent pixels exist in CIImage/UIImage? For example: My first thought, if we speak about efficiency, is to use Metal Kernel using either CIColorKernel or so, but I can't understand how to use it to…
Roi Mulia
  • 5,626
  • 11
  • 54
  • 105
1
2 3 4 5 6