mpsgraph-rs
Safe Rust bindings for Apple's
MetalPerformanceShadersGraph
framework on macOS.
The GitHub repository is mpsgraph-rs; the published crates.io package is
apple-mpsgraph because the short package name is already taken.
Install
Quick start
use MetalDevice;
use ;
let device = system_default.expect;
let graph = new.expect;
let input = graph
.placeholder
.expect;
let bias = graph.constant_scalar.expect;
let added = graph.addition.expect;
let output = graph.relu.expect;
let data = from_f32_slice
.expect;
let results = graph
.run
.expect;
let values = results.read_f32.expect;
assert_eq!;
v0.1 surface
Graph,Tensor, and orderedFeed/FeedDescriptionhelpersTensorDatafrom CPU bytes,f32slices, or existingMTLBuffers- Direct graph execution plus compiled
Executableruns onMTLCommandQueue - Core graph construction ops:
- placeholders and constants
- addition, subtraction, multiplication, division
- matrix multiplication
- reshape, transpose/permute, slice, broadcast
reLU,sigmoid,softMax- reduction sum / max / min and mean
- 2D convolution, max pooling, and normalization helpers
- Shared constants for
MPSDataType,MPSGraphTensorNamedDataLayout, andMPSGraphPaddingStyle
Smoke examples