{"id":22604867,"url":"https://github.com/elftausend/custos-macro","last_synced_at":"2025-03-28T21:28:42.231Z","repository":{"id":65777806,"uuid":"550448836","full_name":"elftausend/custos-macro","owner":"elftausend","description":"A macro crate used for testing purposes. Will be integrated into the custos repo later.","archived":false,"fork":false,"pushed_at":"2024-02-12T18:26:08.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-17T15:19:07.194Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elftausend.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-10-12T19:36:44.000Z","updated_at":"2022-10-12T19:37:33.000Z","dependencies_parsed_at":"2024-02-12T18:56:06.298Z","dependency_job_id":null,"html_url":"https://github.com/elftausend/custos-macro","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"1307e0da008c6b8391e228195ca42a187312511f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elftausend%2Fcustos-macro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elftausend%2Fcustos-macro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elftausend%2Fcustos-macro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elftausend%2Fcustos-macro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elftausend","download_url":"https://codeload.github.com/elftausend/custos-macro/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246103263,"owners_count":20723925,"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":[],"created_at":"2024-12-08T13:11:38.201Z","updated_at":"2025-03-28T21:28:42.203Z","avatar_url":"https://github.com/elftausend.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# custos-macro\n\nAdds a `Stack` operation based on a `CPU` operation.\n\n# Example\n\nExpands a `CPU` implementation to a `Stack` and `CPU` implementation.\n\n```rust\n#[impl_stack]\nimpl\u003cT, D, S\u003e ElementWise\u003cT, D, S\u003e for CPU\nwhere\n    T: Number,\n    D: MainMemory,\n    S: Shape\n{\n    fn add(\u0026self, lhs: \u0026Buffer\u003cT, D, S\u003e, rhs: \u0026Buffer\u003cT, D, S\u003e) -\u003e Buffer\u003cT, CPU, S\u003e {\n        let mut out = self.retrieve(lhs.len, (lhs, rhs));\n        cpu_element_wise(lhs, rhs, \u0026mut out, |o, a, b| *o = a + b);\n        out\n    }\n\n    fn mul(\u0026self, lhs: \u0026Buffer\u003cT, D, S\u003e, rhs: \u0026Buffer\u003cT, D, S\u003e) -\u003e Buffer\u003cT, CPU, S\u003e {\n        let mut out = self.retrieve(lhs.len, (lhs, rhs));\n        cpu_element_wise(lhs, rhs, \u0026mut out, |o, a, b| *o = a * b);\n        out\n    }\n}\n\n'#[impl_stack]' expands the implementation above to the following 'Stack' implementation:\n\nimpl\u003cT, D, S\u003e ElementWise\u003cT, D, S\u003e for Stack\nwhere\n    T: Number,\n    D: MainMemory,\n    S: Shape\n{\n    fn add(\u0026self, lhs: \u0026Buffer\u003cT, D, S\u003e, rhs: \u0026Buffer\u003cT, D, S\u003e) -\u003e Buffer\u003cT, Stack, S\u003e {\n        let mut out = self.retrieve(lhs.len, (lhs, rhs));\n        cpu_element_wise(lhs, rhs, \u0026mut out, |o, a, b| *o = a + b);\n        out\n    }\n\n    fn mul(\u0026self, lhs: \u0026Buffer\u003cT, D, S\u003e, rhs: \u0026Buffer\u003cT, D, S\u003e) -\u003e Buffer\u003cT, Stack, S\u003e {\n        let mut out = self.retrieve(lhs.len, (lhs, rhs));\n        cpu_element_wise(lhs, rhs, \u0026mut out, |o, a, b| *o = a * b);\n        out\n    }\n}\n\n// Now is it possible to execute this operations with a CPU and Stack device.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felftausend%2Fcustos-macro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felftausend%2Fcustos-macro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felftausend%2Fcustos-macro/lists"}