-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
209 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "luminal_nn" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
itertools = "0.12.1" | ||
luminal = {path="../.."} | ||
rustc-hash = "1.1.0" | ||
rand = "0.8.5" | ||
|
||
[dev-dependencies] | ||
dfdx = { version = "0.13", features = ["f16"] } | ||
paste = "1.0.14" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use luminal::prelude::*; | ||
|
||
mod activation; | ||
pub use activation::*; | ||
mod convolution; | ||
pub use convolution::*; | ||
mod embedding; | ||
pub use embedding::*; | ||
mod linear; | ||
pub use linear::*; | ||
mod norm; | ||
pub use norm::*; | ||
mod transformer; | ||
pub use transformer::*; | ||
|
||
pub struct Repeated<T, const N: usize> { | ||
pub modules: Vec<T>, | ||
} | ||
|
||
impl<T: InitModule, const N: usize> InitModule for Repeated<T, N> { | ||
fn initialize(cx: &mut Graph) -> Self { | ||
Self { | ||
modules: (0..N).map(|_| InitModule::initialize(cx)).collect(), | ||
} | ||
} | ||
} | ||
|
||
impl<T: SerializeModule, const N: usize> SerializeModule for Repeated<T, N> { | ||
fn serialize(&self, s: &mut Serializer) { | ||
for (i, l) in self.modules.iter().enumerate() { | ||
s.module(&format!("layer{i}"), l); | ||
} | ||
} | ||
} | ||
|
||
impl<I, T: Module<I, Output = I>, const N: usize> Module<I> for Repeated<T, N> { | ||
type Output = I; | ||
|
||
fn forward(&self, mut input: I) -> Self::Output { | ||
for m in &self.modules { | ||
input = m.forward(input); | ||
} | ||
input | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.