From 0de3ee627736952f7ee768e5b962c7575b30c172 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Fri, 11 Oct 2024 19:41:00 +0100 Subject: [PATCH 1/4] Support running tests with "random" feature disabled --- src/model.rs | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/model.rs b/src/model.rs index 409d8e56..18dbed2c 100644 --- a/src/model.rs +++ b/src/model.rs @@ -1421,28 +1421,31 @@ mod tests { add_operator!(Pad, [input_node, pads]); add_operator!(Pow, [input_node, input_node]); - add_operator!(RandomNormal, [], { - shape: vec![50, 50], - mean: 0., - scale: 1., - seed: None, - }); - add_operator!(RandomNormalLike, [input_node], { - mean: 0., - scale: 1., - seed: None, - }); - add_operator!(RandomUniform, [], { - shape: vec![50, 50], - low: 0., - high: 1., - seed: None, - }); - add_operator!(RandomUniformLike, [input_node], { - low: 0., - high: 1., - seed: None, - }); + #[cfg(feature = "random")] + { + add_operator!(RandomNormal, [], { + shape: vec![50, 50], + mean: 0., + scale: 1., + seed: None, + }); + add_operator!(RandomNormalLike, [input_node], { + mean: 0., + scale: 1., + seed: None, + }); + add_operator!(RandomUniform, [], { + shape: vec![50, 50], + low: 0., + high: 1., + seed: None, + }); + add_operator!(RandomUniformLike, [input_node], { + low: 0., + high: 1., + seed: None, + }); + } let range_start_node = graph_builder.add_value("range_start", None); let range_limit_node = graph_builder.add_value("range_limit", None); From 12f0b93f3675af975ec040c19423b61f487bac65 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Fri, 11 Oct 2024 19:41:20 +0100 Subject: [PATCH 2/4] Remove rten crate's self dependency in development The rten crate had a dependency on itself in development in order to enable additional features. This worked when building, but appeared to prevent rust analyzer from working properly in the rten-examples crate. See also https://github.com/rust-lang/cargo/issues/2911. --- Cargo.lock | 1 - Cargo.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ab81a349..f99fdf83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -365,7 +365,6 @@ dependencies = [ "memmap2", "num_cpus", "rayon", - "rten", "rten-bench", "rten-simd", "rten-tensor", diff --git a/Cargo.toml b/Cargo.toml index c7a3b0c2..ded4c9ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,7 +55,6 @@ num_cpus = "1.16.0" [dev-dependencies] libm = "0.2.6" -rten = { path = ".", features = ["mmap", "random"] } rten-bench = { path = "./rten-bench" } serde_json = { workspace = true } From a6b343582866d107e29c419f06748af1e04ca33e Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Fri, 11 Oct 2024 19:44:10 +0100 Subject: [PATCH 3/4] Enable all features supported under stable Rust in `make test` --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ac29c50d..5c6828ea 100644 --- a/Makefile +++ b/Makefile @@ -31,9 +31,11 @@ miri: # require changes to prevent tests taking too long to run. cargo +nightly miri test -p rten-tensor +# Run tests for all crates with all features enabled that do not require +# nightly Rust. .PHONY: test test: - cargo test --workspace + cargo test --workspace --features mmap,random .PHONY: wasm wasm: From 0556beda0501877909c56ace5ed3e5b2b0874ae0 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Fri, 11 Oct 2024 19:52:23 +0100 Subject: [PATCH 4/4] Remove rten-generate's self-dependency in development See commit 12f0b93f3675af975ec040c19423b61f487bac65. --- Cargo.lock | 1 - Makefile | 2 +- rten-generate/Cargo.toml | 3 --- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f99fdf83..fb5df0f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -414,7 +414,6 @@ version = "0.13.1" dependencies = [ "fastrand", "rten", - "rten-generate", "rten-tensor", "rten-text", ] diff --git a/Makefile b/Makefile index 5c6828ea..14ae3373 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ miri: # nightly Rust. .PHONY: test test: - cargo test --workspace --features mmap,random + cargo test --workspace --features mmap,random,text-decoder .PHONY: wasm wasm: diff --git a/rten-generate/Cargo.toml b/rten-generate/Cargo.toml index c20cfe9e..2912b2a2 100644 --- a/rten-generate/Cargo.toml +++ b/rten-generate/Cargo.toml @@ -15,9 +15,6 @@ rten = { path = "../", version = "0.13.1" } rten-text = { path = "../rten-text", version = "0.13.0", optional = true } rten-tensor = { path = "../rten-tensor", version = "0.13.1" } -[dev-dependencies] -rten-generate = { path = ".", features = ["text-decoder"] } - [features] # Enable text decoding using tokenizers from rten-text text-decoder = ["rten-text"]