Documentation
¶
Overview ¶
Command executable demonstrates the MPSGraphExecutable deployment path: compile a graph once, ship the compiled package, load it later without rebuilding the graph.
An MPSGraph is a description. Running it with MPSGraph.run repeats the compile work the graph needs before the GPU sees anything. Compiling the graph yields an MPSGraphExecutable, which holds the specialized result and takes its inputs positionally instead of through a feeds dictionary. An executable can be serialized to an .mpsgraphpackage directory and read back on another process or machine, so the graph-building code does not have to ship with the program that runs it.
The example builds a two-layer network (matmul, ReLU, matmul, bias), then runs it three ways and compares the results elementwise:
interpreted MPSGraph.run with a feeds dictionary compiled MPSGraphExecutable.run from compile(with:feeds:...) reloaded MPSGraphExecutable.init(package:descriptor:) after serialize
All three must agree exactly; the measured deltas are printed.
Usage:
executable [-out dir]
Without -out the package is written to a temporary directory and removed.