Deconvolution with metal shaders

It turns out that MPSthere is no such operation as deconvolution. The closest analogue to tensorflowis conv2d_transpose.

Is it possible to sort custom plugin MPSoperations between default operations?

+4
source share
3 answers

MPS now provides MPSCNNConvolutionTranspose on macOS X.13 and tvOS / iOS 11.

0
source

You can write your own nuclear processing cores and execute them between MPS operations.

For instance:

let commandBuffer = commandQueue.makeCommandBuffer()

. . .

// Do something with an MPSCNN layer:
layer1.encode(commandBuffer: commandBuffer, sourceImage: img1, destinationImage: img2)

// Perform your own compute kernel:
let encoder = commandBuffer.makeComputeCommandEncoder()
encoder.setComputePipelineState(yourOwnComputePipeline)
encoder.setTexture(img2.texture, at: 0)
encoder.setTexture(img3.texture, at: 1)
let threadGroupSize = MTLSizeMake(. . .)
let threadGroups = MTLSizeMake(img2.texture.width / threadGroupSize.width,
                               img2.texture.height / threadGroupSize.height, 1)
encoder.dispatchThreadgroups(threadGroups, threadsPerThreadgroup: threadGroupSize)
encoder.endEncoding()

// Do something with another MPSCNN layer:
layer2.encode(commandBuffer: commandBuffer, sourceImage: img3, destinationImage: img4)

. . .

commandBuffer.commit()

​​ Metal Shading Language yourOwnComputePipeline. , .

+5

[ , .]

, " ", , , , , .

, MPSCNNConvolution , MPSImage, , , " " , .

, MPS.

: . , ​​conv :

1, 2, 3
4, 5, 6
7, 8, 9

, , :

9, 8, 7
6, 5, 4
3, 2, 1

, . :

1, 2, 3, 4, 5, 6, 7, 8, 9

​​ , , :

9, 8, 7, 6, 5, 4, 3, 2, 1

, . deconv.

, , MPSCNNConvolution. .

+1

Source: https://habr.com/ru/post/1668669/


All Articles