MPSKernel MTLComputePipelineStateCache unable to load function DilateFilter4. Compiler encountered an internal error

I try to use MPSImageErode and MPSImageDilate in an app right now with SwiftUI and BigSur, Xcode 12.3
The code

Code Block let edSize = 9
var erodedilateKernelValues:[Float] = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0,
0.0, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.0,
0.0, 0.2, 0.1, 0.0, 0.0, 0.0, 0.1, 0.2, 0.0,
0.0, 0.2, 0.1, 0.0, 0.0, 0.0, 0.1, 0.2, 0.0,
0.0, 0.2, 0.0, 0.0, 0.0, 0.0, 0.1, 0.2, 0.0,
0.0, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.0,
0.0, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
let dilateShader = MPSImageDilate(
device: self.metalDevice!,
kernelWidth:edSize,
kernelHeight:edSize,
values:&erodedilateKernelValues)
dilateShader.encode(commandBuffer: cmdBuf,
sourceTexture: wipTexture!,
destinationTexture: erodila)
let erodeShader = MPSImageErode(
device: self.metalDevice!,
kernelWidth:edSize,
kernelHeight:edSize,
values:&erodedilateKernelValues)
erodeShader.encode(commandBuffer: cmdBuf,
sourceTexture: erodila,
destinationTexture: erodila2)
cmdBuf.commit()
cmdBuf.waitUntilCompleted()
wipTexture = erodila2


Resulting in

Code Block 2021-01-02 19:33:40.320954+0900 ***[5330:369599] /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShaders/MetalPerformanceShaders-124.2.1/MPSCore/Utility/MPSLibrary.mm, line 338: error 'MPSKernel MTLComputePipelineStateCache unable to load function DilateFilter4.
Compiler encountered an internal error: (null)
'
/AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShaders/MetalPerformanceShaders-124.2.1/MPSCore/Utility/MPSLibrary.mm:338: failed assertion `MPSKernel MTLComputePipelineStateCache unable to load function DilateFilter4.
Compiler encountered an internal error: (null)
'
/AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShaders/MetalPerformanceShaders-124.2.1/MPSCore/Utility/MPSLibrary.mm:338: failed assertion `MPSKernel MTLComputePipelineStateCache unable to load function DilateFilter4.
Compiler encountered an internal error: (null)
'


when I use the filter with only Zero it actually works

Code Block
var erodedilateKernelValues = [Float].init(repeating: 0.0, count: edSize * edSize)


But I want to try different filter values to see if I can improve the analytics on an image.


Any suggestions ?

What platform you are running it on ?
Can you file radar with MTLCompilerService crash in CrashLogs when you run the test.
Sorry for late reply; got busy with other stuff. Running on a MBP 2018 with BigSur 11.2.1; GPU Intel UHD Graphics 630 1536 MB
Will try to get the crashlog next time and file radar
MPSKernel MTLComputePipelineStateCache unable to load function DilateFilter4. Compiler encountered an internal error
 
 
Q