Skip to content

Instantly share code, notes, and snippets.

@dneprDroid
Last active August 12, 2019 10:27
Show Gist options
  • Select an option

  • Save dneprDroid/edfe3c32f7de102dd43ed432ad25e032 to your computer and use it in GitHub Desktop.

Select an option

Save dneprDroid/edfe3c32f7de102dd43ed432ad25e032 to your computer and use it in GitHub Desktop.
func buildGraph(device: MTLDevice) -> MPSNNGraph {
let inputNode = MPSNNImageNode()
let node1 = SomeNode1(input: inputNode, weights: ...)
let node2 = SomeNode2(input: node1.resultImage, weights: ...)
let node3 = SomeNode3(input: node2.resultImage, weights: ...)
.....
return MPSNNGraph(device: device,
resultImage: nodeN.resultImage)
}
....
let device = MTLCreateSystemDefaultDevice()
let graph = buildGraph(device: device)
graph.executeAsync(withSourceImages: [inputImage]) { outputImage, error in
// parse data from outputImage
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment