Skip to content

Commit

Permalink
Add further docs
Browse files Browse the repository at this point in the history
  • Loading branch information
EricLBuehler committed Sep 11, 2023
1 parent 9db450c commit 4fe27dd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub mod loralinear;
pub struct Lora;

impl Lora {
/// Convert the selected layers into their LoRA counterparts.
pub fn convert_model<T: Eq + PartialEq + Hash>(
selected: SelectedLayers<'_, T>,
) -> NewLayers<T> {
Expand Down Expand Up @@ -79,6 +80,7 @@ pub struct NewLayers<T: Eq + PartialEq + Hash> {
pub embed: HashMap<T, LoraEmbedding>,
}

/// Any layer that is linear-like.
pub trait LinearLayerLike: Module {
fn weight(&self) -> &Tensor;
fn bias(&self) -> Option<&Tensor>;
Expand All @@ -97,6 +99,7 @@ impl LinearLayerLike for Linear {
}
}

/// Any layer that is conv1d-like.
pub trait Conv1dLayerLike: Module {
fn weight(&self) -> &Tensor;
fn bias(&self) -> Option<&Tensor>;
Expand Down Expand Up @@ -128,6 +131,7 @@ impl Conv1dLayerLike for Conv1dWithWB {
}
}

/// Any layer that is conv2d-like.
pub trait Conv2dLayerLike: Module {
fn weight(&self) -> &Tensor;
fn bias(&self) -> Option<&Tensor>;
Expand Down Expand Up @@ -159,6 +163,7 @@ impl Conv2dLayerLike for Conv2dWithWB {
}
}

/// Any layer that is embedding-like.
pub trait EmbeddingLayerLike: Module {
fn embeddings(&self) -> &Tensor;
fn hidden_size(&self) -> usize;
Expand Down

0 comments on commit 4fe27dd

Please sign in to comment.