Skip to content

Commit

Permalink
style: cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: YdrMaster <[email protected]>
  • Loading branch information
YdrMaster committed Aug 19, 2024
1 parent c555ba4 commit 04d450b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 56 deletions.
15 changes: 8 additions & 7 deletions models/llama/common-cpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use common_cpu::{
tensor::{reslice, slice, udim, Tensor},
CpuKernels, Kernels, KernelsA, KernelsB, ThisThread,
};
use llama::{ComputeConst, ComputeStream, Handle, LayerStorage, QueueOf, SliceOn, Storage, Weight};
use llama::{
ComputeConst, ComputeStream, Handle, InferenceConfig, LayerStorage, QueueOf, SliceOn, Storage,
Weight,
};
use std::{iter::repeat, ops::Deref, path::Path, slice::from_raw_parts};

pub struct Transformer {
Expand Down Expand Up @@ -133,12 +136,10 @@ impl CausalLM for Transformer {
}
#[inline]
fn duplicate_cache(&self, cache: &Tensor<Self::Storage>, pos: upos) -> Tensor<Self::Storage> {
self.s
.config
.duplicate_cache(cache, pos, Blob::new, |dst, src| {
src.map_physical(|u| &**u)
.reform_to(&mut dst.map_physical(|u| &mut **u))
})
InferenceConfig::duplicate_cache(cache, pos, Blob::new, |dst, src| {
src.map_physical(|u| &**u)
.reform_to(&mut dst.map_physical(|u| &mut **u))
})
}

fn token_embed(&self, queries: impl IntoIterator<Item = utok>) -> Tensor<Self::Storage> {
Expand Down
1 change: 0 additions & 1 deletion models/llama/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ impl InferenceConfig {
}

pub fn duplicate_cache<S>(
&self,
cache: &Tensor<S>,
pos: upos,
malloc: impl FnOnce(usize) -> S,
Expand Down
2 changes: 1 addition & 1 deletion models/llama/nvidia-gpu-distributed/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl CausalLM for Transformer {

fn duplicate_cache(&self, cache: &Tensor<Self::Storage>, pos: upos) -> Tensor<Self::Storage> {
let contexts = Arc::new(self.comms.contexts().collect::<Vec<_>>());
self.config.duplicate_cache(
InferenceConfig::duplicate_cache(
cache,
pos,
|len| Cache {
Expand Down
2 changes: 1 addition & 1 deletion models/llama/nvidia-gpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl CausalLM for Transformer {
}

fn duplicate_cache(&self, cache: &Tensor<Self::Storage>, pos: upos) -> Tensor<Self::Storage> {
self.0.config.duplicate_cache(
InferenceConfig::duplicate_cache(
cache,
pos,
|len| self.cache(len),
Expand Down
46 changes: 0 additions & 46 deletions tensor/src/compatibility.rs

This file was deleted.

0 comments on commit 04d450b

Please sign in to comment.