s1d*_*dok 4 metal tensorflow metal-performance-shaders
原来没有这样的操作deconvolution在MPS.最接近的类比tensorflow是conv2d_transpose.
是否可以在MPS默认操作之间进行插件自定义操作?
您可以编写自己的Metal计算内核并在MPS操作之间执行.
例如:
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()
Run Code Online (Sandbox Code Playgroud)
您必须使用Metal Shading Language编写自己的计算内核并将其加载到yourOwnComputePipeline对象中.然后,您可以随时将其编码到当前命令缓冲区中.