{"id":18823608,"url":"https://github.com/yvt/amx-rs","last_synced_at":"2025-04-14T01:30:50.786Z","repository":{"id":138153650,"uuid":"327882754","full_name":"yvt/amx-rs","owner":"yvt","description":"Rust wrapper for Apple Matrix Coprocessor (AMX) instructions","archived":false,"fork":false,"pushed_at":"2023-11-14T00:06:36.000Z","size":62,"stargazers_count":48,"open_issues_count":1,"forks_count":6,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-11T16:16:09.010Z","etag":null,"topics":["amx","apple-m1","apple-matrix-coprocessor","dont-use-this-in-production","mac","matrix","rust","simd"],"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/yvt.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}},"created_at":"2021-01-08T11:23:05.000Z","updated_at":"2025-03-23T16:50:24.000Z","dependencies_parsed_at":"2023-11-14T01:34:09.233Z","dependency_job_id":null,"html_url":"https://github.com/yvt/amx-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yvt%2Famx-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yvt%2Famx-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yvt%2Famx-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yvt%2Famx-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yvt","download_url":"https://codeload.github.com/yvt/amx-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248807372,"owners_count":21164677,"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":["amx","apple-m1","apple-matrix-coprocessor","dont-use-this-in-production","mac","matrix","rust","simd"],"created_at":"2024-11-08T00:54:10.592Z","updated_at":"2025-04-14T01:30:50.745Z","avatar_url":"https://github.com/yvt.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `amx`\n\n[\u003cimg src=\"https://docs.rs/amx/badge.svg\" alt=\"docs.rs\"\u003e](https://docs.rs/amx/)\n\nRust wrapper for Apple Matrix Coprocessor (AMX) instructions\n\nThis crate provides wrapper functions for the undocumented AMX instructions,\nwhich are found in Apple Silicon processors.\n\n## Resources\n\n - \u003chttps://gist.github.com/dougallj/7a75a3be1ec69ca550e7c36dc75e0d6f\u003e\n - \u003chttps://www.realworldtech.com/forum/?threadid=187087\u0026curpostid=187120\u003e\n\n## Example\n\n```rust\nuse amx::{Amx, XRow, YRow, XBytes, YBytes, ZRow};\nlet mut ctx = amx::AmxCtx::new().unwrap();\nlet x = [1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16,\n         17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32i16];\nlet y = [51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,\n         67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82i16];\nunsafe { ctx.load512(x.as_ptr(), XRow(0)) };\nunsafe { ctx.load512(y.as_ptr(), YRow(0)) };\nctx.outer_product_i16_xy_to_z(\n    Some(XBytes(0)),    // input from X starting from byte offset 0\n    Some(YBytes(0)),    // input from Y starting from byte offset 0\n    ZRow(0),            // output to Z starting from row offset 0\n    false,              // don't accumulate\n);\nlet z: [[i16; 32]; 64] = unsafe { std::mem::transmute(ctx.read_z()) };\nfor (x_i, \u0026x) in x.iter().enumerate() {\n    for (y_i, \u0026y) in y.iter().enumerate() {\n        assert_eq!(z[y_i * 2][x_i], x * y);\n    }\n}\n```\n\n## Registers\n\n```rust\nstruct AmxState {\n    /// \"8 64-byte registers\"\n    x: [[u8; 64]; 8],\n    /// \"8 64-byte registers\"\n    y: [[u8; 64]; 8],\n    /// \"64 64-byte registers in an M-by-N matrix\"\n    z: [[u8; 64]; 64],\n}\n```\n\nLicense: MIT/Apache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyvt%2Famx-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyvt%2Famx-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyvt%2Famx-rs/lists"}