Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/jafioti/luminal
Browse files Browse the repository at this point in the history
  • Loading branch information
jafioti committed Apr 26, 2024
2 parents a7f8230 + 862af13 commit 7357817
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
6 changes: 3 additions & 3 deletions crates/luminal_metal/src/elementwise_fusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ impl<T: MetalFloat> Compiler for ElementwiseFusionCompiler<T> {
},
)
.0;
if val_exp != true.into() {
if val_exp != true {
*subexp = format!(
"(({} != 0) ? {subexp} : 0.0)",
expr_to_metal_string(val_exp)
Expand Down Expand Up @@ -875,8 +875,8 @@ mod tests {
.permute::<_, Axes4<0, 2, 1, 3>>();

// Rotary embed queries and keys
let queries = apply_rotary_embeddings_ggml(queries, PrevSeq::const_size().into());
let keys = apply_rotary_embeddings_ggml(keys, PrevSeq::const_size().into());
let queries = apply_rotary_embeddings_ggml(queries, PrevSeq::const_size().big());
let keys = apply_rotary_embeddings_ggml(keys, PrevSeq::const_size().big());

// Add KV cache
let (keys, values) = (
Expand Down
34 changes: 14 additions & 20 deletions crates/luminal_nn/src/convolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,15 @@ impl<
for Conv1D<CHANNELS_IN, CHANNELS_OUT, KERNEL, STRIDE, DILATION, CHANNELS_IN_TIMES_KERNEL>
{
fn initialize(cx: &mut Graph) -> Self {
let conv = Self {
weight: cx.named_tensor("Weight"),
};

// Init weight as uniform(-1, 1)
let mut rng = thread_rng();
conv.weight.set(
(0..(CHANNELS_IN * CHANNELS_OUT * KERNEL))
.map(|_| rng.gen_range(-1_f32..1_f32))
.collect::<Vec<_>>(),
);
conv
Self {
weight: cx.named_tensor("Weight").set(
(0..(CHANNELS_IN * CHANNELS_OUT * KERNEL))
.map(|_| rng.gen_range(-1_f32..1_f32))
.collect::<Vec<_>>(),
),
}
}
}

Expand Down Expand Up @@ -118,18 +115,15 @@ impl<
>
{
fn initialize(cx: &mut Graph) -> Self {
let conv = Self {
weight: cx.named_tensor("Weight"),
};

// Init weight as uniform(-1, 1)
let mut rng = thread_rng();
conv.weight.set(
(0..(CHANNELS_IN * CHANNELS_OUT * KERNELX * KERNELY))
.map(|_| rng.gen_range(-1_f32..1_f32))
.collect::<Vec<_>>(),
);
conv
Self {
weight: cx.named_tensor("Weight").set(
(0..(CHANNELS_IN * CHANNELS_OUT * KERNELX * KERNELY))
.map(|_| rng.gen_range(-1_f32..1_f32))
.collect::<Vec<_>>(),
),
}
}
}

Expand Down

0 comments on commit 7357817

Please sign in to comment.