-
Notifications
You must be signed in to change notification settings - Fork 151
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
14 changed files
with
443 additions
and
72 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,43 @@ | ||
use serde::Serialize; | ||
|
||
use super::LowRatio; | ||
|
||
pub(crate) const N_WORDS: usize = 4; | ||
|
||
pub(crate) const CELLS_PER_MOD: u32 = 7; | ||
|
||
#[derive(Serialize, Debug, PartialEq, Clone)] | ||
pub(crate) struct ModInstanceDef { | ||
pub(crate) ratio: Option<u32>, | ||
pub(crate) ratio: Option<LowRatio>, | ||
pub(crate) word_bit_len: u32, | ||
pub(crate) batch_size: usize, | ||
} | ||
|
||
impl ModInstanceDef { | ||
pub(crate) fn new(ratio: Option<u32>, batch_size: usize, word_bit_len: u32) -> Self { | ||
ModInstanceDef { | ||
ratio, | ||
ratio: ratio.map(LowRatio::new_int), | ||
word_bit_len, | ||
batch_size, | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[cfg(target_arch = "wasm32")] | ||
use wasm_bindgen_test::*; | ||
|
||
#[test] | ||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] | ||
fn test_new() { | ||
let builtin_instance = ModInstanceDef { | ||
ratio: Some(LowRatio::new_int(10)), | ||
word_bit_len: 3, | ||
batch_size: 3, | ||
}; | ||
assert_eq!(ModInstanceDef::new(Some(10), 3, 3), builtin_instance); | ||
} | ||
} |
Oops, something went wrong.