From 4c64e53e7a9836b86192faff9f5dee7d2460e570 Mon Sep 17 00:00:00 2001 From: FL03 Date: Thu, 12 Jun 2025 23:55:42 -0500 Subject: [PATCH 1/5] v0.0.3 Signed-off-by: FL03 --- Cargo.lock | 12 ++++++------ Cargo.toml | 25 ++++++++----------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35f4785..a24034a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -878,7 +878,7 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rsdiff" -version = "0.0.2" +version = "0.0.3" dependencies = [ "anyhow", "approx", @@ -894,7 +894,7 @@ dependencies = [ [[package]] name = "rsdiff-core" -version = "0.0.2" +version = "0.0.3" dependencies = [ "anyhow", "approx", @@ -914,7 +914,7 @@ dependencies = [ [[package]] name = "rsdiff-derive" -version = "0.0.2" +version = "0.0.3" dependencies = [ "proc-macro2", "quote", @@ -923,7 +923,7 @@ dependencies = [ [[package]] name = "rsdiff-graphs" -version = "0.0.2" +version = "0.0.3" dependencies = [ "anyhow", "approx", @@ -944,7 +944,7 @@ dependencies = [ [[package]] name = "rsdiff-macros" -version = "0.0.2" +version = "0.0.3" dependencies = [ "approx", "num", @@ -955,7 +955,7 @@ dependencies = [ [[package]] name = "rsdiff-math" -version = "0.0.2" +version = "0.0.3" dependencies = [ "anyhow", "approx", diff --git a/Cargo.toml b/Cargo.toml index e743fbb..3a30fcf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,5 @@ [workspace] -default-members = [ - "rsdiff" -] - -exclude = [ -] - +default-members = ["rsdiff"] members = [ "rsdiff", "core", @@ -13,7 +7,6 @@ members = [ "graphs", "macros", "math", - ] resolver = "3" @@ -38,20 +31,18 @@ license = "Apache-2.0" repository = "https://github.com/FL03/rsdiff.git" readme = "README.md" rust-version = "1.85.0" -version = "0.0.2" -# version = "0.3.2-nightly" +version = "0.0.3" [workspace.dependencies] # local -rsdiff = { default-features = false, path = "rsdiff", version = "0.0.2" } -rsdiff-core = { default-features = false, path = "core", version = "0.0.2" } -rsdiff-derive = { default-features = false, path = "derive", version = "0.0.2" } -rsdiff-graphs = { default-features = false, path = "graphs", version = "0.0.2" } -rsdiff-macros = { default-features = false, path = "macros", version = "0.0.2" } -rsdiff-math = { default-features = false, path = "math", version = "0.0.2" } +rsdiff = { default-features = false, path = "rsdiff", version = "0.0.3" } +rsdiff-core = { default-features = false, path = "core", version = "0.0.3" } +rsdiff-derive = { default-features = false, path = "derive", version = "0.0.3" } +rsdiff-graphs = { default-features = false, path = "graphs", version = "0.0.3" } +rsdiff-macros = { default-features = false, path = "macros", version = "0.0.3" } +rsdiff-math = { default-features = false, path = "math", version = "0.0.3" } # custom scsys = { default-features = false, features = ["derive"], version = "0.3.0" } - # benchmarking criterion = { version = "0.6" } # concurrency & parallelism From 364ded91ae1c6777aa6d192abcf23ccaeea746fa Mon Sep 17 00:00:00 2001 From: FL03 Date: Thu, 12 Jun 2025 23:59:37 -0500 Subject: [PATCH 2/5] update Cargo.toml Signed-off-by: FL03 --- rsdiff/Cargo.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rsdiff/Cargo.toml b/rsdiff/Cargo.toml index 013d79c..6c23afb 100644 --- a/rsdiff/Cargo.toml +++ b/rsdiff/Cargo.toml @@ -44,7 +44,7 @@ num = { workspace = true } [features] default = [ - "core", + "std", "math", "graph", ] @@ -58,8 +58,6 @@ full = [ ] # ************* [FF:Features] ************* -core = [] - derive = [ "dep:rsdiff-derive", "macros" @@ -73,6 +71,7 @@ math = ["dep:rsdiff-math"] # ************* [FF:Environments] ************* std = [ + "alloc", "rsdiff-core/std", "rsdiff-graphs/std", ] From d4f7ab25aca03010f0bd0a0fbb489440b6106b61 Mon Sep 17 00:00:00 2001 From: FL03 Date: Fri, 13 Jun 2025 00:02:40 -0500 Subject: [PATCH 3/5] update Signed-off-by: FL03 --- .github/workflows/rust.yml | 2 +- rsdiff/Cargo.toml | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 10232d0..3d96fca 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -78,7 +78,7 @@ jobs: cache-key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Benchmark (${{ matrix.target }}) - run: cargo bench --locked --workspace --all-features --workspace --verbose -- + run: cargo bench --locked --verbose --workspace --all-features -- - name: Upload the benchmarks id: artifacts diff --git a/rsdiff/Cargo.toml b/rsdiff/Cargo.toml index 6c23afb..ee72bbf 100644 --- a/rsdiff/Cargo.toml +++ b/rsdiff/Cargo.toml @@ -45,13 +45,14 @@ num = { workspace = true } [features] default = [ "std", + "macros", "math", - "graph", ] full = [ "default", "derive", + "graph", "json", "serde", "tracing", @@ -60,7 +61,7 @@ full = [ # ************* [FF:Features] ************* derive = [ "dep:rsdiff-derive", - "macros" + "macros", ] graph = ["dep:rsdiff-graphs"] From 6e26aa8a640fd4507daf4712a97d03667b819da0 Mon Sep 17 00:00:00 2001 From: FL03 Date: Fri, 13 Jun 2025 00:03:30 -0500 Subject: [PATCH 4/5] update rust.yml Signed-off-by: FL03 --- .github/workflows/rust.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3d96fca..85be674 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -60,6 +60,7 @@ jobs: runs-on: ubuntu-latest outputs: results: ${{ steps.artifacts.outputs.artifact-id }} + url: ${{ steps.artifacts.outputs.artifact-url }} permissions: contents: write checks: write From 346f38000b778bc271ebd7c5bc517a6afc15feef Mon Sep 17 00:00:00 2001 From: FL03 Date: Fri, 13 Jun 2025 00:06:26 -0500 Subject: [PATCH 5/5] update README.md Signed-off-by: FL03 --- README.md | 62 ++++++++++++++++++++----------------------------------- 1 file changed, 22 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 9d3715b..660c491 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Autodifferentiation is a powerful technique used in machine learning and optimiz ## Features -- [x] `hash_graph` - A hash-based hypergraph implementation. +- [x] `macros` - enables the `autodiff` macro for automatically differentiating in-place logic. ## Usage @@ -25,10 +25,9 @@ Add this to your `Cargo.toml`: ```toml [dependencies.rsdiff] features = [ - "hash_graph", "macros", ] -version = "0.1.x" +version = "0.0.x" ``` ### Examples @@ -38,45 +37,28 @@ For more detailed examples, please refer to the [examples directory](https://git #### _Example #1:_ Basic Usage ```rust - extern crate rsdiff; - - fn main() -> rsdiff::Result<()> { - // initialize a new instance of a hypergraph - let mut graph: HashGraph = HashGraph::new(); - // use the macro to insert nodes into the graph - rsdiff::hypernode! { - graph { - let v0; - let v1 = 2; - let v2 = 3; - let v3 = 4; - } - } - // Add some hyperedges - let e1 = graph.insert_edge(vec![v0, v1, v2])?; - println!("Added hyperedge {e1}: {:?}", [v0, v1, v2]); - - let e2 = graph.insert_edge(vec![v1, v2, v3])?; - println!("Added hyperedge {e2}: {:?}", [v1, v2, v3]); - - // Get neighbors of vertex v1 - let neighbors = graph.neighbors(&v1)?; - println!("Neighbors of {}: {:?}", v1, neighbors); - - // Get degree of vertex v1 - let degree = graph.get_degree_of_node(&v1); - println!("Degree of {v1}: {degree}"); - - // Remove a vertex - graph.remove_vertex(&v2)?; - println!("Removed vertex {v2}"); - - println!("---------\nFinal graph state: {:?}", graph); - Ok(()) - } - +use rsdiff::autodiff; + +fn main() { + let x = 3f64; + let y = 4f64; + assert_eq!(y, autodiff!(x: x * y)); + assert_eq!(x, autodiff!(y: x * y)); + assert_eq!(1f64, autodiff!(x: x + y)); +} ``` +### _Example #2:_ Trigonometric functions + +```rust +use rsdiff::autodiff; + +fn main() { + let x = 2f64; + assert_eq!(autodiff!(x: x.cos()), -x.sin()); + assert_eq!(autodiff!(x: x.sin()), x.cos()); + assert_eq!(autodiff!(x: x.tan()), x.cos().powi(2).recip()); +} ## Getting Started ### Prerequisites