Skip to content

computer-graphics-tools/ane

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ane

Rust bindings for Apple Neural Engine (ANE) via the private AppleNeuralEngine.framework.

Provides a symbolic graph builder and a compile-then-run lifecycle through _ANEInMemoryModel, using IOSurface-backed zero-copy I/O.

Example

use ane::{Graph, Shape, TensorData, NSQualityOfService};

let mut graph = Graph::new();

let input   = graph.placeholder(Shape::channels(64));
let weights = graph.constant(&weight_data, Shape { channels: 64, height: 1, width: 1, batch: 1 });
let output  = graph.convolution_2d_1x1(input, weights, None);
let output  = graph.relu(output);

let executable = graph.compile(NSQualityOfService::Default)?;

let input_tensor  = TensorData::with_f32(&data, Shape::channels(64));
let output_tensor = TensorData::new(Shape::channels(64));
executable.run(&[&input_tensor], &[&output_tensor])?;

let result = output_tensor.read_f32();

GPT-2 forward pass

The included gpt2_forward example downloads GPT-2 124M from Hugging Face, compiles the transformer layers to ANE, and runs autoregressive text generation with KV-cache:

cargo run --release --example gpt2_forward

Research

The ANE internals research behind this crate was inspired by Mohamed Ghannam's weightBufs exploit chain writeup, which documents the ANE architecture, the aned / ANECompilerService pipeline, and the kernel interface (AppleH11ANEInterface).

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages