Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ exclude = [
"crates/luminal_2",
"demos/flash_attention",
]

#[patch."https://github.com/kvark/blade"]
#blade-graphics = { path = "../blade/blade-graphics" }
2 changes: 2 additions & 0 deletions crates/luminal_2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2024"
default = []
cuda = ["dep:cudarc", "dep:luminal_cuda"]
metal = ["dep:objc2", "dep:objc2-metal", "dep:objc2-foundation"]
blade = ["dep:blade-graphics"]

[dependencies]
luminal = { path = "../../" }
Expand Down Expand Up @@ -42,3 +43,4 @@ objc2-foundation = { version = "0.3.1", optional = true }
eframe = "0.28"
egui = "0.28"
anyhow = "1.0.99"
blade-graphics = { git = "https://github.com/kvark/blade", rev = "99162daf690e05d4489b57adeb37a2cc0086d1be", optional = true }
513 changes: 358 additions & 155 deletions crates/luminal_2/src/codegen.rs

Large diffs are not rendered by default.

346 changes: 139 additions & 207 deletions crates/luminal_2/src/extract.rs

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions crates/luminal_2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ pub mod utils;
#[cfg(test)]
mod tests;

#[cfg(feature = "blade")]
use blade_graphics as gpu;

#[cfg(feature = "cuda")]
use itertools::Itertools;
use luminal::prelude::*;
Expand All @@ -30,10 +33,17 @@ pub type Buffer = Retained<ProtocolObject<dyn MTLBuffer>>;
#[cfg(feature = "metal")]
pub type Function = Retained<ProtocolObject<dyn MTLFunction>>;

#[cfg(feature = "cuda")]
pub type Device = CudaContext;

#[cfg(feature = "blade")]
pub type Device = gpu::Context;

#[derive(Clone, PartialEq, Eq)]
pub enum GPUArch {
CUDA,
Metal(HashMap<usize, &'static str>),
Blade,
}

impl GPUArch {
Expand Down Expand Up @@ -179,6 +189,12 @@ impl Operator for CompatKernel {
todo!()
}
}
#[cfg(feature = "blade")]
impl Operator for CompatKernel {
fn process(&mut self, _inputs: Vec<(InputTensor, ShapeTracker)>) -> Vec<Tensor> {
todo!()
}
}

pub fn custom_kernel(
inputs: &[GraphTensor],
Expand Down Expand Up @@ -226,6 +242,12 @@ impl Operator for Diff {
todo!()
}
}
#[cfg(feature = "blade")]
impl Operator for Diff {
fn process(&mut self, _inp: Vec<(InputTensor, ShapeTracker)>) -> Vec<Tensor> {
todo!()
}
}

pub trait GT2 {
fn diff2(self, name: impl ToString) -> Self;
Expand Down Expand Up @@ -268,3 +290,9 @@ impl Operator for GraphBreak {
inp.into_iter().map(|i| i.0.cloned()).collect()
}
}

#[cfg(feature = "blade")]
pub struct Buffer {
pub raw: gpu::Buffer,
pub size: usize,
}
Loading