{"id":26720937,"url":"https://github.com/cospectrum/microgemm","last_synced_at":"2025-10-13T01:46:08.573Z","repository":{"id":204266972,"uuid":"703787496","full_name":"cospectrum/microgemm","owner":"cospectrum","description":"General matrix multiplication with custom configuration in Rust. Supports no_std and no_alloc environments.","archived":false,"fork":false,"pushed_at":"2025-06-29T22:07:59.000Z","size":622,"stargazers_count":6,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-26T09:17:50.427Z","etag":null,"topics":["linear-algebra","matrix","matrix-multiplication"],"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/cospectrum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2023-10-11T23:25:25.000Z","updated_at":"2025-06-29T22:07:24.000Z","dependencies_parsed_at":"2024-08-14T22:21:30.724Z","dependency_job_id":"16af2c72-f347-4444-a290-93f5748cf4cf","html_url":"https://github.com/cospectrum/microgemm","commit_stats":null,"previous_names":["cospectrum/microgemm"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/cospectrum/microgemm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cospectrum%2Fmicrogemm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cospectrum%2Fmicrogemm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cospectrum%2Fmicrogemm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cospectrum%2Fmicrogemm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cospectrum","download_url":"https://codeload.github.com/cospectrum/microgemm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cospectrum%2Fmicrogemm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013906,"owners_count":26085326,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["linear-algebra","matrix","matrix-multiplication"],"created_at":"2025-03-27T19:35:06.220Z","updated_at":"2025-10-13T01:46:08.569Z","avatar_url":"https://github.com/cospectrum.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg align=\"middle\" src=\"./assets/logo.png\" width=\"240px\" alt=\"αAB + βC\"\u003e\n\n# microgemm\n[![github_logo]](https://github.com/cospectrum/microgemm)\n[![latest_version_logo]][crates.io]\n[![docs.rs_logo]](https://docs.rs/microgemm)\n[![dependency status](https://deps.rs/repo/github/cospectrum/microgemm/status.svg)](https://deps.rs/repo/github/cospectrum/microgemm)\n\n[github_logo]: https://img.shields.io/badge/github-cospectrum/microgemm-8da0cb?logo=github\n[latest_version_logo]: https://img.shields.io/crates/v/microgemm.svg?logo=rust\n[crates.io]: https://crates.io/crates/microgemm\n[docs.rs]: https://docs.rs/microgemm\n[docs.rs_logo]: https://img.shields.io/badge/docs.rs-microgemm-66c2a5?logo=docs.rs\n\n\u003e ⚠️ **Note:**\n\u003e This README describes the latest changes in the `master` branch, which may not yet be available in the version published on [crates.io][crates.io].\n\u003e\n\u003e For documentation matching the latest published version, see [crates.io][crates.io] or [docs.rs][docs.rs].\n\nGeneral matrix multiplication with custom configuration in Rust. \u003cbr\u003e\nSupports `no_std` and `no_alloc` environments.\n\nThe implementation is based on the [BLIS](https://github.com/flame/blis) microkernel approach.\n\n## Content\n- [Install](#install)\n- [Usage](#usage)\n    - [gemm](#gemm)\n    - [Implemented Kernels](#implemented-kernels)\n    - [Custom Kernel Implementation](#custom-kernel-implementation)\n- [Benchmarks](#benchmarks)\n    - [f32](#f32)\n- [License](#license)\n\n## Install\n```sh\ncargo add microgemm\n```\n\n## Usage\n\nThe `Kernel` trait is the main abstraction of `microgemm`.\nYou can implement it yourself or use kernels that are already provided out of the box.\n\n### gemm\n\n```rust\nuse microgemm::{kernels::GenericKernel8x8, Kernel as _, MatMut, MatRef, PackSizes};\n\nfn main() {\n    let kernel = GenericKernel8x8::\u003cf32\u003e::new();\n    let [m, k, n] = [100, 380, 250];\n\n    let [mc, kc, nc] = [m, k / 2, n];\n    let pack_sizes = PackSizes { mc, kc, nc };\n    let mut packing_buf = vec![0.0; pack_sizes.buf_len()];\n\n    let (alpha, beta) = (2.0, -3.0);\n\n    let a = vec![2.0; m * k];\n    let b = vec![3.0; k * n];\n    let mut c = vec![4.0; m * n];\n\n    let a = MatRef::row_major(m, k, \u0026a);\n    let b = MatRef::row_major(k, n, \u0026b);\n    let mut c = MatMut::row_major(m, n, \u0026mut c);\n\n    // c \u003c- alpha a b + beta c\n    kernel.gemm(alpha, a, b, beta, \u0026mut c, pack_sizes, \u0026mut packing_buf);\n    println!(\"{:?}\", c.as_slice());\n}\n```\nAlso see [no_alloc](./examples/no_alloc.rs) example for use without `Vec`.\n\n### Implemented Kernels\n\n| Name | Scalar Types | Target |\n| ---- | ------------ | ------ |\n| GenericKernelNxN \u003cbr\u003e (N: 2, 4, 8, 16, 32) | T: Copy + Zero + One + Mul + Add | Any |\n| NeonKernel4x4 | f32 | aarch64 and target feature neon |\n| NeonKernel8x8 | f32 | aarch64 and target feature neon |\n\n### Custom Kernel Implementation\n\n```rust\nuse microgemm::{typenum::U4, Kernel, MatMut, MatRef};\n\nstruct CustomKernel;\n\nimpl Kernel for CustomKernel {\n    type Scalar = f64;\n    type Mr = U4;\n    type Nr = U4;\n\n    // dst \u003c- alpha lhs rhs + beta dst\n    fn microkernel(\n        \u0026self,\n        alpha: f64,\n        lhs: MatRef\u003cf64\u003e,\n        rhs: MatRef\u003cf64\u003e,\n        beta: f64,\n        dst: \u0026mut MatMut\u003cf64\u003e,\n    ) {\n        // lhs is col-major\n        assert_eq!(lhs.row_stride(), 1);\n        assert_eq!(lhs.nrows(), Self::MR);\n\n        // rhs is row-major\n        assert_eq!(rhs.col_stride(), 1);\n        assert_eq!(rhs.ncols(), Self::NR);\n\n        // dst is col-major\n        assert_eq!(dst.row_stride(), 1);\n        assert_eq!(dst.nrows(), Self::MR);\n        assert_eq!(dst.ncols(), Self::NR);\n\n        // your microkernel implementation...\n    }\n}\n```\n\n## Benchmarks\n\nAll benchmarks are performed in a `single thread` on square matrices of dimension `n`.\n\n### f32\n`PackSizes { mc: n, kc: n, nc: n }`\n\n####  aarch64 (M1)\n```\n   n  NeonKernel8x8           faer matrixmultiply\n 128         64.6µs        256.3µs         49.5µs\n 256        419.5µs          3.2ms        518.2µs\n 512          2.9ms         16.3ms          2.8ms\n1024           23ms        132.7ms         22.5ms\n2048        185.5ms             1s        182.8ms\n```\n\n## License\nLicensed under either of [Apache License, Version 2.0](./LICENSE-APACHE)\nor [MIT license](./LICENSE-MIT) at your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcospectrum%2Fmicrogemm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcospectrum%2Fmicrogemm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcospectrum%2Fmicrogemm/lists"}