{"id":13822651,"url":"https://github.com/charles-r-earp/autograph","last_synced_at":"2025-05-16T17:31:29.517Z","repository":{"id":41443382,"uuid":"192432911","full_name":"charles-r-earp/autograph","owner":"charles-r-earp","description":"A machine learning library for Rust.","archived":false,"fork":false,"pushed_at":"2024-08-19T00:18:17.000Z","size":73455,"stargazers_count":314,"open_issues_count":0,"forks_count":17,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-10-31T11:51:46.631Z","etag":null,"topics":["cuda","machine-learning","neural-networks","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charles-r-earp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-17T23:43:49.000Z","updated_at":"2024-10-29T17:56:12.000Z","dependencies_parsed_at":"2024-02-20T05:28:12.021Z","dependency_job_id":"03bb352d-5b59-496f-9053-28ac1ce72d0e","html_url":"https://github.com/charles-r-earp/autograph","commit_stats":{"total_commits":501,"total_committers":4,"mean_commits":125.25,"dds":0.007984031936127733,"last_synced_commit":"59fb4a026e999d929c0b82184639d7be3cf78444"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charles-r-earp%2Fautograph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charles-r-earp%2Fautograph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charles-r-earp%2Fautograph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charles-r-earp%2Fautograph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charles-r-earp","download_url":"https://codeload.github.com/charles-r-earp/autograph/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225442877,"owners_count":17475127,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cuda","machine-learning","neural-networks","rust"],"created_at":"2024-08-04T08:02:11.179Z","updated_at":"2024-11-19T23:30:49.518Z","avatar_url":"https://github.com/charles-r-earp.png","language":"Rust","funding_links":[],"categories":["Rust","Machine Learning","Neural Networks","Frameworks"],"sub_categories":[],"readme":"[![LicenseBadge]][License]\n[![DocsBadge]][Docs]\n[![build](https://github.com/charles-r-earp/autograph/actions/workflows/ci.yml/badge.svg)](https://github.com/charles-r-earp/autograph/actions/workflows/ci.yml)\n\n[License]: https://github.com/charles-r-earp/autograph/blob/main/LICENSE-APACHE\n[LicenseBadge]: https://img.shields.io/badge/license-MIT/Apache_2.0-blue.svg\n[Docs]: https://docs.rs/autograph\n[DocsBadge]: https://docs.rs/autograph/badge.svg\n\n# autograph\n\nA machine learning library for Rust.\n\nGPGPU kernels implemented with [krnl](https://github.com/charles-r-earp/krnl).\n\n- Host and device execution.\n- Tensors emulate [ndarray](https://github.com/rust-ndarray/ndarray)\n  - Host tensors can be borrowed as arrays.\n- Tensors, models, and optimizers can be serialized with [serde](https://github.com/serde-rs/serde).\n  - Portable between platforms.\n  - Save and resume training progress.\n- Fully extensible, in Rust.\n\n## Neural Networks\n\n```rust\n#[derive(Layer, Forward)]\n#[autograph(forward(Variable4, Output=Variable2))]\nstruct LeNet5 {\n    conv1: Conv2,\n    relu1: Relu,\n    pool1: MaxPool2,\n    conv2: Conv2,\n    relu2: Relu,\n    pool2: MaxPool2,\n    flatten: Flatten,\n    dense1: Dense,\n    relu3: Relu,\n    dense2: Dense,\n    relu4: Relu,\n    dense3: Dense,\n}\n\nimpl LeNet5 {\n    fn new(device: Device, scalar_type: ScalarType) -\u003e Result\u003cSelf\u003e {\n        let conv1 = Conv2::builder()\n            .device(device.clone())\n            .scalar_type(scalar_type)\n            .inputs(1)\n            .outputs(6)\n            .filter([5, 5])\n            .build()?;\n        let relu1 = Relu;\n        let pool1 = MaxPool2::builder().filter([2, 2]).build();\n        let conv2 = Conv2::builder()\n            .device(device.clone())\n            .scalar_type(scalar_type)\n            .inputs(6)\n            .outputs(16)\n            .filter([5, 5])\n            .build()?;\n        let relu2 = Relu;\n        let pool2 = MaxPool2::builder().filter([2, 2]).build();\n        let flatten = Flatten;\n        let dense1 = Dense::builder()\n            .device(device.clone())\n            .scalar_type(scalar_type)\n            .inputs(16 * 4 * 4)\n            .outputs(128)\n            .build()?;\n        let relu3 = Relu;\n        let dense2 = Dense::builder()\n            .device(device.clone())\n            .scalar_type(scalar_type)\n            .inputs(128)\n            .outputs(84)\n            .build()?;\n        let relu4 = Relu;\n        let dense3 = Dense::builder()\n            .device(device.clone())\n            .scalar_type(scalar_type)\n            .inputs(84)\n            .outputs(10)\n            .bias(true)\n            .build()?;\n        Ok(Self {\n            conv1,\n            relu1,\n            pool1,\n            conv2,\n            relu2,\n            pool2,\n            flatten,\n            dense1,\n            relu3,\n            dense2,\n            relu4,\n            dense3,\n        })\n    }\n}\n\nlet mut model = LeNet5::new(device.clone(), ScalarType::F32)?;\nmodel.init_parameter_grads()?;\nlet y = model.forward(x)?;\nlet loss = y.cross_entropy_loss(t)?;\nloss.backward()?;\nmodel.update(learning_rate, \u0026optimizer)?;\n```\n\nSee the [Neural Network MNIST](examples/neural-network-mnist) example.\n\n# Benchmarks\n\n_NVIDIA GeForce GTX 1060 with Max-Q Design_\n\n## LeNet5(training, batch_size = 100)\n\n|                   | `autograph`               | `tch`                            | `candle`                         |\n|:------------------|:--------------------------|:---------------------------------|:-------------------------------- |\n| **`bf16_host`**   | `498.54 ms` (✅ **1.00x**) | `75.26 ms` (🚀 **6.62x faster**)  | `N/A`                            |\n| **`f32_host`**    | `8.25 ms` (✅ **1.00x**)   | `3.14 ms` (🚀 **2.63x faster**)   | `34.17 ms` (❌ *4.14x slower*)    |\n| **`bf16_device`** | `1.76 ms` (✅ **1.00x**)   | `17.63 ms` (❌ *10.02x slower*)   | `N/A`                            |\n| **`f32_device`**  | `1.73 ms` (✅ **1.00x**)   | `1.19 ms` (✅ **1.45x faster**)   | `9.76 ms` (❌ *5.64x slower*)     |\n\n## LeNet5(inference, batch_size = 1,000)\n\n|                   | `autograph`              | `tch`                            | `candle`                         |\n|:------------------|:-------------------------|:---------------------------------|:-------------------------------- |\n| **`bf16_host`**   | `1.81 s` (✅ **1.00x**)   | `193.60 ms` (🚀 **9.37x faster**) | `N/A`                            |\n| **`f32_host`**    | `15.56 ms` (✅ **1.00x**) | `9.46 ms` (✅ **1.64x faster**)   | `94.23 ms` (❌ *6.06x slower*)    |\n| **`bf16_device`** | `4.65 ms` (✅ **1.00x**)  | `48.63 ms` (❌ *10.46x slower*)   | `N/A`                            |\n| **`f32_device`**  | `4.65 ms` (✅ **1.00x**)  | `1.84 ms` (🚀 **2.52x faster**)   | `10.81 ms` (❌ *2.33x slower*)    |\n\nSee the [Neural Network](benches/neural-network-benches) benchmark.\n\n# License\n\nDual-licensed to be compatible with the Rust project.\n\nLicensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 or the MIT license http://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.\n\n# Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharles-r-earp%2Fautograph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharles-r-earp%2Fautograph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharles-r-earp%2Fautograph/lists"}